:root {
  --ink: #17211b;
  --muted: #617066;
  --paper: #fffaf0;
  --panel: #fffdf7;
  --line: #d8d0bf;
  --leaf: #2e6f57;
  --leaf-dark: #1e4f3f;
  --sun: #f3b23f;
  --berry: #b34848;
  --sky: #d6edf1;
  --shadow: 0 18px 50px rgba(48, 42, 28, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(214, 237, 241, 0.78), rgba(255, 250, 240, 0.9) 42%, rgba(245, 224, 176, 0.72)),
    radial-gradient(circle at 8% 12%, rgba(46, 111, 87, 0.12), transparent 30%);
  font-family: "Trebuchet MS", "Noto Sans SC", sans-serif;
}

body.download-body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, rgba(255, 247, 214, 0.5), transparent 26%),
    radial-gradient(circle at bottom right, rgba(46, 111, 87, 0.14), transparent 24%),
    linear-gradient(135deg, #f6ead1, #fffaf0 48%, #dceee4);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

.mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--leaf);
  box-shadow: var(--shadow);
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a,
.ghost,
.primary,
.danger,
.choice {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.nav a {
  color: var(--ink);
  background: rgba(255, 253, 247, 0.7);
  border: 1px solid rgba(216, 208, 191, 0.8);
}

.nav a.active,
.primary {
  color: #fff;
  background: var(--leaf);
}

.danger {
  color: #fff;
  background: var(--berry);
}

.ghost {
  color: var(--leaf-dark);
  background: #fffdf7;
  border: 1px solid var(--line);
}

.primary:hover,
.ghost:hover,
.danger:hover,
.choice:hover,
.nav a:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(42, 42, 31, 0.12);
}

.layout {
  max-width: 1180px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card,
.panel {
  border: 1px solid rgba(216, 208, 191, 0.9);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.88);
  box-shadow: var(--shadow);
}

.card {
  display: flex;
  min-height: 230px;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
}

.panel {
  padding: 18px;
}

.bookshelf-scene {
  position: relative;
  display: grid;
  gap: 0;
  padding: 10px 0 28px;
}

.bookshelf-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.78), transparent 22%),
    linear-gradient(180deg, rgba(111, 154, 117, 0.12), rgba(91, 53, 19, 0.08) 36%, rgba(91, 53, 19, 0.15) 100%);
  pointer-events: none;
}

.bookshelf-hero {
  position: relative;
  z-index: 1;
  padding: 12px 20px 26px;
}

.bookshelf-copy {
  max-width: 42rem;
}

.bookshelf-wood {
  position: relative;
  z-index: 1;
  min-height: 26px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 243, 218, 0.42), transparent 35%),
    linear-gradient(90deg, #8c5528, #a86732 18%, #7c461f 42%, #a56b38 68%, #74411d 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 236, 205, 0.45),
    inset 0 -4px 0 rgba(75, 40, 15, 0.26),
    0 12px 28px rgba(71, 42, 18, 0.18);
}

.bookshelf-wood.top {
  margin-top: 8px;
}

.bookshelf-wood.bottom {
  margin-top: -4px;
}

.bookshelf-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  padding: 18px 14px 22px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.42), rgba(241, 228, 196, 0.32)),
    repeating-linear-gradient(90deg, rgba(111, 80, 40, 0.06) 0 2px, transparent 2px 22px);
  border-left: 10px solid rgba(126, 77, 38, 0.36);
  border-right: 10px solid rgba(126, 77, 38, 0.36);
}

.shelf-book {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 430px;
  padding: 18px 16px 16px;
  border-radius: 16px 16px 14px 14px;
  background:
    linear-gradient(180deg, rgba(255, 251, 241, 0.98), rgba(248, 241, 224, 0.94));
  border: 1px solid rgba(126, 77, 38, 0.22);
  box-shadow:
    0 26px 30px rgba(71, 42, 18, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
  overflow: hidden;
}

.shelf-book::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: -22px;
  height: 36px;
  border-radius: 50%;
  background: rgba(79, 51, 26, 0.16);
  filter: blur(10px);
}

.book-spine-accent {
  width: 100%;
  height: 12px;
  margin-bottom: 14px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, #8e2d2d, #c16542 35%, #d7b15f 70%, #44644d 100%);
}

.shelf-book-cover {
  position: relative;
  padding: 20px 18px 16px;
  border-radius: 14px;
  background:
    radial-gradient(circle at top right, rgba(255, 241, 189, 0.42), transparent 22%),
    linear-gradient(160deg, rgba(31, 84, 65, 0.96), rgba(110, 150, 102, 0.88) 44%, rgba(242, 178, 63, 0.88));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.shelf-book-cover::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 249, 228, 0.22);
  border-radius: 10px;
}

.shelf-age,
.shelf-book-title,
.shelf-book-subtitle,
.shelf-sticker-row {
  position: relative;
  z-index: 1;
}

.shelf-age {
  margin: 0 0 8px;
  color: rgba(255, 248, 228, 0.86);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.shelf-book-title {
  margin: 0;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.18;
}

.shelf-book-subtitle {
  margin: 10px 0 0;
  min-height: 42px;
  color: rgba(255, 250, 238, 0.92);
  line-height: 1.55;
}

.shelf-sticker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.shelf-book-summary {
  position: relative;
  z-index: 1;
  margin: 16px 2px 12px;
  color: #55452d;
  line-height: 1.75;
}

.shelf-save-meta {
  margin: -2px 2px 12px;
  color: #7a6037;
  font-size: 13px;
  font-weight: 800;
}

.shelf-actions {
  position: relative;
  z-index: 1;
  margin-top: 14px;
}

.shelf-actions .primary,
.shelf-actions .ghost {
  flex: 1 1 130px;
  min-height: 48px;
  border-radius: 999px;
  font-weight: 800;
}

.shelf-actions .primary {
  background: linear-gradient(90deg, #285842, #3d7f5f);
}

.save-ready {
  background: #dff1cf;
}

.save-empty {
  color: #725e45;
  background: #f1e7d3;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.story-cover {
  display: grid;
  min-height: 96px;
  margin: -2px -2px 14px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(46, 111, 87, 0.92), rgba(243, 178, 63, 0.82)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 6px, transparent 6px 14px);
  font-size: 34px;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.05;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

p {
  line-height: 1.75;
}

.muted {
  color: var(--muted);
}

.tags,
.actions,
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--leaf-dark);
  background: var(--sky);
  font-size: 13px;
  font-weight: 700;
}

.status {
  background: #efe4ca;
}

.player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
}

.stage {
  min-height: 560px;
  padding: 28px;
}

.scene {
  margin-top: 24px;
  border-left: 5px solid var(--sun);
  padding: 8px 0 8px 18px;
  font-size: 22px;
  line-height: 1.9;
}

.speaker {
  margin-top: 22px;
  padding: 18px;
  border-radius: 8px;
  background: #eef7ec;
}

.speaker-name {
  margin-bottom: 8px;
  color: var(--leaf-dark);
  font-weight: 800;
}

.choices {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.choice {
  width: 100%;
  min-height: 64px;
  border: 1px solid rgba(46, 111, 87, 0.24);
  color: var(--ink);
  background: #fffdf7;
  text-align: left;
}

.choice strong {
  display: block;
  margin-bottom: 4px;
}

.side-list {
  display: grid;
  gap: 10px;
}

.session-box {
  position: sticky;
  top: 16px;
}

.tablet-reader {
  min-height: calc(100vh - 118px);
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.storybook {
  display: grid;
  min-height: min(720px, calc(100vh - 170px));
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(101, 83, 51, 0.28);
  border-radius: 8px;
  background: #e7dcc6;
  box-shadow: 0 28px 80px rgba(55, 43, 26, 0.22);
  overflow: hidden;
}

.book-page {
  position: relative;
  min-width: 0;
  padding: 34px;
  background:
    linear-gradient(90deg, rgba(88, 66, 38, 0.1), transparent 9%),
    repeating-linear-gradient(0deg, rgba(107, 87, 55, 0.035) 0 1px, transparent 1px 32px),
    #fffaf0;
}

.illustration-page {
  display: grid;
  place-items: center;
  border-right: 1px solid rgba(101, 83, 51, 0.22);
  background:
    linear-gradient(270deg, rgba(88, 66, 38, 0.13), transparent 8%),
    #f8efd9;
}

.text-page {
  display: grid;
  grid-template-rows: auto 1fr;
}

.story-image,
.generated-illustration {
  width: min(100%, 520px);
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.44), 0 20px 45px rgba(58, 43, 25, 0.2);
}

.generated-illustration {
  position: relative;
  display: grid;
  align-content: end;
  padding: 26px;
  color: #fff;
  background:
    linear-gradient(180deg, #7ab6c4 0%, #517d65 58%, #294738 100%);
  overflow: hidden;
}

.moon {
  position: absolute;
  top: 30px;
  right: 42px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #ffe9a8;
  box-shadow: 0 0 34px rgba(255, 233, 168, 0.7);
}

.hill {
  position: absolute;
  bottom: -60px;
  width: 75%;
  height: 170px;
  border-radius: 50% 50% 0 0;
  background: rgba(28, 76, 54, 0.92);
}

.hill-one {
  left: -15%;
}

.hill-two {
  right: -18%;
  background: rgba(39, 104, 73, 0.78);
}

.illustration-title,
.generated-illustration p {
  position: relative;
  z-index: 1;
}

.illustration-title {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 900;
}

.generated-illustration p {
  max-width: 28em;
  margin-bottom: 0;
}

.page-number {
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.reading-page {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 16px;
}

.pinyin-text {
  display: grid;
  align-content: start;
  gap: 10px;
  padding-top: 10px;
}

.read-line {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  column-gap: 0.08em;
  row-gap: 0.12em;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: clamp(21px, 2.2vw, 30px);
  line-height: 1.16;
  cursor: pointer;
}

.read-line:hover {
  background: rgba(46, 111, 87, 0.08);
}

.pinyin-token {
  display: inline-grid;
  grid-template-rows: 1.15em auto;
  align-items: end;
  justify-items: center;
  align-self: end;
  margin: 0;
  vertical-align: bottom;
}

.pinyin-token.is-space {
  min-width: 0.34em;
}

.pinyin-annotation {
  display: block;
  min-height: 1.15em;
  color: #7f6a42;
  font-size: 0.45em;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.pinyin-token.is-punct .pinyin-annotation,
.pinyin-token.is-space .pinyin-annotation {
  visibility: hidden;
}

.pinyin-base,
.pinyin-punct,
.pinyin-space {
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
}

.pinyin-punct {
  min-width: 1em;
}

.pinyin-space {
  min-width: 0.34em;
}

.reader-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.audio-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.speaker-button {
  min-height: 48px;
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--leaf-dark);
  background: #fff3c8;
  border: 1px solid #efd27c;
  font-weight: 900;
}

.speaker-button.secondary {
  min-height: 44px;
  padding-inline: 14px;
  background: #fffdf7;
}

.speaker-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
  box-shadow: none;
}

.choice-page {
  display: grid;
  align-content: center;
  gap: 18px;
  min-height: 100%;
}

.tablet-choices {
  display: grid;
  gap: 14px;
}

.tablet-choice {
  min-height: 78px;
  border: 1px solid rgba(46, 111, 87, 0.22);
  border-radius: 8px;
  padding: 16px 18px;
  color: var(--ink);
  background: #fffdf7;
  text-align: left;
  box-shadow: 0 10px 24px rgba(54, 44, 29, 0.08);
}

.tablet-choice strong {
  display: block;
  margin-bottom: 5px;
  font-size: 20px;
}

.tablet-choice span {
  color: var(--muted);
}

.child-shell {
  min-height: 100vh;
  padding: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 245, 205, 0.28), transparent 28%),
    linear-gradient(180deg, #8a572d 0%, #5f341b 48%, #3e2112 100%);
}

.child-layout {
  max-width: none;
  min-height: 100vh;
  margin: 0;
}

.fullscreen-bookshelf {
  min-height: 100vh;
  padding: 18px 24px 24px;
  background:
    linear-gradient(90deg, rgba(59, 31, 14, 0.45), transparent 10%, transparent 90%, rgba(59, 31, 14, 0.45)),
    repeating-linear-gradient(90deg, rgba(255, 225, 164, 0.05) 0 2px, transparent 2px 22px),
    linear-gradient(180deg, #b7783f, #8d5429 46%, #6f3d1e);
}

.fullscreen-bookshelf::before {
  border-radius: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 229, 168, 0.42), transparent 28%),
    linear-gradient(90deg, rgba(40, 19, 8, 0.25), transparent 18%, transparent 82%, rgba(40, 19, 8, 0.25));
}

.bookshelf-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: #fff6df;
  text-shadow: 0 2px 8px rgba(50, 22, 5, 0.28);
}

.bookshelf-topbar .eyebrow,
.bookshelf-topbar .muted {
  color: rgba(255, 246, 223, 0.78);
}

.shelf-top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.shelf-author-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 999px;
  padding: 9px 14px;
  color: #583015;
  background: rgba(255, 246, 223, 0.92);
  font-weight: 900;
  text-decoration: none;
}

.wooden-case {
  position: relative;
  z-index: 1;
  display: grid;
  margin-top: 14px;
  min-height: calc(100vh - 132px);
  border: 14px solid rgba(82, 43, 18, 0.78);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(70, 35, 12, 0.22), transparent 8%, transparent 92%, rgba(70, 35, 12, 0.22)),
    linear-gradient(180deg, rgba(255, 226, 170, 0.35), rgba(150, 82, 35, 0.18)),
    #b87942;
  box-shadow:
    inset 0 0 0 5px rgba(255, 213, 142, 0.22),
    0 26px 80px rgba(38, 18, 7, 0.42);
}

.fullscreen-bookshelf .bookshelf-wood {
  min-height: 20px;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 228, 175, 0.52), transparent 36%),
    linear-gradient(90deg, #74411c, #c18345 24%, #8f5528 52%, #d09453 76%, #6a3918);
  box-shadow:
    inset 0 2px 0 rgba(255, 236, 194, 0.52),
    inset 0 -5px 0 rgba(63, 30, 9, 0.38),
    0 9px 18px rgba(47, 23, 8, 0.26);
}

.fullscreen-bookshelf .bookshelf-grid {
  align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(148px, 148px));
  grid-auto-rows: 252px;
  align-items: end;
  justify-content: space-around;
  gap: 0 22px;
  padding: 28px 32px 38px;
  border: 0;
  background:
    repeating-linear-gradient(180deg, transparent 0 252px, rgba(70, 33, 10, 0.42) 252px 270px, rgba(255, 218, 150, 0.38) 270px 276px),
    repeating-linear-gradient(90deg, rgba(83, 43, 17, 0.07) 0 2px, transparent 2px 28px);
}

.fullscreen-bookshelf .shelf-book {
  position: relative;
  display: block;
  width: 148px;
  height: 224px;
  min-height: 0;
  align-self: end;
  padding: 0;
  border-radius: 4px 10px 10px 4px;
  transform: perspective(900px) rotateY(-1.8deg);
  background: transparent;
  border: 1px solid rgba(44, 22, 8, 0.34);
  box-shadow:
    9px 16px 18px rgba(47, 22, 6, 0.26),
    inset 7px 0 0 rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.fullscreen-bookshelf .shelf-book::before {
  display: none;
}

.fullscreen-bookshelf .shelf-book > div:first-child {
  position: absolute;
  inset: 0;
}

.fullscreen-bookshelf .shelf-book-cover {
  position: absolute;
  inset: 0;
  display: block;
  min-height: 0;
  height: 100%;
  padding: 0;
  border-radius: inherit;
  overflow: hidden;
}

.fullscreen-bookshelf .shelf-book-title {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 70px;
  z-index: 2;
  margin: 0;
  color: #fffaf0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.58);
  font-size: 15px;
  line-height: 1.2;
}

.fullscreen-bookshelf .shelf-book.has-cover .shelf-book-title {
  display: none;
}

.fullscreen-bookshelf .shelf-book-subtitle,
.fullscreen-bookshelf .shelf-book-summary,
.fullscreen-bookshelf .tags,
.fullscreen-bookshelf .shelf-age,
.fullscreen-bookshelf .shelf-sticker-row,
.fullscreen-bookshelf .shelf-save-meta {
  display: none;
}

.shelf-cover-image,
.shelf-cover-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.shelf-cover-image {
  object-fit: cover;
}

.shelf-cover-fallback {
  display: grid;
  place-items: center;
  color: rgba(255, 249, 228, 0.94);
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 232, 151, 0.32), transparent 28%),
    linear-gradient(145deg, #2f6d59, #14342f);
  font-size: 34px;
  font-weight: 900;
}

.fullscreen-bookshelf .shelf-actions {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 9px;
  z-index: 3;
  display: grid;
  gap: 6px;
}

.fullscreen-bookshelf .shelf-actions .primary,
.fullscreen-bookshelf .shelf-actions .ghost {
  min-height: 31px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  box-shadow: 0 8px 18px rgba(30, 13, 4, 0.24);
}

.fullscreen-bookshelf .shelf-actions .primary {
  background: rgba(46, 111, 87, 0.9);
}

.fullscreen-bookshelf .shelf-actions .ghost {
  background: rgba(255, 253, 247, 0.94);
}

.report-screen {
  display: grid;
  align-content: start;
  gap: 16px;
}

.report-shelf {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
}

.report-book-card {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 16px;
  border: 8px solid rgba(84, 45, 21, 0.82);
  border-radius: 20px;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(89, 52, 24, 0.12), transparent 18%),
    #fff5dc;
  box-shadow: 0 24px 50px rgba(30, 13, 4, 0.28);
}

.report-cover {
  display: grid;
  aspect-ratio: 3 / 4;
  place-items: center;
  border-radius: 14px;
  overflow: hidden;
  color: #fff6df;
  background: linear-gradient(145deg, #2e6f57, #9b6a32);
  font-size: 30px;
  font-weight: 900;
}

.report-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.report-card-body {
  display: grid;
  align-content: start;
  gap: 10px;
}

.report-book {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(94vw, calc(82vh * 1.58));
  min-height: min(76vh, calc(94vw / 1.58));
  margin: 0 auto;
  border: 10px solid #5a3118;
  border-radius: 22px;
  overflow: hidden;
  background: #f5e3bd;
  box-shadow: 0 34px 90px rgba(20, 10, 5, 0.45);
}

.report-page {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
  padding: clamp(24px, 3vw, 46px);
  background:
    repeating-linear-gradient(0deg, rgba(126, 101, 58, 0.035) 0 1px, transparent 1px 30px),
    #fff5dc;
}

.report-page:first-child {
  border-right: 1px solid rgba(72, 45, 24, 0.26);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.report-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.report-stat {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(114, 84, 47, 0.22);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 252, 241, 0.76);
}

.report-grid.compact .report-stat {
  border-radius: 12px;
  padding: 9px;
}

.report-grid.compact .report-stat strong {
  font-size: 22px;
}

.report-grid.compact .report-stat span {
  font-size: 12px;
}

.report-stat strong {
  color: #2e6f57;
  font-size: clamp(24px, 3.2vw, 42px);
}

.report-stat span,
.report-event span {
  color: #7a6037;
}

.report-events {
  display: grid;
  gap: 10px;
}

.report-events.compact {
  gap: 6px;
}

.report-event {
  display: grid;
  gap: 3px;
  border-left: 4px solid #d5a24b;
  padding: 9px 12px;
  background: rgba(255, 252, 241, 0.72);
}

.tablet-reader {
  display: grid;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  height: 100dvh;
  min-height: 100dvh;
  place-items: center;
  padding: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 242, 204, 0.5), transparent 36%),
    linear-gradient(135deg, #6f4322, #3b2113 58%, #25140c);
}

.reader-toolbar {
  display: none;
}

.storybook {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(90deg, #e2c99a 0 50%, #e9d5aa 50% 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 244, 215, 0.5);
  overflow: hidden;
}

.storybook::before {
  content: "";
  position: absolute;
  inset: 10px 50% 10px auto;
  width: 34px;
  transform: translateX(50%);
  background:
    radial-gradient(ellipse at center, rgba(35, 18, 8, 0.42), transparent 68%);
  pointer-events: none;
  z-index: 4;
}

.book-page {
  min-width: 0;
  min-height: 0;
  padding: clamp(18px, 2.1vw, 32px);
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.52), transparent 20%),
    repeating-linear-gradient(0deg, rgba(126, 101, 58, 0.035) 0 1px, transparent 1px 30px),
    linear-gradient(90deg, rgba(122, 83, 43, 0.08), transparent 14%),
    #fff5dc;
}

.illustration-page {
  place-items: center;
  border-right: 1px solid rgba(72, 45, 24, 0.26);
  background:
    linear-gradient(270deg, rgba(86, 51, 25, 0.18), transparent 12%),
    #f6e3bd;
}

.book-left-label {
  position: absolute;
  top: 18px;
  left: 22px;
  right: 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(93, 67, 37, 0.78);
  font-size: 12px;
  font-weight: 900;
}

.text-page {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
}

.book-menu {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border-bottom: 1px solid rgba(128, 98, 56, 0.28);
  padding-bottom: 8px;
}

.book-shelf-button {
  min-height: 34px;
  border-radius: 999px;
  padding: 7px 14px;
  color: #5e4727;
  background: rgba(255, 249, 231, 0.78);
  border: 1px solid rgba(124, 93, 52, 0.26);
  box-shadow: 0 8px 18px rgba(78, 56, 28, 0.08);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.book-menu-title {
  display: grid;
  gap: 2px;
  color: #4f3a20;
  font-weight: 900;
}

.book-menu-title small {
  color: #836b45;
  font-size: 11px;
}

.page-number {
  justify-self: end;
  color: #8a724b;
  font-size: 11px;
}

.story-image,
.generated-illustration {
  width: min(68%, 360px);
  max-height: 78%;
  aspect-ratio: 3 / 4;
  border-radius: 22px;
  object-fit: cover;
  box-shadow:
    0 0 0 12px rgba(255, 248, 231, 0.72),
    0 20px 45px rgba(58, 43, 25, 0.28);
}

.reading-page {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
}

.pinyin-text {
  min-height: 0;
  overflow-y: auto;
  gap: 6px;
  padding: 4px 6px 8px 0;
}

.read-line {
  padding: 5px 8px;
  font-size: clamp(23px, 2.3vw, 32px);
  line-height: 1.72;
}

.pinyin-annotation {
  font-size: 0.4em;
}

.reader-controls {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  gap: 10px;
  padding-top: 9px;
}

.speaker-button {
  min-height: 34px;
  padding: 0;
  font-size: 12px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  min-width: 34px;
  place-items: center;
  padding: 0;
  line-height: 1;
}

.speaker-button.secondary {
  min-height: 32px;
  background: transparent;
}

.audio-icon {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 22px;
  color: #315748;
}

.audio-icon.volume {
  width: 22px;
  height: 22px;
}

.speaker-part {
  position: absolute;
  display: block;
  color: inherit;
}

.speaker-mouth {
  left: 1px;
  top: 8px;
  width: 5px;
  height: 6px;
  border-radius: 2px 0 0 2px;
  background: currentColor;
}

.speaker-cone {
  left: 5px;
  top: 4px;
  width: 8px;
  height: 14px;
  background: currentColor;
  clip-path: polygon(0 30%, 100% 0, 100% 100%, 0 70%);
}

.speaker-wave {
  background: transparent;
  border: 2px solid currentColor;
  border-left: 0;
  border-radius: 0 999px 999px 0;
}

.speaker-wave.one {
  left: 12px;
  top: 8px;
  width: 3px;
  height: 6px;
}

.speaker-wave.two {
  left: 14px;
  top: 6px;
  width: 5px;
  height: 10px;
}

.speaker-wave.three {
  left: 16px;
  top: 3px;
  width: 6px;
  height: 16px;
}

.audio-icon.play::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
}

.audio-icon.pause::before,
.audio-icon.pause::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 5px;
  height: 14px;
  border-radius: 2px;
  background: currentColor;
}

.audio-icon.pause::before {
  left: 5px;
}

.audio-icon.pause::after {
  right: 5px;
}

.audio-icon.stop::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: currentColor;
}

.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  justify-self: stretch;
}

.page-nav-button {
  min-height: 40px;
  border-radius: 999px;
  padding: 9px 14px;
  color: #fff;
  background: linear-gradient(90deg, #285842, #3d7f5f);
  box-shadow: 0 10px 22px rgba(45, 79, 60, 0.16);
  font-size: 14px;
  font-weight: 900;
}

.page-nav-button.previous {
  color: #315748;
  border: 1px solid rgba(49, 87, 72, 0.22);
  background: rgba(255, 252, 241, 0.86);
}

.download-shell {
  display: grid;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(20px, 4vw, 44px);
  align-content: center;
}

.download-hero,
.download-card {
  border: 1px solid rgba(136, 104, 62, 0.16);
  border-radius: 30px;
  background: rgba(255, 252, 243, 0.9);
  box-shadow: 0 24px 70px rgba(67, 48, 20, 0.12);
}

.download-hero {
  padding: clamp(28px, 5vw, 52px);
  background:
    radial-gradient(circle at top right, rgba(255, 241, 189, 0.55), transparent 22%),
    linear-gradient(135deg, rgba(34, 95, 74, 0.95), rgba(76, 130, 103, 0.92) 42%, rgba(242, 178, 63, 0.82));
  color: #fff8e8;
}

.download-eyebrow {
  margin: 0 0 12px;
  color: rgba(255, 249, 230, 0.84);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.download-hero h1 {
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.02;
}

.download-copy {
  max-width: 40rem;
  margin: 18px 0 0;
  color: rgba(255, 250, 238, 0.94);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.8;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.download-link {
  min-width: 170px;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 900;
}

.download-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.download-card {
  padding: 24px 22px;
  color: #4d3a23;
}

.download-card h2 {
  font-size: 22px;
}

.download-card p {
  margin: 12px 0 0;
  color: #6b573b;
}

.download-inline-link,
.download-meta {
  display: inline-flex;
  margin-top: 16px;
  color: #2e6f57;
  font-weight: 900;
}

.choice-page {
  min-height: 0;
  align-content: center;
  overflow-y: auto;
}

.choice-page h1 {
  font-size: clamp(22px, 2.4vw, 36px);
}

.tablet-choice {
  min-height: 60px;
  padding: 12px 14px;
}

.tablet-choice strong {
  font-size: 17px;
}

.storybook.turn-forward::after,
.storybook.turn-back::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 8;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(86, 51, 25, 0.18), transparent 18%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.45), transparent 24%),
    #fff5dc;
  box-shadow: -22px 0 38px rgba(55, 32, 15, 0.22);
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.storybook.turn-forward::after {
  right: 0;
  transform-origin: left center;
  animation: pageFlipForward 760ms cubic-bezier(0.2, 0.72, 0.18, 1) both;
}

.storybook.turn-back::after {
  left: 0;
  transform-origin: right center;
  animation: pageFlipBack 680ms cubic-bezier(0.2, 0.72, 0.18, 1) both;
}

@keyframes pageFlipForward {
  0% {
    transform: perspective(1400px) rotateY(0deg);
    filter: brightness(1);
  }
  45% {
    filter: brightness(0.93);
    box-shadow: -32px 0 44px rgba(55, 32, 15, 0.28);
  }
  100% {
    transform: perspective(1400px) rotateY(-178deg);
    filter: brightness(1.02);
  }
}

@keyframes pageFlipBack {
  0% {
    transform: perspective(1400px) rotateY(0deg);
    filter: brightness(1);
  }
  100% {
    transform: perspective(1400px) rotateY(178deg);
    filter: brightness(1.02);
  }
}

.creator {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.pack-list {
  display: grid;
  gap: 10px;
}

.pack-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf7;
  text-align: left;
}

.pack-button.active {
  border-color: var(--leaf);
  background: #eff7ee;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fffdf7;
}

.tab.active {
  color: #fff;
  border-color: var(--leaf);
  background: var(--leaf);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.problems {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.problem {
  border-radius: 8px;
  padding: 10px;
  background: #fff0ec;
}

.warning {
  background: #fff6d8;
}

.chapter-tools {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.chapter-editor,
.node-workbench {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 14px;
}

.node-workbench {
  margin-top: 14px;
  grid-template-columns: 220px minmax(0, 1fr);
}

.editor-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf7;
}

.editor-main {
  display: grid;
  gap: 14px;
}

.panel-lite,
.choice-editor,
.mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 253, 247, 0.72);
}

.stack {
  display: grid;
  gap: 10px;
}

.soft-section {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.editor-titlebar {
  align-items: flex-start;
  margin: 6px 0 0;
}

.editor-titlebar .danger {
  flex: 0 0 auto;
}

.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
}

.event-list {
  display: grid;
  gap: 8px;
  padding-left: 24px;
  line-height: 1.7;
}

.preview-map,
.preview-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.map-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf7;
}

.map-item span {
  color: var(--muted);
  font-size: 13px;
}

.preview-chapter {
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.92), rgba(246, 238, 218, 0.72));
}

.preview-node {
  background: rgba(255, 253, 247, 0.9);
}

.preview-choice-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.preview-choice {
  display: grid;
  gap: 3px;
  border-left: 4px solid var(--leaf);
  padding: 8px 10px;
  background: #f3f8ef;
}

.preview-choice span {
  color: var(--muted);
  font-size: 13px;
}

.illustration-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.illustration-prompt-card textarea {
  min-height: 150px;
  background: #fffaf0;
}

.illustration-importer {
  background:
    linear-gradient(135deg, rgba(214, 237, 241, 0.52), rgba(255, 253, 247, 0.86));
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.illustration-editor {
  border-top-style: dashed;
}

.illustration-thumb-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.illustration-thumb {
  width: 180px;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(54, 44, 29, 0.12);
}

.cover-editor {
  display: grid;
  gap: 10px;
}

.cover-preview,
.cover-empty {
  width: min(100%, 220px);
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  border-radius: 14px;
  object-fit: cover;
  background: #fffaf0;
}

.cover-empty {
  display: grid;
  place-items: center;
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.inline-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(46, 27, 12, 0.62);
  backdrop-filter: blur(5px);
}

.inline-dialog {
  width: min(640px, 92vw);
  padding: 34px;
  border: 5px solid rgba(90, 49, 20, 0.95);
  border-radius: 28px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.92), transparent 34%),
    linear-gradient(135deg, #fff6dc 0%, #f5dfad 100%);
  box-shadow: 0 24px 70px rgba(31, 16, 5, 0.38);
  color: #3d2514;
}

.inline-dialog h2 {
  margin: 0 0 12px;
  font-size: clamp(30px, 3vw, 44px);
}

.inline-dialog p {
  margin: 0;
  color: #725336;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.5;
}

.inline-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 28px;
}

.inline-dialog-actions button {
  min-width: 140px;
  min-height: 58px;
  font-size: 22px;
}

@media (orientation: landscape) and (max-height: 560px) {
  .fullscreen-bookshelf {
    padding: 10px 12px 12px;
  }

  .bookshelf-topbar {
    gap: 12px;
    align-items: flex-start;
  }

  .bookshelf-topbar h1 {
    font-size: clamp(28px, 6vw, 48px);
  }

  .bookshelf-topbar .eyebrow {
    font-size: 11px;
  }

  .shelf-top-actions {
    gap: 8px;
  }

  .shelf-author-link {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 13px;
  }

  .wooden-case {
    margin-top: 10px;
    min-height: calc(100dvh - 96px);
    border-width: 10px;
  }

  .fullscreen-bookshelf .bookshelf-grid {
    grid-template-columns: repeat(auto-fill, minmax(112px, 112px));
    grid-auto-rows: 188px;
    gap: 0 14px;
    padding: 18px 18px 24px;
    background:
      repeating-linear-gradient(180deg, transparent 0 188px, rgba(70, 33, 10, 0.42) 188px 204px, rgba(255, 218, 150, 0.38) 204px 210px),
      repeating-linear-gradient(90deg, rgba(83, 43, 17, 0.07) 0 2px, transparent 2px 24px);
  }

  .fullscreen-bookshelf .shelf-book {
    width: 112px;
    height: 170px;
  }

  .fullscreen-bookshelf .shelf-book-title {
    left: 10px;
    right: 10px;
    bottom: 56px;
    font-size: 13px;
  }

  .fullscreen-bookshelf .shelf-actions .primary,
  .fullscreen-bookshelf .shelf-actions .ghost {
    min-height: 28px;
    padding: 5px 8px;
    font-size: 11px;
  }

  .storybook::before {
    inset: 8px 50% 8px auto;
    width: 26px;
  }

  .book-page {
    padding: 14px 16px 12px;
  }

  .book-left-label {
    top: 12px;
    left: 14px;
    right: 14px;
    font-size: 10px;
  }

  .book-menu {
    gap: 8px;
    padding-bottom: 6px;
  }

  .book-menu-title {
    font-size: 14px;
  }

  .book-menu-title small,
  .page-number {
    font-size: 10px;
  }

  .book-shelf-button {
    min-height: 30px;
    padding: 5px 11px;
    font-size: 12px;
  }

  .story-image,
  .generated-illustration {
    width: min(60%, 250px);
    max-height: 66%;
    border-radius: 16px;
    box-shadow:
      0 0 0 8px rgba(255, 248, 231, 0.68),
      0 16px 30px rgba(58, 43, 25, 0.22);
  }

  .pinyin-text {
    padding-right: 0;
  }

  .read-line {
    padding: 4px 6px;
    font-size: clamp(18px, 2vw, 24px);
    line-height: 1.12;
  }

  .pinyin-annotation {
    font-size: 0.34em;
  }

  .reader-controls {
    grid-template-columns: auto minmax(200px, 1fr);
    gap: 8px;
    padding-top: 7px;
    align-items: end;
  }

  .audio-controls {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .icon-button {
    width: 30px;
    min-width: 30px;
  }

  .page-nav-button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
  }
}

@media (orientation: landscape) and (min-width: 980px) and (max-aspect-ratio: 16/10) {
  .storybook {
    grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  }

  .book-page {
    padding: clamp(16px, 1.8vw, 22px);
  }

  .story-image,
  .generated-illustration {
    width: min(72%, 390px);
    max-height: 72%;
  }

  .read-line {
    font-size: clamp(20px, 1.85vw, 28px);
    line-height: 1.62;
  }

  .reader-controls {
    grid-template-columns: auto minmax(240px, 1fr);
  }

  .fullscreen-bookshelf .bookshelf-grid {
    justify-content: space-between;
    gap: 0 18px;
    padding-inline: 24px;
  }
}

@media (max-width: 820px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .player,
  .creator,
  .form-grid,
  .chapter-editor,
  .node-workbench {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage {
    min-height: auto;
    padding: 18px;
  }

  .scene {
    font-size: 19px;
  }

  .storybook {
    min-height: auto;
  }

  .child-shell {
    padding: 0;
  }

  .storybook {
    grid-template-columns: 1fr 1fr;
  }

  .book-page {
    padding: 20px;
  }

  .bookshelf-hero {
    padding-inline: 10px;
  }

  .bookshelf-grid {
    grid-template-columns: 1fr;
    padding-inline: 8px;
  }
}

@media (max-width: 980px), (orientation: portrait) {
  .tablet-reader {
    display: block;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 12px;
    overflow-y: auto;
  }

  .storybook {
    width: min(100%, 860px);
    height: auto;
    min-height: calc(100dvh - 24px);
    margin: 0 auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: 28px;
    box-shadow:
      0 24px 60px rgba(35, 18, 8, 0.28),
      inset 0 0 0 2px rgba(255, 244, 215, 0.38);
    background:
      linear-gradient(180deg, #ead1a3 0 48%, #6d4529 48% 49.2%, #f3e2bd 49.2% 100%);
  }

  .storybook::before,
  .storybook.turn-forward::after,
  .storybook.turn-back::after {
    display: none;
  }

  .book-page {
    padding: clamp(16px, 4vw, 24px);
  }

  .illustration-page {
    min-height: min(45dvh, 420px);
    border-right: 0;
    border-bottom: 1px solid rgba(72, 45, 24, 0.2);
  }

  .book-left-label {
    position: static;
    margin-bottom: 12px;
    font-size: 11px;
  }

  .story-image,
  .generated-illustration {
    width: min(84%, 360px);
    max-height: min(68vw, 360px);
    box-shadow:
      0 0 0 10px rgba(255, 248, 231, 0.7),
      0 18px 34px rgba(58, 43, 25, 0.24);
  }

  .text-page {
    gap: 10px;
  }

  .book-menu {
    grid-template-columns: 1fr;
  }

  .book-shelf-button,
  .page-nav-button {
    min-height: 44px;
    font-size: 15px;
  }

  .page-number {
    justify-self: start;
  }

  .reading-page {
    min-height: min(50dvh, 560px);
  }

  .pinyin-text {
    padding-right: 0;
  }

  .read-line {
    padding: 6px 2px;
    font-size: clamp(20px, 4.8vw, 28px);
    line-height: 1.12;
    column-gap: 0.05em;
    row-gap: 0.1em;
  }

  .pinyin-token.is-space {
    min-width: 0.28em;
  }

  .pinyin-annotation {
    min-height: 1.05em;
    font-size: 0.37em;
  }

  .pinyin-punct {
    min-width: 0.92em;
  }

  .reader-controls {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .audio-controls {
    justify-content: flex-start;
  }

  .icon-button {
    width: 38px;
    min-width: 38px;
  }

  .page-nav {
    width: 100%;
  }

  .choice-page h1 {
    font-size: clamp(24px, 6vw, 34px);
  }

  .tablet-choice {
    min-height: 72px;
  }

  .download-shell {
    padding: 18px;
  }

  .download-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) and (max-width: 940px) and (min-aspect-ratio: 16/9) {
  .storybook {
    min-height: 100dvh;
    border-radius: 0;
  }

  .illustration-page {
    min-height: 34dvh;
  }

  .reading-page {
    min-height: min(42dvh, 360px);
  }
}
