@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/fredoka-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(fonts/fredoka-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --ink: #4a3b5c; --sky: #bfe3ff; --cream: #fff8ef; --lav: #efe6ff;
  --red: #ef6f6c; --orange: #f7a14a; --yellow: #ffd45e; --green: #79c97a; --blue: #4f8fe0; --purple: #a982e0; --pink: #ff9fc4;
  --font: 'Fredoka', 'Baloo 2', 'Arial Rounded MT Bold', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #f6efff; color: var(--ink); font-family: var(--font); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

#app { position: relative; max-width: 560px; height: 100dvh; margin: 0 auto; overflow: hidden; background: var(--cream); }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; opacity: 0; pointer-events: none; transform: scale(.98); transition: opacity .35s ease, transform .35s ease; padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bot) + 16px); }
.screen.active { opacity: 1; pointer-events: auto; transform: none; }

/* ---------- clay buttons ---------- */
.clay { border: 0; border-radius: 50%; display: grid; place-items: center; position: relative;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.12), inset 0 6px 10px rgba(255,255,255,.55), 0 8px 0 rgba(74,59,92,.18), 0 14px 22px rgba(74,59,92,.22);
  transition: transform .12s ease, box-shadow .12s ease; touch-action: manipulation; }
.clay::after { content: ''; position: absolute; left: 22%; top: 12%; width: 30%; height: 18%; border-radius: 50%; background: rgba(255,255,255,.45); filter: blur(2px); pointer-events: none; }
.clay:active, .clay.pressed { transform: translateY(5px) scale(.97); box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), inset 0 6px 10px rgba(255,255,255,.5), 0 3px 0 rgba(74,59,92,.18), 0 6px 10px rgba(74,59,92,.2); }
.clay:disabled { filter: grayscale(.7) opacity(.55); }
.clay svg { width: 52%; height: 52%; }
.clay.big { width: min(52vw, 220px); height: min(52vw, 220px); }
.clay.mid { width: 84px; height: 84px; }
.clay.small { width: 54px; height: 54px; }
.clay.small svg { width: 56%; height: 56%; }
.blue { background: radial-gradient(circle at 35% 30%, #7fb3f5, #3f7fd6 70%); }
.pink { background: radial-gradient(circle at 35% 30%, #ffc2da, #ff86b3 70%); }
.yellow { background: radial-gradient(circle at 35% 30%, #ffe89a, #ffc93f 70%); }
.green { background: radial-gradient(circle at 35% 30%, #a9e7a3, #5fbf63 70%); }
.white { background: radial-gradient(circle at 35% 30%, #ffffff, #efe6f7 75%); }
.white svg { stroke: var(--ink); fill: var(--ink); }
.white svg path[fill=none] { fill: none; }
.green svg { fill: #fff8c9; }
.mic rect { fill: #ff8a5c; } .mic path { stroke: #ff8a5c; }
.big .mic { width: 46%; height: 46%; filter: drop-shadow(0 3px 0 rgba(0,0,0,.15)); }

/* ---------- home ---------- */
#home { padding: 0; justify-content: flex-start; }
.hero-art { position: absolute; inset: 0; z-index: 0; }
.hero-art svg { width: 100%; height: 100%; }
.title { position: relative; z-index: 1; margin: calc(var(--safe-top) + 44px) 0 0; text-align: center; line-height: .95; font-weight: 700; font-size: clamp(54px, 17vw, 84px); letter-spacing: 1px; }
.title .w { display: block; }
.title span.l { display: inline-block; -webkit-text-stroke: 7px #fff; paint-order: stroke fill; text-shadow: 0 4px 0 rgba(74,59,92,.18), 0 10px 18px rgba(74,59,92,.18); animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(var(--r, 0deg)); } 50% { transform: translateY(-5px) rotate(calc(var(--r, 0deg) * -1)); } }
.home-actions { position: relative; z-index: 1; margin-top: auto; margin-bottom: calc(var(--safe-bot) + 150px); display: flex; flex-direction: column; align-items: center; gap: 26px; }
#micBtn { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.row { display: flex; gap: 22px; justify-content: center; align-items: center; }
.pick-ico { width: 64%; height: 64%; display: block; }
.pick-ico svg { width: 100%; height: 100%; }
.books { width: 58%; height: 58%; }
.gear { position: absolute; z-index: 2; top: calc(var(--safe-top) + 10px); right: 12px; width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(255,255,255,.55); display: grid; place-items: center; touch-action: none; }
.gear .ico { width: 24px; height: 24px; fill: #8a7aa0; grid-area: 1/1; }
.gear .ring { width: 48px; height: 48px; grid-area: 1/1; transform: rotate(-90deg); }
.gear .ring circle { fill: none; stroke: var(--purple); stroke-width: 4; stroke-dasharray: 132; stroke-dashoffset: 132; stroke-linecap: round; }
.gear.holding .ring circle { transition: stroke-dashoffset 3s linear; stroke-dashoffset: 0; }

/* ---------- listening ---------- */
#listen { background: linear-gradient(#e7f3ff, #fdf3ff); justify-content: center; }
.close { position: absolute; top: calc(var(--safe-top) + 12px); left: 14px; }
.listen-stage { display: flex; flex-direction: column; align-items: center; gap: 28px; margin-top: -40px; }
.pulse { position: relative; display: grid; place-items: center; }
.pulse span { position: absolute; width: min(52vw, 220px); height: min(52vw, 220px); border-radius: 50%; background: rgba(79,143,224,.25); animation: ripple 2s ease-out infinite; }
.pulse span:nth-child(2) { animation-delay: .6s; } .pulse span:nth-child(3) { animation-delay: 1.2s; }
#listen:not(.on) .pulse span { animation-play-state: paused; opacity: 0; }
@keyframes ripple { from { transform: scale(1); opacity: .8; } to { transform: scale(1.7); opacity: 0; } }
.fake-mic { pointer-events: none; }
.transcript { min-height: 3.2em; max-width: 92%; text-align: center; font-size: 28px; font-weight: 600; line-height: 1.25; margin: 0; color: var(--ink); }
.transcript .interim { opacity: .55; }
.listen-actions { position: absolute; bottom: calc(var(--safe-bot) + 40px); }

/* ---------- picker ---------- */
#pick { background: linear-gradient(#fff3fa, #eef7ff); }
.pick-head { display: flex; gap: 10px; margin: 26px 0 10px; }
.step-dot { width: 16px; height: 16px; border-radius: 50%; background: #e3d9f0; }
.step-dot.on { background: var(--pink); box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.pick-grid { flex: 1; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 14px 6px 10px; align-content: center; }
.tile { aspect-ratio: 1; border: 0; border-radius: 34px; background: #fff; overflow: hidden; padding: 0; box-shadow: inset 0 -7px 0 rgba(0,0,0,.07), 0 7px 0 rgba(74,59,92,.12), 0 12px 20px rgba(74,59,92,.14); transition: transform .12s; }
.tile:active { transform: translateY(4px) scale(.97); }
.tile svg { width: 100%; height: 100%; }
.tile.char { padding: 10%; background: radial-gradient(circle at 40% 30%, #fff, #f3ecfb); }
.tile.pop { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.08); } }

/* ---------- making ---------- */
#making { justify-content: center; background: radial-gradient(circle at 50% 40%, #fff6d6, #f1e6ff 70%); }
.magic { position: relative; width: 230px; height: 230px; }
.magic-book { position: absolute; inset: 30px; animation: wobble 1.6s ease-in-out infinite; }
.magic-book svg { width: 100%; height: 100%; }
@keyframes wobble { 0%,100% { transform: rotate(-4deg) scale(1); } 50% { transform: rotate(4deg) scale(1.05); } }
.spark { position: absolute; left: 50%; top: 45%; width: 26px; height: 26px; background: var(--yellow); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: fly 2.2s ease-in infinite; opacity: 0; }
.s2 { background: var(--pink); animation-delay: .4s; --dx: -90px; } .s3 { background: #8fd0ff; animation-delay: .8s; --dx: 80px; } .s4 { background: #b8f0a8; animation-delay: 1.2s; --dx: -40px; } .s5 { background: #d7b8ff; animation-delay: 1.6s; --dx: 60px; }
@keyframes fly { 0% { transform: translate(-50%, 0) scale(.3) rotate(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx, 20px)), -150px) scale(1.2) rotate(180deg); opacity: 0; } }
.making-text { font-size: 26px; font-weight: 600; text-align: center; margin-top: 20px; min-height: 1.4em; }

/* ---------- story ---------- */
#story { background: linear-gradient(#fdf6ff, #fff8ef); padding-left: 12px; padding-right: 12px; }
.story-top { width: 100%; display: flex; align-items: center; gap: 10px; }
.story-title { flex: 1; margin: 0; text-align: center; font-size: 20px; font-weight: 600; line-height: 1.15; color: #7a6a90; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#speakBtn.on { background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd45e 75%); }
#speakBtn.on .wave { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.book { width: 100%; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding-top: 8px; touch-action: pan-y; min-height: 0; }
.page-pic { position: relative; width: 100%; aspect-ratio: 5 / 4; max-height: 50dvh; border-radius: 30px; overflow: hidden; background: #f1e9fb; box-shadow: 0 0 0 6px #fff, 0 10px 0 6px rgba(74,59,92,.10), 0 16px 26px rgba(74,59,92,.18); }
.page-pic > svg, .page-pic > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.page-pic > img { animation: fadein .6s ease; }
@keyframes fadein { from { opacity: 0; transform: scale(1.03); } }
.paint { position: absolute; z-index: 2; right: 12px; bottom: 12px; display: none; gap: 6px; padding: 9px 12px; border-radius: 22px; background: rgba(255,255,255,.85); }
.paint.on { display: flex; }
.paint span { width: 14px; height: 14px; border-radius: 50%; background: var(--red); animation: hop .9s ease-in-out infinite; }
.paint span:nth-child(2) { background: var(--yellow); animation-delay: .15s; } .paint span:nth-child(3) { background: var(--blue); animation-delay: .3s; }
@keyframes hop { 50% { transform: translateY(-8px); } }
.page-text { flex: 0 1 auto; max-height: 34dvh; margin: 0 6px; font-size: clamp(24px, 6.6vw, 32px); line-height: 1.38; font-weight: 500; text-align: center; overflow-y: auto; min-height: 0; }
.page-text.zh { font-size: clamp(26px, 7.4vw, 36px); letter-spacing: 1px; }
.page-text .wd { border-radius: 10px; padding: 0 2px; transition: background .15s, color .15s; }
.page-text .wd.hi { background: #ffe58a; color: #3b2b4c; box-shadow: 0 2px 0 #f1c94a; }
.story-nav { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 0; }
.dots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #e3d9f0; }
.dots i.on { background: var(--purple); transform: scale(1.25); }
.end-card { position: absolute; inset: 70px 12px 120px; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px; border-radius: 34px; background: radial-gradient(circle at 50% 35%, #fff8d6, #f6ecff 75%); box-shadow: 0 0 0 6px #fff, 0 16px 26px rgba(74,59,92,.18); animation: fadein .5s ease; }
.end-card[hidden] { display: none; }
.end-title { font-size: 64px; font-weight: 700; color: var(--purple); -webkit-text-stroke: 6px #fff; paint-order: stroke fill; text-shadow: 0 6px 12px rgba(74,59,92,.2); }

/* ---------- library ---------- */
#library { background: linear-gradient(#fff9e6, #f3ecff); }
.lib-top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.lib-ico { width: 56px; height: 56px; }
.lib-top > span { width: 54px; }
.lib-grid { width: 100%; flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 18px 4px 20px; align-content: start; }
.card { border: 0; padding: 0; border-radius: 26px; background: #fff; overflow: hidden; text-align: center; box-shadow: inset 0 -6px 0 rgba(0,0,0,.06), 0 6px 0 rgba(74,59,92,.10), 0 10px 18px rgba(74,59,92,.12); transition: transform .12s; }
.card:active { transform: translateY(3px) scale(.98); }
.card .cov { position: relative; aspect-ratio: 4/3; background: #f1e9fb; }
.card .cov > svg, .card .cov > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .ct { display: block; padding: 9px 8px 12px; font-size: 16px; font-weight: 600; line-height: 1.15; }
.card .badge { position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; background: var(--yellow); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }

/* ---------- settings ---------- */
#settings { background: #f7f3fc; padding: 0; align-items: stretch; -webkit-user-select: text; user-select: text; }
.set-wrap { overflow-y: auto; height: 100%; padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bot) + 40px); font-size: 16px; }
.set-head { display: flex; align-items: center; justify-content: space-between; }
.set-head h2 { margin: 6px 0; font-size: 24px; }
fieldset { border: 0; background: #fff; border-radius: 20px; padding: 14px 16px 16px; margin: 14px 0; box-shadow: 0 3px 10px rgba(74,59,92,.08); }
legend { float: left; width: 100%; font-weight: 600; font-size: 18px; margin-bottom: 8px; color: #7a5fb0; }
fieldset label { display: block; margin: 10px 0; font-weight: 500; }
fieldset input:not([type=checkbox]):not([type=radio]):not([type=range]), fieldset select { display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 2px solid #e4dcef; background: #fcfaff; color: var(--ink); }
fieldset input[type=range] { width: 100%; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--purple); }
.seg { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-top: 6px; }
.seg > span { width: 100%; font-weight: 500; }
.seg label { display: flex; gap: 6px; align-items: center; margin: 0; }
.seg input { width: 20px; height: 20px; accent-color: var(--purple); }
.hint { font-size: 14px; color: #8a7d99; margin: 6px 0; line-height: 1.35; }
.hint.center { text-align: center; }
.hint.ok { color: #2f8a3a; } .hint.err { color: #c0392b; }
details { margin-top: 10px; } summary { font-weight: 600; color: #7a5fb0; cursor: pointer; padding: 6px 0; }
.btn { font: inherit; font-weight: 600; font-size: 16px; padding: 10px 18px; border-radius: 14px; border: 0; background: #a982e0; color: #fff; box-shadow: 0 3px 0 #8a64c4; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a64c4; }
.btn.ghost { background: #efe8f9; color: #6b5a85; box-shadow: 0 3px 0 #d9cdea; }
.btn.danger { background: #ef6f6c; box-shadow: 0 3px 0 #c9504d; margin-top: 10px; }
.btn.tiny { padding: 6px 12px; font-size: 14px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.set-list .item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0eaf7; }
.set-list .item b { flex: 1; font-weight: 500; }
.set-list .item small { color: #9a8daa; display: block; }

/* ---------- gate + toast ---------- */
.modal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(74,59,92,.45); }
.modal[hidden] { display: none; }
.gate-card { width: 86%; max-width: 360px; background: #fff; border-radius: 26px; padding: 22px; text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.gate-q { font-size: 22px; font-weight: 600; margin: 4px 0 16px; }
.gate-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.gate-answers button { font: inherit; font-size: 26px; font-weight: 600; padding: 14px 0; border-radius: 16px; border: 0; background: #f1ebfa; box-shadow: 0 3px 0 #ddd0ee; }
.toast { position: absolute; left: 50%; bottom: calc(var(--safe-bot) + 26px); z-index: 30; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; max-width: 88%; padding: 12px 18px; border-radius: 18px; background: #fff; box-shadow: 0 8px 22px rgba(74,59,92,.25); font-size: 18px; font-weight: 500; text-align: center; transition: all .3s ease; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
@media print { .story-nav, .story-top, .clay { display: none !important; } }

/* ---------- Tonight's Story (bedtime: dark, calm, audio only) ---------- */
.moon-btn { position: absolute; z-index: 2; top: calc(var(--safe-top) + 10px); left: 12px; width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3b4a8a, #232b5c); box-shadow: 0 4px 0 rgba(30,30,70,.35), 0 8px 16px rgba(30,30,70,.25); display: grid; place-items: center; }
.moon-btn svg { width: 34px; height: 34px; }
#bedtime { background: radial-gradient(120% 70% at 50% 18%, #2a3270 0%, #161b45 55%, #0b0e28 100%); color: #d9dcf5; justify-content: flex-start; gap: 0; overflow: hidden; }
.bed-stars { position: absolute; inset: 0; pointer-events: none; }
.bed-stars i { position: absolute; width: var(--s); height: var(--s); border-radius: 50%; background: #fff6d8; opacity: .5; animation: twinkle 5s ease-in-out infinite; }
.bed-layer { position: absolute; inset: -4% -6%; will-change: transform; }
.bed-layer.far { animation: bedDrift 90s ease-in-out infinite alternate; }
.bed-layer.near { animation: bedDrift 55s ease-in-out infinite alternate-reverse; }
.bed-layer.near i { box-shadow: 0 0 6px 1px rgba(255,240,190,.45); }
.bed-layer b { position: absolute; width: var(--s); height: var(--s); background: #fff3c4; clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); animation: sparkle 7s ease-in-out infinite; }
@keyframes sparkle { 0%, 70%, 100% { opacity: 0; transform: scale(.3) rotate(0); } 80% { opacity: .95; transform: scale(1) rotate(45deg); } 90% { opacity: 0; transform: scale(.5) rotate(90deg); } }
@keyframes bedDrift { from { transform: translate3d(-10px, 0, 0); } to { transform: translate3d(10px, -6px, 0); } }
.bed-neb { position: absolute; inset: 0; background: radial-gradient(40% 22% at 22% 30%, rgba(160,120,255,.16), transparent 70%), radial-gradient(36% 20% at 80% 46%, rgba(110,170,255,.12), transparent 70%), radial-gradient(50% 26% at 50% 12%, rgba(255,214,140,.10), transparent 70%); animation: nebula 16s ease-in-out infinite alternate; }
@keyframes nebula { from { opacity: .6; } to { opacity: 1; } }
.bed-shoot { position: absolute; top: 12%; left: 78%; width: 90px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, rgba(255,246,216,.9), transparent); transform: rotate(-28deg); opacity: 0; animation: shoot 14s ease-in infinite; }
.bed-shoot.s2 { top: 30%; left: 30%; animation-delay: -6s; animation-duration: 19s; }
@keyframes shoot { 0%, 88% { opacity: 0; transform: rotate(-28deg) translateX(0); } 90% { opacity: 1; } 96%, 100% { opacity: 0; transform: rotate(-28deg) translateX(-160px); } }
.bed-hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 13%; opacity: .9; }
.bed-moon::before { content: ""; position: absolute; inset: -38%; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,226,150,.38), rgba(255,226,150,.12) 55%, transparent 100%); animation: moonGlow 6s ease-in-out infinite alternate; z-index: -1; }
.bed-moon svg { position: relative; }
@keyframes moonGlow { from { transform: scale(.92); opacity: .7; } to { transform: scale(1.08); opacity: 1; } }
/* While the screen is black during play, pause the sky so the phone does no extra work. */
#bedtime:has(#bedDim:not([hidden])) .bed-stars *, #bedtime:has(#bedDim:not([hidden])) .bed-moon::before { animation-play-state: paused; }
@keyframes twinkle { 0%,100% { opacity: .15; } 50% { opacity: .7; } }
.bed-top { position: relative; z-index: 1; width: 100%; display: flex; justify-content: space-between; align-items: center; }
.night-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); display: grid; place-items: center; }
.night-btn svg { width: 24px; height: 24px; stroke: #c9cdf0; fill: none; }
.bed-lang { display: flex; background: rgba(255,255,255,.07); border-radius: 999px; padding: 4px; }
.bed-lang button { border: 0; background: transparent; color: #aab0dd; font-size: 16px; font-weight: 600; padding: 8px 16px; border-radius: 999px; }
.bed-lang button.on { background: rgba(255,226,140,.18); color: #ffe7a6; }
.bed-moon { position: relative; width: 92px; height: 92px; margin-top: 8px; filter: drop-shadow(0 0 22px rgba(255,220,130,.35)); animation: float 7s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.bed-title { position: relative; margin: 10px 0 2px; font-size: 26px; font-weight: 600; color: #f3e6bd; text-align: center; max-width: 92%; }
.bed-sub { position: relative; margin: 0 0 18px; font-size: 15px; color: #9097c8; text-align: center; }
.bed-play { position: relative; width: min(56vw, 210px); height: min(56vw, 210px); border-radius: 50%; border: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 40% 35%, #4a4f8f, #2a2f66 70%); box-shadow: 0 0 0 10px rgba(255,255,255,.03), 0 0 50px rgba(255,214,120,.18), inset 0 -6px 0 rgba(0,0,0,.25); }
.bed-play .bed-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.bed-ring circle { fill: none; stroke-width: 5; }
.bed-ring .track { stroke: rgba(255,255,255,.07); }
.bed-ring .prog { stroke: #f2d27a; stroke-linecap: round; stroke-dasharray: 603; stroke-dashoffset: 603; transition: stroke-dashoffset .5s linear; opacity: .8; }
.bed-play .ico { grid-area: 1/1; width: 38%; height: 38%; fill: #ffe7a6; }
.bed-play .pause, .bed-play .wait { display: none; }
.bed-play.playing .play { display: none; } .bed-play.playing .pause { display: block; }
.bed-play.loading .play, .bed-play.loading .pause { display: none; }
.bed-play.loading .wait { display: flex; gap: 10px; align-items: center; justify-content: center; }
.bed-play .wait i { width: 14px; height: 14px; border-radius: 50%; background: #ffe7a6; animation: dots 1.4s ease-in-out infinite; }
.bed-play .wait i:nth-child(2) { animation-delay: .2s; } .bed-play .wait i:nth-child(3) { animation-delay: .4s; }
@keyframes dots { 0%,100% { opacity: .2; transform: scale(.7); } 50% { opacity: 1; transform: scale(1); } }
.bed-time { position: relative; margin: 14px 0 0; font-size: 18px; color: #aab0dd; font-variant-numeric: tabular-nums; }
.bed-msg { position: relative; margin: 4px 0 0; min-height: 22px; font-size: 15px; color: #c9b98a; text-align: center; }
.bed-themes { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0 0; max-width: 100%; }
.chip { border: 0; border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 500; background: rgba(255,255,255,.07); color: #b9bee6; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: rgba(255,226,140,.2); color: #ffe7a6; }
.chip svg { width: 16px; height: 16px; fill: currentColor; stroke: currentColor; }
.chip.listening { animation: dots 1.2s ease-in-out infinite; }
.bed-tools { position: relative; margin-top: auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding-bottom: 6px; }
.pill { border: 1px solid rgba(255,255,255,.12); background: transparent; color: #9aa0d0; border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 500; }
.pill:disabled { opacity: .35; }
.bed-sheet { position: absolute; inset: 0; z-index: 5; background: rgba(6,8,24,.7); display: flex; align-items: flex-end; }
.bed-sheet-in { position: relative; width: 100%; max-height: 82%; overflow: auto; background: #171c45; border-radius: 26px 26px 0 0; padding: 18px 20px calc(var(--safe-bot) + 24px); color: #d9dcf5; -webkit-user-select: text; user-select: text; }
.bed-sheet h3 { margin: 4px 48px 6px 0; color: #f3e6bd; font-weight: 600; }
.bed-sheet h4 { color: #f3e6bd; margin: 8px 0; font-weight: 500; }
.bed-sheet .hint { color: #8a90c0; }
.sheet-x { position: absolute; top: 12px; right: 12px; }
.bed-words p { font-size: 18px; line-height: 1.6; margin: 0 0 14px; }
.py-p .han { display: block; } .py-p .py { display: block; font-size: 15px; color: #9fb4e8; margin-top: 2px; }
.seg-tabs { display: flex; gap: 6px; margin: 10px 0 14px; }
.seg-tabs button { border: 0; border-radius: 999px; padding: 7px 14px; background: rgba(255,255,255,.07); color: #b9bee6; font-size: 15px; }
.seg-tabs button.on { background: rgba(255,226,140,.2); color: #ffe7a6; }
.past { display: flex; flex-direction: column; gap: 8px; }
.past-row { text-align: left; border: 0; border-radius: 16px; background: rgba(255,255,255,.06); padding: 12px 14px; color: #e3e5fa; }
.past-row b { display: block; font-weight: 600; } .past-row small { color: #8a90c0; }
.bed-dim { position: absolute; inset: 0; z-index: 4; background: #000; display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(var(--safe-bot) + 30px); }
.bed-dim span { color: #2d3048; font-size: 16px; font-variant-numeric: tabular-nums; }
fieldset .two { display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
fieldset .two label { margin: 4px 0; }

/* Tonight's idea (optional parent prompt) */
.bed-idea { position: relative; z-index: 1; width: 100%; display: flex; align-items: center; gap: 12px; margin: 2px 0 4px; }
.idea-mic { flex: none; width: 64px; height: 64px; border-radius: 50%; border: 0; display: grid; place-items: center; background: radial-gradient(circle at 40% 35%, #4a4f8f, #2a2f66 70%); box-shadow: 0 0 0 6px rgba(255,255,255,.04); }
.idea-mic svg { width: 30px; height: 30px; fill: #ffe7a6; stroke: #ffe7a6; }
.idea-mic.listening { animation: dots 1.2s ease-in-out infinite; box-shadow: 0 0 0 8px rgba(255,226,140,.18); }
.idea-field { position: relative; flex: 1; display: block; }
.idea-field input { width: 100%; font: inherit; font-size: 17px; color: #f3e6bd; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 14px 40px 14px 14px; outline: none; -webkit-user-select: text; user-select: text; }
.idea-field input::placeholder { color: #8a90c0; }
.idea-field input:focus { border-color: rgba(255,226,140,.45); }
.idea-x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); color: #c9cdf0; font-size: 20px; line-height: 1; }
.idea-hint { position: relative; margin: 2px 0 10px; font-size: 13.5px; color: #7d84b6; text-align: center; line-height: 1.35; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.past-row .idea { display: block; margin-top: 3px; color: #c9b98a; font-size: 14px; font-style: italic; }
#bedtime .bed-moon { width: 64px; height: 64px; margin-top: 0; }
#bedtime .bed-title { margin-top: 4px; font-size: 24px; }
#bedtime .bed-sub { margin-bottom: 12px; }
#bedtime .bed-play { width: min(46vw, 176px); height: min(46vw, 176px); }
#bedtime .bed-time { margin-top: 10px; }
#bedtime .bed-themes { margin-top: 8px; }

/* ---- v1.2 storybook art: gentle, cheap motion (only on the big picture + home art; never in thumbnails) ---- */
.ss-a { animation: none; transform-box: fill-box; transform-origin: center; }
.page-pic .ss-drift, .hero-art .ss-drift { animation: ssDrift 30s ease-in-out infinite alternate; }
.page-pic .ss-twinkle, .hero-art .ss-twinkle { animation: ssTwinkle 3.2s ease-in-out infinite; }
.page-pic .ss-bob, .hero-art .ss-bob { animation: ssBob 3.6s ease-in-out infinite; }
.page-pic .ss-breathe, .hero-art .ss-breathe { transform-origin: 50% 100%; animation: ssBreathe 4.2s ease-in-out infinite; }
.page-pic .ss-spin { animation: ssSpin 40s linear infinite; }
.page-pic .ss-wave { transform-box: view-box; animation: ssWave 6s ease-in-out infinite alternate; }
.page-pic .ss-flicker { transform-origin: 50% 0; animation: ssFlicker .35s ease-in-out infinite alternate; }
.page-pic .ss-flutter, .hero-art .ss-flutter { animation: ssFlutter .5s ease-in-out infinite alternate; }
.page-pic .ss-shoot { transform-box: view-box; animation: ssShoot 9s ease-in infinite; }
@keyframes ssDrift { from { transform: translateX(-14px); } to { transform: translateX(14px); } }
@keyframes ssTwinkle { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ssBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes ssBreathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.015, .985); } }
@keyframes ssSpin { to { transform: rotate(360deg); } }
@keyframes ssWave { from { transform: translateX(-10px); } to { transform: translateX(10px); } }
@keyframes ssFlicker { from { transform: scaleY(.85); } to { transform: scaleY(1.12); } }
@keyframes ssFlutter { from { transform: scaleX(1); } to { transform: scaleX(.55); } }
@keyframes ssShoot { 0%, 78% { transform: translate(0, 0); opacity: 0; } 80% { opacity: 1; } 92% { transform: translate(-140px, 60px); opacity: 0; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ss-a { animation: none !important; } }
