:root {
  --bg: #0f1115; --panel: #1a1a2e; --field: #0d1117; --border: #2a2d3a;
  --text: #e0e0e0; --muted: #8b90a0; --accent: #4f8cff; --ok: #3ddc84; --warn: #f5b942; --bad: #ff5c5c;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif; }
body { display: flex; flex-direction: column; min-height: 100vh; }
header { padding: 14px 20px 6px; max-width: 640px; width: 100%; margin: 0 auto; }
h1 { margin: 0; font-size: 22px; }
h2 { margin: 0 0 6px; font-size: 22px; }
h3 { margin: 16px 0 6px; font-size: 16px; }
.tag { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
main { flex: 1; padding: 8px 20px 16px; max-width: 640px; width: 100%; margin: 0 auto; }
section { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.banner { margin: 0 0 14px; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.banner.warn { background: #3a2f1a; border: 1px solid #8a6a2a; }
.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.label, .field > label { font-weight: 600; font-size: 14px; }

button, select {
  background: var(--field); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font: inherit; min-height: 44px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.big { width: 100%; margin-top: 14px; font-size: 17px; }
.linkbtn { background: none; border: none; color: var(--accent); padding: 0 4px; min-height: 0; text-decoration: underline; font-size: inherit; }

/* Two-option direction switch */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button[aria-checked="true"] { border-color: var(--accent); background: #1f2b47; font-weight: 600; }

/* Topic buttons */
.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.topics button { text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.topics button .sub { color: var(--muted); font-size: 12.5px; }
.topics button.due { border-color: #8a6a2a; }
@media (max-width: 380px) { .topics { grid-template-columns: 1fr; } }

/* Quiz */
.quizbar { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.meter { height: 6px; background: var(--field); border-radius: 3px; margin: 8px 0 14px; overflow: hidden; }
.meter div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.ask { margin: 0 0 4px; font-size: 14px; }
.prompt { font-size: 34px; font-weight: 700; margin: 0 0 18px; overflow-wrap: anywhere; }
.choices { display: grid; gap: 10px; }
.choices button { text-align: left; font-size: 18px; display: flex; gap: 12px; align-items: center; }
.choices button .key { color: var(--muted); font-size: 13px; min-width: 1.2em; }
.choices button .mark { margin-left: auto; font-weight: 700; }
.choices button.right { border-color: var(--ok); background: #143322; }
.choices button.wrong { border-color: var(--bad); background: #3a1a1e; }
.choices button:disabled { cursor: default; opacity: 1; }
.feedback { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 15px; }
.feedback.ok { background: #143322; border: 1px solid var(--ok); }
.feedback.bad { background: #3a1a1e; border: 1px solid var(--bad); }

/* Summary */
.missed { margin: 0; padding-left: 18px; }
.missed li { margin: 4px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

@media (prefers-reduced-motion: reduce) { .meter div { transition: none; } }

footer { padding: 10px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
footer a { color: var(--accent); text-decoration: none; }
.tip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tip a { border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px; }
.tip a:hover { border-color: var(--accent); background: var(--panel); }
