/* Wrong Train workspace system -- wrongtrain-ui.css
 *
 * GENERATED from the Education Hub stylesheet (app/static/education.css) by
 * scripts in wrongtrain-ui/; edit the source, regenerate, then re-vendor. The core
 * (tokens, base, gate, controls, status, shell, cards, lists, overlays) is byte-for-byte
 * the Education Hub's, so every service that vendors this file paints the same design.
 *
 * Contract for a service:
 *   <link rel="stylesheet" href=".../fonts.css">      (fonts/ must sit beside it)
 *   <link rel="stylesheet" href=".../wrongtrain-ui.css">
 *   <link rel="stylesheet" href=".../<service>.css">  (service-specific rules, last)
 *
 * Shell markup: see reference/shell.html. Sign-in page: see reference/gate.html.
 * Rules: one accent (sand) for the next action only; status = sage/amber/clay tints;
 * sentence-case labels; two surfaces (page + panel); hairlines, not shadows.
 */

/* ============================================================== tokens ==== */

:root {
  --field: #0A0A0A;            /* the page */
  --rail: #0D0D0C;             /* the identity rail; the gate's intro panel tone */
  --surface: #111110;          /* panels and cards; the gate's work panel tone */
  --surface-raised: #171716;   /* inputs, hover, secondary surfaces */
  --surface-soft: #0D0D0C;     /* inset wells inside a panel */
  --sidebar: var(--rail);

  --ink: #F1EEE7; --ink-2: #A9A59C; --ink-3: #7A766F;
  --line: #27251F; --line-soft: #1C1B18;

  --accent: #D6CBB8; --accent-strong: #F0E7D8;
  --accent-soft: rgba(214, 203, 184, 0.10); --accent-ink: #0B0B0B;
  --btn-bg: var(--accent); --btn-bg-hover: var(--accent-strong); --btn-fg: var(--accent-ink);

  --ok: #8DBE9E;   --ok-soft: rgba(141, 190, 158, 0.14);
  --warn: #D9B36E; --warn-soft: rgba(217, 179, 110, 0.14);
  --bad: #E08A80;  --bad-soft: rgba(224, 138, 128, 0.14);
  --danger: var(--bad);

  --scrim: rgba(0, 0, 0, 0.72);
  --shadow-sm: none;
  --shadow-lg: 0 24px 72px rgba(0, 0, 0, 0.56);
  --radius-card: 14px; --radius-control: 8px;

  --font-ui: 'Schibsted Grotesk', system-ui, -apple-system, sans-serif;
  --font-read: 'Literata', Georgia, serif;
  --font-mono: 'Spline Sans Mono', ui-monospace, monospace;

  --rail-w: 236px;
  --gutter: clamp(20px, 3vw, 40px);
  --content-w: 1160px;

  /* density: one root knob keeps cards and rows in sync */
  --pad-card: 22px; --gap-card: 16px; --pad-row: 12px;

  color-scheme: dark;
}
:root[data-density="compact"] { --pad-card: 16px; --gap-card: 12px; --pad-row: 8px; }

/* Light is an explicit opt-out, NOT an OS preference: warm paper, same structure. */
:root[data-theme="light"] {
  --field: #EDE9E0; --rail: #E6E1D6; --surface: #F8F5EE; --surface-raised: #FFFCF5;
  --surface-soft: #EFEBE2;
  --ink: #171613; --ink-2: #625E57; --ink-3: #7A756D;
  --line: #D3CCC0; --line-soft: #E2DCD0;
  --accent: #292722; --accent-strong: #11100E; --accent-soft: rgba(41, 39, 34, 0.08);
  --accent-ink: #FFFFFF;
  --ok: #36795B;   --ok-soft: rgba(54, 121, 91, 0.12);
  --warn: #8F6224; --warn-soft: rgba(143, 98, 36, 0.12);
  --bad: #A64036;  --bad-soft: rgba(166, 64, 54, 0.12);
  --scrim: rgba(23, 22, 19, 0.42);
  --shadow-lg: 0 24px 72px rgba(23, 22, 19, 0.20);
  color-scheme: light;
}

/* ================================================================ base ==== */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh;
  background: var(--field); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }
.f-read { font-family: var(--font-read); }
.f-mono { font-family: var(--font-mono); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0 0 0.6em; }
p:last-child { margin-bottom: 0; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; padding: 0; }
button:disabled { cursor: default; opacity: 0.55; }
input, textarea, select { font: inherit; color: var(--ink); }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code { font-family: var(--font-mono); font-size: 0.9em; }
kbd, .palette-kbd {
  font-family: var(--font-mono); font-size: 11px; line-height: 1;
  border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px;
  color: var(--ink-3); background: var(--field);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Small labels: sentence case, never tracked. */
.eyebrow { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }

/* The honesty layer. Unknown is NEVER drawn as zero: it is an em dash with a reason. */
.unknown-val, .stale-val { font-family: var(--font-mono); border-bottom: 1px dotted var(--ink-3); cursor: help; }
.unknown-val { color: var(--ink-3); }
.partial-val { border-bottom: 1px dotted var(--ink-3); cursor: help; }
.partial-mark { color: var(--ink-3); font-size: 0.85em; vertical-align: super; }

/* ================================================================ gate ==== */
/* Kept as shipped. This composition is the reference the whole system is drawn from. */

.gate-wrap { min-height: 100vh; display: grid; place-items: center; padding: clamp(18px, 4vw, 64px); }
.gate-card {
  width: 100%; max-width: 1040px; min-height: min(650px, calc(100vh - 72px));
  display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  overflow: hidden; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.gate-intro {
  position: relative; overflow: hidden; display: flex; flex-direction: column;
  justify-content: space-between; padding: clamp(36px, 6vw, 72px);
  background: var(--surface-soft); border-right: 1px solid var(--line);
}
.gate-badge, .app-mark-badge {
  width: 42px; height: 42px; display: inline-grid; place-items: center;
  border-radius: 3px; background: transparent; color: var(--accent);
  border: 1px solid var(--line); font-family: var(--font-mono);
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.gate-kicker { margin: 34px 0 14px; }
.gate-mark {
  max-width: 10ch; margin: 0; font-size: clamp(42px, 5.4vw, 68px);
  font-weight: 600; line-height: 1.02; letter-spacing: -0.04em;
}
.gate-intro-copy { max-width: 40ch; margin: 22px 0 0; color: var(--ink-2); font-size: 16px; }
.gate-index { margin: 44px 0 0; color: var(--ink-3); font-size: 10px; letter-spacing: 0.14em; }
.gate-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 5vw, 64px); }
.gate-panel-head { margin-bottom: 30px; }
.gate-panel-head h2 { margin: 6px 0 5px; font-size: 31px; font-weight: 600; letter-spacing: -0.025em; }
.gate-sub { color: var(--ink-2); margin: 0; font-size: 14px; }
.gate-field { margin-bottom: 16px; }
.gate-field label { display: block; font-size: 12px; font-weight: 650; color: var(--ink-2); margin-bottom: 7px; }
.gate-error {
  background: var(--bad-soft); border: 1px solid rgba(224, 138, 128, 0.45);
  border-radius: var(--radius-control); padding: 11px 13px; margin-bottom: 20px;
  font-size: 13px; color: var(--ink);
}
.gate-submit { width: 100%; margin-top: 10px; }
.gate-foot {
  margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line-soft);
  font-size: 11px; color: var(--ink-3); display: flex; justify-content: space-between; gap: 12px;
}
.field-optional { color: var(--ink-3); font-size: 11px; font-weight: 500; }

/* ============================================================ controls ==== */

.btn-primary, .btn-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-control);
  font-weight: 600; font-size: 14.5px; line-height: 1.2; text-decoration: none;
  white-space: nowrap; transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); border: 1px solid transparent; }
.btn-primary:hover { background: var(--btn-bg-hover); color: var(--btn-fg); }
.btn-quiet { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn-quiet:hover { color: var(--ink); border-color: var(--ink-3); background: var(--surface-raised); }
.btn-quiet[aria-pressed="true"], .btn-quiet.is-on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn-small { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn-hero { min-height: 48px; padding: 12px 26px; font-size: 16px; }
.btn-primary kbd, .btn-quiet kbd { background: transparent; border-color: currentColor; opacity: 0.55; }
.linklike, .link-quiet { color: var(--ink-2); border-bottom: 1px dotted var(--ink-3); font-size: inherit; }
.linklike:hover, .link-quiet:hover { color: var(--ink); }

.field-input {
  width: 100%; min-height: 44px; padding: 10px 13px;
  background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-control);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field-input::placeholder { color: var(--ink-3); }
.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
select.field-input { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea.field-input { min-height: 96px; resize: vertical; line-height: 1.5; }
.field-hint { font-size: 12.5px; color: var(--ink-3); margin: 5px 0 0; }
.field-error { font-size: 12.5px; color: var(--bad); margin: 5px 0 0; }
.field-label { display: block; font-size: 12px; font-weight: 650; color: var(--ink-2); margin-bottom: 7px; }
.field-color { width: 64px; height: 38px; padding: 3px; cursor: pointer; }
.check, .row-check, .toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-control); overflow: hidden; }
.seg { min-height: 34px; padding: 5px 13px; font-size: 13px; font-weight: 500; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg:last-child { border-right: none; }
.seg:hover { color: var(--ink); }
.seg-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.toggle-row { margin-bottom: 16px; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-label { font-weight: 500; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.chip {
  min-height: 34px; display: inline-flex; align-items: center; padding: 5px 13px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent;
  font-weight: 500; font-size: 13.5px; color: var(--ink-2); transition: border-color 120ms ease, color 120ms ease;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-known { border-color: var(--accent); color: var(--accent); }
.chip-unknown, .chip-overruns { border-style: dashed; color: var(--ink-3); }
.chip-input { width: 90px; }

.rating { display: flex; gap: 8px; margin-bottom: 8px; }
.rating-dot {
  width: 40px; height: 40px; border-radius: var(--radius-control); border: 1px solid var(--line);
  background: transparent; font-weight: 600; color: var(--ink-2);
}
.rating-dot:hover { border-color: var(--ink-3); color: var(--ink); }
.rating-on { background: var(--accent); border-color: var(--accent); color: var(--btn-fg); }

/* ============================================================== status ==== */

.pill {
  display: inline-flex; align-items: center; min-height: 22px; padding: 1px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.3;
  letter-spacing: 0; text-transform: none; white-space: nowrap;
  color: var(--ink-2); background: var(--surface-raised); border: 1px solid transparent;
}
.pill-planned, .pill-active { color: var(--accent); background: var(--accent-soft); }
.pill-in_progress { color: var(--accent); background: var(--accent-soft); border-color: rgba(214, 203, 184, 0.35); }
.pill-completed, .pill-graded, .pill-submitted, .pill-indexed, .pill-comfortable, .pill-strong { color: var(--ok); background: var(--ok-soft); }
.pill-missed { color: var(--warn); background: var(--warn-soft); }
.pill-failed, .pill-weak { color: var(--bad); background: var(--bad-soft); }
.pill-deferred, .pill-dropped, .pill-archived, .pill-processing, .pill-uploaded, .pill-developing { color: var(--ink-3); background: var(--surface-raised); }

.course-tag {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 5px; white-space: nowrap;
}
/* Runway is a fact about the calendar, not a verdict on the task: a dot carries the
   state and the word stays quiet, so forty of them in a list do not read as forty alarms. */
.runway-chip {
  display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; padding: 0 8px 0 7px; min-height: 20px;
  font-size: 11px; color: var(--ink-3); border: 1px solid var(--line-soft); border-radius: 999px; vertical-align: middle;
}
.runway-chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); }
.runway-comfortable::before { background: var(--ok); }
.runway-tight::before { background: var(--warn); }
.runway-short::before, .runway-no_room::before { background: var(--bad); }

.doctor-state { font-weight: 600; font-size: 12.5px; }
.doctor-healthy { color: var(--ok); }
.doctor-degraded { color: var(--warn); }
.doctor-unknown { color: var(--ink-3); }

.save-state { font-size: 12.5px; color: var(--ink-3); margin: 0; }
.save-saving, .save-unsaved { color: var(--ink-2); }
.save-saved { color: var(--ok); }
.save-conflict, .save-error { color: var(--bad); font-weight: 600; }

/* =============================================================== shell ==== */

.skip-link {
  position: fixed; top: 10px; left: 50%; z-index: 100; transform: translate(-50%, -160%);
  padding: 10px 16px; border-radius: var(--radius-control); background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 700; text-decoration: none; transition: transform 140ms ease;
}
.skip-link:focus { transform: translate(-50%, 0); }

/* Chromeless shells (focus, launch, one thing, resume, body double). */
.shell { max-width: 1320px; margin: 0 auto; padding: 28px 28px 72px; }
.shell-focus { max-width: 640px; padding-top: 8vh; }

/* The open book: rail on the left, page on the right. */
.shell-app {
  max-width: none; min-height: 100vh; display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr); gap: 0; padding: 0;
}
.app-sidebar { min-width: 0; background: var(--rail); border-right: 1px solid var(--line-soft); }
.app-sidebar-inner {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin;
  display: flex; flex-direction: column; padding: 20px 14px 18px;
}
.app-mark { display: flex; align-items: center; gap: 12px; padding: 4px 6px 22px; color: var(--ink); text-decoration: none; }
.app-mark .app-mark-badge { width: 36px; height: 36px; flex: 0 0 36px; }
.app-mark-copy { display: grid; line-height: 1.15; min-width: 0; }
.app-mark-copy strong { font-size: 14.5px; letter-spacing: -0.01em; }
.app-mark-copy span { margin-top: 3px; color: var(--ink-3); font-size: 12px; }

.sidebar-start {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 18px; padding: 12px 14px; min-height: 56px;
  color: var(--accent-ink); text-decoration: none; background: var(--accent);
  border-radius: var(--radius-control); transition: background 120ms ease;
}
.sidebar-start:hover { color: var(--accent-ink); background: var(--accent-strong); }
.sidebar-start > span:first-child { min-width: 0; display: grid; line-height: 1.2; }
.sidebar-start strong { font-size: 14px; font-weight: 700; }
.sidebar-start small { margin-top: 3px; font-size: 12px; opacity: 0.7; }
.sidebar-start-arrow { display: none; }
.start-label-short { display: none; }
.sidebar-start-mobile { display: none; }

.primary-nav { display: grid; gap: 2px; }
.navlink {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px;
  color: var(--ink-2); font-weight: 600; font-size: 14.5px; text-decoration: none;
  border-radius: var(--radius-control); transition: color 120ms ease, background 120ms ease;
}
.navlink:hover { color: var(--ink); background: var(--surface-raised); }
.navlink[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.nav-index { display: none; }
.nav-copy { min-width: 0; display: grid; line-height: 1.2; }
.nav-copy strong { font-weight: inherit; }
.nav-copy > span { display: none; }

/* Only the active group's destinations are shown, nested under it in the rail. */
.nav-children { display: grid; gap: 1px; margin: 2px 0 8px 14px; padding-left: 12px; border-left: 1px solid var(--line); }
.nav-child {
  display: flex; align-items: center; min-height: 32px; padding: 5px 10px;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500; text-decoration: none;
  border-radius: 6px; transition: color 120ms ease, background 120ms ease;
}
.nav-child:hover { color: var(--ink); background: var(--surface-raised); }
.nav-child[aria-current="page"] { color: var(--accent); font-weight: 600; }

.sidebar-utility { margin-top: 20px; padding: 16px 0 0; border-top: 1px solid var(--line-soft); }
.sidebar-utility .eyebrow { display: none; }
.utility-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 36px; padding: 6px 12px; color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  text-decoration: none; border-radius: var(--radius-control); transition: color 120ms ease, background 120ms ease;
}
.utility-link:hover { color: var(--ink); background: var(--surface-raised); }
.utility-link[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.sidebar-foot { margin-top: auto; padding: 18px 6px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-note { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink-3); font-size: 12px; }
.sidebar-note > span { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sidebar-index { margin: 0; color: var(--ink-3); font-size: 10px; letter-spacing: 0.14em; }

.app-workspace { min-width: 0; display: flex; flex-direction: column; }
.app-nav {
  position: sticky; top: 0; z-index: 30; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--field) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.app-nav-row { max-width: var(--content-w); margin: 0 auto; min-height: 58px; display: flex; align-items: center; gap: 14px; }
.mobile-mark { display: none; color: inherit; text-decoration: none; }
.mobile-mark .app-mark-badge { width: 32px; height: 32px; }
.toolbar-context { display: grid; line-height: 1.15; min-width: 0; }
.toolbar-context .eyebrow { display: none; }
.toolbar-context strong { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-nav-end { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.app-nav-end form { margin: 0; }
.app-nav-end .btn-small { min-height: 34px; }
.app-user {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 8px 0 2px; margin-left: 4px;
  color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: none; border-radius: 999px;
  transition: color 120ms ease, background 120ms ease;
}
.app-user:hover { color: var(--ink); background: var(--surface-raised); }
.user-avatar {
  width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
.user-settings-label { display: none; }
.toolbar-logout .btn-small { color: var(--ink-3); border-color: transparent; }
.toolbar-logout .btn-small:hover { color: var(--ink); border-color: var(--line); }

/* The section strip only exists on small screens; on desktop the rail nests it. */
.subnav { display: none; }
.subnav-link {
  flex: 0 0 auto; min-height: 34px; display: inline-flex; align-items: center; padding: 5px 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-decoration: none;
  border: 1px solid transparent;
}
.subnav-link[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.app-main { width: 100%; max-width: var(--content-w); margin: 0 auto; min-width: 0; padding: clamp(26px, 3.4vw, 44px) var(--gutter) 88px; }
.app-main:focus { outline: none; }

/* Page header: one title, its context above, its actions beside. */
.shell-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.shell-top > div:first-child { min-width: 0; }
.shell-top .eyebrow { margin: 0 0 8px; color: var(--ink-3); }
.shell-greet { margin: 0; font-size: clamp(28px, 3vw, 36px); font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; }
.shell-greet a { color: var(--ink-3); text-decoration: none; }
.shell-greet a:hover { color: var(--ink); }
.page-sub, .today-headline { margin: 10px 0 0; color: var(--ink-2); font-size: 15.5px; line-height: 1.55; max-width: 62ch; }
.workspace-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.workspace-actions kbd { margin-left: 2px; }

/* ================================================================ cards ==== */

.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: var(--pad-card); margin-bottom: var(--gap-card);
  box-shadow: var(--shadow-sm);
}
.card > h2, .card > .section-head h2, .card > .section-head .eyebrow { font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: 0; }
.card > h2 { margin: 0 0 12px; }
.card > .eyebrow:first-child { margin: 0 0 8px; }
.card h3 { font-size: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head > .eyebrow { font-size: 14px; font-weight: 600; color: var(--ink); }
.pending { color: var(--ink-2); font-size: 14.5px; margin: 0; line-height: 1.55; }
.pending code { font-size: 12.5px; }
.empty-line { min-height: 56px; padding: 8px 0; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.empty-line p { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--gap-card); }
.stack { display: grid; gap: var(--gap-card); }


/* Disclosures: secondary information stays reachable without competing. A run of them
   reads as one grouped list rather than a stack of boxes. */
.quiet-disclosure { border: 1px solid var(--line); border-radius: var(--radius-card); margin-bottom: var(--gap-card); background: var(--surface); }
.quiet-disclosure:has(+ .quiet-disclosure) { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.quiet-disclosure + .quiet-disclosure { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.quiet-disclosure > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; min-height: 52px; font-weight: 600; font-size: 15px;
}
.quiet-disclosure > summary::-webkit-details-marker { display: none; }
.quiet-disclosure > summary::before {
  content: ""; width: 7px; height: 7px; flex: none; border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(-45deg); transition: transform 120ms ease; margin-left: 2px;
}
.quiet-disclosure[open] > summary::before { transform: rotate(45deg); }
.quiet-disclosure > summary:hover { color: var(--accent); }
.quiet-disclosure > summary > span { margin-left: auto; color: var(--ink-3); font-size: 13px; font-weight: 400; text-align: right; }
.quiet-disclosure[open] > summary { border-bottom: 1px solid var(--line-soft); }
.quiet-disclosure[open] { padding-bottom: 6px; }
.quiet-disclosure > :not(summary) { margin-left: 18px; margin-right: 18px; }
.quiet-disclosure > .card, .quiet-disclosure > .runway-panel, .quiet-disclosure > .resumecard { margin-top: 14px; }
.quiet-disclosure > .card:last-child { margin-bottom: 12px; }
.quiet-disclosure > .card { background: var(--surface-soft); }
.coverage-disclosure, .coverage-disclosure:has(+ .quiet-disclosure) { width: fit-content; background: transparent; border: 0; border-radius: 0; margin: 0 0 14px; }
.coverage-disclosure > summary { padding: 4px 0; min-height: 30px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.coverage-disclosure[open] { padding: 0; }
.coverage-disclosure[open] > summary { border: 0; margin-bottom: 6px; }
.coverage-disclosure > :not(summary) { margin-left: 0; margin-right: 0; }
.coverage-note {
  width: fit-content; max-width: 72ch; margin: 0 0 12px; padding: 9px 12px;
  font-size: 13px; color: var(--ink-2); background: var(--surface-soft); border: 1px solid var(--line-soft); border-radius: 9px;
}

/* ================================================================ lists ==== */

.row-list { list-style: none; margin: 0; padding: 0; }
.row-list li { border-top: 1px solid var(--line-soft); }
.row-list li:first-child { border-top: none; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  min-height: 50px; padding: var(--pad-row) 6px; margin: 0 -6px; border-radius: 9px;
  text-decoration: none; color: inherit; transition: background 120ms ease;
}
a.row:hover, .row-link:hover { background: var(--surface-raised); }
a.row:hover .row-title, .row-link:hover .row-title { color: var(--accent); }
.row-title { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-meta { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; line-height: 1.45; }
.row-active .row-title { color: var(--accent); }
.row-note { font-size: 12.5px; color: var(--ink-3); margin: 0 0 8px; }
.row-selectable { display: flex; align-items: center; gap: 12px; width: 100%; flex-wrap: nowrap; }
.row-link { display: flex; flex: 1; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 4px 6px; margin: -4px 0; border-radius: 8px; text-decoration: none; color: inherit; }
.row-selected { background: var(--accent-soft); border-radius: 9px; }
.row-actions { display: flex; gap: 6px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 14.5px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; }

.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.check-list label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; }
.done { text-decoration: line-through; color: var(--ink-3); }

.tabs { display: flex; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { min-height: 38px; padding: 8px 2px; margin-bottom: -1px; font-weight: 500; font-size: 14.5px; color: var(--ink-2); border-bottom: 2px solid transparent; transition: color 120ms ease; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.status-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.inline-form .field-input { width: auto; flex: 1 1 140px; }
.edit-toggle { margin-top: 6px; }
.edit-panel { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 16px; }

/* ===================================================== overlays and feedback ==== */

.scrim, .palette-scrim, .capture-scrim {
  position: fixed; inset: 0; z-index: 50; padding: 20px;
  background: var(--scrim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: clamp(22px, 4vw, 30px); box-shadow: var(--shadow-lg);
}
.modal .section-head { margin-bottom: 16px; }
.modal .section-head .eyebrow { font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bad-soft); border: 1px solid rgba(224, 138, 128, 0.4); border-radius: 10px;
  padding: 11px 14px; margin-bottom: 16px; font-size: 14px;
}
.banner-ref { font-size: 11px; color: var(--ink-3); }
.banner-x { font-size: 20px; line-height: 1; color: var(--ink-3); margin-left: auto; }
.banner-x:hover { color: var(--ink); }

.toast-stack { position: fixed; left: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column-reverse; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-size: 14px;
  background: var(--surface-raised); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; box-shadow: var(--shadow-lg);
}
.toast-error { border-left-color: var(--bad); }
.toast-text { flex: 1; min-width: 0; }
.toast-ref { font-size: 11px; color: var(--ink-3); }

.palette-scrim { align-items: start; padding-top: 12vh; }
.palette { width: 100%; max-width: 580px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-lg); }
.palette-input { width: 100%; border: none; border-bottom: 1px solid var(--line-soft); padding: 16px 18px; font-size: 16px; background: none; }
.palette-results { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
.palette-row { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; }
.palette-on { background: var(--accent-soft); }
.palette-label { display: block; font-weight: 500; }
.palette-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.palette-snippet { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-empty { padding: 18px; color: var(--ink-3); font-size: 14px; text-align: center; }
.palette-foot { margin: 0; padding: 9px 14px; border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--ink-3); }
.palette-trigger { gap: 8px; }

.shortcut-groups { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.shortcut-list { margin: 8px 0 0; }
.shortcut-row { display: flex; align-items: baseline; gap: 12px; padding: 5px 0; }
.shortcut-row dt { display: flex; gap: 4px; min-width: 76px; }
.shortcut-row dd { margin: 0; font-size: 14px; color: var(--ink-2); }

.capture-scrim { align-items: start; padding-top: 18vh; z-index: 60; }
.capture-box { width: min(560px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 18px; box-shadow: var(--shadow-lg); }
.capture-hint { margin: 0 0 8px; font-size: 12.5px; color: var(--ink-2); }
.capture-input { font-size: 16px; padding: 12px 14px; }
.capture-foot { margin: 10px 0 0; font-size: 11.5px; color: var(--ink-3); }
.capture-error { margin: 10px 0 0; font-size: 12.5px; color: var(--bad); }


/* ================================================ system additions ==== */
/* Primitives the dashboards need that the study app does not. Same tokens, same rules. */

/* Page header: `.page-head` is `.shell-top` under a name that reads naturally in a
   server-rendered template. Both work. */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head > div:first-child { min-width: 0; }
.page-head .eyebrow, .crumbs { margin: 0 0 8px; color: var(--ink-3); font-size: 12.5px; font-weight: 600; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs span { margin: 0 6px; color: var(--line); }
.page-title { margin: 0; font-size: clamp(28px, 3vw, 36px); font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; }
.page-sub { margin: 10px 0 0; color: var(--ink-2); font-size: 15.5px; line-height: 1.55; max-width: 62ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Section title inside a page (between cards). */
.section-title { margin: 28px 0 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.section-title:first-child { margin-top: 0; }

/* Stat tiles: a figure with its label. The figure is the content; no decoration. */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap-card); margin-bottom: var(--gap-card); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px 18px; min-width: 0; }
.stat-label { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.stat-value { margin: 4px 0 0; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-note { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-3); }
.stat-ok .stat-value { color: var(--ok); }
.stat-warn .stat-value { color: var(--warn); }
.stat-bad .stat-value { color: var(--bad); }

/* Tables: hairline rows, quiet header, numbers in mono. Wrap in `.table-wrap` so a
   wide table scrolls inside itself instead of the page. */
.table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--line-soft); }
.table thead th { border-top: 0; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-raised); }
.table .num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .mono, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.table a { color: var(--ink); text-decoration: none; }
.table a:hover { color: var(--accent); }
.card > .table-wrap { margin: 0 calc(var(--pad-card) * -1); width: auto; }
.card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: var(--pad-card); }
.card > .table-wrap .table th:last-child, .card > .table-wrap .table td:last-child { padding-right: var(--pad-card); }

/* Key / value pairs (details, metadata). */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 14.5px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Notices: information, never alarm, unless the state really is one. */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: var(--gap-card); font-size: 14px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 10px; }
.notice-ok { border-left-color: var(--ok); }
.notice-warn { border-left-color: var(--warn); }
.notice-bad { border-left-color: var(--bad); }
.notice-accent { border-left-color: var(--accent); }
.notice strong { color: var(--ink); }

/* Status dot + word, for rows where a pill is too heavy. */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); margin-right: 7px; vertical-align: middle; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-bad { background: var(--bad); }
.dot-accent { background: var(--accent); }
.pill-ok { color: var(--ok); background: var(--ok-soft); }
.pill-warn { color: var(--warn); background: var(--warn-soft); }
.pill-bad { color: var(--bad); background: var(--bad-soft); }
.pill-accent { color: var(--accent); background: var(--accent-soft); }

/* Progress bars: one track, one fill, no gradient. */
.bar { height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-ok > span { background: var(--ok); }
.bar-warn > span { background: var(--warn); }
.bar-bad > span { background: var(--bad); }

/* Code and logs. */
.code-block { margin: 0; padding: 14px 16px; background: var(--field); border: 1px solid var(--line-soft); border-radius: 10px; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; overflow-x: auto; color: var(--ink-2); white-space: pre; }
.code-block strong { color: var(--ink); font-weight: 500; }

/* Empty states direct, they do not decorate. */
.empty { padding: 28px 20px; text-align: center; color: var(--ink-2); font-size: 14.5px; border: 1px dashed var(--line); border-radius: var(--radius-card); }
.empty p { margin: 0 0 12px; }

/* Prose (reports, docs): the reading face, comfortable measure. */
.prose { max-width: 68ch; font-size: 16px; line-height: 1.65; }
.prose h2 { margin: 28px 0 10px; font-size: 20px; letter-spacing: -0.02em; }
.prose h3 { margin: 22px 0 8px; font-size: 16px; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose li { margin: 4px 0; }
.prose code { background: var(--surface-raised); padding: 1px 5px; border-radius: 4px; }
.prose-read { font-family: var(--font-read); }

/* Simple button group and split layouts. */
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: 1fr; gap: var(--gap-card); }
.split > * { min-width: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* Forms outside the gate: same field, same label. */
.field { margin-bottom: 16px; }
.field label, .field > .field-label { display: block; font-size: 12px; font-weight: 650; color: var(--ink-2); margin-bottom: 7px; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 12px 16px; }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* Rail nav without a "group" structure: a flat list with optional section labels. */
.rail-section { margin: 14px 0 4px; padding: 0 12px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.primary-nav + .rail-section { margin-top: 18px; }

/* ========================================================== responsive ==== */

@media (min-width: 720px) { .split-2 { grid-template-columns: 1fr 1fr; } .field-row { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } .split-3 { grid-template-columns: 1fr 1fr 1fr; } }

@media (max-width: 1120px) and (min-width: 901px) {
  :root { --rail-w: 212px; }
  .app-sidebar-inner { padding-inline: 10px; }
  .app-user .user-name { display: none; }
}

/* Phones and narrow tablets: the rail becomes a bottom bar, the toolbar carries the
   mark, and the section strip appears under it. Up to five `.navlink`s fit; mark any
   beyond that `.navlink-more` so they drop into the section strip instead. */
@media (max-width: 900px) {
  .shell-app { display: block; min-height: 100vh; padding: 0 0 calc(76px + env(safe-area-inset-bottom)); }
  .app-sidebar { min-height: 0; background: transparent; border: 0; }
  .app-sidebar-inner {
    position: fixed; inset: auto 0 0; z-index: 40; height: auto; min-height: 0; overflow: visible;
    display: block; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--rail) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 0; border-top: 1px solid var(--line);
  }
  .app-mark, .sidebar-utility, .sidebar-foot, .nav-children, .rail-section, .sidebar-start-desktop { display: none; }
  .primary-nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
  .navlink { min-height: 55px; display: flex; align-items: center; justify-content: center; padding: 8px 4px; text-align: center; border-radius: 10px; font-size: 12px; }
  .navlink[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .navlink.navlink-more { display: none; }
  .nav-copy { display: block; }
  .nav-copy > span { display: none; }
  .sidebar-start-mobile { display: flex; position: static; width: auto; max-width: none; min-height: 55px; margin: 0; padding: 8px 4px; align-items: center; justify-content: center; text-align: center; border-radius: 10px; }
  .sidebar-start-mobile strong { font-size: 12px; }
  .start-label-short { display: inline; }

  .app-workspace { padding: 0; }
  .app-nav { padding-inline: 14px; }
  .app-nav-row { min-height: 54px; gap: 10px; }
  .mobile-mark { display: inline-flex; }
  .toolbar-context strong { font-size: 14px; }
  .app-nav-end { gap: 4px; }
  .app-user { padding: 0 2px; margin-left: 0; }
  .user-name { display: none; }
  .subnav { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; margin: 0 -14px; padding: 6px 14px 10px; }
  .subnav::-webkit-scrollbar { display: none; }
  .app-main { padding: 22px 14px 40px; }
  .toast-stack { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

@media (max-width: 760px) {
  .gate-wrap { padding: 12px; }
  .gate-card { min-height: 0; grid-template-columns: 1fr; border-radius: 12px; }
  .gate-intro { min-height: 230px; padding: 26px 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .gate-kicker { margin: 22px 0 10px; }
  .gate-mark { max-width: 11ch; font-size: clamp(38px, 12vw, 54px); }
  .gate-intro-copy { margin-top: 14px; }
  .gate-index { display: none; }
  .gate-panel { padding: 22px 24px 24px; }
  .gate-panel-head { margin-bottom: 20px; }
  .gate-field { margin-bottom: 12px; }
  .gate-submit { margin-top: 6px; }
  .gate-foot { margin-top: 18px; padding-top: 14px; }

  .shell { padding: 20px 16px 60px; }
  .shell-top, .page-head { margin-bottom: 22px; gap: 14px; }
  .shell-greet, .page-title { font-size: clamp(26px, 8vw, 34px); }
  .card { border-radius: 12px; }
  .workspace-actions, .page-actions { width: 100%; }
  .workspace-actions .btn-primary, .workspace-actions .btn-quiet, .page-actions .btn-primary, .page-actions .btn-quiet { flex: 1 1 140px; }
  .app-nav-end kbd, .workspace-actions kbd { display: none; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions > * { flex: 1 1 120px; }
  .quiet-disclosure > summary { padding: 13px 14px; }
  .quiet-disclosure > :not(summary) { margin-left: 12px; margin-right: 12px; }
  .tabs { gap: 14px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 470px) {
  .app-nav-row { gap: 6px; }
  .app-nav-end { min-width: 0; }
  .app-nav-end .btn-small { padding-inline: 8px; font-size: 12px; }
  .toolbar-context { display: none; }
  .modal { align-self: end; max-width: none; max-height: min(86vh, 760px); margin: 0 -8px -8px; border-radius: 12px 12px 0 0; }
  .scrim { align-items: end; padding: 8px; }
}

@media (max-width: 700px) { .palette-trigger kbd { display: none; } }

/* Reduced motion: the OS setting and the in-app one are both honoured, and either alone
   is enough. Someone who asked for stillness should not have to ask twice. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
:root[data-motion="reduced"] * { transition: none !important; animation: none !important; }
