:root {
  color-scheme: light;
  --background: #f9f5e9;
  --paper: #fffdf5;
  --paper-deep: #f4edda;
  --sand: #f0e7ce;
  --ink: #26382e;
  --muted: #5d6659;
  --green: #235442;
  --green-deep: #163d31;
  --rust: #a34935;
  --line: #dfd7c3;
  --soft-green: #dfebdc;
  --shadow: 0 12px 32px #664e2520;
  --serif: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-family: var(--sans);
  font-synthesis: none;
  color: var(--ink);
  background: var(--background);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
body, button, input, textarea, select { font-family: var(--sans); }
button, input, textarea, select { font-size: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--green); }
:focus-visible { outline: 3px solid #a35a31; outline-offset: 3px; }
[hidden] { display: none !important; }
main { flex: 1; min-height: 55vh; }
main:focus { outline: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { overflow-wrap: anywhere; }
img { display: block; max-width: 100%; }
::selection { color: var(--ink); background: #e8cca2; }
.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: 6; top: 10px; left: 10px; padding: 10px;
  background: var(--paper); transform: translateY(-180%);
}
.skip-link:focus { transform: none; }

.site-header {
  position: relative; z-index: 1; background: color-mix(in srgb, var(--background), white 24%);
  border-bottom: 1px solid var(--line);
}
.header-inner, .page-shell, .site-footer {
  width: min(100% - 40px, 1150px); margin-inline: auto;
}
.header-inner { height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 21px; white-space: nowrap; letter-spacing: .015em; color: var(--green-deep); }
.brand-mark {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 34px; width: 34px; height: 34px;
  background: var(--green); border-radius: 10px; color: #fff3cf;
}
.brand-mark i { display: block; width: 9px; height: 12px; border: 1.4px solid currentColor; border-radius: 2px 2px 3px 1px; transform: rotate(-13deg); margin-inline: -1px 0; }
.brand-mark i + i { transform: rotate(13deg); border-radius: 2px 2px 1px 3px; margin-inline: 0 -1px; }
.brand-mark b { position: absolute; width: 3px; height: 3px; left: 15.5px; top: 6px; color: #efca78; background: currentColor; transform: rotate(45deg); }
.site-nav { display: flex; align-items: center; gap: clamp(11px, 3vw, 32px); font-size: 14px; font-weight: 650; white-space: nowrap; }
.site-nav > a:not(.top-action) { padding-block: 8px; color: var(--muted); }
.site-nav > a[aria-current="page"]:not(.top-action) { color: var(--green); border-bottom: 2px solid var(--green); }
.site-nav .top-action { border: 1px solid #b6c3ad; color: var(--green-deep); padding: 8px 13px; border-radius: 999px; }
.top-action span { margin-left: 3px; }
.site-nav .top-action:hover, .site-nav .top-action[aria-current="page"] { background: var(--soft-green); }

.site-footer {
  min-height: 84px; margin-top: 64px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center; gap: 12px 22px; color: var(--muted); font-size: 13px;
}
.site-footer > span { color: var(--green-deep); font-weight: 750; }
.site-footer a, .text-button { text-underline-offset: 4px; }
.site-footer a:hover, .text-button:hover { text-decoration: underline; }

.button {
  min-height: 47px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: 1px solid transparent; border-radius: 12px; font-size: 15px;
  font-weight: 700; line-height: 1.25; text-align: center; text-wrap: balance;
  transition: background-color .14s ease, border-color .14s ease, transform .14s ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { color: #fffdf1; background: var(--green); border-color: var(--green); }
.button.primary:hover { background: var(--green-deep); }
.button.secondary { color: var(--green-deep); background: var(--paper); border-color: #d7ccb4; }
.button.secondary:hover { border-color: #aebaa8; background: #fbf6e8; }
.button.danger { background: #9f3d2a; color: var(--paper); }
.button.danger:hover { background: #832e20; }
.button:disabled { opacity: .58; box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.text-button { padding: 0; border: 0; background: none; color: var(--green-deep); font: inherit; font-weight: 650; }
.play-icon { font-size: .73em; }

.hero {
  min-height: 550px; display: grid; grid-template-columns: .98fr 1.02fr; gap: clamp(30px, 7vw, 112px);
  align-items: center; padding-block: 68px 74px;
}
.hero-copy h1 {
  font-family: var(--serif); font-size: clamp(37px, 5.5vw, 73px); line-height: 1.17;
  font-weight: 800; letter-spacing: -.047em; color: var(--green-deep);
}
.hero-copy h1 em { color: var(--rust); font-style: normal; }
.lede { color: var(--muted); font-size: 16px; line-height: 1.8; }
.hero .lede { max-width: 31em; margin-top: 21px; font-size: clamp(16px, 1.5vw, 19px); }
.hero-actions { margin-top: 26px; }
.hero-actions .button { padding-inline: 19px; }
.hero-book {
  position: relative; justify-self: end; width: min(100%, 465px); display: block; padding: 17px;
  background: #f1e7cb; border: 1px solid #e1d5b7; border-radius: 24px;
  box-shadow: 0 22px 48px #71603a20; isolation: isolate;
}
.hero-book::before, .hero-book::after {
  position: absolute; z-index: -1; content: ""; pointer-events: none;
}
.hero-book::before {
  inset: -14px -11px 17px 25px; transform: rotate(3deg); border: 1px solid #faf4e2;
  border-radius: 25px; background: #e8ddbd; box-shadow: inset 0 0 30px #f8f1d8;
}
.hero-book::after {
  inset: -25px 6px 24px 46px; border-radius: 24px; border: 1px solid #e0d6b7;
  transform: rotate(6deg); z-index: -2;
}
.book-shadow {
  border-radius: 15px; position: relative; z-index: 0; overflow: hidden;
  box-shadow: 0 8px 17px #503a2a28; transition: transform .22s ease;
}
.hero-book:hover .book-shadow { transform: translateY(-3px); }
.cover-art {
  position: relative; overflow: hidden; aspect-ratio: 1; background:
    radial-gradient(ellipse at 62% 62%, #ddae6190 0%, transparent 28%),
    radial-gradient(ellipse at 32% 74%, #66a58665 0%, transparent 32%),
    linear-gradient(144deg, #254841, #497368 52%, #b99c64);
}
.cover-art::before {
  position: absolute; content: ""; top: 23%; left: 49%; width: 14%; aspect-ratio: 1; border-radius: 50%;
  background: #fbe4a9; box-shadow: 0 0 42px #e7c377, -70px 15px 0 -18px #e3d193, 62px 42px 0 -18px #e6d28f;
}
.cover-art::after {
  position: absolute; content: ""; inset: 50% -15% -12%; background:
    radial-gradient(ellipse at 30% 85%, #254846 0 42%, transparent 43%),
    radial-gradient(ellipse at 80% 85%, #3c5d4c 0 52%, transparent 53%);
}
.cover-art:has(img)::before, .cover-art:has(img)::after { content: none; }
.cover-art img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.hero-cover { border-radius: 14px; aspect-ratio: 1.16; }
.hero-cover img { object-position: center 48%; }
.hero-book-caption { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 4px 1px; }
.sample-label, .status {
  display: inline-flex; width: fit-content; align-items: center; max-width: 100%; padding: 5px 9px;
  background: var(--soft-green); color: var(--green-deep); border-radius: 999px;
  font-family: var(--sans); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.sample-label { background: #fffbec; }
.hero-book-caption strong { font-family: var(--serif); font-size: 18px; min-width: 0; overflow-wrap: anywhere; }
.open-sample { margin-left: auto; font-size: 21px; color: var(--green); }

.steps { margin-top: 4px; border-top: 1px solid var(--line); padding: 28px 0 6px; }
.steps > h2 { margin-bottom: 18px; font-family: var(--serif); font-size: 26px; color: var(--green-deep); }
.step-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.step-grid article {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px 14px; min-height: 95px;
  background: #fffdf780; border: 1px solid var(--line); border-radius: 13px;
}
.step-icon { display: grid; width: 38px; height: 38px; flex: 0 0 38px; align-items: center; justify-content: center; font-size: 19px; border-radius: 10px; color: var(--green-deep); }
.icon-pencil { background: #eee1bf; }
.icon-stars { background: #dfebdc; }
.icon-music { background: #f0ddd1; color: var(--rust); }
.step-grid h3 { font-size: 15px; line-height: 1.45; }
.step-grid p { font-size: 13px; margin-top: 3px; line-height: 1.55; color: var(--muted); }

.narrow { max-width: 560px; }
.form-page { max-width: 740px; }
.page-head { margin: 49px 0 27px; }
.eyebrow { margin-bottom: 9px; font-size: 13px; font-weight: 700; color: var(--rust); }
.page-head h1 {
  font-family: var(--serif); color: var(--green-deep); font-size: clamp(31px, 5.8vw, 49px);
  line-height: 1.23; font-weight: 800; letter-spacing: -.03em;
}
.page-head .lede { margin-top: 10px; }
.paper { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 22px #664e2511; }
.form-stack, .state-card, .prose { display: grid; gap: 18px; padding: clamp(16px, 4vw, 29px); }
.form-stack .actions { margin-top: 4px; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 7px; font-size: 14px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; background: #fcf8ed; color: var(--ink); border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 12px; line-height: 1.55; font-size: 16px; font-weight: 400;
}
.field input, .field select { min-height: 47px; }
.field textarea { resize: vertical; min-height: 95px; }
.field input::placeholder, .field textarea::placeholder { color: #736e5d; opacity: 1; }
.input-help { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; margin-top: -12px; }
.style-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.style-field legend { font-weight: 700; font-size: 14px; margin-bottom: 8px; padding: 0; }
.style-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.style-choice {
  display: flex; min-height: 72px; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 9px; cursor: pointer;
}
.style-choice:has(input:checked) { border-color: #71916d; background: #edf3e8; }
.style-choice input { width: 15px; height: 15px; accent-color: var(--green); margin: 0; flex-shrink: 0; }
.style-choice strong { display: block; font-size: 14px; }
.style-choice small { display: block; margin-top: 3px; line-height: 1.45; font-size: 12px; color: var(--muted); }
.style-dot { flex-shrink: 0; width: 29px; height: 29px; border-radius: 8px; }
.style-dot.watercolor { background: radial-gradient(ellipse at 35% 40%, #d8b694 15%, #e5ceb0 40%, transparent 70%), linear-gradient(125deg, #c3d6ba, #e8d3bd); }
.style-dot.crayon { background: repeating-linear-gradient(38deg, #bd6d4e57 0 3px, transparent 3px 6px), linear-gradient(135deg, #e2ac79 30%, #ba8c60); }
.form-message, .standalone-message { min-width: 0; font-size: 14px; line-height: 1.65; color: var(--green-deep); }
.form-message:empty, .standalone-message:empty { display: none; }
.form-message.problem, .standalone-message.problem { color: #9b3e2b; }
.dev-link { display: block; text-decoration: underline; text-underline-offset: 3px; }

.draft-form { display: grid; gap: 15px; }
.title-field, .draft-page, .draft-actions { padding: clamp(13px, 3vw, 19px); border-radius: 14px; }
.draft-pages { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.page-label { color: var(--rust); }
.draft-actions .form-message { margin-top: 9px; }
.shelf-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 49px 0 27px; }
.shelf-head .page-head { margin: 0; }
.books-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 19px; }
.book-card { overflow: hidden; min-width: 0; }
.card-cover { display: block; }
.card-cover .cover-art { aspect-ratio: 1.48; }
.card-copy { padding: 13px 15px 17px; }
.card-meta, .card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.card-copy h2 { margin: 9px 0 13px; font-family: var(--serif); font-size: 23px; color: var(--green-deep); }
.delete-link { color: var(--muted); font-weight: 500; }
.delete-link:hover { color: var(--rust); }
.status-failed { background: #f0e0d8; color: #8e3a2c; }
.status-queued, .status-generating, .status-draft { background: #eee3cd; color: #6a5131; }
.empty-shelf { display: grid; place-items: center; min-height: 250px; gap: 13px; text-align: center; padding: 24px; }
.empty-shelf h2 { font-family: var(--serif); font-size: 24px; color: var(--green-deep); }
.mini-book { width: 45px; height: 58px; border-radius: 4px 7px 7px 4px; transform: rotate(-10deg); background: var(--soft-green); border: 1px solid #bccbb9; border-left: 5px solid #adc0a5; box-shadow: 3px 3px #efe2bf; }
.shelf .standalone-message { margin-top: 14px; }
.loading { padding-block: 75px; color: var(--muted); }
.prose, .state-card { line-height: 1.8; }

.progress-panel { display: grid; gap: 17px; padding: clamp(16px, 4vw, 26px); }
.progress-art { justify-self: start; }
.progress-cover { width: 82px; border-radius: 12px; box-shadow: var(--shadow); }
.progress-panel h2 { font-family: var(--serif); font-size: 25px; color: var(--green-deep); }
.progress-panel p { color: var(--muted); line-height: 1.7; margin-top: 6px; }
.progress-reading { display: grid; gap: 8px; }
progress { width: 100%; height: 11px; appearance: none; border: 0; border-radius: 99px; background: var(--paper-deep); accent-color: var(--green); }
progress::-webkit-progress-bar { background: var(--paper-deep); border-radius: 99px; }
progress::-webkit-progress-value { background: #527b54; border-radius: 99px; }
progress::-moz-progress-bar { background: #527b54; border-radius: 99px; }
.progress-count { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.failed-count { color: #9b3e2b; }

.reader-page { max-width: 980px; }
.reader-head {
  min-height: 67px; display: grid; grid-template-columns: 1fr minmax(0, 2fr) 1fr;
  align-items: center; gap: 8px; text-align: center; font-size: 14px;
}
.reader-head > a:first-child { justify-self: start; }
.reader-title { color: var(--green-deep); font-weight: 700; display: flex; min-width: 0; align-items: center; justify-content: center; gap: 7px; }
.reader-title > :last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-progress { justify-self: end; }
.reader-stage {
  display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; overflow: hidden; min-width: 0;
  background: var(--paper); border: 1px solid #d8cbb0; border-radius: 21px;
  box-shadow: 0 20px 40px #664e2520; touch-action: pan-y;
}
.reader-art {
  background-color: var(--green); min-width: 0; aspect-ratio: 1; border-radius: 0; box-shadow: inset -3px 0 6px #34302a30;
}
.reader-art img { object-fit: contain; background: var(--paper-deep); }
.reader-text {
  position: relative; display: flex; min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 16px; padding: clamp(18px, 5.6vw, 55px); background: linear-gradient(90deg, #f0e8d3 0, var(--paper) 13%);
}
.reader-text h1 { font-family: var(--serif); color: var(--green-deep); font-weight: 800; font-size: clamp(28px, 4.8vw, 48px); line-height: 1.25; overflow-wrap: anywhere; }
.reader-text .button { margin-top: 4px; }
.reader-page-number, .reader-meta { color: var(--muted); font-size: 13px; }
.story-text { color: var(--ink); white-space: pre-wrap; font-family: var(--serif); font-size: clamp(19px, 2.5vw, 27px); line-height: 1.72; font-weight: 600; }
.reader-console { display: grid; gap: 14px; margin-top: 16px; }
.reader-nav { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; gap: 10px; }
.reader-nav > :first-child { justify-self: start; }
.reader-nav > :last-child { justify-self: end; }
.reader-nav .button { min-height: 41px; padding-block: 8px; font-size: 14px; }
.page-indicator { text-align: center; font-size: 13px; color: var(--muted); }
.page-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.page-dots button {
  position: relative; display: grid; place-items: center; width: 23px; height: 26px;
  background: none; border: 0; padding: 0;
}
.page-dots button::after { content: ""; width: 7px; height: 7px; border-radius: 999px; background: #bbb19a; }
.page-dots button:hover::after { background: #659074; }
.page-dots button[aria-current="page"]::after { background: var(--green); width: 11px; }
.sound-controls { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 7px; }
.sound-button {
  min-height: 40px; border: 1px solid #d7ccb4; border-radius: 12px; padding: 7px 10px;
  color: var(--green-deep); background: var(--paper); font-family: var(--sans); font-size: 13px; font-weight: 650;
}
.sound-button[aria-pressed="true"] { border-color: #87a687; background: var(--soft-green); }
.sound-button:disabled { opacity: .53; }
.sound-button > span:first-child { display: inline-block; width: 1em; }
.audio-note { color: var(--muted); font-size: 12px; }
.reader-console .standalone-message { text-align: center; }

dialog { max-width: min(calc(100% - 32px), 390px); padding: 0; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
dialog::backdrop { background: #1a291f88; }
.dialog-content { display: grid; gap: 14px; padding: 23px; }
.dialog-content h2 { font-family: var(--serif); font-size: 24px; }
.dialog-content p { color: var(--muted); }
.dialog-content .actions { justify-content: flex-end; }

@media (max-width: 780px) {
  .hero { gap: 30px; min-height: 0; padding-block: 46px; }
  .hero-copy h1 { font-size: clamp(33px, 6.15vw, 51px); }
  .hero-book { padding: 12px; }
  .hero-book::before { inset: -8px -5px 14px 20px; }
  .hero-book::after { inset: -13px 7px 22px 34px; }
  .hero .lede { margin-top: 15px; }
  .hero-actions { margin-top: 18px; }
  .hero-actions .button { padding-inline: 13px; }
  .books-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-text { gap: 11px; }
}
@media (max-width: 620px) {
  .header-inner, .page-shell, .site-footer { width: calc(100% - 30px); }
  .header-inner { height: 62px; }
  .brand { font-size: 18px; gap: 7px; }
  .brand-mark { width: 30px; height: 30px; flex-basis: 30px; border-radius: 8px; }
  .brand-mark b { left: 13.5px; top: 5px; }
  .site-nav { font-size: 12px; gap: 11px; }
  .site-nav .top-action { padding: 7px 8px; }
  .top-action span { display: none; }
  .hero { grid-template-columns: 1fr; gap: 29px; padding-block: 33px 33px; }
  .hero-copy h1 { font-size: clamp(37px, 9vw, 51px); line-height: 1.18; }
  .hero .lede { font-size: 15px; line-height: 1.65; max-width: 28em; }
  .hero-actions { gap: 9px; }
  .hero-book { justify-self: center; width: min(100% - 12px, 410px); border-radius: 18px; }
  .hero-cover, .book-shadow { border-radius: 10px; }
  .hero-cover { aspect-ratio: 1.26; }
  .hero-book-caption { padding: 11px 1px 1px; }
  .hero-book-caption strong { font-size: 16px; }
  .step-grid { grid-template-columns: 1fr; gap: 8px; }
  .steps { padding-top: 21px; }
  .steps > h2 { font-size: 23px; margin-bottom: 12px; }
  .step-grid article { min-height: 0; padding: 10px 12px; align-items: center; }
  .step-icon { width: 32px; height: 32px; flex-basis: 32px; font-size: 16px; }
  .site-footer { margin-top: 40px; min-height: 72px; }
  .page-head, .shelf-head { margin-block: 30px 20px; }
  .page-head .lede { font-size: 15px; }
  .shelf-head { align-items: flex-start; flex-direction: column; }
  .reader-head { min-height: 56px; font-size: 13px; grid-template-columns: 1fr minmax(0, 1.6fr) 1fr; }
  .reader-title .status { display: none; }
  .reader-stage { grid-template-columns: 1fr; border-radius: 16px; }
  .reader-text { min-height: 162px; background: var(--paper); padding: 15px 18px 18px; gap: 8px; }
  .reader-text h1 { font-size: clamp(28px, 8vw, 39px); }
  .story-text { font-size: clamp(18px, 5vw, 25px); }
  .reader-console { margin-top: 12px; }
  .page-dots { gap: 0; }
  .page-dots button { width: 16px; height: 22px; }
  .reader-nav .button { padding-inline: 9px; }
}
@media (max-width: 420px) {
  .draft-pages { grid-template-columns: 1fr; }
  .books-grid { gap: 10px; }
  .card-copy { padding: 10px; }
  .card-copy h2 { font-size: 18px; }
  .card-meta, .card-actions { font-size: 12px; }
  .style-dot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
