/* Zoey's Corner: warm, calm, readable. Tokens first, dark mode follows the device. */
:root {
  --bg: #f7f3ff; --card: #ffffff; --ink: #2a2140; --muted: #6b6185;
  --brand: #7b5cd6; --brand-ink: #ffffff; --accent: #ff9f43; --line: #e2daf5; --soft: #efe9fc;
  --good: #1f8a5b; --good-bg: #e3f6ec; --try: #b35b00; --try-bg: #fff1e0;
  --info-bg: #eaf2ff; --danger: #c0392b;
  --display: "Secular One", "Varela Round", Arial, sans-serif;
  --body: "Varela Round", Arial, "Segoe UI", sans-serif;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17131f; --card: #221c2e; --ink: #f1ecfb; --muted: #b3a9c9;
    --brand: #a58bf0; --brand-ink: #17131f; --accent: #ffb366; --line: #3a3150; --soft: #2c2440;
    --good: #5fd39b; --good-bg: #1a3a2b; --try: #ffb366; --try-bg: #3d2a17; --info-bg: #1e2a40; --danger: #ff7b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17131f; --card: #221c2e; --ink: #f1ecfb; --muted: #b3a9c9;
  --brand: #a58bf0; --brand-ink: #17131f; --accent: #ffb366; --line: #3a3150; --soft: #2c2440;
  --good: #5fd39b; --good-bg: #1a3a2b; --try: #ffb366; --try-bg: #3d2a17; --info-bg: #1e2a40; --danger: #ff7b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 18px; line-height: 1.6; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.25; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: clamp(26px, 5vw, 36px); } h2 { font-size: 22px; }
p { margin: 0 0 .6em; }
a { color: var(--brand); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--card); border-bottom: 2px solid var(--line);
}
.logo { font-family: var(--display); font-size: 24px; color: var(--ink); text-decoration: none; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a { text-decoration: none; color: var(--ink); padding: 6px 12px; border-radius: 999px; }
.topnav a[aria-current="page"] { background: var(--soft); color: var(--brand); }

.wrap { max-width: 860px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right)) 56px max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 16px; outline: none; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card.narrow { max-width: 420px; width: 100%; margin-inline: auto; display: flex; flex-direction: column; gap: 10px; }
.card.review { border-color: var(--accent); }
.hero { padding: 8px 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.subject.soon { opacity: .7; }
.subject-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.subject-head p { margin: 0; }
.emoji { font-size: 30px; line-height: 1; }
.unit-list { display: flex; flex-direction: column; gap: 8px; }
.unit { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 14px; background: var(--soft); color: var(--ink); text-decoration: none; }
.unit:hover { outline: 2px solid var(--brand); }
.unit-meta { font-size: 14px; color: var(--muted); }
.crumbs { font-size: 15px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: 15px;
  color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums; }
a.chip:hover { border-color: var(--brand); }

.skills { list-style: none; padding: 0; margin: 0 0 14px; }
.skills li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.skill-level { color: var(--muted); white-space: nowrap; }
.stars { color: var(--accent); letter-spacing: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 18px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--brand); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.big { font-size: 20px; padding: 12px 26px; }
.btn[hidden] { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.exercise { display: flex; flex-direction: column; gap: 14px; }
.ex-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; }
.dots { display: flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dot.done { background: var(--good); } .dot.now { background: var(--brand); }
.prompt { font-size: 24px; margin: 0; }
.math { unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; }
.answer-in, .frac-in, .card.narrow input { border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--bg); min-height: 48px; }
.answer-in { width: min(100%, 280px); font-size: 22px; }
.fraction { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; align-self: flex-start; }
.frac-in { width: 90px; text-align: center; font-size: 22px; }
.frac-bar { width: 100px; height: 3px; background: var(--ink); border-radius: 2px; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { min-height: 52px; min-width: 90px; padding: 8px 18px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); font-size: 22px; cursor: pointer; }
.choice[aria-pressed="true"] { border-color: var(--brand); background: var(--soft); }
.hints { margin: 0; padding-inline-start: 22px; color: var(--muted); }
.hints:empty { display: none; }
.hints li { margin-bottom: 4px; }
.hints li::marker { content: "💡 "; }
.feedback:empty { display: none; }
.feedback { border-radius: 14px; padding: 10px 14px; margin: 0; }
.feedback p:last-child { margin: 0; }
.feedback.good { background: var(--good-bg); }
.feedback.good .praise { color: var(--good); font-weight: bold; }
.feedback.try { background: var(--try-bg); }
.feedback.info, .feedback.reveal { background: var(--info-bg); }

.table { width: 100%; border-collapse: collapse; font-size: 16px; }
.table th, .table td { text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: normal; }
.table tr.hard td { background: var(--try-bg); }
section.card:has(.table) { overflow-x: auto; }
label { display: flex; flex-direction: column; gap: 4px; }
.loading { text-align: center; padding: 40px 0; }
