/* v134 mobile add/search flow and desktop baseline alignment. */
@media (min-width: 720px) {
  html body .topbar .top-actions {
    gap: 4px !important;
  }

  html body .topbar .top-actions > #exportButton,
  html body .topbar .top-actions > #importButton,
  html body .topbar .top-actions > #personalizeButton,
  html body .topbar .top-actions > #historyButton,
  html body .topbar .top-actions > #updatesButton,
  html body .topbar .top-actions > #accountButton {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 34px !important;
    padding: 0 10px !important;
    border: 0 !important;
    border-radius: 7px !important;
    color: var(--share-muted) !important;
    background: transparent !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    box-shadow: none !important;
  }

  html body .topbar .top-actions > #exportButton:hover,
  html body .topbar .top-actions > #importButton:hover,
  html body .topbar .top-actions > #personalizeButton:hover,
  html body .topbar .top-actions > #historyButton:hover,
  html body .topbar .top-actions > #updatesButton:hover,
  html body .topbar .top-actions > #accountButton:hover {
    color: var(--share-text) !important;
    background: var(--share-selected) !important;
  }

  /* Home and Database now share the exact same hero-to-grid baseline. */
  html body.view-database #library.library {
    position: relative !important;
  }

  html body.view-database #library > .controls {
    position: absolute !important;
    top: -76px !important;
    right: 0 !important;
    left: 0 !important;
    z-index: 5 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: 40px !important;
    min-height: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    border: 0 !important;
    background: transparent !important;
  }

  html body.view-database #library > .controls .search {
    width: min(320px, 100%) !important;
    height: 40px !important;
    margin: 0 !important;
  }
}

@media (max-width: 719px) {
  /* The add screen is one coherent top-to-bottom document, not a split header/footer form. */
  html body #searchDialog[open] {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto auto minmax(0, 1fr) !important;
    overflow: hidden !important;
  }

  html body #searchDialog#searchDialog .dialog-head {
    position: relative !important;
    inset: auto !important;
    z-index: 3 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: calc(88px + env(safe-area-inset-top, 0px)) !important;
    height: auto !important;
    margin: 0 !important;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 12px 14px 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--share-line) !important;
    background: var(--share-surface) !important;
  }

  html body #searchDialog .dialog-head > div {
    min-width: 0 !important;
  }

  html body #searchDialog .dialog-head .eyebrow {
    position: static !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    margin: 0 0 6px !important;
    color: var(--share-accent) !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    letter-spacing: .08em !important;
  }

  html body #searchDialog .dialog-head h2 {
    position: static !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    color: var(--share-text) !important;
    font-size: 22px !important;
    font-weight: 560 !important;
    line-height: 1.2 !important;
    letter-spacing: -.025em !important;
  }

  html body #searchDialog #closeSearchDialog {
    position: static !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border-radius: 50% !important;
  }

  html body #searchDialog #remoteSearchForm.remote-search,
  html body #searchDialog.search-dialog.mobile-search-docked #remoteSearchForm.remote-search,
  html body #searchDialog.search-dialog.mobile-search-docked:not(.mobile-ime-visible) #remoteSearchForm.remote-search,
  html body #searchDialog.search-dialog.mobile-search-docked:has(#remoteSearchInput:focus) #remoteSearchForm.remote-search {
    position: relative !important;
    inset: auto !important;
    z-index: 4 !important;
    align-self: end !important;
    transform: none !important;
    translate: 0 16px !important;
    box-sizing: border-box !important;
    width: auto !important;
    min-width: 0 !important;
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 18px 16px !important;
    padding: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 50px !important;
    gap: 8px !important;
    pointer-events: auto !important;
  }

  html body #searchDialog #remoteSearchInput {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 50px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    border: 1px solid var(--share-line) !important;
    border-radius: 13px !important;
    color: var(--share-text) !important;
    background: var(--share-card) !important;
    font-size: 16px !important;
  }

  html body #searchDialog #remoteSearchForm > button {
    position: static !important;
    width: 50px !important;
    min-width: 50px !important;
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    border-radius: 13px !important;
    pointer-events: auto !important;
  }

  html body #searchDialog #remoteSearchForm > button .material-symbols-rounded {
    font-size: 24px !important;
  }

  html body #searchDialog .search-status {
    box-sizing: border-box !important;
    width: 100% !important;
    min-height: 47px !important;
    margin: 0 !important;
    padding: 10px 18px 13px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--share-line) !important;
    color: var(--share-muted) !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    text-align: left !important;
  }

  html body #searchDialog .remote-results {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 18px calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  /* The header magnifier must reveal a real, focusable search row. */
  html body.view-database.database-search-open #library > .controls {
    position: sticky !important;
    top: 0 !important;
    z-index: 74 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: 58px !important;
    min-height: 58px !important;
    margin: 0 !important;
    padding: 8px 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--share-line) !important;
    background: var(--share-bg) !important;
  }

  html body.view-database.database-search-open #library > .controls > .search {
    flex: 1 1 auto !important;
    display: flex !important;
    width: auto !important;
    min-width: 0 !important;
    height: 42px !important;
    margin: 0 !important;
    padding: 0 2px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--share-text) !important;
    border-radius: 0 !important;
    background: transparent !important;
  }

  html body.view-database.database-search-open #library > .controls > .search #searchInput {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    pointer-events: auto !important;
  }

  html body.view-database.database-search-open #library > .controls > #mobileSearchClose {
    display: grid !important;
    flex: 0 0 34px !important;
    width: 34px !important;
    height: 42px !important;
    place-items: center !important;
    pointer-events: auto !important;
  }

  /* Balance every profile title with an equal invisible right rail. */
  html body #profileDialog.mobile-tab-page .mobile-profile-account,
  html body #profileDialog.mobile-tab-page .mobile-profile-actions > button {
    grid-template-columns: 34px minmax(0, 1fr) 34px !important;
    justify-content: stretch !important;
    column-gap: 10px !important;
    padding-right: 16px !important;
    padding-left: 16px !important;
  }

  html body #profileDialog.mobile-tab-page .mobile-profile-account > span:nth-child(2),
  html body #profileDialog.mobile-tab-page .mobile-profile-actions > button > span:nth-child(2) {
    text-align: center !important;
  }

  html body #profileDialog.mobile-tab-page .mobile-profile-account > .material-symbols-rounded:last-child,
  html body #profileDialog.mobile-tab-page .mobile-profile-actions > button > .material-symbols-rounded:last-child {
    display: block !important;
    visibility: hidden !important;
    width: 34px !important;
  }
}
