:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1d232c;
  --border: #2b3441;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #4c8dff;
  --accent-dim: #23324b;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 14px;
  --maxw: 720px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top));
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(14, 17, 22, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__brand {
  background: none; border: 0; color: var(--text);
  font-size: 17px; font-weight: 700; letter-spacing: 0.2px;
  flex: 0 0 auto;
}
.topbar__nav { display: flex; gap: 16px; flex-wrap: wrap; }
@media (max-width: 460px) {
  .topbar { gap: 8px 14px; }
  .topbar__brand { flex-basis: 100%; }
}
.topbar__nav a {
  color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 4px 0;
}
.topbar__nav a.is-active { color: var(--text); border-bottom: 2px solid var(--accent); }
.topbar__auth { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar__auth a, .topbar__auth button.link-btn {
  color: var(--text-dim); text-decoration: none; font-size: 13px; font-weight: 600;
  background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit;
}
.topbar__auth a:hover, .topbar__auth button.link-btn:hover { color: var(--text); }

.app {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 40px;
  flex: 1;
}

.footer {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

h1 { font-size: 24px; line-height: 1.25; margin-bottom: 6px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 6px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
p { margin-bottom: 12px; }
ul, ol { margin: 0 0 14px 20px; }
li { margin-bottom: 6px; }
strong { color: #fff; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 90%; }

.lead { color: var(--text-dim); font-size: 15px; margin-bottom: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card--tight { padding: 13px 14px; }
.card__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-dim); margin-bottom: 4px; }

.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid--2 { grid-template-columns: 1fr 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0;
  padding: 12px 18px; border-radius: 10px;
  font-size: 15px; font-weight: 650; cursor: pointer;
  text-decoration: none;
  width: 100%;
}
.btn--ghost { background: var(--accent-dim); color: var(--text); }
.btn--sm { width: auto; padding: 9px 14px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: inherit; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.field .hint { color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.field input[type=text], .field textarea, .field select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
}
.field textarea { min-height: 92px; resize: vertical; }
.checks label { display: flex; gap: 9px; align-items: flex-start; font-weight: 500; margin-bottom: 8px; }
.checks input { margin-top: 4px; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
}
.pill--unknown { background: #30363d; color: var(--text-dim); }
.pill--emerging { background: #3a2d12; color: var(--warn); }
.pill--guided { background: #12303a; color: #56b6c2; }
.pill--independent { background: #12351d; color: var(--good); }
.pill--transferable, .pill--advanced { background: #1d2b4d; color: var(--accent); }
.pill--pro { background: #402a12; color: var(--warn); }

.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.next {
  border: 1px solid var(--accent);
  background: linear-gradient(180deg, var(--accent-dim), var(--surface));
}
.next .card__label { color: var(--accent); }

.caplist { display: flex; flex-direction: column; gap: 8px; }
.caprow {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
  text-decoration: none; color: var(--text);
}
.caprow__id { font-weight: 800; color: var(--text-dim); width: 26px; }
.caprow__name { flex: 1; font-size: 14px; }

.evidence-item { border-left: 3px solid var(--accent); padding-left: 12px; margin-bottom: 16px; }
.evidence-item time { color: var(--text-dim); font-size: 12px; }

.feedback { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-2); margin-bottom: 12px; }
.feedback .row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.feedback .row:last-child { border-bottom: 0; }
.feedback .ok { color: var(--good); }
.feedback .miss { color: var(--warn); }

.stepline { display: flex; gap: 6px; margin: 14px 0; flex-wrap: wrap; }
.stepline span {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
}
.stepline span.done { background: #12351d; color: var(--good); }
.stepline span.now { background: var(--accent); color: #fff; }

.notice { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; color: var(--text-dim); font-size: 14px; }

/* "watch it done" play-through — a lightweight visual clip */
.demo__bar { height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.demo__bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
.demo-step { position: relative; transition: opacity .45s ease, transform .45s ease; }
.demo.playing .demo-step { opacity: 0; transform: translateY(10px); }
.demo.playing .demo-step.reveal { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .demo-step { transition: none; }
  .demo.playing .demo-step { opacity: 1; transform: none; }
}
/* the rail turns the step cards into one connected flow instead of a stack — a line
   through every numbered dot, ending at the result. Cards stay untouched (still just
   .card/.card--tight), so any length of move/result text still just reflows normally. */
.demo__rail { position: relative; padding-left: 26px; margin-left: 4px; }
.demo__rail::before {
  content: ""; position: absolute; left: 9px; top: 14px; bottom: 14px;
  width: 2px; background: var(--border);
}
.demo-step__dot {
  position: absolute; left: -26px; top: 13px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--accent);
  color: var(--accent); font: 700 10.5px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  display: flex; align-items: center; justify-content: center; z-index: 1;
}
.demo-step__dot--end { border-color: var(--good); color: var(--good); font-size: 11px; }
details.card summary { list-style: revert; }
details.card summary::-webkit-details-marker { display: revert; }

/* before/after on a critique challenge — shown only once the rubric is met */
.beforeafter { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 4px; }
@media (min-width: 560px) { .beforeafter { grid-template-columns: 1fr 1fr; } }
.beforeafter__panel { border-radius: 10px; padding: 12px 13px; border: 1px solid var(--border); background: var(--surface-2); }
.beforeafter__panel--before { border-color: #3a2530; }
.beforeafter__panel--after { border-color: #1d3a26; }
.beforeafter__label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-bottom: 7px; }
.beforeafter__panel--before .beforeafter__label { color: var(--bad); }
.beforeafter__panel--after .beforeafter__label { color: var(--good); }
.beforeafter__text { font-style: italic; font-size: 13.5px; white-space: pre-wrap; margin: 0; }
.beforeafter__changes { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.beforeafter__changes li::before { content: "→ "; color: var(--good); }

/* prerequisite-chain diagram (checkpoint "Reference" panel) */
.chainlinks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.chainlink {
  font: 500 12.5px ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--accent); text-decoration: none;
}
.chainlink:hover { text-decoration: underline; }

/* quick-check MCQs */
.qcheck__opts { display: flex; flex-direction: column; gap: 8px; }
.qopt {
  text-align: left; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 10px 12px; font: inherit; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.qopt:hover:not(:disabled) { border-color: var(--accent); }
.qopt:disabled { cursor: default; }
.qopt--right { border-color: var(--good); background: #12351d; color: #b8f0c4; }
.qopt--wrong { border-color: var(--bad); background: #3a1a1a; color: #f6c6c2; }

/* stepline chips wrap nicely with icons */
.stepline span { display: inline-flex; align-items: center; gap: 4px; }

/* The `hidden` attribute is only `display: none` in the UA stylesheet, so ANY author rule that
   sets `display` beats it — which silently defeats `el.hidden = true` on anything with a display
   rule of its own (every .btn here). Keep the attribute authoritative. */
[hidden] { display: none !important; }
