/* Story Owl – bright but calm, big touch targets, readable type. System fonts only (nothing loaded from outside). */
:root {
  --bg: #fff7e8; --ink: #2b2b3a; --muted: #5d5d70; --card: #ffffff; --line: #eadcc3;
  --sun: #f5a524; --sky: #6cb4ee; --leaf: #5bb57a; --berry: #e46f8a; --plum: #8f7bd8; --owl: #8a5a3b;
  --hl: #ffe27a; --radius: 22px; --shadow: 0 4px 0 rgba(43, 43, 58, .12);
  --font: ui-rounded, "Nunito", "Trebuchet MS", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --read: "Atkinson Hyperlegible", "Verdana", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 19px; line-height: 1.5;
  background-image: radial-gradient(circle at 10% 0%, #fff 0, transparent 40%), radial-gradient(circle at 100% 30%, #fdeccd 0, transparent 35%); min-height: 100vh; }
a { color: #2f6db3; }
h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.15; margin: .4em 0 .3em; }
h2 { font-size: 1.35rem; margin: .2em 0 .4em; }
.sr-only { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px; z-index: 10; }
:focus-visible { outline: 4px solid var(--plum); outline-offset: 3px; border-radius: 10px; }
.muted { color: var(--muted); } .small { font-size: .85rem; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: #fff; border-bottom: 3px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--owl); font-weight: 800; font-size: 1.4rem; }
.brand-owl { width: 46px; height: 46px; }
.topnav { display: flex; gap: 6px; flex-wrap: wrap; }
.topnav a { text-decoration: none; color: var(--ink); font-weight: 700; padding: 10px 14px; border-radius: 999px; min-height: 48px; display: inline-flex; align-items: center; gap: 4px; }
.topnav a:hover, .topnav a.active { background: #fdeccd; }

main { max-width: 980px; margin: 0 auto; padding: 12px 16px 32px; outline: none; }
.panel { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 16px 0; box-shadow: var(--shadow); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 56px; padding: 10px 22px; border-radius: 999px; border: 0; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 1.1rem; text-decoration: none; color: #fff; background: var(--plum); box-shadow: 0 4px 0 #6a58b3; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #6a58b3; }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: var(--shadow); }
.btn.small { min-height: 46px; font-size: .95rem; padding: 6px 16px; }
.btn.tiny { min-height: 40px; min-width: 40px; padding: 4px 10px; font-size: .95rem; background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.read { background: var(--leaf); box-shadow: 0 4px 0 #3e8a59; font-size: 1.25rem; min-width: 200px; }

/* home */
.hero { display: flex; align-items: center; gap: 16px; }
.hero-owl { width: 120px; height: 120px; flex: none; animation: bob 3s ease-in-out infinite; }
.lead { font-size: 1.2rem; margin: 0; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
.bigbtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 18px 0; }
.bigbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 140px; border-radius: var(--radius); text-decoration: none;
  color: var(--ink); font-weight: 800; font-size: 1.35rem; box-shadow: 0 6px 0 rgba(0,0,0,.12); border: 3px solid rgba(255,255,255,.7); }
.bigbtn:active { transform: translateY(3px); }
.bb-ico { font-size: 3rem; line-height: 1; }
.b-rhymes { background: #ffe0a3; } .b-stories { background: #c7e6ff; } .b-owl { background: #d9f2df; } .b-badge { background: #fbd5de; }

/* levels */
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lvl { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; min-height: 92px; border-radius: 18px; border: 3px solid var(--line); background: #fff; font: inherit; cursor: pointer; color: var(--ink); }
.lvl-icon { font-size: 1.8rem; line-height: 1; } .lvl-name { font-weight: 800; } .lvl-hint { font-size: .8rem; color: var(--muted); }
.lvl.on { border-color: var(--leaf); background: #e9f7ee; box-shadow: 0 0 0 3px #bfe7cc inset; }

/* cards & art */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.grid.one { grid-template-columns: minmax(200px, 340px); }
.card { display: block; background: #fff; border-radius: var(--radius); border: 2px solid var(--line); overflow: hidden; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .15s; }
.card:hover { transform: translateY(-3px) rotate(-.5deg); }
.card-title { display: block; padding: 12px 14px 14px; font-weight: 800; font-size: 1.1rem; }
.art { position: relative; height: 150px; overflow: hidden; }
.art-big { height: 220px; border-radius: var(--radius); border: 3px solid #fff; box-shadow: var(--shadow); }
.art-main { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); font-size: 72px; filter: drop-shadow(0 4px 2px rgba(0,0,0,.15)); animation: bob 4s ease-in-out infinite; }
.art-big .art-main { font-size: 110px; }
.art-x { position: absolute; font-size: 34px; } .art-big .art-x { font-size: 52px; }
.art-x1 { left: 10%; top: 12%; } .art-x2 { right: 10%; top: 14%; } .art-x3 { right: 16%; bottom: 8%; }
.scene-night { background: linear-gradient(#24305e, #4b5aa0); }
.scene-meadow { background: linear-gradient(#bfe5ff 0 62%, #9fd88a 62%); }
.scene-castle { background: linear-gradient(#cfe8ff 0 65%, #c9b99a 65%); }
.scene-water { background: linear-gradient(#cfeeff 0 50%, #7cc3e8 50%); }
.scene-garden { background: linear-gradient(#e3f1ff 0 70%, #8fcf7f 70%); }
.scene-house { background: linear-gradient(#fbe7c6 0 75%, #d4a373 75%); }
.scene-forest { background: linear-gradient(#d6f0d0 0 60%, #7fb069 60%); }
.scene-farm { background: linear-gradient(#fff0c2 0 62%, #e3c770 62%); }
.scene-savanna { background: linear-gradient(#ffe2b0 0 62%, #d8b65d 62%); }

/* reader */
.crumbs { margin: 6px 0 0; } .crumbs a { font-weight: 700; }
.controls { display: grid; gap: 14px; }
.readrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.speeds { display: flex; gap: 6px; flex-wrap: wrap; }
.speed { min-height: 48px; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); }
.speed.on { border-color: var(--sky); background: #e6f3fd; }
.text { font-family: var(--read); background: #fffdf8; border: 2px solid var(--line); border-radius: var(--radius); padding: 18px 20px; font-size: 1.45rem; line-height: 1.75; letter-spacing: .01em; }
.text-little { font-size: 1.75rem; } .text-big { font-size: 1.3rem; }
.text-rhyme { text-align: center; }
.para { margin: 0 0 .8em; padding: 4px 8px; border-radius: 12px; transition: background .2s; }
.para.reading { background: #fff3c9; }
.word { border-radius: 6px; padding: 0 1px; transition: background .1s; }
.word.hl { background: var(--hl); box-shadow: 0 0 0 3px var(--hl); }
button.word.vocab { font: inherit; color: inherit; background: none; border: 0; padding: 0 1px; cursor: pointer; text-decoration: underline dotted #b47b1f 3px; text-underline-offset: 6px; }
button.word.vocab.hl { background: var(--hl); }
.wordbox { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #eef7ff; border: 2px solid #bcdcf5; border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
.wordbox p { margin: 0; flex: 1 1 200px; }
.fit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; font-weight: 700; }
.talk ul { padding-left: 1.2em; } .talk li { margin: .3em 0; }
.prevnext { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.owl { width: 40px; height: 40px; flex: none; } .owl.mini { width: 42px; height: 42px; } .owl-big { width: 96px; height: 96px; }

/* owl chat */
.owlhead { display: flex; align-items: center; gap: 14px; }
.mode { display: inline-block; margin: 0; padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.mode-simple { background: #e9f7ee; } .mode-live { background: #f1ecff; }
.safe-note { background: #fff3c9; border: 2px dashed #e9c45a; border-radius: 16px; padding: 10px 14px; font-weight: 700; }
.pickstory { width: 100%; min-height: 54px; font: inherit; font-size: 1.05rem; padding: 8px 12px; border-radius: 14px; border: 2px solid var(--line); background: #fff; margin: 4px 0 12px; color: var(--ink); }
.chat { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 220px; max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 92%; flex: none; }
.msg.from-me { align-self: flex-end; flex-direction: row-reverse; }
.kid { font-size: 32px; line-height: 1; flex: none; }
.msg.from-owl { align-self: flex-start; }
.bubble { flex: 0 1 auto; min-width: 0; }
.bubble { background: #f3ecff; border-radius: 18px 18px 18px 4px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.msg.from-me .bubble { background: #dff1ff; border-radius: 18px 18px 4px 18px; }
.bubble p { margin: 0; } .tip { font-size: .9rem; color: #6a4b00; background: #fff3c9; padding: 4px 8px; border-radius: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { min-height: 46px; padding: 6px 14px; border-radius: 999px; border: 2px solid #d6ccf5; background: #fff; font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; color: var(--ink); }
.chip:active { background: #f1ecff; }
.askrow { display: flex; gap: 8px; }
.ask { flex: 1; min-width: 0; min-height: 58px; font: inherit; font-size: 1.15rem; padding: 8px 16px; border-radius: 999px; border: 3px solid #d6ccf5; background: #fff; color: var(--ink); }
.btn.send { flex: none; }
.howto ol { padding-left: 1.3em; } summary { cursor: pointer; font-weight: 800; min-height: 40px; }

/* badge */
.dots { display: flex; gap: 8px; margin: 8px 0; } .dot { width: 18px; height: 18px; border-radius: 50%; background: #eadcc3; } .dot.on { background: var(--plum); } .dot.done { background: var(--leaf); }
.lesson { background: #fff; border: 3px solid var(--line); border-radius: 28px; padding: 22px; text-align: center; box-shadow: var(--shadow); font-size: 1.25rem; }
.lesson-ico { font-size: 4rem; line-height: 1.1; }
.navrow { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.answers { display: grid; gap: 12px; margin: 14px 0; }
.answer { min-height: 64px; border-radius: 20px; border: 3px solid var(--line); background: #fffdf8; font: inherit; font-size: 1.2rem; font-weight: 700; cursor: pointer; color: var(--ink); padding: 8px 14px; }
.answer.right { border-color: var(--leaf); background: #e9f7ee; } .answer.wrong { border-color: var(--berry); background: #fde8ed; }
.feedback { font-weight: 800; min-height: 1.5em; }
.earned-note { font-weight: 800; color: #3e8a59; }
.medal { width: 210px; height: 210px; margin: 16px auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1b8, #f5a524 70%); border: 10px solid #e46f8a;
  display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 8px 0 rgba(0,0,0,.12); }
.medal span { font-size: 64px; line-height: 1; } .medal strong { font-size: 1.4rem; } .medal small { letter-spacing: .3em; font-weight: 800; }

/* misc */
.grownups li { margin: .4em 0; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  max-width: calc(100% - 24px); z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-weight: 700; }
.toast[hidden] { display: none; }
.foot { text-align: center; padding: 18px 12px 28px; color: var(--muted); border-top: 3px solid var(--line); background: #fff; }
.foot p { margin: .3em 0; }

@media (max-width: 600px) {
  body { font-size: 18px; }
  .topnav a span { display: none; }
  .topnav a { font-size: 1.5rem; padding: 6px 10px; }
  .brand span { font-size: 1.2rem; }
  .hero-owl { width: 84px; height: 84px; }
  .bigbtns { grid-template-columns: 1fr 1fr; }
  .bigbtn { min-height: 120px; font-size: 1.1rem; }
  .text { font-size: 1.3rem; padding: 14px; } .text-little { font-size: 1.55rem; }
  .art-big { height: 180px; } .art-big .art-main { font-size: 90px; }
  .btn.read { width: 100%; }
  .lvl-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .top, .foot, .navrow, .toast { display: none; }
  body { background: #fff; }
}

/* ---- Story Library ---- */
.lib-filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.lib-search { flex: 1 1 240px; font: inherit; font-size: 1.1rem; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); }
.lib-cat, .lib-age { font: inherit; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); background: #fff; }
.lib-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.card-lib { padding-top: 10px; }
.lib-ico { display: block; font-size: 2.4rem; text-align: center; }
.lib-meta { display: block; padding: 0 14px 14px; font-size: .85rem; color: #6b5a4a; }
.card-featured { border-color: #c98a3d; background: #fff4df; }
.true-badge { display: inline-block; background: #fff4df; border: 2px solid #c98a3d; border-radius: 999px; padding: 4px 12px; font-weight: 700; }
.text-book .para { font-size: 1.3rem; line-height: 1.7; }
.book-nav { display: flex; justify-content: space-between; gap: 10px; margin: 18px 0; }
.source.small { font-size: .8rem; }
