:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #e3e3e0;
  --empty: #ececea;
  --good: #1f8a4c;
  --bad: #c2362b;
  --focus: #428af6;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --surface: #1e1e21;
    --text: #ececef;
    --muted: #9a9aa2;
    --line: #34343a;
    --empty: #2c2c31;
    --good: #4cc27f;
    --bad: #ff6b5e;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--empty); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button:disabled { cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--focus); text-decoration: underline; text-underline-offset: 2px; }
.hint { color: var(--muted); font-size: 0.9rem; }
.warn { color: var(--bad); }

/* header */
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand h1 { font-size: 1.5rem; }
.brand span, .who { color: var(--muted); }
.tabs { display: flex; gap: 4px; margin: 16px 0 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.sync { min-height: 1.5em; margin: 4px 0 16px; font-size: 0.85rem; color: var(--muted); }

/* name gate */
.gate { max-width: 460px; margin: 10vh auto 0; }
.gate h1 { font-size: 2rem; margin-bottom: 12px; }
.gate form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 20px; }
.gate label { width: 100%; font-weight: 600; }
.gate input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }

/* shared buttons */
.gate button, .nav button {
  padding: 10px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.gate button, .nav .primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.nav button:disabled { opacity: 0.4; }
.nav .ghost { background: none; }

/* level pips */
.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: var(--empty); }
.pips i.on { background: var(--cat, var(--text)); }

/* topic list */
.category { margin-bottom: 28px; }
.category h2 { color: var(--cat); margin-bottom: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--cat); border-radius: var(--radius);
}
.card:hover { border-color: var(--cat); }
.card-open {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 14px 14px 10px; background: none; border: 0; border-radius: var(--radius);
}
.card-name { font-weight: 600; }
.card-meta { color: var(--muted); font-size: 0.85rem; }
.card-verb { color: var(--cat); font-size: 0.85rem; font-weight: 600; margin-top: 2px; }

.card.locked { opacity: 0.55; }
.card.locked:hover { border-color: var(--line); }
.card.locked .card-verb { color: var(--muted); }
.legend li.locked { opacity: 0.6; }

.card-share { display: flex; gap: 6px; align-items: center; margin-top: auto; padding: 8px 14px 10px; border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); cursor: pointer; }

/* topic documentation */
.readme { display: block; font-size: 0.8rem; color: var(--focus); text-decoration: none; }
.card .readme { padding: 0 14px 12px; overflow-wrap: anywhere; }
.readme:hover { text-decoration: underline; }
.readme.none { color: var(--muted); }
.readme.none a { color: var(--focus); }
.topic-readme { margin: -4px 0 14px; }

/* topic / question */
.topic-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0; }
.topic-head h2 { color: var(--cat); font-size: 1.35rem; }
.dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); padding: 0; }
.dot.right { background: var(--good); border-color: var(--good); }
.dot.wrong { background: var(--bad); border-color: var(--bad); }
.dot.current { outline: 2px solid var(--cat); outline-offset: 2px; }
.question { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.qnum { margin: 0 0 6px; color: var(--muted); font-size: 0.85rem; }
.question h3 { font-size: 1.1rem; margin-bottom: 14px; }
.options { display: grid; gap: 8px; }
.option {
  text-align: left; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg);
}
.option:not(:disabled):hover { border-color: var(--cat); }
.option:disabled { opacity: 0.6; }
.option.correct { opacity: 1; border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.option.incorrect { opacity: 1; border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.reveal { margin-top: 12px; font-size: 0.9rem; }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--bg); border-left: 4px solid; }
.explain.good { border-color: var(--good); }
.explain.good strong { color: var(--good); }
.explain.bad { border-color: var(--bad); }
.explain.bad strong { color: var(--bad); }
.explain p { margin: 6px 0 0; }
.source { color: var(--muted); font-size: 0.85rem; }
.nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 14px; }

/* snowflakes */
.snowflake { display: block; width: 100%; height: auto; }
.snowflake .band { fill: var(--empty); }
.snowflake text { fill: var(--muted); }
.me { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.flake-big { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.overall { margin: 0 0 12px; color: var(--muted); }
.overall span { font-size: 2rem; font-weight: 700; color: var(--text); }
.me-side h3 { margin: 16px 0 6px; }
.focus, .legend { list-style: none; margin: 0; padding: 0; }
.focus li { padding: 2px 0; }
.legend label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.legend li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }

/* team */
.team h2 { margin: 20px 0 6px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th[scope="row"], thead th:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; }
td.private { color: var(--muted); font-style: italic; }
td.lead { font-weight: 700; background: color-mix(in srgb, var(--good) 16%, transparent); }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.gap { display: inline-block; font-size: 0.72rem; font-weight: 700; color: var(--bad); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-left: 4px; }
.flakes { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.flakes figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; text-align: center; }
.flakes figcaption { font-size: 0.9rem; margin-top: 4px; }

/* flags */
.flag-link { display: block; margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.flag-note { margin: 12px 0 0; }
.flag-form { display: grid; gap: 8px; margin-top: 14px; }
.flag-form label { font-weight: 600; font-size: 0.9rem; }
.flag-form textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; resize: vertical; }
.flag-form .primary { padding: 8px 14px; border-radius: var(--radius); background: var(--text); color: var(--bg); border: 1px solid var(--text); }
.flag-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.flags ul { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.flag { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--cat); border-radius: var(--radius); padding: 12px 14px; }
.flag p { margin: 0 0 6px; }
.flag-topic { color: var(--muted); font-size: 0.85rem; }
.flag-q { font-weight: 600; }
.flag-a { font-size: 0.9rem; }
.flag blockquote { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--line); overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .me { grid-template-columns: 1fr; }
  .nav { justify-content: stretch; }
  .nav button { flex: 1; }
}
