:root {
  color-scheme: light;
  --ink: #18243a;
  --muted: #778397;
  --paper: #fffdf8;
  --blue: #6e9ac0;
  --blue-dark: #315878;
  --gold: #cfaa68;
  --serif: Georgia, 'Times New Roman', serif;
  font-family: 'DM Sans', 'Noto Sans SC', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { min-height: 100dvh; color: var(--ink); background: #f1eee7; }
button { font: inherit; }
button:focus-visible { outline: 3px solid #eccb83; outline-offset: 3px; }
[hidden] { display: none !important; }

.shelf-screen {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  padding: max(36px, env(safe-area-inset-top)) clamp(22px, 7vw, 112px) max(30px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 84% 8%, rgba(227, 197, 142, .24), transparent 31%),
    radial-gradient(ellipse at 11% 68%, rgba(156, 187, 203, .18), transparent 36%),
    linear-gradient(145deg, #f7f3e9 0%, #ece9df 46%, #e7eceb 100%);
}
.shelf-screen::before, .shelf-screen::after {
  position: absolute;
  z-index: 0;
  content: '';
  pointer-events: none;
  border: 1px solid rgba(103, 126, 144, .11);
  border-radius: 50%;
}
.shelf-screen::before { width: 570px; height: 570px; top: -330px; right: -135px; }
.shelf-screen::after { width: 410px; height: 410px; bottom: -260px; left: -140px; }
.shelf-header, .shelf-intro, .book-grid, .shelf-message, .shelf-footer { position: relative; z-index: 1; }
.shelf-header { display: flex; align-items: center; gap: 18px; max-width: 1180px; margin: 0 auto; }
.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid rgba(156, 119, 57, .34);
  border-radius: 50%;
  color: #ad8545;
  font-size: 27px;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.38);
}
.eyebrow, .reader-kicker { margin: 0 0 5px; color: #9c8055; font-size: 10px; font-weight: 700; letter-spacing: .23em; }
.shelf-header h1 { margin: 0; font-family: Manrope, 'Noto Sans SC', sans-serif; font-size: clamp(25px, 3vw, 35px); font-weight: 700; letter-spacing: .04em; }
.quiet-button {
  width: 42px;
  height: 42px;
  margin-left: auto;
  border: 1px solid rgba(55, 76, 94, .16);
  border-radius: 50%;
  color: #4d6c82;
  background: rgba(255,255,255,.44);
  cursor: pointer;
  font-size: 22px;
  transition: transform .25s, background .25s;
}
.quiet-button:hover { transform: rotate(45deg); background: #fff; }
.shelf-intro { display: flex; align-items: baseline; justify-content: space-between; max-width: 1180px; margin: clamp(48px, 9vh, 92px) auto 34px; }
.shelf-intro p { margin: 0; color: #43566a; font-family: var(--serif); font-size: clamp(20px, 2.4vw, 28px); }
.shelf-intro span { color: var(--muted); font-size: 12px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: clamp(22px, 3vw, 43px); max-width: 1180px; margin: 0 auto; }
.book-card {
  position: relative;
  display: flex;
  min-width: 0;
  padding: 0;
  flex-direction: column;
  align-items: stretch;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  animation: rise-in .55s both;
  animation-delay: calc(var(--card-index, 0) * 55ms);
}
.book-cover-wrap {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border: 7px solid rgba(255,255,255,.78);
  border-radius: 5px 12px 12px 5px;
  background: linear-gradient(145deg, #b9c7c1, #e9d7b8 55%, #c7d6dc);
  box-shadow: 3px 8px 17px rgba(36, 47, 56, .13), 11px 15px 27px rgba(38, 50, 57, .12), inset 4px 0 rgba(80, 67, 45, .16);
  transform: perspective(900px) rotateY(-4deg);
  transform-origin: left center;
  transition: transform .45s cubic-bezier(.2,.8,.2,1), box-shadow .45s;
}
.book-cover-wrap::before { position: absolute; z-index: 1; top: 0; bottom: 0; left: 0; width: 8px; content: ''; background: linear-gradient(90deg, rgba(26,37,39,.2), rgba(255,255,255,.16)); }
.book-cover { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-shine { position: absolute; inset: 0; z-index: 2; background: linear-gradient(118deg, transparent 32%, rgba(255,255,255,.24) 49%, transparent 62%); opacity: .55; transition: transform .6s; transform: translateX(-120%); }
.book-card:hover .book-cover-wrap, .book-card:focus-visible .book-cover-wrap { transform: perspective(900px) rotateY(-11deg) translateY(-5px); box-shadow: 5px 15px 22px rgba(36,47,56,.16), 15px 20px 35px rgba(38,50,57,.15); }
.book-card:hover .cover-shine { transform: translateX(120%); }
.book-info { display: flex; min-width: 0; padding: 16px 2px 0; flex-direction: column; gap: 5px; }
.book-info strong { overflow: hidden; font-family: var(--serif); font-size: 18px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.book-info > span { color: var(--muted); font-size: 12px; }
.book-open-label { margin-top: 12px; color: #9a7d51; font-size: 11px; font-weight: 700; letter-spacing: .04em; opacity: 0; transform: translateY(4px); transition: .2s; }
.book-card:hover .book-open-label, .book-card:focus-visible .book-open-label { opacity: 1; transform: translateY(0); }
.shelf-message { max-width: 1180px; margin: 52px auto; padding: 25px 28px; border: 1px solid rgba(91,113,128,.13); border-radius: 17px; color: #68778a; background: rgba(255,255,255,.48); text-align: center; }
.shelf-message.is-error { color: #9b4a45; }
.shelf-footer { display: flex; max-width: 1180px; margin: clamp(60px, 13vh, 140px) auto 0; justify-content: space-between; color: #89939a; font-size: 10px; letter-spacing: .13em; }

.reader-screen {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: block;
  overflow: hidden;
  padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(11px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  color: #fff;
  background: #111923;
  isolation: isolate;
}
.reader-backdrop { position: absolute; z-index: -2; inset: -8%; background: radial-gradient(ellipse at 50% 43%, #4f5d64 0%, #293643 39%, #101722 78%); }
.reader-backdrop::after { position: absolute; inset: 0; content: ''; background: linear-gradient(180deg, rgba(8,14,22,.44), transparent 18%, transparent 58%, rgba(8,14,22,.76)); }
.reader-header { position: absolute; z-index: 4; top: max(12px, env(safe-area-inset-top)); right: max(20px, env(safe-area-inset-right)); left: max(20px, env(safe-area-inset-left)); display: flex; min-height: 50px; align-items: center; gap: 14px; padding: 6px 10px; border-radius: 15px; background: linear-gradient(90deg, rgba(13,21,30,.68), rgba(13,21,30,.24)); backdrop-filter: blur(8px); }
.reader-icon-button { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; color: white; background: rgba(255,255,255,.1); cursor: pointer; font-size: 23px; transition: background .2s; }
.reader-icon-button:hover { background: rgba(255,255,255,.22); }
.reader-heading { min-width: 0; }
.reader-kicker { display: block; margin-bottom: 2px; color: #d5bd8b; font-size: 8px; letter-spacing: .22em; }
.reader-heading h1 { overflow: hidden; margin: 0; font-family: var(--serif); font-size: clamp(16px, 2vw, 21px); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.page-count { margin-left: auto; color: rgba(255,255,255,.75); font-family: var(--serif); font-size: 14px; font-variant-numeric: tabular-nums; letter-spacing: .11em; }
.reader-layout { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 0; perspective: 1800px; }
.storybook-book-wrap { --cover-size: 7px; position: relative; z-index: 1; display: flex; flex: none; margin: 0 auto; }
.storybook-book-wrap::before { position: absolute; inset: -7px; border: 1px solid rgba(255,255,255,.28); border-radius: 8px 14px 14px 8px; background: linear-gradient(145deg, #ded0b5, #9c8767 52%, #d9c8a9); box-shadow: 0 28px 65px rgba(0,0,0,.44), inset 0 0 0 2px rgba(255,255,255,.16); content: ''; }
.storybook-book-wrap::after { position: absolute; z-index: 3; inset: 0; border-radius: 3px; background: linear-gradient(90deg, rgba(23,29,30,.3), transparent 8%, transparent 93%, rgba(23,29,30,.1)); content: ''; pointer-events: none; }
.storybook-book-wrap.spread::after { background: linear-gradient(90deg, rgba(23,29,30,.18) 43%, rgba(23,29,30,.1) 48.2%, rgba(23,29,30,.34) 50%, rgba(23,29,30,.1) 51.8%, rgba(23,29,30,.18) 57%); }
.reader-book { position: relative; z-index: 2; flex: none; height: min(100dvh, calc(100vw * 4 / 3), 1000px); aspect-ratio: 3 / 4; }
.storybook-book-wrap.spread .reader-book { height: min(100dvh, calc(100vw * 2 / 3), 1000px); aspect-ratio: 3 / 2; }
.pf-page { overflow: hidden; background: #fffdf6; }
.pf-page img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-select: none; }
.reader-book .stf__parent { border-radius: 3px 5px 5px 3px; }
.page-loading { position: absolute; padding: 12px 18px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; color: white; background: rgba(10,16,24,.7); font-size: 13px; }
.page-arrow { position: absolute; z-index: 2; top: 50%; display: grid; width: 42px; height: 60px; place-items: center; border: 1px solid rgba(255,255,255,.16); border-radius: 22px; color: rgba(255,255,255,.85); background: rgba(7,13,20,.23); cursor: pointer; font-family: var(--serif); font-size: 38px; line-height: 1; transform: translateY(-50%); transition: background .2s, opacity .2s; }
.page-arrow:hover:not(:disabled) { background: rgba(7,13,20,.55); }
.page-arrow:disabled { cursor: default; opacity: .2; }
.page-arrow-left { left: 0; }
.page-arrow-right { right: 0; }
.reading-dock { position: absolute; z-index: 4; right: max(20px, env(safe-area-inset-right)); bottom: max(11px, env(safe-area-inset-bottom)); left: max(20px, env(safe-area-inset-left)); width: min(calc(100% - 40px), 1000px); max-height: 28dvh; overflow-y: auto; margin: 0 auto; padding: 12px 20px 8px; border: 1px solid rgba(255,255,255,.22); border-radius: 19px 19px 9px 9px; background: rgba(18,27,38,.82); box-shadow: 0 -12px 42px rgba(0,0,0,.22); backdrop-filter: blur(20px); }
.reading-dock.is-collapsed { max-height: 58px; overflow: hidden; padding-top: 7px; padding-bottom: 7px; }
.reading-dock.is-collapsed #page-text, .reading-dock.is-collapsed .dock-bottomline { display: none; }
.dock-topline { display: flex; min-height: 34px; align-items: center; justify-content: flex-start; gap: 14px; }
.language-switches { display: flex; min-width: 0; flex: 1; align-items: center; gap: 7px; }
.language-toggle { display: inline-flex; min-height: 29px; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: rgba(255,255,255,.67); background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; transition: .2s; }
.language-toggle span { font-size: 10px; font-weight: 500; }
.language-toggle.is-on { border-color: rgba(235,204,149,.68); color: #f6e4c0; background: rgba(210,174,106,.14); }
.audio-button { display: inline-flex; min-height: 30px; align-items: center; gap: 6px; padding: 0 11px; border: 1px solid rgba(164,197,214,.32); border-radius: 999px; color: #d9edf6; background: rgba(114,160,184,.13); cursor: pointer; font-size: 11px; transition: .2s; }
.audio-button:hover:not(:disabled) { background: rgba(114,160,184,.28); }
.audio-button:disabled { cursor: default; opacity: .35; }
.dock-collapse-button { flex: 0 0 auto; min-height: 29px; padding: 0 10px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: rgba(255,255,255,.76); background: rgba(255,255,255,.06); cursor: pointer; font-size: 11px; }
.dock-collapse-button:hover { border-color: rgba(235,204,149,.6); color: #f6e4c0; }
.page-text { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 9px 0; }
.page-text.has-spread { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page-copy-card { min-width: 0; padding: 7px 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 11px; background: rgba(255,255,255,.045); }
.page-copy-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.page-copy-number { color: #d5bd8b; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.page-audio-actions { display: flex; flex: none; gap: 5px; }
.page-line { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 9px; align-items: baseline; margin: 3px 0; color: #fffdf7; font-family: var(--serif), 'Noto Sans SC', serif; font-size: clamp(13px, 1.45vw, 17px); line-height: 1.4; }
.page-line-zh { color: #d0d7df; font-family: 'Noto Sans SC', sans-serif; font-size: clamp(13px, 1.45vw, 16px); }
.line-language { color: #d5bd8b; font-family: 'DM Sans', sans-serif; font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.line-copy { white-space: pre-line; }
.no-language-hint { margin: 8px 0; color: rgba(255,255,255,.65); font-size: 13px; }
.dock-bottomline { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.43); font-size: 10px; }
.bottom-navigation { display: flex; gap: 8px; }
.text-nav-button { min-height: 33px; padding: 0 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: rgba(255,255,255,.75); background: transparent; cursor: pointer; font-size: 11px; }
.text-nav-button:hover:not(:disabled) { border-color: rgba(235,204,149,.6); color: #f6e4c0; }
.text-nav-button:disabled { cursor: default; opacity: .32; }
.next-text-button { border-color: rgba(231,198,137,.56); color: #f1dba9; }
.next-text-button span { margin-left: 5px; }

@keyframes rise-in { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 1400px) {
  .reader-layout { padding: 0; }
  .reading-dock { max-height: 26dvh; }
}
@media (max-width: 700px) {
  .shelf-screen { padding-right: 22px; padding-left: 22px; }
  .shelf-intro { margin-top: 48px; margin-bottom: 24px; align-items: flex-start; flex-direction: column; gap: 9px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 17px; }
  .book-cover-wrap { border-width: 5px; }
  .book-info { padding-top: 11px; }
  .book-info strong { font-size: 15px; }
  .book-open-label { margin-top: 7px; opacity: 1; transform: none; }
  .shelf-footer { margin-top: 60px; font-size: 8px; }
  .reader-screen { padding-right: max(10px, env(safe-area-inset-right)); padding-left: max(10px, env(safe-area-inset-left)); }
  .reader-layout { padding: 0; }
  .page-arrow { width: 29px; height: 46px; border-radius: 15px; font-size: 28px; }
  .storybook-book-wrap::before { inset: -5px; }
  .reading-dock { right: max(6px, env(safe-area-inset-right)); bottom: max(6px, env(safe-area-inset-bottom)); left: max(6px, env(safe-area-inset-left)); width: auto; max-height: 35dvh; padding: 8px 10px max(7px, env(safe-area-inset-bottom)); border-radius: 15px 15px 7px 7px; }
  .dock-topline { min-height: 29px; }
  .language-switches { width: auto; }
  .language-toggle { flex: 1; justify-content: center; padding: 0 6px; }
  .page-text { gap: 4px; padding: 5px 0; }
  .page-copy-card { padding: 5px 7px; }
  .page-copy-top { margin-bottom: 2px; }
  .page-copy-number { font-size: 9px; }
  .page-audio-actions { gap: 3px; }
  .audio-button { min-height: 25px; padding: 0 7px; font-size: 9px; }
  .page-line { grid-template-columns: 34px minmax(0, 1fr); gap: 6px; margin: 2px 0; font-size: 13px; }
  .page-line-zh { font-size: 12px; }
  .line-language { font-size: 8px; }
  .dock-bottomline { font-size: 8px; }
  .text-nav-button { min-height: 30px; padding: 0 9px; font-size: 10px; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .reader-header { min-height: 37px; }
  .reader-icon-button { width: 34px; height: 34px; }
  .reading-dock { max-height: 30dvh; padding-top: 8px; }
  .dock-topline { min-height: 28px; }
  .page-text { gap: 2px; padding: 5px 0; }
  .page-line { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* Integrated paper narration layout */
.storybook-book-wrap { --narration-height: clamp(170px, 26dvh, 270px); width: min(94vw, 1400px); height: min(89dvh, 1050px); flex-direction: column; }
.storybook-book-wrap::after { bottom: var(--narration-height); }
.storybook-book-wrap.narration-collapsed { --narration-height: 52px; }
.reader-book { width: 100%; height: auto; min-width: 0; min-height: 0; flex: 1 1 auto; aspect-ratio: auto; overflow: hidden; border-radius: 5px 10px 0 0; }
.storybook-book-wrap.spread .reader-book { width: 100%; height: auto; aspect-ratio: auto; }
.reading-dock { position: relative; z-index: 2; top: auto; right: auto; bottom: auto; left: auto; width: 100%; height: var(--narration-height); min-height: 0; max-height: none; flex: 0 0 var(--narration-height); overflow-y: auto; margin: 0; padding: 10px clamp(14px, 2vw, 28px) 8px; border: 0; border-top: 1px solid #d9c9a6; border-radius: 0 0 12px 12px; color: #382f25; background: linear-gradient(180deg, #fffdf6 0%, #f6f0e3 100%); box-shadow: inset 0 8px 16px rgba(104,79,43,.08); backdrop-filter: none; }
.reading-dock.is-collapsed { height: 52px; min-height: 52px; flex-basis: 52px; overflow: hidden; padding-top: 7px; padding-bottom: 7px; }
.reading-dock.is-collapsed #page-text, .reading-dock.is-collapsed .dock-bottomline { display: none; }
.dock-topline { min-height: 32px; gap: 12px; }
.language-toggle { border-color: rgba(105,85,54,.22); color: #70644f; background: rgba(255,255,255,.5); }
.language-toggle.is-on { border-color: #b38a4f; color: #65491f; background: #ead8b4; }
.audio-button { min-height: 28px; padding: 0 10px; border-color: rgba(82,113,128,.28); color: #37566a; background: rgba(255,255,255,.72); }
.audio-button:hover:not(:disabled) { background: #e6eff0; }
.dock-collapse-button { min-height: 28px; border-color: rgba(105,85,54,.24); color: #6d5a3a; background: rgba(255,255,255,.55); }
.dock-collapse-button:hover { border-color: #b38a4f; color: #49391f; background: #f3e7cc; }
.page-copy-card { padding: 5px 16px 7px; border: 0; border-radius: 0; background: transparent; }
.page-copy-card + .page-copy-card { border-left: 1px solid rgba(125,98,51,.18); }
.page-copy-number, .line-language { color: #9b7a43; }
.page-line { color: #302c25; }
.page-line-zh { color: #706c63; }
.no-language-hint { color: #777064; }
.dock-bottomline { border-top-color: rgba(125,98,51,.18); color: #8a806e; }
.text-nav-button { border-color: rgba(105,85,54,.23); color: #6d5a3a; background: rgba(255,255,255,.55); }
.text-nav-button:hover:not(:disabled) { border-color: #b38a4f; color: #49391f; background: #f3e7cc; }
.next-text-button { border-color: #b38a4f; color: #65491f; }
@media (min-width: 1400px) {
  .storybook-book-wrap { --narration-height: clamp(180px, 26dvh, 280px); }
}
@media (max-width: 700px) {
  .storybook-book-wrap { --narration-height: clamp(135px, 30dvh, 260px); width: 96vw; height: 92dvh; }
  .reading-dock { padding: 7px 10px max(7px, env(safe-area-inset-bottom)); border-radius: 0 0 7px 7px; }
  .language-switches { width: auto; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .storybook-book-wrap { --narration-height: clamp(115px, 30dvh, 185px); width: min(94vw, 88dvh); height: 90dvh; }
  .reading-dock { padding-top: 8px; }
}