:root {
  --bg: #FFF8EE;
  --card: #FFFFFF;
  --ink: #2B2A33;
  --ink-2: #5E5C6B;
  --ink-3: #8F8C9C;
  --line: #EDE3D3;
  --brand: #2F6B4F;
  --brand-2: #E3F1E8;
  --coral: #E8664D;
  --coral-2: #FCE6E0;
  --sun: #FFC94A;
  --sun-2: #FFF1CC;
  --sky: #4C9BE0;
  --sky-2: #E3F0FB;
  --plum: #7B5A86;
  --radius: 18px;
  --head: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar: 68px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0 0 12px; }
button { font: inherit; color: inherit; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.center { text-align: center; }

/* Loading */
.loading { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--ink-2); }
.logo-mark { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: var(--brand); position: relative; }
.logo-mark::after { content: ''; position: absolute; inset: 16px; background: var(--sun); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }

/* Screens */
.screen { padding: 20px 18px 32px; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen.tabbed { padding-bottom: calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); min-height: 0; }
.grow { flex: 1; }
.stack > * + * { margin-top: 14px; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 12px 18px;
  border: 0; border-radius: 16px; cursor: pointer;
  font-family: var(--head); font-weight: 600; font-size: 18px;
  background: var(--brand); color: #fff;
  box-shadow: 0 4px 0 #1F4A36;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1F4A36; }
.btn.coral { background: var(--coral); box-shadow: 0 4px 0 #B84A35; }
.btn.light { background: var(--card); color: var(--ink); box-shadow: 0 0 0 2px var(--line) inset, 0 4px 0 var(--line); }
.btn.light:active { box-shadow: 0 0 0 2px var(--line) inset, 0 1px 0 var(--line); }
.btn.small { min-height: 44px; font-size: 16px; }
.btn[disabled] { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--brand); font-weight: 700; padding: 8px 4px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.back { background: none; border: 0; padding: 8px 0; color: var(--ink-2); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 0 0 1.5px var(--line); }
.card.brand { background: var(--brand); color: #fff; box-shadow: none; }
.card.brand .muted { color: #CFE5D8; }
.card.sun { background: var(--sun-2); box-shadow: 0 0 0 1.5px #F5DB94; }
.card.coral { background: var(--coral-2); box-shadow: 0 0 0 1.5px #F6C5B9; }
.card.sky { background: var(--sky-2); box-shadow: 0 0 0 1.5px #C5DDF3; }
.card-label { font-family: var(--head); font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card.brand .card-label { color: #CFE5D8; }
.chip { display: inline-block; font-family: var(--body); font-size: 12px; font-weight: 700; text-transform: none; letter-spacing: 0; padding: 2px 10px; border-radius: 999px; background: var(--brand-2); color: var(--brand); }

/* Story */
.story-art { border-radius: 22px; overflow: hidden; box-shadow: 0 0 0 2px var(--ink); background: #fff; margin: 8px 0 18px; }
.story-art { aspect-ratio: 16 / 11; }
.story-art svg, .story-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.story-quote { font-family: var(--head); font-size: 20px; color: var(--coral); margin-top: 4px; }
.dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--coral); width: 22px; border-radius: 4px; }
.topline { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }
.brand-word { font-family: var(--head); font-weight: 600; font-size: 20px; color: var(--brand); display: flex; align-items: center; gap: 8px; }
.brand-word .logo-mark { width: 28px; height: 28px; margin: 0; }
.brand-word .logo-mark::after { inset: 8px; }

/* Forms */
.tabs2 { display: grid; grid-template-columns: 1fr 1fr; background: var(--line); border-radius: 14px; padding: 4px; margin-bottom: 18px; }
.tabs2 button { border: 0; background: none; padding: 10px; border-radius: 11px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.tabs2 button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
label.field { display: block; font-weight: 700; margin-bottom: 14px; }
label.field span.hint { display: block; font-weight: 400; color: var(--ink-2); font-size: 14px; margin-top: 2px; }
input.text, textarea.text, select.text {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-size: 18px; color: var(--ink);
  background: var(--card); border: 2px solid var(--line); border-radius: 14px;
  padding: 12px 14px; outline: none;
}
input.text:focus, textarea.text:focus, select.text:focus { border-color: var(--brand); }
input.code { letter-spacing: .5em; font-family: var(--head); font-size: 26px; text-align: center; }
textarea.text { min-height: 120px; resize: vertical; }
.error { color: #B3261E; font-weight: 700; font-size: 15px; margin: 6px 0 12px; }
.tipbox { background: var(--sun-2); border-radius: 14px; padding: 12px 14px; font-size: 15px; margin-bottom: 16px; }

/* Options */
.options { display: grid; gap: 10px; }
.opt {
  text-align: left; width: 100%; padding: 14px 16px; min-height: 54px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 17px; cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.opt:active { transform: scale(.99); }
.opt.on { border-color: var(--brand); background: var(--brand-2); }
.opt.right { border-color: var(--brand); background: var(--brand-2); }
.opt.wrong { border-color: var(--coral); background: var(--coral-2); }
.opt .mark { margin-left: auto; font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips .opt { width: auto; min-width: 58px; justify-content: center; }

.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 6px 0 18px; }
.progress div { height: 100%; background: var(--brand); border-radius: 4px; transition: width .25s; }

/* Kids */
.kidrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1.5px solid var(--line); }
.kidrow:first-child { border-top: 0; }
.kidrow .who { font-weight: 700; flex: 1; }
.kidrow .who small { display: block; font-weight: 600; color: var(--brand); font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 22px; font-weight: 700; cursor: pointer; }
.stepper output { min-width: 44px; text-align: center; font-family: var(--head); font-size: 22px; }

/* Tutorial */
.tut-icon { font-size: 64px; text-align: center; margin: 30px 0 16px; line-height: 1; }
.mini-bar { background: var(--card); border-radius: 16px; padding: 12px 14px; box-shadow: 0 0 0 1.5px var(--line); margin: 6px 0 18px; }

/* Header */
.hdr { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 18px 10px; border-bottom: 1.5px solid var(--line); }
.hdr-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hdr-top h2 { margin: 0; font-size: 21px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--card); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; font-size: 20px; font-weight: 700; display: grid; place-items: center; }
.bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.daydots { display: flex; gap: 5px; }
.daydots i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); display: block; }
.daydots i.did { background: var(--brand); }
.daydots i.hard { background: var(--sun); }
.daydots i.skip { background: var(--ink-3); }
.daydots i.next { background: var(--card); box-shadow: 0 0 0 2.5px var(--brand) inset; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.pill.missed { background: var(--coral-2); color: #A33C27; }
.pill.streak { background: var(--sun-2); color: #8A5A00; }
.pill.ok { background: var(--brand-2); color: var(--brand); }
.pill.wait { background: var(--line); color: var(--ink-2); }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border-top: 1.5px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { border: 0; background: none; height: var(--tabbar); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 700; font-size: 13px; color: var(--ink-3); }
.tabbar button .ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .6; }
.tabbar button.on { color: var(--brand); }
.tabbar button.on .ic { filter: none; opacity: 1; }
.tabbar .dot { position: absolute; margin: -18px 0 0 22px; width: 9px; height: 9px; border-radius: 50%; background: var(--coral); }

/* Quest */
.quest-title { font-family: var(--head); font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.quest-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.qa { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 4px; cursor: pointer; font-weight: 700; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; justify-content: center; }
.qa .e { font-size: 22px; line-height: 1; }
.qa.on.did { border-color: var(--brand); background: var(--brand-2); color: var(--brand); }
.qa.on.skip { border-color: var(--ink-3); background: #F1EFF4; }
.qa.on.hard { border-color: #E2A400; background: var(--sun-2); color: #8A5A00; }
.qa[disabled] { cursor: default; }
.qa[disabled]:not(.on) { opacity: .45; }
.done-banner { display: flex; align-items: center; gap: 12px; background: var(--brand-2); color: var(--brand); border-radius: 14px; padding: 12px 14px; font-weight: 700; }
.done-banner .e { font-size: 26px; }

.door-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.yesterday { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1.5px dashed #F5DB94; font-size: 15px; font-weight: 600; flex-wrap: wrap; }
.yesterday button { border: 0; background: var(--card); border-radius: 10px; padding: 6px 12px; font-weight: 700; cursor: pointer; box-shadow: 0 0 0 1.5px #F5DB94; }

/* Learn */
.badges { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.badge { border-radius: 16px; padding: 14px 10px; text-align: center; background: var(--card); box-shadow: 0 0 0 1.5px var(--line); }
.badge .e { font-size: 34px; line-height: 1.1; }
.badge b { display: block; font-family: var(--head); font-weight: 600; font-size: 15px; margin-top: 4px; }
.badge.locked .e { filter: grayscale(1); opacity: .35; }
.badge.locked b { color: var(--ink-3); }
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; border-radius: 14px; border: 0; background: var(--card); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; }
.item .n { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family: var(--head); font-weight: 600; background: var(--line); flex-shrink: 0; }
.item.done .n { background: var(--brand); color: #fff; }
.item.next { box-shadow: 0 0 0 2.5px var(--brand); }
.item.next .n { background: var(--sun); }
.item.locked { opacity: .55; cursor: default; }
.item .t { flex: 1; font-weight: 700; }
.item .t small { display: block; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.read-text { font-size: 21px; line-height: 1.6; }
.feedback { border-radius: 14px; padding: 12px 14px; margin-top: 14px; font-size: 16px; }
.feedback.right { background: var(--brand-2); }
.feedback.wrong { background: var(--coral-2); }
.feedback b { font-family: var(--head); font-weight: 600; }
.big-badge { font-size: 96px; text-align: center; line-height: 1; margin: 30px 0 10px; animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

/* Ask */
details.article { background: var(--card); border-radius: 14px; box-shadow: 0 0 0 1.5px var(--line); }
details.article summary { list-style: none; cursor: pointer; padding: 14px 40px 14px 14px; font-weight: 700; position: relative; }
details.article summary::-webkit-details-marker { display: none; }
details.article summary::after { content: '+'; position: absolute; right: 14px; top: 10px; font-size: 24px; color: var(--brand); font-family: var(--head); }
details.article[open] summary::after { content: '–'; }
details.article .body { padding: 0 14px 14px; color: var(--ink); white-space: pre-line; }
details.article.mine { box-shadow: 0 0 0 2.5px var(--sun); }
.myq { padding: 12px 0; border-top: 1.5px solid var(--line); }
.myq:first-of-type { border-top: 0; }

/* Menu sheet */
.sheet-wrap { position: fixed; inset: 0; background: rgba(43,42,51,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet .btn { margin-top: 10px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 30; max-width: calc(100% - 32px); width: max-content; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.18); }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 14px; text-align: center; box-shadow: 0 0 0 1.5px var(--line); }
.stat b { display: block; font-family: var(--head); font-size: 30px; font-weight: 600; color: var(--brand); line-height: 1.1; }
.stat span { font-size: 13px; font-weight: 700; color: var(--ink-2); }

@media (min-width: 520px) {
  body { background: #F4EBDD; }
  #app { background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
  .hdr { background: var(--bg); }
}
