:root{color-scheme:light;--ink:#344d43;--muted:#8b8f7d;--paper:#fffdf5;--accent:#49725d}
*{box-sizing:border-box}
html,body{margin:0;width:100%;height:100%;overflow:hidden}
body{color:var(--ink);font-family:var(--site-font,'Kaiti SC','STKaiti','KaiTi',serif);background:radial-gradient(ellipse at 50% 25%,#fffdf5 0%,#f6f0e2 75%)}
button,a{-webkit-tap-highlight-color:transparent}
button{font:inherit;color:inherit;cursor:pointer}
svg{fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex:none}
.reader{height:100vh;height:100dvh;max-width:1240px;margin:auto;padding:20px 26px;display:grid;grid-template-rows:auto minmax(0,1fr);gap:18px;position:relative}
.reader-heading{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:16px;padding:0 3px;min-height:44px}
h1{margin:0;font-size:clamp(22px,2.4vw,30px);font-weight:600;letter-spacing:.08em;line-height:1.5}
.library-link{justify-self:start;color:#607263;text-decoration:none;font-size:15px;display:inline-flex;align-items:center;gap:5px;min-height:44px;white-space:nowrap}
.library-link svg{width:22px;height:22px}
.heading-ornament{justify-self:end;display:grid;place-items:center;width:29px;height:32px;border:1px solid #ad7058;border-radius:3px;color:#ad7058;font-size:21px;transform:rotate(3deg)}
.book{width:min(100%,calc((100dvh - 230px)*1.5));justify-self:center;align-self:center;min-height:0;height:100%;max-height:100%;display:grid;grid-template-rows:minmax(0,1fr) auto auto;background:var(--paper);border:1px solid #d9cdb6;border-radius:12px;overflow:hidden;box-shadow:0 14px 38px #68563a16,0 3px 0 #e5dcc9,inset 0 0 0 5px #fffaf0}
.illustration{position:relative;min-height:0;min-width:0;display:grid;place-items:center;overflow:hidden;background:#f5edda;touch-action:pan-y;border-bottom:1px solid #e7dcc9}
.illustration img{display:block;width:100%;height:100%;min-height:0;object-fit:contain}
.bubble-hotspots{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);pointer-events:none}
.bubble-hotspot{position:absolute;pointer-events:auto;border:0;padding:0;background:transparent;border-radius:50%}
.bubble-hotspot:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
.sentence-button{justify-self:center;max-width:calc(100% - 24px);display:flex;align-items:center;justify-content:center;gap:14px;margin:13px 0 5px;padding:6px 20px;border:1px solid transparent;border-radius:30px;background:transparent;transition:background .15s,color .15s}
.sentence-text{font-size:clamp(25px,3vw,37px);line-height:1.4;letter-spacing:.05em;font-weight:600}
.sound-icon{width:25px;height:25px;color:var(--accent)}
.sentence-button:hover,.sentence-button.is-speaking{background:#eef3e6;border-color:#dce5d2}
.sentence-button.is-loading .sound-icon{opacity:.45}
.reading-controls{display:flex;align-items:center;justify-content:center;gap:38px;padding:5px 20px 15px}
.page-arrow{width:46px;height:46px;display:grid;place-items:center;border:1px solid #ccbda2;border-radius:50%;background:#f5efdf;box-shadow:0 2px 2px #78603a0b;transition:background .15s,transform .15s}
.page-arrow svg{width:22px;height:22px}
.page-arrow:hover:enabled{background:#e8eddd;transform:translateY(-1px)}
.page-arrow:disabled{opacity:.3;cursor:default}
.page-progress{display:grid;justify-items:center;gap:7px;min-width:76px}
.page-label{font:12px/1.3 system-ui,sans-serif;letter-spacing:.16em;color:#8a795d;font-variant-numeric:tabular-nums}
.page-dots{display:flex;gap:7px}
.dot{width:5px;height:5px;border-radius:50%;background:#e0d7c4}
.dot.selected{background:var(--accent)}
button:focus-visible,a:focus-visible{outline:3px solid #5c826c;outline-offset:3px}
.speech-status{position:absolute;bottom:3px;left:20px;right:20px;text-align:center;margin:0;color:#9b443b;font-size:12px}
.speech-status:empty{display:none}
/* Legacy approved complete-scene books retain their existing accessible bubble. */
.dynamic-dialogue-bubble{position:absolute;z-index:3;top:4.5%;max-width:56%;min-width:32%;min-height:60px;display:flex;align-items:center;justify-content:center;gap:8px;padding:10px 19px;border:2px solid #8c9b84;border-radius:48% 51% 46% 50%;background:#fffdf6f2;box-shadow:0 3px 11px #75624a28;font-size:clamp(16px,2.5vw,29px);line-height:1.3;text-align:center;font-weight:700}
.dynamic-dialogue-bubble[hidden]{display:none!important}
.dynamic-dialogue-bubble[data-side='left']{left:31%}
.dynamic-dialogue-bubble[data-side='right']{right:28%}
.dynamic-dialogue-bubble::after{content:'';position:absolute;bottom:-13px;left:23%;width:18px;height:18px;border-bottom:2px solid #8c9b84;border-right:2px solid #8c9b84;background:#fffdf6;transform:rotate(45deg)}
.dynamic-dialogue-bubble[data-side='right']::after{left:auto;right:23%}
.dynamic-dialogue-bubble.is-loading{opacity:.65}
.dynamic-dialogue-bubble.is-speaking{color:#397453}
.dialogue-audio-icon{font-size:.55em;color:#9a7559}
/* The painted balloon is part of the stage; its live text remains clickable. */
.dynamic-dialogue-bubble.painted-bubble{min-width:0;max-width:none;min-height:0;right:auto;bottom:auto;transform:none;padding:2% 3%;border:0;border-radius:50%;background:transparent;box-shadow:none;white-space:normal}
.dynamic-dialogue-bubble.painted-bubble::after{display:none}
.painted-bubble[data-side='right']{color:#315d81}
.painted-bubble #dynamic-bubble-text{overflow-wrap:anywhere}
@media(max-width:600px){
 .reader{padding:max(10px,env(safe-area-inset-top)) 12px max(12px,env(safe-area-inset-bottom));gap:10px}
 .reader-heading{grid-template-columns:1fr auto 1fr;gap:5px;padding:0;min-height:40px}
 h1{font-size:20px;letter-spacing:.015em}
 .library-link{font-size:12px;gap:0;min-height:40px}
 .library-link svg{width:17px;height:17px}
 .heading-ornament{width:22px;height:26px;font-size:17px}
 .book{width:100%;border-radius:10px;height:min(100%,calc((100vw - 26px)*.666667 + 132px));align-self:center}
 html[data-reader-layout='portrait'] .book{width:min(100%,calc((100dvh - 190px)*.75));height:min(100%,calc((100vw - 26px)*1.333333 + 130px))}
 .sentence-button{gap:9px;padding:5px 12px;margin:10px 0 4px}
 .sentence-text{font-size:clamp(23px,6.4vw,29px);letter-spacing:.02em}
 .sound-icon{width:22px;height:22px}
 .reading-controls{padding-bottom:12px;gap:29px}
 .page-arrow{width:43px;height:43px}
 .speech-status{font-size:11px;left:8px;right:8px}
 .dynamic-dialogue-bubble:not(.painted-bubble){min-height:42px;padding:6px 12px;font-size:16px}
 .dynamic-dialogue-bubble:not(.painted-bubble)[data-side='left']{left:21%}
 .dynamic-dialogue-bubble:not(.painted-bubble)[data-side='right']{right:19%}
}
@media(max-height:500px){
 .reader{padding:5px 14px;gap:5px}
 .reader-heading{min-height:32px}
 h1{font-size:19px}
 .library-link{min-height:32px}
 .book{width:min(100%,calc((100dvh - 130px)*1.5));height:100%;border-radius:8px}
 .sentence-button{margin:3px 0 0;padding:2px 12px}
 .sentence-text{font-size:23px;line-height:1.25}
 .sound-icon{width:19px;height:19px}
 .reading-controls{padding:3px 12px 6px;gap:25px}
 .page-arrow{height:35px;width:35px}
 .page-progress{gap:3px}
}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
/* Quiet Chinese study: xuan-paper tones, walnut rules and cinnabar seal. */
body{background-color:#f3ecdc;background-image:radial-gradient(ellipse at 50% 20%,#fffdf5 0%,#f3ecdc 76%),repeating-linear-gradient(0deg,#94734604 0 1px,transparent 1px 4px)}
.reader-heading{border-bottom:3px double #c5ac7a;padding-bottom:8px}
h1{color:#294f43;letter-spacing:.12em;text-shadow:0 1px #fffaf0}
.heading-ornament{border:2px solid #a9523d;color:#a9523d;border-radius:2px;font-weight:600;box-shadow:inset 0 0 0 2px #fff9ee}
.book{position:relative;border:2px solid #8e704a;border-radius:3px;outline:1px solid #d4bf96;outline-offset:4px;box-shadow:0 16px 34px #6650351a,0 4px 0 #d6c6a8}
.book::before,.book::after{content:'';position:absolute;z-index:5;pointer-events:none;width:20px;height:20px;border-top:2px solid #9e7847;border-left:2px solid #9e7847;box-shadow:-4px -4px 0 -2px #fff7e7;left:6px;top:6px}
.book::after{left:auto;top:auto;right:6px;bottom:6px;transform:rotate(180deg)}
.illustration{border-bottom:3px double #c9b48a}
.sentence-button{border-radius:4px}
.page-arrow{border-radius:4px;border-color:#9c9a7b;background:#f1eedf}
.page-arrow:hover:enabled{background:#dfe8d5;border-color:#6c8568}
.page-label{color:#7c6645}
.dot{border-radius:0;transform:rotate(45deg);width:4px;height:4px}
.illustration:not([data-ready='true'])::after,.illustration[data-loading='true']::after{content:'正在翻开绘本…';position:absolute;z-index:6;left:50%;top:50%;transform:translate(-50%,-50%);padding:8px 16px;border:1px solid #d9c9a9;border-radius:3px;background:#fffaf0ed;color:#806944;font-size:15px;white-space:nowrap;pointer-events:none}
.illustration[data-loading='true']::after{top:auto;bottom:10px;transform:translateX(-50%);font-size:13px}
@media(max-width:600px){.reader-heading{padding-bottom:4px}.book::before,.book::after{width:13px;height:13px;left:4px;top:4px}.book::after{left:auto;top:auto;right:4px;bottom:4px}.book{outline-offset:3px}}
@media(max-height:500px){.reader-heading{padding-bottom:2px}.book{outline-offset:2px}}
.book::before,.book::after{width:26px;height:26px;border:0;box-shadow:none;background:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M2 30V2h28M8 24V8h16v10H14v-4h4M2 8h6M8 2v6' fill='none' stroke='%239e7847' stroke-width='1.5'/%3E%3C/svg%3E")}
@media(max-width:600px){.book::before,.book::after{width:18px;height:18px}}
/* Side-mounted turns leave the page itself as the main reading surface. */
.reader{max-width:1440px;gap:12px;padding-top:14px;padding-bottom:14px}
.book{width:min(100%,calc((100dvh - 160px)*1.5));height:100%;grid-template-rows:minmax(0,1fr) auto}
.illustration .page-arrow{position:absolute;z-index:4;top:53%;transform:translateY(-50%);width:44px;height:58px;background:#fff9e9e8;border-color:#a58a61;box-shadow:0 2px 8px #5d432225}
.illustration #previous-page{left:8px}
.illustration #next-page{right:8px}
.illustration .page-arrow:hover:enabled{transform:translateY(-50%);background:#f1f0dc}
.illustration .page-arrow:disabled{opacity:.25}
.sentence-button{margin:5px 100px 5px 12px;padding:6px 16px;min-height:48px;max-width:calc(100% - 200px);justify-self:center;gap:10px}
.sentence-text{font-size:clamp(22px,2.3vw,30px);line-height:1.25}
.sound-icon{width:23px;height:23px}
.reading-controls{position:absolute;bottom:14px;right:28px;padding:0;pointer-events:none}
.page-progress{gap:6px;min-width:80px}
.painted-bubble{padding:1% 2%!important}
@media(max-width:600px){
 .reader{padding:max(8px,env(safe-area-inset-top)) 10px max(10px,env(safe-area-inset-bottom));gap:8px}
 .book{width:100%;height:min(100%,calc((100vw - 24px)*.666667 + 58px))}
 html[data-reader-layout='portrait'] .book{width:min(100%,calc((100dvh - 136px)*.642857));height:min(100%,calc((100vw - 24px)*1.555556 + 58px))}
 .illustration .page-arrow{width:44px;height:48px;top:56%}
 .illustration #previous-page{left:3px}.illustration #next-page{right:3px}
 .sentence-button{max-width:calc(100% - 90px);margin:3px 82px 3px 2px;padding:5px 7px;min-height:46px;gap:7px}
 .sentence-text{font-size:clamp(18px,5.2vw,24px);letter-spacing:0;white-space:nowrap}
 .sound-icon{width:19px;height:19px}
 .reading-controls{right:20px;bottom:13px}.page-progress{min-width:66px;gap:5px}.page-label{font-size:10px}.page-dots{gap:5px}.dot{width:3px;height:3px}
}
@media(max-height:500px){
 .reader{padding:5px 12px;gap:5px}
 .book{width:min(100%,calc((100dvh - 105px)*1.5));height:100%}
 .sentence-button{min-height:35px;margin-top:1px;margin-bottom:1px;padding-top:2px;padding-bottom:2px}
 .sentence-text{font-size:21px}.reading-controls{bottom:8px}.illustration .page-arrow{height:42px;width:38px}
}

.reader-unavailable{position:absolute;inset:0;z-index:6;display:flex;flex-wrap:wrap;align-content:center;justify-content:center;gap:16px;padding:24px;background:var(--paper);text-align:center}
.reader-unavailable p{width:100%;font-size:20px;line-height:1.8}
.reader-unavailable a,.reader-unavailable button{padding:10px 14px;background:#f1eedf;color:var(--ink);border:1px solid #b49b70;border-radius:3px;text-decoration:none;font:inherit}
.reader-unavailable[hidden],.sentence-button[hidden]{display:none!important}
