/* OnlyShows 0.13.2: PWA shell, account-aware profile and compact mobile chrome. */

.profile-sign-in-gate {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 22px;
  border: 1px solid var(--outline-variant);
  border-radius: 22px;
  background: var(--surface-container-low);
}

.profile-sign-in-gate[hidden] { display: none !important; }
.profile-summary[hidden],
[data-profile-auth][hidden] { display: none !important; }
.profile-sign-in-gate > .material-symbols-rounded { color: var(--primary); font-size: 30px; }
.profile-sign-in-gate strong { display: block; color: var(--on-surface); }
.profile-sign-in-gate p { margin: 5px 0 0; color: var(--on-surface-variant); font-size: 13px; line-height: 1.55; }
.profile-sign-in-gate .primary-button { white-space: nowrap; }

.pwa-install-dialog {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

body.pwa-install-help-open { overflow: hidden !important; }
body.pwa-install-help-open > .mobile-bottom-shell,
body.pwa-install-help-open > #mobileWorkspaceDock { display: none !important; }

@media (max-width: 719px) {
  /* Keep the first-run recovery page calm and deliberately typeset. */
  body.library-empty:not(.mobile-database-tab):not(.mobile-profile-tab) .hero .stats,
  body.library-empty:not(.mobile-database-tab):not(.mobile-profile-tab) .hero .more-data-button,
  body.library-empty .site-footer { display: none !important; }

  body.library-empty:not(.mobile-database-tab):not(.mobile-profile-tab) #emptyState:not([hidden]) {
    position: fixed;
    inset: 104px 18px calc(var(--mobile-nav-row-height) + 12px) 18px;
    display: grid;
    width: auto;
    margin: 0;
    padding: 24px;
    align-content: center;
    justify-items: center;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    text-align: center;
  }

  body.library-empty #emptyState .empty-mark {
    width: 54px;
    height: 54px;
    margin: 0 0 20px;
    border-radius: 50%;
    font: 600 27px/1 var(--font-ui);
  }

  body.library-empty #emptyState h2 {
    margin: 0 0 10px;
    font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
    font-size: 27px;
    font-weight: 600;
    letter-spacing: -.035em;
  }

  body.library-empty #emptyState > p:not(.format-note) {
    max-width: 310px;
    margin: 0 0 22px;
    color: var(--on-surface-variant);
    font-size: 13px;
    line-height: 1.7;
  }

  body.library-empty #emptyState .large { min-height: 48px; padding: 0 24px; }
  body.library-empty #emptyState .format-note { margin: 10px 0 0; font-size: 11px; }

  /* A small browser must never be able to layer its app Tab above install help. */
  .pwa-install-dialog[open] {
    position: fixed !important;
    inset: 12px 14px calc(12px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    height: max-content !important;
    max-height: calc(100svh - 24px - env(safe-area-inset-bottom)) !important;
    margin: auto !important;
    z-index: 2147483647 !important;
  }

  .pwa-install-dialog-head { position: sticky; top: 0; z-index: 2; background: var(--surface-container-high); }
  .pwa-install-dialog-body { padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important; }

  .profile-dialog .pwa-install-button[data-install-state="installed"] { cursor: pointer !important; }
  .profile-dialog .pwa-install-button > span:nth-child(2) small {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.35 !important;
  }

  .profile-sign-in-gate {
    grid-template-columns: 38px minmax(0, 1fr);
    margin: 8px 14px 24px;
    padding: 18px;
    border-radius: 20px;
  }

  .profile-sign-in-gate .primary-button {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 46px;
  }

  /* Scroll chrome and its reserved geometry together, leaving no wallpaper strip. */
  body:not(.mobile-profile-tab) .library:not([hidden]) {
    transition: top 260ms cubic-bezier(.2, .8, .2, 1), bottom 260ms cubic-bezier(.2, .8, .2, 1) !important;
  }

  body.mobile-chrome-hidden:not(.mobile-profile-tab) .library:not([hidden]) {
    top: 0 !important;
    bottom: 0 !important;
  }

  body.mobile-chrome-hidden .mobile-workspace-heading,
  body.mobile-chrome-hidden.mobile-profile-tab .profile-dialog.mobile-tab-page .insights-head {
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
  }

  /* In database browsing, the whole search/Tab shell leaves; filters remain reachable. */
  html body.mobile-database-tab.mobile-chrome-hidden > .mobile-bottom-shell {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(calc(100% + 8px)) !important;
  }

  html body.mobile-database-tab.mobile-chrome-hidden #mobileWorkspaceDock {
    bottom: calc(6px + env(safe-area-inset-bottom)) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
  }

  html body.mobile-database-tab.mobile-chrome-hidden .library:not([hidden]) {
    bottom: calc(56px + env(safe-area-inset-bottom)) !important;
    padding-top: 0 !important;
  }

  html body.library-empty #noResults {
    display: none !important;
  }

  body.mobile-chrome-hidden.mobile-profile-tab .profile-dialog.mobile-tab-page[open] {
    inset-bottom: 0 !important;
  }

  body.mobile-chrome-hidden.mobile-profile-tab .profile-dialog.mobile-tab-page .insights-scroll {
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin-bottom: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body:not(.mobile-profile-tab) .library:not([hidden]) { transition: none !important; }
}
