:root {
  color-scheme: light dark;
  --bg: #f4f5f8; --surface: #ffffff; --text: #1c1e26; --muted: #6b7080; --track: #e4e6ec;
  --accent: #5e64f6; --accent-soft: rgba(94, 100, 246, .12);
  --good: #2e9e7d; --warn: #c98a1e; --bad: #d6615c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --surface: #1c1f27; --text: #eceef3; --muted: #9197a6; --track: #2a2e39;
    --accent: #8f94ff; --accent-soft: rgba(143, 148, 255, .16);
    --good: #4cc3a0; --warn: #e3ae4f; --bad: #ee837d;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--track); margin: 14px 0; }

#app { height: 100%; height: 100dvh; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; }
header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 20px 10px;
}
header h1 { font-size: 17px; font-weight: 600; margin: 0; }
header .side { justify-self: end; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
main { flex: 1; overflow-y: auto; padding: 8px 20px 24px; -webkit-overflow-scrolling: touch; }

nav {
  display: flex; background: var(--surface); border-top: 1px solid var(--track);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button { flex: 1; padding: 14px 0; font-size: 13px; font-weight: 500; color: var(--muted); }
nav button.on { color: var(--accent); font-weight: 600; }

.actions { display: flex; gap: 12px; padding: 12px 20px; }
.btn {
  flex: 1; display: block; width: 100%; padding: 15px; border-radius: 14px;
  font-weight: 600; color: #fff; background: var(--accent);
}
.btn.good { background: var(--good); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.inline { width: auto; display: inline-block; padding: 13px 22px; }
.btn:disabled { opacity: .35; cursor: default; }
.link { display: block; width: 100%; text-align: left; color: var(--accent); text-decoration: none; padding: 2px 0; }
.link.bad { color: var(--bad); }

.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.accent { color: var(--accent); } .muted { color: var(--muted); }
.small { font-size: 14px; } .strong { font-weight: 600; }
.bg-good { background: var(--good); } .bg-warn { background: var(--warn); } .bg-bad { background: var(--bad); }

.chip {
  display: inline-block; padding: 5px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.label.section { margin: 28px 0 10px; }
.panel { background: var(--surface); border-radius: 16px; padding: 16px; }
.panel > p + p { margin-top: 10px; }
.panel h3 { margin: 0 0 8px; font-size: 17px; }
.panel .label { margin-bottom: 6px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.note { margin-top: 12px; font-size: 14px; color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 22vh 12px 0; }
.empty h2 { color: var(--text); margin: 0 0 8px; font-size: 22px; }
.empty .btn { margin-top: 22px; }

/* Qbank */
.stem { margin: 16px 0 18px; line-height: 1.6; }
.choices { display: grid; gap: 10px; margin-bottom: 18px; }
.choice {
  display: flex; gap: 12px; text-align: left; width: 100%; padding: 14px;
  background: var(--surface); border: 1.5px solid transparent; border-radius: 14px; line-height: 1.45;
}
.choice .letter { font-weight: 600; color: var(--accent); width: 18px; flex: none; }
.choice.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.choice.correct .letter { color: var(--good); }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.choice.wrong .letter { color: var(--bad); }
.choice.dim, .choice.dim .letter { color: var(--muted); }
.panel p { line-height: 1.55; }

/* Flashcards */
.card { background: var(--surface); border-radius: 20px; padding: 22px; min-height: 280px; cursor: pointer; }
.card .tag { font-size: 13px; }
.cloze-text { font-size: 21px; line-height: 1.6; margin-top: 18px; }
.cloze { color: var(--accent); font-weight: 600; white-space: nowrap; }
.cloze.shown { color: var(--good); white-space: normal; }
.extra { color: var(--muted); line-height: 1.55; }
.hint { margin-top: 20px; font-size: 14px; color: var(--muted); opacity: .7; }

/* Analytics */
.ring { position: relative; width: 200px; height: 200px; margin: 8px auto 16px; }
.ring svg { width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 14; }
.ring-track { stroke: var(--track); }
.ring-value { stroke-linecap: round; }
.ring-value.good { stroke: var(--good); } .ring-value.warn { stroke: var(--warn); } .ring-value.bad { stroke: var(--bad); }
.ring-goal { stroke: var(--text); stroke-width: 3; stroke-linecap: round; opacity: .55; }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score { font-size: 52px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.goal { font-size: 14px; color: var(--muted); }
.next { text-align: center; color: var(--muted); margin: 0 8px 20px; }
.metrics { display: flex; text-align: center; }
.metrics div { flex: 1; }
.metrics b { display: block; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metrics span { font-size: 13px; color: var(--muted); }
.topic + .topic, .missed + .missed { margin-top: 14px; }
.topic .row { font-size: 15px; margin-bottom: 6px; }
.topic b { font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; }
.topic + p { margin-top: 14px; }
.missed p { margin-top: 3px; font-size: 16px; }
main > p.small { margin: 10px 4px 0; }

/* Login */
.login { margin: auto 0; padding: 0 24px 12vh; text-align: center; }
.login h1 { font-size: 44px; letter-spacing: -.03em; margin: 0 0 4px; }
.users { display: grid; gap: 10px; margin: 28px 0 12px; }
.user { padding: 16px; border-radius: 14px; background: var(--surface); font-weight: 600; border: 1.5px solid transparent; }
.user.on { border-color: var(--accent); color: var(--accent); }
.login form { display: grid; gap: 12px; }
.login input {
  font: inherit; color: inherit; padding: 16px; border-radius: 14px; border: 0;
  background: var(--surface); text-align: center; outline: none;
}
.login input:focus { box-shadow: 0 0 0 2px var(--accent); }
