/* ==========================================================================
   Kumu — AI Finance & Economics Tutor
   Design system: warm-paper light theme / deep-ocean dark theme,
   serif display + humanist sans body, teal + kukui-gold accents.
   ========================================================================== */

:root {
  --bg: #faf7f0;
  --bg-raised: #ffffff;
  --bg-sunken: #f1ecdf;
  --ink: #1d2733;
  --ink-soft: #4a5568;
  --ink-faint: #5d6a78;
  --line: #e3dccb;
  --accent: #0f766e;          /* deep teal */
  --accent-soft: #d6ece9;
  --accent-ink: #0b5a54;
  --gold: #b45309;            /* kukui gold-amber */
  --gold-soft: #fdecd2;
  --good: #15803d;
  --good-soft: #dcf1e3;
  --bad: #b91c1c;
  --bad-soft: #fbe4e4;
  --code-bg: #f1ecdf;
  --shadow: 0 1px 2px rgba(29, 39, 51, .06), 0 8px 24px rgba(29, 39, 51, .07);
  --radius: 12px;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0f1720;
  --bg-raised: #17222e;
  --bg-sunken: #0b111a;
  --ink: #e8e6df;
  --ink-soft: #b3bcc7;
  --ink-faint: #7b8794;
  --line: #263442;
  --accent: #2dd4bf;
  --accent-soft: #123f3b;
  --accent-ink: #7ee8dc;
  --gold: #f0b35f;
  --gold-soft: #3a2b12;
  --good: #4ade80;
  --good-soft: #12301d;
  --bad: #f87171;
  --bad-soft: #3a1414;
  --code-bg: #0b111a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  letter-spacing: -0.01em;
}
h1 { font-size: 2.4rem; margin: 0 0 .5rem; }
h2 { font-size: 1.6rem; margin: 2.6rem 0 .8rem; }
h3 { font-size: 1.2rem; margin: 1.8rem 0 .5rem; }

p { margin: .7rem 0; color: var(--ink-soft); }
strong { color: var(--ink); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .nr {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1em .35em;
  color: var(--accent-ink);
}
/* .nr marks short numeric refs (e.g. a formula's ± range) that must stay on one line;
   plain code spans hold arbitrary-length filenames/paths and must be allowed to wrap
   or they blow out the whole page width at narrow viewports. */
code { white-space: normal; overflow-wrap: break-word; }
.nr { white-space: nowrap; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
pre code { background: none; border: none; padding: 0; white-space: pre; }

/* ---------- layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 0 1.4rem; }
main.wrap { padding-top: 2.2rem; padding-bottom: 5rem; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .bar {
  max-width: 980px; margin: 0 auto; padding: .65rem 1.4rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.2rem;
}
.brand {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  color: var(--ink); display: flex; align-items: baseline; gap: .45rem;
}
.brand .lei { color: var(--accent); }
.brand small {
  font-family: var(--font-body); font-weight: 500; font-size: .68rem;
  color: var(--ink-faint); letter-spacing: .08em; text-transform: uppercase;
}
.site-nav { margin-left: auto; display: flex; align-items: center; gap: .2rem; }
.site-nav a {
  padding: .35rem .7rem; border-radius: 8px; font-size: .92rem;
  color: var(--ink-soft); font-weight: 500;
}
.site-nav a:hover { background: var(--bg-sunken); text-decoration: none; }
.site-nav a.active { color: var(--accent-ink); background: var(--accent-soft); }
.theme-btn {
  border: 1px solid var(--line); background: var(--bg-raised); color: var(--ink-soft);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem;
}

/* ---------- header: courses dropdown ---------- */
.nav-dd { position: relative; }
.nav-dd summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: .35rem .7rem; border-radius: 8px; font-size: .92rem;
  color: var(--ink-soft); font-weight: 500;
  display: flex; align-items: center; gap: .3rem;
}
.nav-dd summary::-webkit-details-marker { display: none; }
.nav-dd summary:hover, .nav-dd[open] summary { background: var(--bg-sunken); }
.nav-dd summary.active { color: var(--accent-ink); background: var(--accent-soft); }
.nav-dd .dd-caret { font-size: .68rem; opacity: .7; }
.nav-dd-panel {
  position: absolute; top: calc(100% + .5rem); right: 0; z-index: 50;
  min-width: 250px; padding: .4rem;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .15rem;
}
.nav-dd-panel a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: .5rem .7rem; border-radius: 8px; font-size: .92rem;
  color: var(--ink-soft); font-weight: 500;
}
.nav-dd-panel a small { color: var(--ink-faint); font-size: .72rem; letter-spacing: .04em; }
.nav-dd-panel a:hover { background: var(--bg-sunken); text-decoration: none; }
.nav-dd-panel a.active { color: var(--accent-ink); background: var(--accent-soft); }

/* ---------- header: contextual breadcrumb trail ----------
   Plain text rather than a pill: the trail is two or three links wide, and the bar is capped at
   980px, so the border and padding a pill needs are exactly the width that pushes the nav onto a
   second row. Keeping the header one row tall matters more on every page than the chrome does. */
.header-trail {
  /* flex-basis 0 is what keeps the header one row tall: the trail never contributes a minimum
     width, so it can never be the item that forces a wrap. It grows into whatever the brand and
     the nav leave behind, and truncates with an ellipsis when that is not enough. */
  flex: 1 1 0; min-width: 0;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ink-faint); font-size: .8rem; font-weight: 500;
}
.header-trail > * { margin-right: .3rem; }
.site-header.has-trail .brand small { display: none; }
.header-trail .arrow { color: var(--ink-faint); }
.header-trail a { color: var(--ink-soft); }
.header-trail a:hover { color: var(--accent-ink); text-decoration: none; }
/* --line would be right for a rule and wrong here: at ~1.3:1 against the header the separators
   vanish and the trail reads as three loose words instead of a path, which is the one thing it
   exists to communicate. --ink-faint keeps them subordinate without erasing them. */
.header-trail .trail-sep { color: var(--ink-faint); }
.header-trail .trail-parent { color: var(--ink); font-weight: 600; }

/* ---------- hero ---------- */
.hero { padding: 4.5rem 0 3rem; }
.hero .eyebrow {
  color: var(--gold); font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; font-size: .78rem;
}
.hero h1 { font-size: 3rem; max-width: 21ch; }
.hero h1 em { color: var(--accent-ink); font-style: italic; }
.hero .lede { font-size: 1.15rem; max-width: 58ch; }

.btn {
  display: inline-block; padding: .6rem 1.25rem; border-radius: 10px;
  font-weight: 600; font-size: .95rem; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); text-decoration: none; color: #fff; }
[data-theme="dark"] .btn-primary { color: #06251f; }
.btn-ghost { border-color: var(--line); color: var(--ink-soft); background: var(--bg-raised); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }

/* ---------- cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin: 1.4rem 0; }
.card {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.3rem 1.4rem; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card .tag {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 999px; padding: .15rem .6rem; margin-bottom: .5rem;
}

/* ---------- stage path ---------- */
.stage-path { display: flex; flex-direction: column; gap: .8rem; margin: 1.6rem 0; }
.stage-row {
  display: flex; align-items: center; gap: 1.1rem;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.3rem; box-shadow: var(--shadow); color: inherit;
}
a.stage-row:hover { border-color: var(--accent); text-decoration: none; }
.stage-num {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 700;
  background: var(--bg-sunken); color: var(--ink-soft); border: 2px solid var(--line);
}
.stage-row.done .stage-num { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.stage-info { flex: 1; min-width: 0; }
.stage-info h3 { margin: 0 0 .15rem; font-size: 1.08rem; }
.stage-info p { margin: 0; font-size: .9rem; color: var(--ink-faint); }
.stage-meta { flex: none; text-align: right; font-size: .82rem; color: var(--ink-faint); }
.stage-meta .weight { display: block; font-weight: 700; color: var(--gold); font-size: 1rem; }

.progress-band {
  display: flex; align-items: center; gap: 1rem; margin: 1.2rem 0 0;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1.3rem;
}
.progress-track { flex: 1; height: 9px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 999px; transition: width .5s ease; }
.progress-label { font-size: .85rem; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }

/* ---------- stage page chrome ---------- */
.stage-hero { padding: 2.4rem 0 .5rem; }
.stage-hero .crumbs { font-size: .85rem; color: var(--ink-faint); margin-bottom: .8rem; }
.stage-hero .crumbs a { color: var(--ink-faint); }
.pill-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.pill {
  font-size: .8rem; font-weight: 600; padding: .22rem .75rem; border-radius: 999px;
  background: var(--bg-sunken); color: var(--ink-soft); border: 1px solid var(--line);
}
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.pill.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
/* Inline-in-a-heading variant — retires the per-page style="font-size:.68rem" overrides. */
.pill.tiny { font-size: .68rem; }

.callout {
  border-left: 4px solid var(--accent); background: var(--bg-raised);
  border-radius: 0 var(--radius) var(--radius) 0; padding: .9rem 1.2rem; margin: 1.3rem 0;
  box-shadow: var(--shadow);
}
.callout.warn { border-left-color: var(--gold); }
.callout.danger { border-left-color: var(--bad); }
.callout p { margin: .3rem 0; }
.callout .callout-title { font-weight: 700; color: var(--ink); font-size: .95rem; }

.footnote { font-size: .85rem; color: var(--ink-faint); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; background: var(--bg-raised); }
th, td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); background: var(--bg-sunken); }
tr:last-child td { border-bottom: none; }
td .nr { white-space: nowrap; }

/* ---------- checklist ---------- */
.checklist { list-style: none; margin: 1rem 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.checklist li {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px;
  padding: .65rem .9rem; cursor: pointer; transition: border-color .15s;
}
.checklist li:hover { border-color: var(--accent); }
.checklist li input { margin-top: .3rem; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.checklist li.checked { background: var(--good-soft); border-color: transparent; }
.checklist li.checked span { text-decoration: line-through; color: var(--ink-faint); }

/* ---------- quiz ---------- */
.quiz { margin: 1.5rem 0; display: flex; flex-direction: column; gap: 1.1rem; }
.quiz-q {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; box-shadow: var(--shadow);
}
.quiz-q .qtext { font-weight: 600; color: var(--ink); margin: 0 0 .7rem; }
.quiz-q .opts { display: flex; flex-direction: column; gap: .45rem; }
.quiz-q button.opt {
  text-align: left; padding: .55rem .9rem; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft);
  font: inherit; font-size: .93rem; transition: border-color .12s;
}
.quiz-q button.opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-q button.opt.correct { background: var(--good-soft); border-color: var(--good); color: var(--ink); font-weight: 600; }
.quiz-q button.opt.wrong { background: var(--bad-soft); border-color: var(--bad); }
.quiz-q .expl {
  display: none; margin-top: .7rem; font-size: .9rem; color: var(--ink-soft);
  border-top: 1px dashed var(--line); padding-top: .6rem;
}
.quiz-q.answered .expl { display: block; }
.quiz-score { font-weight: 700; color: var(--accent-ink); }

/* ---------- ratio lab ---------- */
.lab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin: 1.4rem 0; }
@media (max-width: 840px) { .lab-grid { grid-template-columns: 1fr; } }
.lab-panel {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.4rem; box-shadow: var(--shadow);
}
.lab-panel h3 { margin-top: 0; }
.lab-field { display: grid; grid-template-columns: 1fr 110px 110px; gap: .5rem; align-items: center; margin: .3rem 0; }
.lab-field label { font-size: .85rem; color: var(--ink-soft); }
.lab-field label .nr {
  font-size: .72rem; display: inline-block; margin-top: .1rem;
  white-space: normal; overflow-wrap: break-word;
}
.lab-field input {
  width: 100%; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--ink); font-family: var(--font-mono); font-size: .85rem;
  text-align: right;
}
.lab-field input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.lab-field.two-col { grid-template-columns: 1fr 140px; }
.lab-cols { display: grid; grid-template-columns: 1fr 110px 110px; gap: .5rem; font-size: .72rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4rem; }
.lab-cols span:nth-child(n+2) { text-align: right; }

@media (max-width: 480px) {
  /* two fixed 110px input columns don't fit next to a label on narrow phones —
     restack the label onto its own row above the two (now-flexible) input columns */
  .lab-field { grid-template-columns: 1fr 1fr; row-gap: .2rem; }
  .lab-field label { grid-column: 1 / -1; }
  .lab-cols { grid-template-columns: 1fr 1fr; }
  .lab-cols span:first-child { display: none; }
}

.ratio-cat { margin: 1.4rem 0; }
.ratio-cat h3 { display: flex; align-items: center; gap: .6rem; }
.ratio-line {
  display: grid; grid-template-columns: 170px 1fr 110px; gap: .3rem .8rem; align-items: baseline;
  padding: .5rem .2rem; border-bottom: 1px dashed var(--line); font-size: .92rem;
}
.ratio-line:last-child { border-bottom: none; }
.ratio-line .rname { font-weight: 600; color: var(--ink); }
.ratio-line .rformula { font-size: .78rem; color: var(--ink-faint); font-family: var(--font-mono); overflow-wrap: break-word; white-space: normal; }
.ratio-line .rval { text-align: right; font-family: var(--font-mono); font-weight: 700; color: var(--accent-ink); white-space: nowrap; }
.ratio-line .rval.na { color: var(--ink-faint); font-weight: 400; }

@media (max-width: 900px) {
  .ratio-line { grid-template-columns: 1fr 110px; }
  .ratio-line .rformula { grid-column: 1 / -1; order: 3; }
}

.dupont-tree { display: flex; flex-wrap: wrap; align-items: stretch; gap: .6rem; margin: 1rem 0; }
.dupont-box {
  flex: 1; min-width: 150px; background: var(--bg-raised); border: 1.5px solid var(--accent);
  border-radius: 10px; padding: .7rem .9rem; text-align: center;
}
.dupont-box .dlabel { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.dupont-box .dval { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 700; color: var(--accent-ink); }
.dupont-box .dform { font-size: .7rem; color: var(--ink-faint); font-family: var(--font-mono); }
.dupont-op { align-self: center; font-size: 1.5rem; color: var(--gold); font-weight: 700; }

.balance-flag { font-size: .85rem; font-weight: 600; padding: .4rem .8rem; border-radius: 8px; margin: .6rem 0; display: inline-block; }
.balance-flag.ok { background: var(--good-soft); color: var(--good); }
.balance-flag.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- tutor chat ---------- */
.tutor-fab {
  position: fixed; right: 1.4rem; bottom: 1.4rem; z-index: 60;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 1.5rem; box-shadow: var(--shadow);
  display: grid; place-items: center; transition: transform .15s;
}
.tutor-fab:hover { transform: scale(1.07); }
[data-theme="dark"] .tutor-fab { color: #06251f; }

.tutor-panel {
  position: fixed; right: 1.4rem; bottom: 5.6rem; z-index: 60;
  width: min(400px, calc(100vw - 2rem)); height: min(580px, calc(100vh - 8rem));
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,.25);
  display: none; flex-direction: column; overflow: hidden;
}
.tutor-panel.open { display: flex; }
.tutor-head {
  padding: .8rem 1.1rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .6rem; background: var(--bg-sunken);
}
.tutor-head .t-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.tutor-head .t-sub { font-size: .72rem; color: var(--ink-faint); }
.tutor-head .spacer { flex: 1; }
.tutor-head button { background: none; border: none; cursor: pointer; color: var(--ink-faint); font-size: 1rem; padding: .3rem; }
.tutor-head button:hover { color: var(--ink); }

.tutor-msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.t-msg { max-width: 88%; padding: .6rem .9rem; border-radius: 14px; font-size: .92rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word; }
.t-msg.user { align-self: flex-end; background: var(--accent-soft); color: var(--ink); border-bottom-right-radius: 4px; }
.t-msg.kumu { align-self: flex-start; background: var(--bg-sunken); color: var(--ink-soft); border-bottom-left-radius: 4px; }
.t-msg.sys { align-self: center; background: var(--gold-soft); color: var(--gold); font-size: .82rem; text-align: center; }
.t-msg.kumu.thinking::after { content: "…"; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.tutor-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .6rem; }
.tutor-chips button {
  font-size: .76rem; padding: .3rem .7rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft);
}
.tutor-chips button:hover { border-color: var(--accent); color: var(--accent-ink); }

.tutor-input { display: flex; gap: .5rem; padding: .8rem; border-top: 1px solid var(--line); }
.tutor-input textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); padding: .55rem .8rem; font: inherit; font-size: .92rem;
  height: 44px; max-height: 120px;
}
.tutor-input textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.tutor-input button {
  border: none; background: var(--accent); color: #fff; border-radius: 10px;
  padding: 0 1rem; font-weight: 700; cursor: pointer;
}
[data-theme="dark"] .tutor-input button { color: #06251f; }
.tutor-input button:disabled { opacity: .5; cursor: default; }

.tutor-settings { padding: 1rem 1.1rem; border-top: 1px solid var(--line); background: var(--bg-sunken); display: none; }
.tutor-settings.open { display: block; }
.tutor-settings label { font-size: .8rem; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: .3rem; }
.tutor-settings input {
  width: 100%; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font-family: var(--font-mono); font-size: .8rem;
}
.tutor-settings .hint { font-size: .72rem; color: var(--ink-faint); margin: .4rem 0 0; }
.tutor-settings .row { display: flex; gap: .5rem; margin-top: .6rem; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 4rem; padding: 2rem 0 3rem;
  font-size: .85rem; color: var(--ink-faint);
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }

/* ---------- stage nav (prev/next) ---------- */
.stage-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; }
.stage-nav a {
  flex: 1; padding: .9rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raised); color: var(--ink-soft); font-size: .9rem;
}
.stage-nav a:hover { border-color: var(--accent); text-decoration: none; }
.stage-nav a .dir { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.stage-nav a.next { text-align: right; }
.stage-nav a strong { color: var(--ink); }

/* End nav — the forward action on pages that have no next stage to point at. */
.end-nav {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid var(--line);
}
.end-nav-hubs { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .88rem; }
.end-nav-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint);
}
.end-nav-hubs a {
  padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-raised); color: var(--ink-soft);
}
.end-nav-hubs a:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }

@media (max-width: 640px) {
  .hero h1 { font-size: 2.2rem; }
  .site-nav a { padding: .3rem .45rem; font-size: .82rem; }
  .brand small { display: none; }
  .stage-meta { display: none; }
}

/* The full trail needs horizontal room the nav also wants. Below ~900px only the immediate
   parent survives — that is the link a student on a narrow window actually reaches for, and the
   complete path is still on the page itself two lines down. */
@media (max-width: 900px) {
  .header-trail a:not(.trail-parent),
  .header-trail .trail-sep { display: none; }
}
/* Below ~640px the nav needs the whole bar, and a trail squeezed to "←…" is a mystery button
   rather than a shortcut. It goes away entirely; the page's own breadcrumb line is two lines
   down, and the brand still returns to the index. */
@media (max-width: 640px) {
  .header-trail { display: none; }
  .site-header.has-trail .brand small { display: none; }
}

/* ---------- onboarding: working-style preference picker ---------- */
.pref-q {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; box-shadow: var(--shadow);
  margin: 1rem 0;
}
.pref-q .qtext { font-weight: 600; color: var(--ink); margin: 0 0 .7rem; }
.pref-q .opts { display: flex; flex-direction: column; gap: .45rem; }
.pref-q button.pref {
  text-align: left; padding: .55rem .9rem; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft);
  font: inherit; font-size: .93rem; transition: border-color .12s;
}
.pref-q button.pref:hover { border-color: var(--accent); }
.pref-q button.pref.selected { background: var(--good-soft); border-color: var(--good); color: var(--ink); font-weight: 600; }
.pref-q .pref-note { display: none; margin-top: .7rem; font-size: .9rem; color: var(--ink-soft); border-top: 1px dashed var(--line); padding-top: .6rem; }
.pref-q.answered .pref-note { display: block; }
.pref-input { display: none; margin-top: .7rem; }
.pref-input.open { display: flex; gap: .5rem; }
.pref-input input {
  flex: 1; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--ink); font-family: var(--font-mono); font-size: .85rem;
}
.pref-saved { font-size: .82rem; color: var(--ink-faint); margin-top: .5rem; }

/* ---------- progression soft-lock (gates.js) ---------- */
/* Lock panel — pacing UX, not access control. Sits above the submission checklist. */
.gate-panel {
  background: var(--bg-sunken); border: 1px solid var(--line); border-left: 4px solid var(--gold);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 1rem 0; box-shadow: var(--shadow);
}
.gate-panel h3 { margin: 0 0 .4rem; font-size: 1.02rem; display: flex; align-items: center; gap: .5rem; }
.gate-panel .gate-lock { font-size: 1rem; }
.gate-panel .gate-sub { margin: 0 0 .7rem; font-size: .9rem; color: var(--ink-soft); }
.gate-diag {
  margin: .6rem 0; font-size: .9rem; color: var(--ink); background: var(--bg-raised);
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem;
}
.gate-diag.gate-diag-soft { background: transparent; border-style: dashed; }
.gate-diag code, .gate-panel code { word-break: break-word; }
.gate-actions, .gate-repo-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .7rem;
}
.gate-repo-input {
  flex: 1 1 220px; min-width: 0; padding: .5rem .7rem; border: 1px solid var(--line);
  border-radius: 7px; background: var(--bg); color: var(--ink);
  font-family: var(--font-mono); font-size: .82rem;
}
.gate-invalid { border-color: var(--bad); background: var(--bad-soft); }
.gate-panel .btn { flex: none; }
.gate-checked { font-size: .8rem; color: var(--ink-faint); }
.gate-checked.gate-err { color: var(--bad); }

/* inert-checklist note + disabled affordance */
.gate-note {
  margin: 0 0 .5rem; font-size: .88rem; color: var(--ink-soft);
  background: var(--gold-soft); border-radius: 8px; padding: .5rem .7rem;
}
.checklist.gate-locked li { opacity: .6; }
.checklist.gate-locked li:hover { border-color: var(--line); cursor: default; }
.checklist.gate-locked li input { cursor: not-allowed; }

/* hub verify bar + "Submitted on GitHub" badge */
.gate-verifybar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .7rem;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .9rem; margin: 0 0 1.4rem; box-shadow: var(--shadow);
}
.gate-verifybar-txt { flex: 1 1 240px; font-size: .86rem; color: var(--ink-soft); }
.gate-verifybar .btn { flex: none; }
.gate-badge {
  display: inline-block; margin-top: .4rem; font-size: .74rem; font-weight: 600;
  letter-spacing: .02em; color: var(--good); background: var(--good-soft);
  border-radius: 999px; padding: .12rem .55rem;
}

/* ---------- shared content modules (app.js) ---------- */
/* Stage strip — the stages of THIS engagement, current one marked. Replaced the cross-case arc
   strip on 2026-08-04: inside a case, the page answers questions about that case. Same visual
   language, per-case data. */
.stage-strip-block { margin: 1.2rem 0; }
.stage-strip-caption {
  margin: 0 0 .4rem; font-size: .74rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint);
}
.stage-strip {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: .35rem;
  margin: 0; font-size: .82rem;
}
.stage-strip-step {
  display: flex; align-items: center; gap: .5rem; flex: 1 1 auto; min-width: 0;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px;
  padding: .45rem .7rem; color: var(--ink-faint);
}
a.stage-strip-step:hover { border-color: var(--accent); text-decoration: none; color: var(--ink-soft); }
.stage-strip-step.current { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.stage-strip-n {
  flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: .7rem; font-weight: 700; background: var(--bg-sunken); color: var(--ink-faint);
  border: 1px solid var(--line);
}
.stage-strip-step.current .stage-strip-n { background: var(--accent); color: var(--bg-raised); border-color: transparent; }
.stage-strip-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.stage-strip-txt strong { font-size: .84rem; color: inherit; }
.stage-strip-txt small { font-size: .7rem; color: var(--ink-faint); }
/* No opacity here: an 80% blend of --accent-ink on --accent-soft lands at ~4.16:1, under the
   AA floor for this 11px text. Full-strength clears 7:1 in both themes. */
.stage-strip-step.current .stage-strip-txt small { color: var(--accent-ink); }
.stage-strip-step.pending { opacity: .62; }
.stage-strip-sep { display: flex; align-items: center; color: var(--ink-faint); font-size: .8rem; }
@media (max-width: 620px) {
  .stage-strip { flex-direction: column; }
  .stage-strip-sep { display: none; }
}

/* Client status memo — the one-line "what the consultant has delivered so far" opener. */
.client-memo {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem;
  background: var(--bg-sunken); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0; padding: .6rem .9rem; margin: 1.2rem 0; font-size: .89rem;
}
.client-memo .cm-label {
  flex: none; font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--gold);
}
.client-memo .cm-body { flex: 1 1 240px; color: var(--ink-soft); }

/* Submission-section feedback link. */
.module-feedback { margin: .8rem 0 0; font-size: .85rem; }
.module-feedback a { color: var(--ink-faint); }

/* Portfolio-repo standard module. */
.module-repo h4 { margin-top: 1.6rem; font-size: 1.02rem; }
.module-repo pre { font-size: .8rem; }

/* Resume-aware Start/Continue call to action (case intro pages). */
.resume-cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; margin: 1.4rem 0 .5rem;
}
.resume-cta .resume-sub { font-size: .85rem; color: var(--ink-faint); }

/* Build-walkthrough tabs (fx-hedging Stage 3 pilot): one tab per working surface,
   default tab marked aria-selected in the HTML so the choice reads without JS. */
.wt-tabs { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised); margin: 1.1rem 0; overflow: hidden; }
.wt-tablist { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--bg-sunken); }
.wt-tab {
  appearance: none; border: 0; background: none; font: inherit;
  padding: .6rem 1.05rem .55rem; font-size: .88rem; font-weight: 600; color: var(--ink-faint);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; text-align: left;
}
.wt-tab:hover { color: var(--ink); }
.wt-tab[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); background: var(--bg-raised); }
.wt-tab .wt-level { display: block; font-weight: 400; font-size: .68rem; color: var(--ink-faint); }
.wt-panel { padding: .3rem 1.1rem 1rem; }
.wt-panel[hidden] { display: none; }
.wt-panel ol > li { margin: .55rem 0; }
.wt-diagram { margin: .9rem 0 .2rem; }
.wt-diagram svg { width: 100%; height: auto; display: block; }
