@font-face {
  font-family: "Golos Text";
  src: url("/art/fonts/golos-text.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: "Literata";
  src: url("/art/fonts/literata.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --paper: #fff;
  --ink: #292d28;
  --muted: #62685f;
  --accent: #a73afd;
  --accent-hover: #9026e1;
  --sage: #f4e8ff;
  --line: #d9ddd3;
  --soft: #f5f5f3;
  --danger: #a34538;
  --sans: "Golos Text", sans-serif;
  --serif: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 18px/1.5 var(--sans); }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-weight: 500; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input[type="submit"] { cursor: pointer; }
button { border: 0; }
button:disabled, input:disabled, select:disabled { cursor: wait; opacity: .65; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
img { max-width: 100%; display: block; }
textarea { resize: vertical; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; left: 16px; top: -100px; padding: 12px 18px; border-radius: 8px; background: var(--ink); color: white; }
.skip-link:focus { top: 16px; }
.icon { width: 24px; height: 24px; flex: 0 0 auto; object-fit: contain; }
.wordmark { width: 180px; height: 60px; object-fit: contain; }
.brand-link { display: inline-flex; align-items: center; flex-shrink: 0; }
.button, .pill { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; border: 1px solid transparent; border-radius: 12px; padding: 11px 20px; font-size: 17px; font-weight: 500; line-height: 26px; text-align: center; transition: background-color 120ms ease; }
.button { color: #fff; background: var(--accent); }
.button:hover { background: var(--accent-hover); }
.button > .icon { filter: brightness(0) invert(1); }
.button.secondary, .pill { color: var(--ink); background: #fff; border-color: var(--line); }
.button.secondary:hover, .pill:hover { background: var(--soft); }
.button.secondary > .icon { filter: none; }
.button.soft { color: #fff; background: var(--accent); border-color: var(--accent); }
.pill.selected { color: #7024ad; background: var(--sage); border-color: var(--sage); }
.button.soft:hover { background: #ead7fb; }
.pill { min-height: 48px; white-space: nowrap; padding: 10px 20px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 12px; background: transparent; border-radius: 50%; flex-shrink: 0; }
.icon-button:hover { background: #292d280a; }
.text-button, .text-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 0; background: transparent; font-size: 16px; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover, .text-link:hover { color: var(--accent-hover); }
.text-button .icon { width: 20px; height: 20px; }
.button-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.full-width { width: 100%; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; }
.story-meta { color: var(--muted); font-size: 16px; line-height: 1.5; }
.demo-note { font-size: 12px; line-height: 1.6; color: var(--muted); }
.mobile-only, .mobile-header, .mobile-bottom-nav { display: none; }
.flash-stack { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); pointer-events: auto; }
.flash { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f4e8ff; color: #292d28; padding: 8px 8px 8px 16px; border: 1px solid #dfc6f3; border-radius: 12px; box-shadow: 0 4px 24px #0000000a; font-size: 16px; }
.flash-close { width: 44px; height: 44px; padding: 12px; }
.flash-close .icon { width: 20px; height: 20px; }
.flash-error { background: #fff0ed; color: #873b2e; border-color: #e2bab2; }
.global-status:not(:empty) { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50; width: max-content; max-width: min(600px, calc(100% - 32px)); background: var(--ink); color: #fff; border-radius: 12px; padding: 14px 20px; font-size: 16px; }

/* The home page keeps familiar cover cards around a simple chat composer. */
.site-header { max-width: 1600px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding: 22px 4.45%; border-bottom: 1px solid var(--line); }
.site-header > .button { white-space: nowrap; }
.site-header .wordmark { width: 160px; height: 60px; }
.search-form { display: flex; align-items: center; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; height: 56px; }
.site-header .search-form { flex: 1; }
.search-form input { width: 100%; min-width: 0; background: transparent; border: 0; padding: 14px 16px; font-size: 18px; outline-offset: -4px; }
.search-form input::placeholder { color: var(--muted); opacity: 1; }
.search-form .icon-button { margin-right: 3px; }
.home-main { max-width: 1600px; margin: 0 auto; padding: 42px 4.45% 24px; }
.home-hero { display: grid; grid-template-columns: 1fr 1.04fr; align-items: center; gap: 40px; }
.home-hero h1 { font: 500 clamp(36px, 3.35vw, 52px)/1.22 var(--serif); letter-spacing: -.025em; }
.home-hero > div > p { margin-top: 20px; color: var(--muted); font-size: 18px; }
.category-nav { display: flex; gap: 12px; margin: 32px 0 36px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: thin; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; margin-bottom: 24px; }
.section-heading h2, .section-heading h3 { font: 500 30px/1.3 var(--serif); }
.section-heading p { color: var(--muted); font-size: 16px; }
.idea-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px; }
.idea-card { display: flex; flex-direction: column; min-width: 0; }
.cover-link { display: block; border-radius: 14px; overflow: hidden; }
.story-cover { width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; }
.cover-link img { transition: transform 200ms ease; }
.cover-link:hover img { transform: scale(1.02); }
.idea-card h3 { margin-top: 12px; font-size: 20px; line-height: 1.3; }
.idea-card p { color: var(--muted); font-size: 16px; margin: 6px 0 20px; }
.idea-card .button { margin-top: auto; width: 100%; }
.home-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* Common conversation navigation. */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 10; width: 256px; display: flex; flex-direction: column; padding: 20px 16px; border-right: 1px solid var(--line); background: #fff; }
.sidebar .brand-link { align-self: center; }
.brand-caption { margin: 4px 12px 24px; color: var(--muted); font-size: 14px; }
.sidebar-create { width: 100%; }
.sidebar-nav { margin-top: 24px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 16px; border-radius: 10px; font-size: 17px; }
.nav-link.active, .nav-link:hover { background: var(--sage); }
.recent { margin: 22px 8px 0; padding-top: 24px; border-top: 1px solid var(--line); overflow-y: auto; }
.recent h2, .recent h3 { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 0 4px 12px; }
.recent-link { display: block; padding: 10px 4px; font-size: 16px; line-height: 1.4; color: var(--muted); border-radius: 8px; overflow-wrap: anywhere; }
.recent-link:hover, .recent-link.current { color: var(--ink); background: var(--soft); }
.sidebar-bottom { margin-top: auto; padding-top: 24px; }
.sidebar-bottom .demo-note { padding: 12px 16px 0; }
.app-main { margin-left: 256px; min-height: 100dvh; }
.app-topbar { height: 80px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: 16px 40px; }
.app-topbar h1 { font-size: 20px; line-height: 1.4; min-width: 0; overflow-wrap: anywhere; }
.app-topbar > p { color: var(--muted); font-size: 14px; white-space: nowrap; }
.new-chat-main { max-width: 980px; padding: clamp(64px, 12vh, 164px) 40px 48px; margin: 0 auto; }
.new-chat-intro h2 { font: 500 48px/1.25 var(--serif); letter-spacing: -.025em; }
.new-chat-intro p { margin-top: 24px; color: var(--muted); font-size: 20px; }
.new-chat-composer { margin-top: 42px; }
.prompt-suggestions { margin-top: 30px; }
.prompt-suggestions h3 { font-size: 16px; color: var(--muted); margin-bottom: 16px; }
.suggestion-row { display: flex; flex-wrap: wrap; gap: 12px; }
.chat-boundary { margin-top: 52px; color: var(--muted); font-size: 18px; }
.story-form { min-width: 0; }
.composer { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 16px 20px 10px; }
.composer:focus-within { border-color: #cba2ed; box-shadow: 0 0 0 2px #a73afd12; }
.composer textarea { width: 100%; min-height: 54px; max-height: 240px; display: block; font-size: 18px; line-height: 26px; border: 0; background: transparent; padding: 3px 3px 10px; }
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer textarea:focus-visible { outline: none; }
.composer-toolbar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.composer-toolbar > .pill { min-width: 110px; padding-left: 16px; padding-right: 16px; }
.composer-submit { margin-left: auto; min-width: 150px; }
.composer-submit .icon { display: none; }
.form-feedback { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; }
.form-feedback > p:not(:empty) { padding: 12px 4px 0; font-size: 16px; color: var(--muted); }
.form-errors { border: 1px solid #e2bab2; border-radius: 12px; background: #fff6f3; color: #873b2e; padding: 16px 20px; margin-bottom: 16px; font-size: 16px; }
.form-errors h3 { font-size: 18px; }
.form-errors ul { padding-left: 20px; margin: 8px 0 0; }
.conversation-main { max-width: 980px; margin: 0 auto; padding: 40px 40px 16px; }
.story-turn + .story-turn { margin-top: 44px; }
.user-message { margin-left: auto; max-width: 88%; width: fit-content; padding: 20px 24px; border-radius: 18px; background: var(--sage); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 18px; line-height: 1.5; }
.assistant-message { margin-top: 34px; }
.assistant-name { font: 600 22px/1.4 var(--serif); color: #775342; }
.story-excerpt { max-width: 790px; font-size: 19px; line-height: 1.6; margin: 18px 0 28px; white-space: pre-line; }
.story-result { position: relative; display: flex; gap: 24px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.result-cover-link { display: block; flex-shrink: 0; }
.result-cover { width: 174px; height: 232px; border-radius: 12px; object-fit: cover; }
.result-content { min-width: 0; flex: 1; display: flex; flex-direction: column; padding: 2px 0; }
.result-content h3 { font: 500 30px/1.2 var(--serif); margin: 10px 30px 10px 0; letter-spacing: -.015em; overflow-wrap: anywhere; }
.result-description { font-size: 17px; line-height: 1.5; margin: 12px 0 18px; }
.result-actions { display: flex; gap: 12px; margin-top: auto; }
.result-actions > * { flex: 1; padding-left: 12px; padding-right: 12px; }
.story-result > form { position: absolute; top: 8px; right: 8px; }
.result-favorite { width: 40px; height: 40px; padding: 9px; }
.is-favorite { background: #f4e8ff !important; color: #7024ad !important; }
.is-favorite .icon { filter: invert(31%) sepia(91%) saturate(3375%) hue-rotate(257deg) brightness(98%) contrast(103%) !important; }
.chat-compose-area { position: sticky; bottom: 0; padding: 20px 0 12px; margin-top: 12px; background: linear-gradient(180deg, #ffffff00 0, #fff 16px); }
.refinements { display: flex; gap: 12px; overflow-x: auto; margin-bottom: 18px; padding: 4px 0; scrollbar-width: thin; }
.refinements .pill { font-size: 16px; }

/* Saved stories and preferences use the same restrained shell. */
.library-main { max-width: 1320px; margin: 0 auto; padding: 40px 44px; }
.library-heading { display: flex; justify-content: space-between; align-items: center; gap: 30px; }
.library-heading h2 { font: 500 42px/1.2 var(--serif); letter-spacing: -.025em; }
.library-heading .button { min-width: 204px; }
.library-tools { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 36px 0 32px; }
.library-tabs { display: flex; gap: 12px; }
.library-tools .search-form { width: min(46%, 488px); }
.continue-story { display: flex; gap: 28px; align-items: center; background: var(--sage); border-radius: 18px; padding: 20px; margin-bottom: 32px; }
.continue-story > img { width: 114px; height: 152px; object-fit: cover; border-radius: 10px; }
.continue-story h3 { font: 500 26px/1.35 var(--serif); }
.continue-story p { color: var(--muted); font-size: 18px; margin: 8px 0 16px; }
.library-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 24px; }
.library-card { min-width: 0; display: flex; flex-direction: column; }
.library-cover { position: relative; }
.library-cover > form { position: absolute; top: 8px; right: 8px; }
.favorite-button { background: #fff; box-shadow: 0 1px 5px #0000000a; }
.library-card h4 { font-size: 18px; line-height: 1.35; margin: 12px 0 6px; overflow-wrap: anywhere; }
.library-card .button { width: 100%; margin-top: 16px; }
.library-card-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.library-card-actions .text-button { font-size: 14px; text-decoration: none; }
.delete-button { color: var(--muted); }
.delete-button:hover { color: var(--danger); }
.library-note { color: var(--muted); font-size: 13px; padding: 24px 0 0; margin-top: 32px; border-top: 1px solid var(--line); }
.empty-state { text-align: center; padding: 70px 24px; max-width: 680px; margin: 0 auto; }
.empty-state > .icon { width: 40px; height: 40px; margin: 0 auto 24px; }
.empty-state h2, .empty-state h3 { font: 500 30px/1.3 var(--serif); }
.empty-state p { color: var(--muted); font-size: 18px; margin: 16px auto 28px; max-width: 480px; }
.empty-state .button-row { justify-content: center; }
.settings-main { max-width: 820px; margin: 0 auto; padding: 56px 40px; }
.settings-main > h2 { font: 500 38px/1.25 var(--serif); letter-spacing: -.025em; }
.settings-intro { color: var(--muted); margin-top: 18px; }
.preferences-form { margin-top: 40px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; font-size: 20px; font-weight: 500; }
.preferences-form fieldset { padding-bottom: 30px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.field-hint { color: var(--muted); font-size: 16px; margin-top: 8px; line-height: 1.5; }
.choice-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.choice { position: relative; cursor: pointer; flex: 1 1 100px; }
.choice > input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.choice > span { display: flex; justify-content: center; align-items: center; padding: 12px 14px; min-height: 52px; border: 1px solid var(--line); border-radius: 12px; font-size: 17px; text-align: center; }
.choice > input:checked + span { border-color: var(--accent); background: #f6eaff; box-shadow: inset 0 0 0 1px var(--accent); }
.choice > input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 4px; }
.field { margin-top: 24px; }
.field > label { display: block; font-size: 18px; margin-bottom: 10px; }
.field input, .field select, .audio-options select { width: 100%; min-height: 56px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 12px 14px; font-size: 18px; }
.device-note { margin-top: 48px; background: var(--soft); border-radius: 18px; padding: 28px; }
.device-note h3 { font: 500 26px/1.3 var(--serif); }
.device-note > p:not(.demo-note) { margin-top: 14px; color: var(--muted); }
.device-note .demo-note { margin-top: 20px; }

/* Full story text lives only in the book. */
.book-layout { height: 100dvh; display: flex; overflow: hidden; }
.book-conversation { flex: 0 0 30%; max-width: 432px; min-width: 300px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fff; }
.book-conversation > header { min-height: 80px; border-bottom: 1px solid var(--line); padding: 18px 24px; }
.back-link { display: flex; align-items: center; gap: 14px; min-height: 44px; font-size: 18px; font-weight: 500; }
.book-chat-content { overflow: auto; padding: 40px 28px 24px; }
.book-chat-content .user-message { max-width: 100%; width: 100%; margin: 0 0 44px; font-size: 17px; }
.book-chat-note { margin-top: 16px; font-size: 20px; line-height: 1.5; }
.book-summary { display: flex; gap: 20px; align-items: center; margin: 36px 0; }
.book-summary > img { width: 100px; height: 134px; object-fit: cover; border-radius: 10px; }
.book-summary h2 { font: 500 26px/1.25 var(--serif); }
.book-summary .story-meta { margin-top: 12px; }
.book-edit-link { margin-top: 24px; }
.book-conversation > .demo-note { padding: 20px 28px; margin-top: auto; }
.reader { --reader-font-size: 22px; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--paper); color: var(--ink); }
.reader-toolbar { display: flex; gap: 10px; align-items: center; padding: 16px 28px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.reader-toolbar > .button, .reader-toolbar > form { flex: 1; min-width: 0; }
.reader-toolbar .button { min-height: 50px; padding: 10px 12px; font-size: 16px; white-space: nowrap; width: 100%; }
.reader-toolbar > .reader-back { flex: 0 0 auto; width: auto; }
.reader-toolbar .button .icon { width: 20px; height: 20px; }
.reader-toolbar .button .icon:not(.reader-back .icon) { display: none; }
.text-icon { font: 500 22px/1 var(--serif); }
.reader-toolbar .text-icon { display: none; }
.reader-scroll { overflow-y: auto; min-height: 0; flex: 1; scroll-behavior: smooth; overscroll-behavior: contain; }
.book-content { max-width: 1020px; margin: 0 auto; padding: 36px clamp(28px, 5.7vw, 88px) 72px; }
.book-content > h1 { font: 500 38px/1.3 var(--serif); letter-spacing: -.02em; margin-bottom: 24px; }
.book-chapter { scroll-margin-top: 24px; }
.book-chapter + .book-chapter { padding-top: 54px; margin-top: 54px; border-top: 1px solid var(--line); }
.book-chapter > .eyebrow { margin-bottom: 8px; }
.book-chapter > h2 { font: 500 24px/1.4 var(--serif); margin-bottom: 24px; }
.chapter-image { width: 100%; height: auto; aspect-ratio: 16 / 7; object-fit: cover; border-radius: 6px; margin-bottom: 30px; }
.reading-text { font: 400 var(--reader-font-size)/1.65 var(--serif); letter-spacing: -.012em; overflow-wrap: anywhere; }
.reading-text p { margin-bottom: 1.2em; }
.opening-paragraph::after { content: ""; display: table; clear: both; }
.drop-cap-image { float: left; width: 90px; height: 112px; object-fit: contain; margin: 2px 18px 2px 0; }
.drop-cap { font: 500 4.2em/.9 var(--serif); color: #775342; float: left; margin: .08em .14em 0 0; }
.reader-footer { display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); margin: 0 40px; padding: 16px 0; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.book-end { text-align: center; padding-top: 48px; margin-top: 48px; border-top: 1px solid var(--line); }
.book-end h2 { font: 500 30px/1.3 var(--serif); }
.book-end p { margin: 16px 0 28px; color: var(--muted); }
.book-end .button-row { justify-content: center; }
.reader[data-theme="dark"] { --paper: #202a2a; --ink: #f1ece1; --muted: #c7cec5; --line: #43504c; }
.reader[data-theme="dark"] .button.secondary { background: #2b3837; color: var(--ink); }
.reader[data-theme="dark"] .button.secondary .icon { filter: invert(1); }
.reader[data-theme="dark"] .drop-cap { color: #dfbb86; }

/* Accessible native dialogs; JavaScript supplies focus and playback behavior. */
dialog { border: 1px solid var(--line); border-radius: 24px; padding: 32px; color: var(--ink); background: #fff; width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: 0 16px 80px #15202024; }
dialog::backdrop { background: #1e282852; backdrop-filter: blur(3px); }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 12px; }
.dialog-top h2 { font: 500 28px/1.25 var(--serif); }
.dialog-top .icon-button { margin: -8px -12px -8px 0; }
.dialog-description { color: var(--muted); font-size: 18px; margin: 16px 0 28px; }
.settings-dialog fieldset + fieldset { margin-top: 28px; }
.settings-dialog > .button, .settings-form > .button { margin-top: 32px; }
.settings-dialog .field { margin-top: 28px; }
.settings-form > .field:first-child { margin-top: 24px; }
.menu-dialog { width: min(380px, calc(100% - 32px)); }
.menu-dialog .wordmark { width: 160px; }
.menu-dialog > .button { width: 100%; margin-top: 20px; }
.menu-links { display: flex; flex-direction: column; gap: 6px; margin-top: 20px; }
.menu-links a { min-height: 48px; display: flex; align-items: center; padding: 8px 12px; border-radius: 10px; }
.menu-links a:hover { background: var(--sage); }
.menu-dialog .demo-note { margin-top: 24px; }
.chapter-links { list-style: none; padding: 0; margin: 28px 0 0; }
.chapter-links li + li { border-top: 1px solid var(--line); }
.chapter-links a { display: block; padding: 18px 8px; font: 500 22px/1.4 var(--serif); }
.chapter-links a span { display: block; font: 400 13px/1.4 var(--sans); color: var(--muted); margin-bottom: 6px; }
.audio-dialog { max-width: 560px; }
.audio-art img { width: 144px; height: 192px; border-radius: 12px; object-fit: cover; margin: 12px auto 20px; }
.audio-dialog > h2 { font: 500 28px/1.25 var(--serif); text-align: center; }
.audio-status { font-size: 15px; color: var(--muted); text-align: center; margin: 14px 0 26px; }
.audio-dialog progress { display: block; width: 100%; height: 6px; accent-color: var(--accent); border: 0; border-radius: 3px; overflow: hidden; }
.audio-dialog progress::-webkit-progress-bar { background: var(--line); }
.audio-dialog progress::-webkit-progress-value { background: var(--accent); }
.audio-dialog progress::-moz-progress-bar { background: var(--accent); }
.audio-progress-label { min-height: 24px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.audio-transport { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 8px 0 24px; }
.audio-transport > .button { min-width: 160px; }
.audio-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.audio-options label { display: block; font-size: 15px; color: var(--muted); }
.audio-options label:first-child { grid-column: 1 / -1; }
.audio-options select { margin-top: 8px; color: var(--ink); font-size: 16px; min-height: 48px; }
.audio-dialog > .demo-note { margin-top: 24px; text-align: center; }

@media (prefers-color-scheme: dark) {
  .reader[data-theme="system"] { --paper: #202a2a; --ink: #f1ece1; --muted: #c7cec5; --line: #43504c; }
  .reader[data-theme="system"] .button.secondary { background: #2b3837; color: var(--ink); }
  .reader[data-theme="system"] .button.secondary .icon { filter: invert(1); }
  .reader[data-theme="system"] .drop-cap { color: #dfbb86; }
}

@media (max-width: 1250px) {
  .site-header { gap: 12px; padding-left: 32px; padding-right: 32px; }
  .site-header .header-catalog { display: none; }
  .home-main { padding-left: 32px; padding-right: 32px; }
  .home-hero { gap: 28px; }
  .idea-grid { gap: 18px; }
  .idea-card h3 { font-size: 18px; }
  .section-heading p { max-width: 330px; text-align: right; }
  .sidebar { width: 224px; }
  .app-main { margin-left: 224px; }
  .app-topbar { padding-left: 28px; padding-right: 28px; }
  .app-topbar > p { display: none; }
  .conversation-main, .new-chat-main { padding-left: 28px; padding-right: 28px; }
  .library-main { padding-left: 28px; padding-right: 28px; }
  .library-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-heading h2 { font-size: 36px; }
  .book-conversation { min-width: 270px; }
  .book-chat-content { padding-left: 20px; padding-right: 20px; }
  .book-summary { gap: 14px; }
  .book-summary h2 { font-size: 22px; }
  .reader-toolbar { padding: 14px 16px; gap: 8px; }
  .reader-toolbar .button { padding: 10px; min-width: 48px; }
  .reader-toolbar .button .icon, .reader-toolbar .text-icon { display: block !important; }
  .reader-toolbar .button span:not(.text-icon) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .reader-toolbar > .reader-back { flex: 1; }
}

@media (max-width: 950px) and (min-width: 701px) {
  .home-hero { grid-template-columns: 1fr; gap: 28px; }
  .home-hero h1 br { display: none; }
  .idea-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 20px; }
  .sidebar { width: 200px; padding: 16px 12px; }
  .sidebar .wordmark { width: 164px; }
  .brand-caption { margin-left: 8px; }
  .app-main { margin-left: 200px; }
  .nav-link { padding-left: 10px; }
  .new-chat-main { padding-top: 80px; }
  .new-chat-intro h2 { font-size: 38px; }
  .result-cover { width: 112px; height: 150px; }
  .story-result { gap: 16px; }
  .result-content h3 { font-size: 24px; }
  .result-description { display: none; }
  .result-actions { margin-top: 18px; }
  .result-actions .button { font-size: 15px; }
  .library-heading { display: block; }
  .library-heading > .button { margin-top: 20px; }
  .library-tools { flex-direction: column; align-items: stretch; }
  .library-tools .search-form { width: 100%; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .continue-story { gap: 16px; }
  .continue-story h3 { font-size: 22px; }
  .continue-story > img { width: 88px; height: 118px; }
  .continue-story .button-row { gap: 8px; }
  .continue-story .button { padding: 10px 14px; font-size: 15px; }
  .book-conversation { display: none; }
  .book-content { max-width: 820px; }
}

@media (max-width: 700px) {
  body { font-size: 18px; }
  .desktop-only, .site-header, .sidebar, .app-topbar { display: none; }
  .mobile-only { display: initial; }
  .has-mobile-nav { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 76px; padding: 12px; border-bottom: 1px solid var(--line); background: #fff; }
  .mobile-header .wordmark { width: 150px; height: 50px; }
  .mobile-title { font-size: 17px; font-weight: 500; text-align: center; line-height: 1.3; max-height: 44px; overflow: hidden; }
  .mobile-brand { min-width: 0; }
  .mobile-bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr); background: #fff; border-top: 1px solid var(--line); min-height: 76px; padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 56px; font-size: 12px; line-height: 1.4; color: var(--muted); }
  .bottom-nav-item .icon { width: 22px; height: 22px; opacity: .7; }
  .bottom-nav-item.active { color: var(--accent); font-weight: 500; }
  .bottom-nav-item.active .icon { opacity: 1; filter: invert(31%) sepia(91%) saturate(3375%) hue-rotate(257deg) brightness(98%) contrast(103%); }
  .button { font-size: 16px; }
  .pill { font-size: 16px; padding: 10px 16px; }
  .home-main { padding: 24px 16px 24px; }
  .home-hero { display: block; }
  .home-hero h1 { font-size: 32px; line-height: 1.22; }
  .home-hero > div > p { margin-top: 14px; font-size: 16px; }
  .home-hero .story-form { margin-top: 22px; }
  .composer { padding: 14px 14px 12px; border-radius: 18px; }
  .composer textarea { font-size: 18px; min-height: 62px; padding: 0 0 8px; }
  .composer-toolbar { gap: 8px; }
  .composer-toolbar > .pill { min-width: 0; padding-left: 12px; padding-right: 12px; }
  .composer-submit { min-width: 48px; width: 48px; height: 48px; min-height: 48px; padding: 12px; border-radius: 50%; }
  .composer-submit .icon { display: block; }
  .submit-label { display: none; }
  .category-nav { margin: 18px -16px 20px; padding: 4px 16px 6px; gap: 8px; scrollbar-width: none; }
  .category-nav::-webkit-scrollbar { display: none; }
  .section-heading { margin-bottom: 16px; }
  .section-heading h2, .section-heading h3 { font: 500 21px/1.35 var(--sans); }
  .section-heading p { display: none; }
  .idea-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 12px; }
  .story-cover { border-radius: 12px; }
  .idea-card h3 { font-size: 16px; min-height: 42px; line-height: 21px; }
  .idea-card p { font-size: 14px; margin: 6px 0 14px; }
  .idea-card .button { min-height: 48px; padding: 10px 8px; font-size: 14px; }
  .home-footer { margin-top: 36px; display: block; }
  .home-footer p + p { margin-top: 8px; }
  .app-main { margin: 0; min-height: calc(100dvh - 76px); }
  .new-chat-main { display: flex; flex-direction: column; min-height: calc(100dvh - 76px); padding: 44px 20px 20px; }
  .new-chat-intro h2 { font-size: 32px; }
  .new-chat-intro p { font-size: 18px; margin-top: 20px; }
  .new-chat-composer { order: 3; margin-top: auto; padding-top: 28px; }
  .prompt-suggestions { margin-top: 32px; }
  .prompt-suggestions h3 { font-size: 15px; }
  .suggestion-row { display: grid; gap: 10px; }
  .suggestion-row .pill { min-height: 52px; white-space: normal; }
  .chat-boundary { font-size: 15px; margin-top: 28px; }
  .conversation-main { padding: 24px 16px 0; }
  .user-message { max-width: 92%; padding: 14px 16px; font-size: 17px; }
  .assistant-message { margin-top: 24px; }
  .assistant-name { font-size: 20px; }
  .story-excerpt { font: 400 18px/1.55 var(--serif); margin: 14px 0 22px; }
  .story-result { display: grid; grid-template-columns: 88px minmax(0, 1fr); padding: 16px; gap: 10px 16px; }
  .result-cover-link { grid-column: 1; grid-row: 1 / 3; }
  .result-cover { width: 88px; height: 118px; border-radius: 10px; }
  .result-content { display: contents; }
  .result-content .eyebrow, .result-description { display: none; }
  .result-content h3 { grid-column: 2; margin: 3px 18px 0 0; font-size: 23px; line-height: 1.28; overflow-wrap: anywhere; }
  .result-content .story-meta { grid-column: 2; align-self: end; font-size: 14px; }
  .result-actions { grid-column: 1 / -1; width: 100%; margin-top: 6px; gap: 10px; }
  .result-actions .button { font-size: 15px; padding: 10px 8px; white-space: nowrap; }
  .result-favorite { width: 32px; height: 32px; padding: 6px; }
  .story-result > form { right: 6px; top: 6px; }
  .chat-compose-area { padding-top: 14px; padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)); margin-top: 12px; }
  .refinements { gap: 8px; margin-bottom: 12px; }
  .refinements .pill { font-size: 14px; padding: 9px 12px; }
  .compact .composer textarea { min-height: 30px; }
  .story-turn + .story-turn { margin-top: 36px; }
  .library-main { padding: 28px 16px; }
  .library-heading { display: block; }
  .library-heading h2 { font-size: 30px; }
  .library-heading > .button { display: none; }
  .library-tools { flex-direction: column-reverse; align-items: stretch; gap: 18px; margin: 24px 0; }
  .library-tools .search-form { width: 100%; }
  .library-tabs > * { flex: 1; }
  .continue-story { padding: 16px; gap: 16px; align-items: flex-start; margin-bottom: 24px; }
  .continue-story > img { width: 72px; height: 96px; }
  .continue-story h3 { font-size: 21px; }
  .continue-story p { font-size: 15px; margin: 8px 0 14px; }
  .continue-story .button { min-height: 46px; font-size: 14px; padding: 9px 12px; }
  .continue-story .button.secondary { display: none; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 12px; }
  .library-card h4 { font-size: 16px; min-height: 42px; }
  .library-card .story-meta { font-size: 14px; }
  .library-card > .button { font-size: 14px; padding: 10px 8px; min-height: 48px; }
  .library-card-actions { flex-wrap: wrap; gap: 0 8px; }
  .library-card-actions .text-button { font-size: 13px; }
  .favorite-button { width: 42px; height: 42px; padding: 10px; }
  .library-cover > form { top: 6px; right: 6px; }
  .empty-state { padding: 48px 8px; }
  .empty-state h2, .empty-state h3 { font-size: 27px; }
  .empty-state p { font-size: 17px; }
  .settings-main { padding: 32px 20px; }
  .settings-main > h2 { font-size: 30px; }
  .settings-intro { font-size: 17px; }
  .preferences-form { margin-top: 32px; }
  .choice-row { gap: 8px; }
  .choice > span { padding: 11px 8px; font-size: 15px; }
  .device-note { padding: 24px; margin-top: 36px; }
  .device-note h3 { font-size: 24px; }
  .device-note p { font-size: 16px; }
  .device-note .demo-note { font-size: 12px; }
  .book-conversation { display: none; }
  .reader-toolbar { padding: 12px 8px; gap: 4px; min-height: 76px; }
  .reader-toolbar .button { padding: 10px; min-height: 48px; border-color: transparent; }
  .reader-toolbar > .reader-back { flex: 1; }
  .book-content { padding: 24px 20px 48px; }
  .book-content > h1 { font-size: 28px; line-height: 1.3; text-align: center; margin-bottom: 24px; }
  .book-chapter > .eyebrow { text-align: center; }
  .book-chapter > h2 { text-align: center; font-size: 23px; margin-bottom: 20px; }
  .chapter-image { border-radius: 10px; margin-bottom: 26px; }
  .reading-text { line-height: 1.65; }
  .drop-cap-image { width: 70px; height: 90px; margin-right: 12px; }
  .reader-footer { margin: 0 16px; padding: 14px 0 max(14px, env(safe-area-inset-bottom, 0px)); gap: 10px; font-size: 11px; }
  .book-end h2 { font-size: 28px; }
  dialog { width: calc(100vw - 24px); padding: 24px; border-radius: 20px; max-height: calc(100dvh - 24px); }
  .dialog-top h2 { font-size: 25px; }
  .dialog-description { font-size: 17px; }
  .settings-dialog .choice-row { gap: 8px; }
  .settings-dialog .choice { flex-basis: 80px; }
  .settings-dialog .choice > span { font-size: 15px; padding: 10px 6px; }
  .audio-dialog { --ink: #f1ece1; --muted: #c7cec5; --line: #50605a; background: #202a2a; }
  .audio-dialog > .dialog-top .icon { filter: invert(1); }
  .audio-art img { width: 144px; height: 192px; margin-top: 8px; }
  .audio-options { gap: 12px; }
  .audio-options select { background: #2b3837; color: var(--ink); font-size: 15px; padding: 10px; }
  .audio-transport > .icon-button .icon { filter: invert(1); }
  .audio-dialog .button.secondary { background: #f1ece1; color: #292d28; }
  .audio-dialog .button.secondary .icon { filter: none; }
  .global-status:not(:empty) { bottom: 88px; }
  .flash-stack { right: 16px; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 359px) {
  .composer-toolbar > .pill { font-size: 14px; padding-left: 9px; padding-right: 9px; }
  .home-hero h1, .new-chat-intro h2 { font-size: 29px; }
  .result-content h3 { font-size: 20px; }
  .result-content .story-meta { font-size: 12px; }
  .result-actions .button { font-size: 13px; }
  .audio-transport { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html, .reader-scroll { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
  .sidebar, .mobile-header, .mobile-bottom-nav, .reader-toolbar, .reader-footer, .book-conversation, .book-end, .flash-stack, .skip-link, dialog { display: none !important; }
  .book-layout, .reader, .reader-scroll { display: block; height: auto; overflow: visible; }
  .reader { color: #292d28 !important; background: white !important; }
  .book-content { padding: 0; max-width: none; }
  .book-chapter { break-before: page; }
  .book-chapter:first-of-type { break-before: auto; }
  .chapter-image { max-height: 250px; }
}

.reader[data-font-size="26"] { --reader-font-size: 26px; }
.reader[data-font-size="30"] { --reader-font-size: 30px; }

.auth-page { min-height: 100vh; padding: 24px 5vw 60px; background: #fff; }
.auth-top { max-width: 1300px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.auth-card { width: min(100%, 500px); margin: 56px auto 0; padding: 36px; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 12px 48px #34203f0b; }
.auth-card h1 { font-family: var(--serif); font-size: clamp(32px, 5vw, 42px); line-height: 1.18; margin: 12px 0 16px; }
.auth-sparkle { color: var(--accent); font-size: 24px; }
.auth-intro, .auth-hint, .auth-footer { color: var(--muted); line-height: 1.55; }
.auth-intro { font-size: 17px; margin-bottom: 28px; overflow-wrap: anywhere; }
.auth-form { display: grid; gap: 10px; }
.auth-form label { font-size: 16px; font-weight: 600; }
.auth-form input:not([type=submit]) { width: 100%; min-height: 54px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: white; font-size: 18px; }
.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-form .button { margin-top: 10px; width: 100%; }
.auth-code { letter-spacing: .24em; font-weight: 600; }
.auth-hint, .auth-footer { font-size: 14px; }
.auth-footer { border-top: 1px solid var(--line); margin-top: 26px; padding-top: 20px; }
@media (max-width: 520px) { .auth-page { padding: 18px 20px 40px; } .auth-card { padding: 26px 20px; margin-top: 36px; } }
