:root {
  --bg: #f6f4ee; --card: #ffffff; --ink: #1d1d1f; --muted: #6b6b70; --line: rgba(0, 0, 0, .09);
  --accent: #2f8a52; --accent-ink: #fff; --accent-soft: #e3f4e8; --star: #e8a33c; --hl: #fac775; --hl-ink: #412402;
  --read: 'Lexend', 'Mukta', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root { --bg: #111214; --card: #1c1c1e; --ink: #f2f2f4; --muted: #a1a1a6; --line: rgba(255, 255, 255, .1); --accent-soft: #1f3a2a; } }
body.night { --bg: #141a33; --card: #1f2747; --ink: #e8e6ff; --muted: #aab0d6; --line: rgba(255, 255, 255, .1); --accent: #8b85ff; --accent-soft: #2a3260; --hl: #4b4f8f; --hl-ink: #fff; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, 'Mukta', system-ui, sans-serif; line-height: 1.5; transition: background-color .5s, color .5s; -webkit-font-smoothing: antialiased; }
html[lang="hi"] body { font-family: 'Mukta', Inter, sans-serif; }
a { color: inherit; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.tiny { width: 15px; height: 15px; vertical-align: -2px; } .ic.sm { width: 20px; height: 20px; }
.ic.star { fill: var(--star); stroke: var(--star); } .ic.flame { color: #e4583f; }
.wrap { max-width: 720px; margin: 0 auto; padding: 8px 16px 110px; }
#view.enter .wrap > * { animation: rise .4s ease-out backwards; }
#view.enter .wrap > *:nth-child(2) { animation-delay: .05s; } #view.enter .wrap > *:nth-child(3) { animation-delay: .1s; } #view.enter .wrap > *:nth-child(4) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
/* top bar */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); max-width: 720px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); } .brand b { color: var(--ink); font-weight: 600; font-size: 1.1rem; }
.sp { flex: 1; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .85rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.iconbtn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.iconbtn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
/* Mithu */
.mithu { display: block; flex: none; overflow: visible; height: auto; }
.m-wave { animation: m-wave .9s ease-in-out 2; } @keyframes m-wave { 50% { transform: rotate(-16deg); } }
.m-spark { animation: m-spark .6s ease-out both; transform-origin: center; transform-box: fill-box; } @keyframes m-spark { from { opacity: 0; transform: scale(.4); } }
.ask { display: flex; align-items: center; gap: 10px; margin: 8px 0 14px; }
.ask .mithu { width: 72px; margin-left: -4px; }
.bubble { position: relative; flex: 1; margin: 0; background: var(--card); border: 2px solid #4cb36f; border-radius: 18px; padding: 12px 16px; font-size: 1.05rem; line-height: 1.45; }
.bubble b { font-weight: 600; }
.bubble::before { content: ""; position: absolute; left: -11px; top: 50%; width: 18px; height: 18px; background: var(--card); border-left: 2px solid #4cb36f; border-bottom: 2px solid #4cb36f; transform: translateY(-50%) rotate(45deg); border-bottom-left-radius: 4px; }
.stats { display: flex; gap: 16px; margin: 0 4px 14px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.stats.big { font-size: 1.05rem; }
/* shelf colours */
.sh-panchatantra { --c: #0f766e; --cb: #dff3ec; } .sh-jataka { --c: #92400e; --cb: #f8ebd4; } .sh-hitopadesha { --c: #1d4ed8; --cb: #e4eefb; }
.sh-birbal { --c: #4338ca; --cb: #ebeafd; } .sh-tenali { --c: #9a3412; --cb: #fbe7dd; } .sh-aesop { --c: #9d174d; --cb: #fbe8ef; }
.sh-world { --c: #3f6212; --cb: #e9f3dc; } .sh-mithu { --c: #2f8a52; --cb: #e1f3e6; }
body.night [class*="sh-"] { --cb: #2a3260; --c: #c9c6ff; }
.ic.sh-panchatantra, .ic[class*="sh-"] { color: var(--c); }
/* pictures */
.pic { margin: 0; border-radius: 18px; overflow: hidden; background: var(--cb, var(--accent-soft)); aspect-ratio: 4 / 3; display: grid; place-items: center; color: var(--c); }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic .ic.big { width: 38%; height: 38%; stroke-width: 1.2; opacity: .55; }
body.night .pic img { filter: brightness(.82) saturate(.9); }
/* home */
.hero { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; padding: 10px; margin-bottom: 12px; border-radius: 22px; background: var(--card); border: 1.5px solid var(--line); border-bottom-width: 3px; text-decoration: none; }
.hero .pic { border-radius: 14px; }
.hero-tx { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hero-tx small { color: var(--c); font-weight: 600; font-size: .82rem; }
.hero-tx b { font-family: var(--read); font-weight: 500; font-size: 1.15rem; line-height: 1.3; }
.hero-meta { color: var(--muted); font-size: .85rem; }
.meter { height: 6px; border-radius: 3px; background: var(--cb); margin-top: 6px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--c); border-radius: 3px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 6px -16px 4px; padding: 4px 16px 8px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.shelf h2 { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 600; margin: 18px 2px 8px; }
.row { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 10px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.card { position: relative; flex: none; width: 150px; scroll-snap-align: start; text-decoration: none; display: flex; flex-direction: column; gap: 4px; animation: rise .4s ease-out backwards; animation-delay: var(--d, 0ms); }
.card .pic { border-radius: 16px; border: 1.5px solid var(--line); border-bottom-width: 3px; }
.card b { font-family: var(--read); font-weight: 500; font-size: .95rem; line-height: 1.3; }
.card small { color: var(--muted); font-size: .78rem; }
.done-tag { position: absolute; top: 8px; right: 8px; background: var(--card); border-radius: 999px; padding: 2px 8px; font-size: .75rem; font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.done-tag .ic { fill: var(--star); stroke: var(--star); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.grid .card { width: auto; }
.ad { margin: 18px 0; min-height: 100px; border-radius: 16px; border: 1px dashed var(--line); display: grid; place-items: start; padding: 8px 12px; color: var(--muted); font-size: .75rem; }
/* cover */
.cover-wrap { text-align: center; }
.cover-big { max-width: 420px; margin: 8px auto 14px; border-radius: 24px; }
.origin { color: var(--muted); margin: 0; font-size: .9rem; }
.cover-wrap h1 { font-family: var(--read); font-weight: 500; font-size: 1.8rem; line-height: 1.2; margin: 6px 0 6px; }
.meta { color: var(--muted); margin: 0 0 18px; font-size: .9rem; }
.btns { display: flex; flex-direction: column; gap: 10px; max-width: 420px; margin: 0 auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; font-size: 1.02rem; text-decoration: none; cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.btn.ghost { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); box-shadow: inset 0 -3px 0 var(--line); }
.btn.big { min-height: 56px; }
.note { color: var(--muted); font-size: .88rem; margin-top: 14px; }
/* reader */
.reader .page-pic { max-width: 520px; margin: 6px auto 14px; border-radius: 22px; aspect-ratio: 16 / 10; }
.page { background: var(--card); border-radius: 22px; border: 1.5px solid var(--line); padding: 20px 20px; max-width: 620px; margin: 0 auto; }
.page p { margin: 0; font-family: var(--read); font-size: calc(1.32rem * var(--fs, 1)); line-height: 1.75; letter-spacing: .01em; }
html[lang="hi"] .page p { font-family: 'Mukta', sans-serif; font-size: calc(1.45rem * var(--fs, 1)); line-height: 1.8; }
.w { border-radius: 6px; padding: 0 1px; cursor: pointer; transition: background-color .12s; }
.w.on { background: var(--hl); color: var(--hl-ink); }
.w.tap { background: var(--accent-soft); }
.dots { display: flex; justify-content: center; gap: 6px; margin: 14px 0 4px; }
.dots i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); } .dots i.on { background: var(--accent); }
.hint { text-align: center; color: var(--muted); font-size: .85rem; margin: 4px 0; }
.rbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 10px; align-items: center; max-width: 720px; margin: 0 auto; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.rbar .btn { flex: 1; min-width: 0; }
.rbar .btn.play { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); box-shadow: inset 0 -3px 0 var(--line); }
/* end */
.end h2 { font-size: 1.15rem; margin: 18px 2px 10px; font-weight: 600; }
.q { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 12px; }
.q > p:first-child { margin: 0 0 10px; font-weight: 600; font-family: var(--read); }
.opt { display: block; width: 100%; text-align: left; min-height: 48px; margin-bottom: 8px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; }
.opt.ok { border-color: #16a34a; background: color-mix(in srgb, #16a34a 12%, var(--card)); }
.opt.no { border-color: #dc2626; opacity: .7; }
.fb { margin: 2px 2px 0; min-height: 1.3em; font-weight: 600; color: var(--muted); }
.night-end { text-align: center; }
.moon-scene { position: relative; height: 160px; margin: 10px auto; max-width: 360px; }
.moon-scene i { position: absolute; left: var(--x); top: var(--y); width: 4px; height: 4px; border-radius: 50%; background: #fff; opacity: .2; animation: twinkle 2.6s ease-in-out infinite; animation-delay: var(--d); }
@keyframes twinkle { 50% { opacity: .9; } }
.ic.moonbig { position: absolute; left: 50%; top: 50%; width: 70px; height: 70px; transform: translate(-50%, -50%); color: #fde68a; fill: #fde68a; }
.gn { font-family: var(--read); font-size: 1.2rem; margin: 0 0 18px; }
body.sleep::after { content: ""; position: fixed; inset: 0; background: #000; z-index: 50; animation: fade 6s ease-in forwards; pointer-events: none; }
@keyframes fade { from { opacity: 0; } to { opacity: .92; } }
/* me */
.set { background: var(--card); border: 1.5px solid var(--line); border-radius: 20px; padding: 4px 14px; margin-bottom: 8px; }
.row-set { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row-set:last-child { border-bottom: 0; }
.row-set > span:first-child { display: flex; flex-direction: column; } .row-set small { color: var(--muted); font-size: .82rem; }
.row-set input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--bg); }
.seg button { min-height: 38px; min-width: 44px; padding: 0 12px; border-radius: 999px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.lh { font-size: 1.15rem; font-weight: 600; margin: 20px 2px 10px; }
/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabs a { flex: 1; max-width: 140px; min-height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 500; }
.tabs a[aria-current] { color: var(--accent); font-weight: 600; }
@media (min-width: 760px) { .card { width: 170px; } .hero { grid-template-columns: 180px 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.rbar .btn { white-space: nowrap; font-size: .95rem; padding: 0 14px; }
/* ===== immersive reader and cover ===== */
.drift img { animation: drift 22s ease-in-out infinite alternate; transform-origin: 60% 40%; }
@keyframes drift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.14) translate(-2%, -1.5%); } }
.reader { max-width: 720px; margin: 0 auto; padding-bottom: 110px; }
.reader .stage { position: relative; margin: 0 0 -34px; }
.reader .page-pic { border-radius: 0 0 28px 28px; aspect-ratio: 4 / 3; max-height: 52vh; width: 100%; }
@media (min-width: 760px) { .reader .page-pic { border-radius: 28px; } .reader .stage { margin: 8px 16px -34px; } }
.reader .page { position: relative; margin: 0 12px; padding: 26px 20px 20px; border-radius: 26px; box-shadow: 0 -10px 30px rgba(0, 0, 0, .08); animation: page-in .5s cubic-bezier(.2, .8, .2, 1) backwards; }
.turn-back .page { animation-name: page-back; }
@keyframes page-in { from { opacity: 0; transform: translateX(40px) rotate(1deg); } }
@keyframes page-back { from { opacity: 0; transform: translateX(-40px) rotate(-1deg); } }
.page .w { animation: word-in .6s ease-out backwards; animation-delay: calc(var(--si, 0) * .5s + .25s); }
@keyframes word-in { from { opacity: 0; } }
.perch { position: absolute; right: 14px; top: -54px; width: 64px; pointer-events: none; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .18)); }
.perch .mithu { width: 100%; }
.perch.talk .mithu { animation: bob .55s ease-in-out infinite alternate; transform-origin: 50% 90%; }
@keyframes bob { to { transform: translateY(-4px) rotate(-3deg); } }
.vine { position: relative; height: 44px; margin: 16px 22px 0; }
.vine svg { position: absolute; left: 0; right: 0; top: 10px; width: 100%; height: 20px; }
.vine path { fill: none; stroke: color-mix(in srgb, var(--accent) 45%, transparent); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.leaf { position: absolute; top: 12px; width: 14px; height: 14px; margin-left: -7px; border-radius: 0 50% 0 50%; background: var(--line); transform: rotate(45deg); transition: background-color .3s; }
.leaf.done { background: var(--accent); } .leaf.now { background: var(--star); transform: rotate(45deg) scale(1.25); }
.vine-m { position: absolute; top: -14px; width: 30px; margin-left: -15px; transition: left .9s cubic-bezier(.4, 0, .2, 1); }
.vine-m .mithu { width: 100%; }
.reader .hint { margin-top: 6px; }
.flies { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; }
.flies i { position: absolute; left: var(--x); top: var(--y); width: 6px; height: 6px; border-radius: 50%; background: #fde68a; box-shadow: 0 0 10px 3px rgba(253, 230, 138, .7); opacity: 0; animation: fly 6s ease-in-out infinite; animation-delay: var(--d); }
@keyframes fly { 20% { opacity: .9; } 50% { transform: translate(18px, -14px); } 80% { opacity: .6; } 100% { opacity: 0; transform: translate(-10px, -30px); } }
/* cover */
.cover-wrap { text-align: left; }
.cover-art { position: relative; max-width: 720px; margin: 0 auto 8px; }
.cover-art .cover-big { margin: 0; max-width: none; border-radius: 0 0 28px 28px; aspect-ratio: 4 / 4.2; max-height: 62vh; width: 100%; }
@media (min-width: 760px) { .cover-art { padding: 0 16px; } .cover-art .cover-big { border-radius: 28px; } }
.cover-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 20px 18px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .62)); border-radius: 0 0 28px 28px; }
@media (min-width: 760px) { .cover-title { left: 16px; right: 16px; } }
.cover-title .origin, .cover-title .meta { color: rgba(255, 255, 255, .85); margin: 0; }
.cover-title h1 { color: #fff; margin: 4px 0 6px; font-size: 2rem; text-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.cover-title .ic { stroke: #fff; }
.cover-wrap .btns { max-width: none; }
@media (prefers-reduced-motion: reduce) { .drift img, .perch.talk .mithu, .flies i { animation: none !important; } }
/* ===== Listen: Mithu reads the whole story ===== */
.listening .bar { position: absolute; left: 0; right: 0; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.listen { max-width: 720px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding-bottom: calc(24px + env(safe-area-inset-bottom)); text-align: center; }
.listen .stage { position: relative; width: 100%; }
.listen .page-pic { width: 100%; aspect-ratio: 4 / 3.3; max-height: 50vh; border-radius: 0 0 32px 32px; }
.l-mithu { width: 96px; margin-top: -60px; position: relative; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .2)); }
.l-mithu .mithu { width: 100%; }
.l-mithu.talk .mithu { animation: bob .5s ease-in-out infinite alternate; transform-origin: 50% 90%; }
.l-title { margin: 4px 16px 0; color: var(--muted); font-size: .85rem; font-weight: 600; }
.l-text { margin: 10px 20px 0; max-width: 560px; font-family: var(--read); font-size: 1.35rem; line-height: 1.7; min-height: 6em; animation: word-in .6s ease-out; }
html[lang="hi"] .l-text { font-family: 'Mukta', sans-serif; font-size: 1.5rem; }
.l-ctrl { display: flex; align-items: center; gap: 28px; margin: 18px 0 10px; }
.l-play { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2), 0 8px 20px rgba(0, 0, 0, .15); }
.l-play .ic { width: 34px; height: 34px; fill: currentColor; }
.l-sleep { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; }
.btn.listen-btn { background: #2f8a52; }
body.night .btn.listen-btn { background: var(--accent); }
@media (min-width: 760px) { .listen .page-pic { border-radius: 32px; margin-top: 64px; } }
.l-play .ic { stroke: none; }
.l-tap { margin: 0 20px 10px; padding: 10px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--ink); font-weight: 600; max-width: 420px; }
.pulse { animation: pulse-ring 1.4s ease-out infinite; }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(47, 138, 82, .55); } 100% { box-shadow: 0 0 0 18px rgba(47, 138, 82, 0); } }
.cover-title .teller { margin: 6px 0 0; display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .2); color: #fff; font-size: .85rem; font-weight: 600; backdrop-filter: blur(6px); }
