/* rustpath design system.
   Tokens → base → shell → components (buttons, alerts, panels, chips, badges, pills) → map →
   track → exercise (prose, highlighting) → attempt (checks, diffs, budgets) → login.
   One accent (rust orange) for calls to action and focus; everything else neutral.
   Light and dark follow the OS. */

@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/vendor/fonts/inter-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/vendor/fonts/inter-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --brand: #b7410e;
  --brand-hover: #9a370c;
  --brand-soft: #fbeee7;
  --brand-ring: 0 0 0 3px rgba(183, 65, 14, .25);

  --ok: #15803d;      --ok-soft: #e8f5ec;
  --warn: #a16207;    --warn-soft: #fdf6e3;
  --error: #b42318;   --error-soft: #fdecea;

  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #8a8580;
  --bg: #f7f6f4;
  --surface: #ffffff;
  --surface-2: #f3f1ee;
  --border: #e5e2dd;
  --border-2: #d4d0c9;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 2px 6px rgba(28, 25, 23, .04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar-h: 60px;

  /* Syntax highlighting (syntect's hl-* classes); each ≥ 4.5:1 on --surface-2. */
  --hl-keyword: #9a2f6e;
  --hl-string: #3d6b1f;
  --hl-number: #a14a00;
  --hl-function: #1f5fa6;
  --hl-type: #0e6f68;
  --hl-macro: #8a3fb0;
  --hl-comment: #6e6862;
  --hl-lifetime: #b7410e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #f0763a;
    --brand-hover: #ff8a50;
    --brand-soft: #3a2116;
    --brand-ring: 0 0 0 3px rgba(240, 118, 58, .3);
    --ok: #4ade80;      --ok-soft: #13291b;
    --warn: #facc15;    --warn-soft: #2e2810;
    --error: #f87171;   --error-soft: #2f1615;
    --text: #ecebe9;
    --text-2: #b4b0aa;
    --text-3: #87827b;
    --bg: #151312;
    --surface: #1d1b19;
    --surface-2: #26231f;
    --border: #322e2a;
    --border-2: #45403a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --hl-keyword: #e08ac0;
    --hl-string: #a3c97a;
    --hl-number: #f0a868;
    --hl-function: #7fb2f0;
    --hl-type: #5cc8bd;
    --hl-macro: #c89cf0;
    --hl-comment: #8f8a83;
    --hl-lifetime: #f0763a;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .75em; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .08rem .35rem; border-radius: 5px; }
pre { font-family: var(--mono); font-size: .88rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem 1rem; overflow-x: auto; }
pre code { background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::selection { background: var(--brand-soft); }
[x-cloak] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; height: var(--topbar-h); display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 750; letter-spacing: .01em; font-size: 1.05rem; }
.brand:hover { color: var(--text); text-decoration: none; }
.nav { display: flex; gap: .25rem; }
.nav a { color: var(--text-2); padding: .4rem .75rem; border-radius: var(--radius-sm); font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.who { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.who form { margin: 0; }
.avatar { border-radius: 50%; border: 1px solid var(--border); }
.page { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.intro { margin-bottom: 1.5rem; }

/* ---------- components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 38px; padding: 0 1rem;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--brand-ring); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-sm { height: 30px; padding: 0 .7rem; font-size: .85rem; }
.btn-lg { height: 46px; padding: 0 1.4rem; font-size: 1rem; }

.alert {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 0 0 1rem;
}
.alert form { margin: 0; }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.alert-error { background: var(--error-soft); border-color: color-mix(in srgb, var(--error) 35%, transparent); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 1rem 0 0; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; }
.cmd { margin: .5rem 0; }

.badge { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .45rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.chip {
  display: inline-block; font-size: .78rem; padding: .1rem .5rem; margin: .15rem .3rem .15rem 0; border-radius: 99px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.chip:hover { color: var(--text); text-decoration: none; border-color: var(--border-2); }

/* Attempt states (queued / running / passed / failed / error), always with their label. */
.pill {
  flex: none; display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 650; line-height: 1;
  padding: .3rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.pill-lg { font-size: .85rem; padding: .4rem .75rem; }
.pill-running { background: var(--brand-soft); color: var(--brand); }
.pill-passed { background: var(--ok-soft); color: var(--ok); }
.pill-failed { background: var(--error-soft); color: var(--error); }
.pill-error { background: var(--warn-soft); color: var(--warn); }
.spinner {
  width: .8em; height: .8em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* A learner's standing on an exercise. */
.standing { flex: none; font-size: .78rem; font-weight: 650; color: var(--text-3); white-space: nowrap; }
.standing-in-progress { color: var(--brand); }
.standing-passed { color: var(--ok); }
.standing-passed::before { content: "✓ "; }

.crumbs { display: flex; flex-wrap: wrap; gap: .25rem .5rem; margin-bottom: .75rem; font-size: .85rem; }
.crumbs a { color: var(--text-2); }
.crumbs a + a::before { content: "›"; color: var(--text-3); margin-right: .5rem; display: inline-block; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.panel-head h2 { margin: 0; }
.tag {
  font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 5px; padding: .05rem .3rem; margin-left: .45rem; white-space: nowrap;
}

/* ---------- map ---------- */
.map { display: flex; flex-direction: column; gap: 1rem; }
.layer { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; position: relative; }
.layer > .track { flex: 0 1 285px; }
.layer + .layer::before {
  content: ""; position: absolute; top: -.85rem; left: 50%; width: 2px; height: .7rem; background: var(--border-2); border-radius: 2px;
}
.track {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem;
  display: flex; flex-direction: column; box-shadow: var(--shadow); scroll-margin-top: calc(var(--topbar-h) + 1rem);
}
.track:target { box-shadow: var(--brand-ring); }
.track header { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.track h2 { margin: 0; font-size: 1.02rem; }
.track h2 a { color: inherit; }
.track .num {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums;
}
.track .star { margin-left: auto; color: var(--brand); }
.track > p { color: var(--text-2); font-size: .9rem; margin-bottom: .5rem; }
.highlights { margin: 0 0 .75rem; padding-left: 1.1rem; color: var(--text-2); font-size: .85rem; }
.highlights li { margin: .1rem 0; }
.track footer { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; }
.state-label { flex: none; font-size: .78rem; font-weight: 650; color: var(--text-3); }
.track.open { border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); }
.track.open .num { background: var(--brand); color: #fff; }
.track.open .state-label { color: var(--brand); }
.track.locked { opacity: .78; }
.track.capstone { background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(135deg, var(--brand), var(--border)) border-box; border: 1px solid transparent; }

/* ---------- track page ---------- */
.track-intro h1 { display: flex; align-items: center; gap: .7rem; }
.track-intro .num {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 1.05rem; font-variant-numeric: tabular-nums;
}
.primer { max-width: 80ch; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: .9rem; padding: .7rem .4rem; color: var(--text); border-radius: var(--radius-sm); }
.row:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.row-num { flex: none; min-width: 2.4rem; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; }
.row-meta { font-size: .82rem; color: var(--text-2); }
.att-failed { color: var(--error); }
.att-error { color: var(--warn); }
.att-queued, .att-running { color: var(--brand); }

/* ---------- exercise page ---------- */
.ex-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.ex-head h1 { margin: 0; }
.ex-meta { color: var(--text-2); font-weight: 500; font-size: 1.05rem; letter-spacing: 0; }
.ex-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.ex-side { display: flex; flex-direction: column; position: sticky; top: calc(var(--topbar-h) + 1rem); }
.ex-side form { margin: 0; }
.assignment { margin-bottom: 0; }
.docs { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.prose .docs h2 { margin-top: 0; }
.docs ul { margin: 0; padding-left: 1.1rem; }
.attempts { list-style: none; margin: 0 -.4rem; padding: 0; }
.attempt-row { display: flex; align-items: flex-start; gap: .65rem; padding: .55rem .4rem; border-radius: var(--radius-sm); color: var(--text); }
.attempt-row:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.attempt-row .pill { min-width: 5.6rem; justify-content: center; }
.attempt-main { min-width: 0; display: flex; flex-direction: column; }
.attempt-summary {
  font-size: .88rem; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.attempt-meta { font-size: .78rem; color: var(--text-2); }
.attempt-meta code { font-size: .95em; }

/* Markdown rendered on the server: assignments and primers. */
.prose { line-height: 1.65; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.05rem; margin: 1.4em 0 .5em; }
.prose h3 { font-size: .98rem; margin: 1.2em 0 .4em; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 .9em; }
.prose li { margin: .2em 0; }
.prose pre { margin: 0 0 1em; line-height: 1.5; }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 0 0 1em; font-size: .92rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: .35rem .7rem; text-align: left; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose blockquote { margin: 0 0 1em; padding: .2rem 1rem; border-left: 3px solid var(--border-2); color: var(--text-2); }

/* syntect's classes: scopes like `keyword.control` become `hl-keyword hl-control`. */
.hl-comment { color: var(--hl-comment); font-style: italic; }
.hl-keyword, .hl-storage, .hl-variable.hl-language { color: var(--hl-keyword); }
.hl-keyword.hl-operator { color: inherit; }
.hl-string { color: var(--hl-string); }
.hl-constant { color: var(--hl-number); }
.hl-entity.hl-name, .hl-support.hl-function { color: var(--hl-function); }
.hl-support.hl-type, .hl-entity.hl-name.hl-struct, .hl-entity.hl-name.hl-impl { color: var(--hl-type); }
.hl-support.hl-macro, .hl-meta.hl-annotation { color: var(--hl-macro); }
.hl-storage.hl-modifier.hl-lifetime { color: var(--hl-lifetime); }
.hl-punctuation { color: inherit; }

/* ---------- attempt page ---------- */
.attempt-head { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: .35rem; }
.attempt-head h1 { margin: 0; }
.attempt-facts { display: flex; flex-wrap: wrap; gap: .15rem 1rem; color: var(--text-2); font-size: .88rem; margin-bottom: .5rem; }
.attempt-summary-line { font-weight: 550; margin-bottom: 1.25rem; overflow-wrap: anywhere; }
.checks { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.check {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-2); border-radius: var(--radius);
  padding: .85rem 1.1rem; box-shadow: var(--shadow); min-width: 0;
}
.check-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .2rem .65rem; }
.check-head h2 { margin: 0; font-size: 1rem; }
.check-kind { font-weight: 500; font-size: .82rem; color: var(--text-3); margin-left: .25rem; }
.check-icon {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .78rem; font-weight: 800;
  background: var(--surface-2); color: var(--text-2);
}
.check-status { font-size: .8rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.check-summary { grid-column: 2 / -1; margin: 0; font-size: .88rem; color: var(--text-2); }
.check > :not(.check-head) { margin-top: .75rem; }
.check.st-passed { border-left-color: var(--ok); }
.check.st-passed .check-icon { background: var(--ok); color: var(--surface); }
.check.st-failed { border-left-color: var(--error); }
.check.st-failed .check-icon { background: var(--error); color: var(--surface); }
.check.st-error { border-left-color: var(--warn); }
.check.st-error .check-icon { background: var(--warn); color: var(--surface); }
.check.st-running { border-left-color: var(--brand); }
.check.st-running .check-icon { border: 2px solid var(--brand); border-right-color: transparent; background: none; animation: spin .8s linear infinite; }
.check.st-running .check-status { color: var(--brand); }
.check.st-pending, .check.st-skipped { box-shadow: none; background: transparent; }
.check.st-pending .check-head h2, .check.st-skipped .check-head h2 { color: var(--text-2); font-weight: 600; }
.check.st-pending .check-icon { background: none; border: 2px dashed var(--border-2); }
.check pre { margin-bottom: 0; font-size: .82rem; line-height: 1.5; }
.check pre + pre { margin-top: .6rem; }
.more > summary { cursor: pointer; color: var(--text-2); font-size: .88rem; font-weight: 550; }
.more[open] > summary { margin-bottom: .6rem; }

.cases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.cases.compact { gap: .2rem; }
.case-name { display: flex; align-items: center; flex-wrap: wrap; gap: .1rem .45rem; }
.case-name code { background: none; padding: 0; font-size: .86rem; overflow-wrap: anywhere; }
.case-name .tag { margin-left: 0; }
.mark { flex: none; font-weight: 800; width: 1rem; text-align: center; }
.case.passed .mark { color: var(--ok); }
.case.failed .mark { color: var(--error); }
.case-output { margin-top: .4rem; }
.io-label { margin-top: .5rem; font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.io-label + pre { margin-top: .25rem; }
.legend { text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: .5rem; }
.legend .del { color: var(--error); }
.legend .add { color: var(--ok); }
.diff code { display: inline-block; min-width: 100%; }
.diff span { display: block; padding: 0 .4rem; margin: 0 -.4rem; white-space: pre; }
.diff .del { background: var(--error-soft); }
.diff .add { background: var(--ok-soft); }

.budget { margin: .75rem 0 0; }
.budget-bar { display: block; overflow: visible; }
.budget-bar .b-track { fill: var(--surface-2); }
.budget-bar .b-measured { fill: var(--text-3); }
.st-passed .budget-bar .b-measured { fill: var(--ok); }
.st-failed .budget-bar .b-measured { fill: var(--error); }
.budget-bar .b-ref { stroke: var(--text-2); stroke-width: 2; }
.budget-bar .b-limit { stroke: var(--text); stroke-width: 2; stroke-dasharray: 4 3; }
.budget-nums { display: flex; flex-wrap: wrap; gap: .4rem 1.75rem; margin: .6rem 0 .2rem; }
.budget-nums dt { font-size: .78rem; color: var(--text-2); display: flex; align-items: center; gap: .4rem; }
.budget-nums dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.key { display: inline-block; width: 14px; height: 10px; border-radius: 3px; background: var(--text-3); }
.st-passed .key-measured { background: var(--ok); }
.st-failed .key-measured { background: var(--error); }
.key-ref { width: 2px; height: 12px; border-radius: 0; background: var(--text-2); }
.key-limit { width: 2px; height: 12px; border-radius: 0; background: repeating-linear-gradient(var(--text) 0 4px, transparent 4px 7px); }
.budget figcaption { font-size: .85rem; color: var(--text-2); }
.budget .facts { margin-top: .5rem; grid-template-columns: max-content max-content; font-variant-numeric: tabular-nums; }

.serial { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.serial .cases { margin-top: .35rem; }

/* ---------- login / error ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
  width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2.2rem 2rem;
  text-align: center; box-shadow: var(--shadow);
}
.login-card h1 { margin-top: .75rem; }
.login-card .lead { color: var(--text-2); margin-bottom: 1.5rem; }
.login-card .alert { text-align: left; }
.error-message { color: var(--text-2); word-break: break-word; }

/* ---------- phone ---------- */
@media (max-width: 640px) {
  .topbar { gap: .75rem; padding: 0 .75rem; }
  .brand span, .who-name { display: none; }
  .page { padding: 1.25rem .75rem 3rem; }
  .layer > .track { flex-basis: 100%; }
  .panel { padding: 1rem; }
  h1 { font-size: 1.35rem; }
  .ex-meta { font-size: .95rem; }
  .check { padding: .75rem .8rem; }
  .check-head { grid-template-columns: auto minmax(0, 1fr); }
  .check-status { grid-column: 2; }
  .serial { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .ex-layout { grid-template-columns: minmax(0, 1fr); }
  .ex-side { position: static; }
}
