/* Tutor. Colors, type, shape and motion from BRAND.md (Focus); structure from app-design. */
:root {
  --page: #f2f3f7; --card: #ffffff; --ctl: #eef0f5;
  --t1: #13151b; --t2: #5d6170; --t3: #8a8e9b;
  --acc: #3b5bdb; --acct: #2f4ac0;
  --hl: #fff0a3; --hlt: #13151b;
  --good: #15803d; --warn: #b45309; --bad: #b91c1c; --bad-fill: #b91c1c;
  --font: Lexend, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --r-card: 24px; --r-hl: 14px; --r-input: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #15161a; --card: #202228; --ctl: #2c2f37;
    --t1: #f1f2f6; --t2: #b0b4c1; --t3: #5c5f6a;
    --acct: #91a7ff; --hl: #3d3614; --hlt: #fff3bf;
    --good: #4ade80; --warn: #fbbf24; --bad: #f87171; --bad-fill: #dc2626;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--t1); font: 400 1.0625rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
main {
  overflow-wrap: anywhere; min-width: 0;
  max-width: 640px; margin: 0 auto; display: grid; gap: 32px;
  padding-block: max(24px, env(safe-area-inset-top)) max(48px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right));
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 2.125rem; font-weight: 700; line-height: 1.15; text-wrap: balance; }
h2 { font-size: 1.25rem; font-weight: 600; text-wrap: balance; }
.sub { color: var(--t2); font-size: 0.9375rem; }
.stack { display: grid; gap: 12px; }
.num { font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* Top bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px 0 0;
  background: none; border: 0; color: var(--acct); font-weight: 600; font-size: 0.9375rem; cursor: pointer; text-decoration: none; }
.back svg { width: 20px; height: 20px; }

/* Hero */
.hero { display: grid; gap: 4px; justify-items: start; }
.hero .big { font-size: 4rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hero .big small { font-size: 1.75rem; font-weight: 600; color: var(--t2); margin-left: 2px; }

/* Cards */
.card { background: var(--card); border-radius: var(--r-card); padding: 20px; display: grid; gap: 16px; min-width: 0; }
a.card, button.card { text-decoration: none; color: inherit; border: 0; text-align: left; cursor: pointer;
  transition: transform 250ms var(--ease); }
a.card:active, button.card:active { transform: scale(0.98); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row > div { min-width: 0; }
.topic-title { font-weight: 600; }
.score { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter { height: 6px; border-radius: 999px; background: var(--ctl); overflow: hidden; }
.meter { display: flex; }
.meter b { display: block; height: 100%; background: var(--acc); opacity: 0.35; }
.meter i { display: block; height: 100%; border-radius: 999px; background: var(--c, var(--acc)); transition: width 250ms var(--ease); }
.lo { --c: var(--bad); color: var(--bad); }
.mid { --c: var(--warn); color: var(--warn); }
.hi { --c: var(--good); color: var(--good); }
.new, .start { --c: var(--t3); color: var(--t2); }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 50px; padding: 0 24px;
  border: 0; border-radius: 999px; background: var(--acc); color: #fff; font-weight: 600; font-size: 1.0625rem;
  cursor: pointer; text-decoration: none; transition: transform 250ms var(--ease), opacity 250ms var(--ease); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn.danger { background: var(--bad-fill); }
.btn.secondary { background: var(--ctl); color: var(--t1); min-height: 44px; }
.btn.text { background: none; color: var(--acct); min-height: 44px; }
.actions { display: grid; gap: 8px; }
.stack.tight { gap: 8px; }

/* Lesson */
.lesson p { max-width: 62ch; }
.lesson strong { font-weight: 600; }
.tbl { overflow-x: auto; margin: 0 -6px; }
.tbl h3 { font-size: 0.9375rem; font-weight: 600; color: var(--t2); padding: 0 8px 4px; }
table { border-collapse: collapse; width: 100%; font-size: 1.0625rem; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 600; font-size: 0.8125rem; color: var(--t2); padding: 4px 6px; }
td { padding: 8px 6px; vertical-align: top; overflow-wrap: normal; }
td.nw { white-space: nowrap; } /* single words: endings, answers */
.row .num { white-space: nowrap; }
tbody tr:nth-child(odd) td { background: var(--ctl); }
tbody tr td:first-child { border-radius: 10px 0 0 10px; }
tbody tr td:last-child { border-radius: 0 10px 10px 0; }
td.key { color: var(--acct); font-weight: 600; white-space: nowrap; }

/* Quiz */
.progress { display: flex; align-items: center; gap: 12px; }
.progress .meter { flex: 1; }
.prompt { font-size: 1.5rem; font-weight: 600; line-height: 1.35; text-wrap: pretty; }
.hint { color: var(--t2); font-size: 0.9375rem; }
.blank { display: inline-block; min-width: 3em; border-bottom: 3px solid var(--t3); margin: 0 2px; }
input.answer { width: 100%; min-height: 56px; padding: 0 16px; border: 0; border-radius: var(--r-input);
  background: var(--ctl); color: var(--t1); font: 600 1.25rem/1 var(--font); }
input.answer::placeholder { color: var(--t3); font-weight: 400; }
input.answer:focus { outline: 2px solid var(--acc); outline-offset: 0; }
input.answer[readonly] { outline: 0; }
.keys { display: flex; flex-wrap: wrap; gap: 8px; }
.keys button { min-width: 44px; min-height: 44px; border: 0; border-radius: 999px; background: var(--ctl);
  font-weight: 600; font-size: 1.0625rem; cursor: pointer; }
.choices { display: grid; gap: 8px; }
.choice { min-height: 52px; padding: 12px 20px; border: 0; border-radius: 999px; background: var(--ctl);
  text-align: left; font-weight: 600; font-size: 1.0625rem; cursor: pointer; }
.choice[aria-pressed="true"] { background: var(--acc); color: #fff; }
.choice.right { background: var(--good); color: var(--card); }
.choice.wrong { background: var(--bad); color: var(--card); }
.verdict { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-size: 1.0625rem; }
.verdict b { font-weight: 700; }
.verdict .ans { font-weight: 700; color: var(--good); }
.why { background: var(--hl); color: var(--hlt); border-radius: var(--r-hl); padding: 14px 16px; display: grid; gap: 4px; }
.why .label { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.why p { max-width: 62ch; }
.pulse { animation: pulse 600ms var(--ease); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 45%, transparent); }
  100% { box-shadow: 0 0 0 16px transparent; } }

/* Results list */
.miss { display: grid; gap: 2px; }
.miss .a { color: var(--good); font-weight: 600; }
.empty { color: var(--t2); }

@media (min-width: 720px) {
  main { padding-left: 32px; padding-right: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
