/* The cover and the review gallery share the same quiet, book-first shell. */
body { height: 100dvh; overflow: hidden; }
/* PDF.js adds a measurement canvas to body; it must not create a text line. */
.hiddenCanvasElement { position: fixed; top: 0; left: 0; visibility: hidden; pointer-events: none; }
.topbar { height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); gap: 12px; }
.brand { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; }
.brand-icon svg { width: 24px; height: 24px; }
.header-book { gap: 3px; flex: 1; }
.header-actions { gap: 4px; flex-shrink: 0; }
.header-actions .zoom-control { display: inline-flex; align-items: center; flex-shrink: 0; }
.zoom-control select { min-height: 44px; }
.icon-button { width: 44px; height: 44px; }
.appearance-button { min-width: 44px; min-height: 44px; justify-content: center; }
.app-layout { height: calc(100dvh - 56px - env(safe-area-inset-top)); min-height: 0; }
.main { min-height: 0; }
.reader-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.popover { top: calc(52px + env(safe-area-inset-top)); max-width: calc(100vw - 16px); max-height: calc(100dvh - 72px - env(safe-area-inset-top)); overflow: auto; }
.backdrop { top: calc(56px + env(safe-area-inset-top)); }
.sidebar { min-height: 0; }
.sidebar-footer { padding: 16px 24px; }
.is-cover .reading-control, .is-cover .reader-footer, .is-cover .sidebar,
.is-reviews .reading-control, .is-reviews .reader-footer, .is-reviews .sidebar,
.is-cover .header-reviews, .is-reviews .header-reviews { display: none; }
.is-cover .reading-area { overflow: hidden; }
.is-cover .welcome { display: flex; flex-direction: column; height: 100%; min-height: 0; max-width: 680px; padding: 20px 24px max(16px, env(safe-area-inset-bottom)); gap: 18px; margin: 0 auto; }
.is-cover .cover-stage { flex: 1; min-height: 0; width: 100%; text-align: center; }
.is-cover .hero-cover { display: block; height: 100%; width: 100%; max-height: none; object-fit: contain; transform: none; border-radius: 0; filter: drop-shadow(0 8px 18px #342a3515); }
.cover-actions { display: flex; gap: 10px; width: min(100%, 420px); flex-shrink: 0; }
.cover-actions > button { flex: 1; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 48px; padding: 12px 20px; font-size: 14px; border-radius: 10px; }
.secondary-button { background: var(--panel); border: 1px solid var(--line); }
.secondary-button:hover { background: var(--hover); }
.secondary-button svg { width: 19px; height: 19px; color: var(--accent); }
.count-badge { padding: 2px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
.cover-progress { display: flex; align-items: center; justify-content: center; gap: 12px; flex-shrink: 0; width: 100%; }
.cover-note { font-size: 11px; color: var(--muted); margin: 0; text-align: center; line-height: 1.5; }
.reset-link { min-height: 44px; flex-shrink: 0; padding: 4px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 11px; }
.settings-note { margin-top: 16px; }
.settings-actions { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); }
.settings-action { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 4px; width: 100%; font-size: 12px; text-align: left; border-radius: 6px; }
.settings-action:hover { background: var(--hover); }
.settings-action svg { width: 18px; height: 18px; color: var(--accent); }
.settings-actions .mobile-extra { display: none; }
#reset-note { font-size: 10px; line-height: 1.7; color: var(--muted); margin: 4px 4px 0; }
.fit-page .page-view { justify-content: center; }
.page-frame { position: relative; flex-shrink: 0; }
.page-paper { transform-origin: top left; }
.is-reading .reading-area { touch-action: none; }
.is-reading .page-paper { touch-action: none; }
.toast { max-width: calc(100vw - 24px); white-space: normal; text-align: center; }
.text-button { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 6px 0; color: var(--muted); font-size: 13px; }
.text-button:hover { color: var(--text); }
.text-button svg { width: 18px; height: 18px; }
.reviews-screen { max-width: 1160px; margin: auto; padding: 12px 32px max(40px, env(safe-area-inset-bottom)); }
.reviews-navigation { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.reviews-heading { margin: 32px 0 28px; }
.reviews-heading .eyebrow { display: block; margin: 0 0 14px; font: 400 10px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; letter-spacing: 1.6px; }
.reviews-heading p { font-size: 13px; color: var(--muted); line-height: 1.8; margin: 14px 0 0; }
.reviews-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.review-card { display: block; position: relative; min-width: 0; width: 100%; border: 1px solid var(--line); padding: 0; border-radius: 12px; overflow: hidden; background: #fffffc; text-align: left; box-shadow: 0 3px 14px #28212b05; }
.review-card img { display: block; width: 100%; height: auto; aspect-ratio: 853 / 1280; object-fit: contain; background: #fffffc; }
.review-card-footer { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; color: #77716d; border-top: 1px solid #f1efea; font-size: 10px; }
.review-card-footer svg { width: 15px; height: 15px; }
.review-card:hover { box-shadow: 0 5px 24px #28212b14; }
.review-card:focus-visible { outline-offset: 3px; }
.reviews-bottom { text-align: center; padding: 42px 0 8px; }
.reviews-bottom p { font: 24px Georgia, serif; margin: 0 0 20px; }
.review-dialog { position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; padding: 0; margin: 0; border: 0; border-radius: 0; background: #242226; color: #f8f6f2; overflow: hidden; box-shadow: none; color-scheme: dark; }
.review-dialog[open] { display: grid; grid-template-rows: calc(56px + env(safe-area-inset-top)) minmax(0, 1fr) calc(60px + env(safe-area-inset-bottom)); }
.review-dialog::backdrop { background: #242226; backdrop-filter: none; }
.review-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); border-bottom: 1px solid #ffffff12; }
#review-title { font-size: 12px; color: #c7c2c9; font-variant-numeric: tabular-nums; }
.review-dialog .icon-button { color: #dcd7df; }
.review-dialog .icon-button:hover { background: #ffffff10; color: white; }
.viewer-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 8px 12px; border-radius: 8px; color: #ece7ef; font-size: 13px; }
.viewer-button:hover { background: #ffffff0c; }
.viewer-button:disabled { opacity: .28; }
.viewer-button svg { width: 19px; height: 19px; }
.review-stage { display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); overflow: auto; overscroll-behavior: contain; touch-action: pan-y pinch-zoom; outline: none; }
.review-stage:focus-visible { outline: 2px solid #b6a2ce; outline-offset: -3px; }
#review-image { display: block; flex-shrink: 0; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 2px; background: #fffffc; user-select: none; }
.review-stage.is-zoomed { display: block; touch-action: auto; }
.review-stage.is-zoomed #review-image { width: max(650px, 150%); max-width: none; max-height: none; height: auto; margin: 0 auto; }
#review-image-error { max-width: 300px; text-align: center; line-height: 1.7; color: #d3cad6; }
.review-footer { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding: 0 max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left)); border-top: 1px solid #ffffff12; }
.theme-dark .hero-cover { filter: drop-shadow(0 8px 18px #0004); }
@media (min-width: 801px) {
  .sidebar { width: 280px; }
  .is-cover .welcome { padding-top: 24px; padding-bottom: 22px; }
  .is-cover .cover-stage { max-width: 560px; }
}
@media (max-width: 800px) {
  .sidebar { top: calc(56px + env(safe-area-inset-top)); }
  .backdrop { left: 280px; }
  .header-book { display: none; }
  .reviews-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .reviews-screen { padding-inline: 24px; }
}
@media (max-width: 570px) {
  .topbar { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); gap: 8px; }
  .brand-icon svg { width: 22px; height: 22px; }
  .header-actions { gap: 0; }
  .is-cover .welcome { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); gap: 14px; }
  .cover-note { font-size: 10px; }
  .cover-actions { max-width: 380px; gap: 8px; }
  .cover-actions .primary-button, .cover-actions .secondary-button { padding-inline: 12px; font-size: 13px; gap: 8px; }
  .reader-footer { padding-inline: 8px; }
  .progress-info { font-size: 9px; }
  .page-navigation { gap: 0; }
  .page-jump input { min-height: 44px; font-size: 14px; }
  .page-view { padding: 12px 8px; }
  .paper-caption { font-size: 8px; max-width: calc(100vw - 24px); text-align: center; }
  .reviews-screen { padding: 8px 14px max(28px, env(safe-area-inset-bottom)); }
  .reviews-heading { margin: 24px 0; }
  .reviews-heading p { font-size: 12px; line-height: 1.75; }
  .reviews-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .review-card { border-radius: 9px; }
  .review-card-footer { padding: 8px 10px; font-size: 9px; }
  .reviews-bottom p { font-size: 22px; }
  .review-header { padding-inline: 8px; }
  .review-header .viewer-button { padding-inline: 8px; font-size: 12px; }
  .review-header .viewer-button svg { width: 17px; }
  .review-stage { padding: 8px; }
  .viewer-button { font-size: 12px; gap: 5px; padding-inline: 8px; }
  #review-title { font-size: 11px; }
}
@media (max-width: 900px) {
  .topbar { height: calc(48px + env(safe-area-inset-top)); padding-inline: max(4px, env(safe-area-inset-left)) max(4px, env(safe-area-inset-right)); gap: 2px; }
  .app-layout { height: calc(100dvh - 48px - env(safe-area-inset-top)); }
  .header-book, .header-reviews, .header-actions .download, .header-actions .fullscreen, .appearance-label { display: none; }
  .header-actions { gap: 0; }
  .appearance-button { padding: 0; width: 44px; }
  .zoom-control select { font-size: 10px; width: 80px; padding: 6px 2px; }
  .reader-footer { display: flex; height: calc(48px + env(safe-area-inset-bottom)); padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .progress-info { max-width: none; font-size: 10px; }
  .keyboard-hint, .paper-caption { display: none; }
  .page-navigation { gap: 0; }
  .page-view { padding: 8px; }
  .popover { top: calc(44px + env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
  .sidebar, .backdrop { top: calc(48px + env(safe-area-inset-top)); }
  .settings-actions .mobile-extra { display: flex; }
  .toast { bottom: calc(64px + env(safe-area-inset-bottom)); }
}
@media (max-height: 440px) and (orientation: landscape) {
  .is-cover .welcome { flex-direction: row; max-width: 640px; gap: 24px; padding: 12px 24px; }
  .is-cover .cover-stage { height: 100%; }
  .cover-actions { flex-direction: column; width: 200px; }
  .cover-progress { display: none; }
}
