/* Shared interface roles. Story typography remains controlled by the reader. */
:root {
  --type-body: 1rem;
  --type-summary: .9375rem;
  --type-meta: .875rem;
  --type-action: 1rem;
  --type-navigation: 1.0625rem;
  --type-filter: 1.0625rem;
  --type-page: 2.25rem;
  --type-section: 1.5rem;
  --type-title: 1.375rem;
}
body { font-size: var(--type-body); }

/* Navigation, actions and prose use the same roles across all screens. */
.site-nav a { font-size: var(--type-navigation); }
.bottom-nav a { font-size: var(--type-meta); line-height: 1.4; min-width: 0; overflow-wrap: anywhere; }
.library .chip, .shelf-tabs .chip { font-size: var(--type-filter); line-height: 1.4; white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
.library .filters {
  min-width: 0; max-width: 100%; flex-wrap: nowrap; justify-content: flex-start;
  overflow-x: auto; overflow-y: hidden; padding-block: 4px;
  overscroll-behavior-x: contain; scrollbar-width: none;
}
.library .filters .chip { flex: 0 0 auto; max-width: none; white-space: nowrap; overflow-wrap: normal; }
.library .filters:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.library .filters .chip:focus-visible { outline-offset: -2px; }
.button, .text-button, .continue-card .button, .shelf-actions .button,
.hero-card .button, .hero-card .text-button, .book-related-read, .book-share,
.book-start-link, .reader-about, .reader-links .text-button,
.reading-motion .reading-motion-toggle { font-size: var(--type-action); line-height: 1.35; }
.button, .text-button { max-width: 100%; overflow-wrap: anywhere; }
.reading-label, .reading-fill { white-space: normal; overflow-wrap: anywhere; text-align: center; }
.reading-label { max-width: 100%; }
.book-card .card-read { font-size: var(--type-action); }
.book-related-read { min-height: 44px; }

.library-intro h1, .page-intro h1, .series-hero h1 { font-size: var(--type-page); line-height: 1.1; letter-spacing: -.03em; overflow-wrap: anywhere; }
.section-heading h2, .library-series h2, .hero-card h2, .empty-state h2,
.finish-panel h2, .dialog-header h2, .settings-dialog .dialog-header h2,
.book-about h2, .book-source h2, .book-related h2 { font-size: var(--type-section); line-height: 1.25; }
.book-card > .card-title, .shelf-copy h2, .person-mini h3, .library-series-item strong, .reader-next h3 { font-size: var(--type-title); line-height: 1.25; overflow-wrap: anywhere; }
.continue-info h2 { font-size: var(--type-body); line-height: 1.4; overflow-wrap: anywhere; }
.book-hero h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
.book-dialog .book-hero h1 { font-size: 2.125rem; }
.book-page { container: book-page / inline-size; }

.page-intro p, .series-hero p, .book-lead, .book-about p,
.info-dialog .dialog-body p, .empty-state p, .finish-panel p,
.reader-ending p, .reader-next p { font-size: var(--type-body); line-height: 1.65; }
.book-card > .card-blurb, .hero-card p, .person-mini p,
.library-series-item p { font-size: var(--type-summary); line-height: 1.6; }
.book-card .card-byline, .book-card > .card-meta, .book-card .card-meta-main,
.book-card .card-status, .book-card .card-status span,
.book-author, .book-facts li, .book-source p, .book-related-item p,
.book-breadcrumbs, .completed-mark, .shelf-meta, .shelf-progress,
.continue-info .label, .progress-line, .hero-card .hero-series, .hero-token,
.collection-counter, .series-badges, .library-series-item small,
.section-heading .count, .catalog-count, .local-note, .results-context p,
.site-footer, .site-footer .text-button, .reading-motion, .reading-motion p,
.reader-source, .reader-next small, .story-figure figcaption, .story-end,
.reward-eyebrow, .reward-series, .lightbox p, .toast, .storage-warning {
  font-size: var(--type-meta); line-height: 1.5;
}
.book-related-item h3 { font-size: var(--type-body); line-height: 1.4; }
.book-series-link { font-size: var(--type-meta) !important; }
.reward-dialog h2 { font-size: 1.875rem; line-height: 1.2; }
.reward-desc { font-size: var(--type-body); line-height: 1.6; }
.results-context .text-button { font-size: var(--type-action); }

/* Larger text may grow or wrap its container; it is never squeezed into a fixed height. */
.search-input { font-size: var(--type-body); line-height: 1.4; height: auto; min-height: 44px; padding-block: .625rem; }
.site-header .search-box > .icon, .search-clear { top: 50%; transform: translateY(-50%); }
.header-account { font-size: var(--type-meta); white-space: nowrap; }
.header-account:not(.has-profile) .header-account-name { overflow: visible; overflow-wrap: normal; }
.page-intro, .section-heading, .series-badges, .collection-counter,
.continue-card, .shelf-actions, .size-control, .account-session { flex-wrap: wrap; }
.page-intro > div, .person-mini > div, .library-series-item > div { min-width: 0; }
.collection-counter { max-width: 100%; white-space: normal; }
.book-card .card-meta-main > span { white-space: normal; }
.book-card .card-byline { overflow-wrap: anywhere; }
.book-card > .card-blurb { overflow-wrap: anywhere; }
.book-card .card-status { min-width: 0; max-width: 100%; white-space: normal; }
.book-card .card-status span { min-width: 0; overflow-wrap: anywhere; }
.book-card .card-kind { min-width: 0; max-width: 100%; }
.page-intro > div { max-width: 100%; }
.series-hero-copy { min-width: 0; max-width: 100%; width: 100%; }
.person-mini { min-width: 0; }
.person-mini p { overflow-wrap: anywhere; }
.skip-link { top: 8px; transform: translateY(calc(-100% - 16px)); max-width: calc(100vw - 40px); }
.skip-link:focus { transform: translateY(0); }
.continue-info { flex: 1 1 10rem; }
.shelf-actions .button { flex: 1 1 9rem; min-width: 0; }
.hero-card { container: hero-card / inline-size; }
.hero-token { overflow-wrap: anywhere; text-align: center; }
.series-hero p { max-width: 65ch; }

/* Reading controls inherit UI roles; --reader-size/font/leading remain untouched. */
body.is-reading .reader-header-name strong { font-size: var(--type-body); line-height: 1.4; }
.reader-start { font-size: var(--type-meta); line-height: 1.4; }
.reader-header-name small, .reader-welcome .reader-duration { font-size: var(--type-summary); line-height: 1.4; }
.reader-header-name small { display: block; }
.image-mode-button { font-size: var(--type-action); }
.reader-start, .reader-welcome { flex-wrap: wrap; }
.reader-welcome { flex: 1 1 12rem; }
.reader-welcome .reader-duration { white-space: normal; }
.finish-panel > div { min-width: 0; }
.reader-next > div { min-width: 0; }

.settings-dialog, .info-dialog, .reward-dialog { overflow: auto; overscroll-behavior: contain; max-height: calc(100dvh - 32px); }
.settings-subtitle, .setting-label, .size-value, .toggle-copy strong,
.toggle-copy small, .reset-area small { font-size: var(--type-meta); line-height: 1.5; }
.segmented { flex-wrap: wrap; }
.segmented button { flex: 1 1 5.5rem; min-width: 0; min-height: 44px; font-size: var(--type-action); line-height: 1.4; overflow-wrap: anywhere; }
.setting-select { font-size: var(--type-body); line-height: 1.4; }
.size-control { gap: 12px; }
.toggle-copy { min-width: 0; }
.dialog-header h2 { min-width: 0; overflow-wrap: anywhere; }
.dialog-header .icon-button { flex: none; }

@media (max-width: 599px) {
  :root { --type-filter: .9375rem; --type-page: 1.875rem; --type-section: 1.375rem; --type-title: 1.25rem; }
  .library .filters { gap: 0 16px; }
  .book-hero h1 { font-size: clamp(1.375rem, 6vw, 1.9375rem); }
  .book-dialog .book-hero h1 { font-size: clamp(1.375rem, 5.7vw, 1.875rem); }
}
@container book-card (max-width: 199px) {
  .book-card .card-read { font-size: var(--type-summary); }
}
@container book-card (max-width: 10rem) {
  .book-card .card-actions { flex-direction: column; }
  .book-card .book-save { align-self: flex-end; }
}
@container hero-card (max-width: 10rem) {
  .hero-token { position: static; margin-top: 8px; }
}
@container book-page (max-width: 12rem) {
  .book-page .book-hero, .book-dialog .book-hero { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .book-hero-cover { grid-column: auto; grid-row: auto; max-width: 120px; }
  .book-hero h1, .book-author, .book-facts { grid-column: auto; grid-row: auto; }
}
/* The wide header can wrap its navigation without shrinking the logo. */
@media (min-width: 1100px) {
  .site-header .header-inner { grid-template-columns: auto minmax(0, max-content) minmax(8rem, 1fr) 44px auto; }
  .site-header .site-nav { flex-wrap: wrap; white-space: normal; gap: 8px 20px; }
}
@media (max-width: 1099px) {
  .shell { padding-bottom: max(110px, calc(6.5rem + env(safe-area-inset-bottom))); }
}
