/* RAG Lab — styles. GCSU Evergreen palette as CSS variables; system fonts only. */

:root {
  color-scheme: light;

  /* Palette. Each color has one role. The roles stay the same in the dark theme below. */
  --green: #245C4F;        /* text, borders, and fills with no text on them */
  --green-fill: #245C4F;   /* a fill with text on it (use --on-fill for the text) */
  --green-fill-hover: #16362F;
  --green-dark: #16362F;
  --ice: #EAF1EE;          /* callout and card backgrounds */
  --gold: #E0A32E;         /* accents, highlights, badges (as background or border, not small text) */
  --gold-soft: #FBF1DC;    /* pale gold for highlighted rows */
  --gold-mark: #B5800F;    /* gold for a mark with no text: a border, a dot, a bar (3:1) */

  /* Pipeline lanes (match the course diagrams) */
  --teal: #1F8A8A;         /* build time: happens once per document (fills, borders) */
  --teal-ink: #0F5C5C;     /* teal for small text */
  --teal-fill: #0F5C5C;    /* a teal fill with text on it */
  --teal-soft: #DDF1F1;
  --amber: #C8741A;        /* run time: happens for every question (fills, borders) */
  --amber-ink: #8A4A0B;    /* amber for small text */
  --amber-fill: #A85E12;   /* an amber fill with text on it */
  --amber-soft: #FBE9D6;

  /* Neutrals */
  --ink: #1F2A27;
  --ink-soft: #4B5854;
  --line: #CFD9D5;
  --paper: #FFFFFF;        /* panels and cards */
  --page: #F6F8F7;         /* the page behind the panels */
  --danger: #A8321F;
  --danger-soft: #F9E3DF;

  /* Text on a colored fill. --on-gold is dark in both themes, because gold stays light. */
  --on-fill: #FFFFFF;
  --on-gold: #1F2A27;

  /* The header and the code box stay dark green in both themes. */
  --header-bg: #16362F;
  --header-ink: #EAF1EE;
  --header-hover: #24493F;
  --code-bg: #16362F;
  --code-ink: #EAF1EE;

  /* Focus ring: 3:1 or more against the page and the panels */
  --focus: #9A6700;
  --focus-on-header: #E0A32E;

  /* Depth: only content that floats over other content has a shadow */
  --shadow-float: 0 6px 16px rgba(22, 54, 47, 0.2);

  /* Type */
  --font-heading: Cambria, Georgia, "Times New Roman", serif;
  --font-body: Calibri, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: Consolas, "Courier New", Menlo, monospace;
  --text-2xs: 0.72rem;
  --text-xs: 0.8rem;
  --text-sm: 0.85rem;
  --text-md: 0.92rem;
  --text-base: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.9rem;
  --text-svg-sm: 10px;     /* labels inside a drawing */
  --text-svg: 12px;

  /* Spacing: steps of a quarter rem. --space-0 is only for tags and chips. */
  --space-0: 0.125rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Corners */
  --radius-sm: 4px;        /* tags, chips, small fields */
  --radius: 8px;           /* buttons and fields */
  --radius-lg: 12px;       /* cards and panels */
  --radius-pill: 999px;

  /* Touch targets */
  --target: 36px;
  --target-touch: 44px;

  --sidebar-width: 260px;
}

/* The dark theme: with the dark setting of the computer, unless the page is set to Light,
   or when the page is set to Dark. The two blocks must stay the same. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --green: #7CC4AD;
    --green-fill: #2C6B5B;
    --green-fill-hover: #3A7F6C;
    --green-dark: #0C1F1B;
    --ice: #17211E;
    --gold: #E0A32E;
    --gold-soft: #2B2414;
    --gold-mark: #E0A32E;
    --teal: #2FA8A8;
    --teal-ink: #74D2D2;
    --teal-fill: #146B6B;
    --teal-soft: #10282A;
    --amber: #D98A2E;
    --amber-ink: #F0B474;
    --amber-fill: #A85E12;
    --amber-soft: #2D2012;
    --ink: #F7F8F8;
    --ink-soft: #A3A9B1;
    --line: #34343A;
    --paper: #141516;
    --page: #0F1011;
    --danger: #FF8C78;
    --danger-soft: #3A1B16;
    --header-bg: #0C1F1B;
    --header-hover: #1C3A32;
    --code-bg: #0C1F1B;
    --focus: #E0A32E;
    --shadow-float: 0 6px 16px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --green: #7CC4AD;
  --green-fill: #2C6B5B;
  --green-fill-hover: #3A7F6C;
  --green-dark: #0C1F1B;
  --ice: #17211E;
  --gold: #E0A32E;
  --gold-soft: #2B2414;
  --gold-mark: #E0A32E;
  --teal: #2FA8A8;
  --teal-ink: #74D2D2;
  --teal-fill: #146B6B;
  --teal-soft: #10282A;
  --amber: #D98A2E;
  --amber-ink: #F0B474;
  --amber-fill: #A85E12;
  --amber-soft: #2D2012;
  --ink: #F7F8F8;
  --ink-soft: #A3A9B1;
  --line: #34343A;
  --paper: #141516;
  --page: #0F1011;
  --danger: #FF8C78;
  --danger-soft: #3A1B16;
  --header-bg: #0C1F1B;
  --header-hover: #1C3A32;
  --code-bg: #0C1F1B;
  --focus: #E0A32E;
  --shadow-float: 0 6px 16px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--page);
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--green);
  line-height: 1.2;
  margin: 0 0 var(--space-2);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-3); }

a { color: var(--green); }

code, pre, .mono { font-family: var(--font-mono); font-size: 0.92em; }

/* Focus: one ring for every control. It sits outside the control, on the page or the panel. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.app-header :focus-visible { outline-color: var(--focus-on-header); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--gold);
  color: var(--on-gold);
  padding: var(--space-2) var(--space-4);
  z-index: 10;
}
.skip-link:focus { left: 1rem; }

/* ---------- Header ---------- */
.app-header {
  background: var(--header-bg);
  color: var(--header-ink);
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.app-header h1 { color: var(--header-ink); margin-bottom: var(--space-0); }
.app-header__subtitle { margin: 0; color: var(--header-ink); }
.app-header__course { margin: 0; color: var(--header-ink); font-size: var(--text-md); opacity: 0.85; }
.app-header__side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-2); }
.mode-switch { display: flex; gap: var(--space-1); }
.mode-switch a {
  color: var(--header-ink);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--header-ink);
  border-radius: var(--radius-pill);
  font-size: var(--text-md);
}
.mode-switch a:hover { background: var(--header-hover); }
.mode-switch a[aria-current="page"] { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.mode-switch a { display: inline-flex; align-items: center; }
.theme-switch { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--header-ink); }
.theme-switch__select {
  font: inherit;
  padding: var(--space-0) var(--space-2);
  border: 1px solid var(--header-ink);
  border-radius: var(--radius);
  background: var(--header-bg);
  color: var(--header-ink);
}

/* ---------- Stepper ---------- */
.stepper {
  background: var(--paper);
  border-bottom: 2px solid var(--green);
  padding: var(--space-3) var(--space-6);
  overflow-x: auto;
}
.stepper__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: stretch;
}
.step {
  flex: 1 1 150px;
  display: flex;
  flex-direction: column;
}
.step__button {
  font: inherit;
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.step__button:hover:not(:disabled) { border-color: var(--green); }
.step__button[aria-current="step"] {
  background: var(--green-fill);
  color: var(--on-fill);
  border-color: var(--green-fill);
}
.step__button:disabled {
  cursor: not-allowed;
  color: var(--ink-soft);
  background: var(--page);
  opacity: 0.75;
}
.step__number {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: bold;
  width: 1.6rem;
  height: 1.6rem;
  line-height: 1.6rem;
  text-align: center;
  border-radius: 50%;
  background: var(--ice);
  color: var(--green);
  flex-shrink: 0;
}
.step__button[aria-current="step"] .step__number { background: var(--gold); color: var(--on-gold); }
.step__label { font-weight: 600; }
.step__optional {
  font-size: var(--text-2xs);
  color: var(--ink-soft);
  margin-left: auto;
  font-style: italic;
}
.step__button[aria-current="step"] .step__optional { color: var(--on-fill); }
.step__hint {
  font-size: var(--text-xs);
  color: var(--ink-soft);
  margin: var(--space-1) 0 0 var(--space-1);
  min-height: 1.2em;
}

/* Lane tags: teal for build time, amber for run time */
.lane-tag {
  display: inline-block;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: var(--space-0) var(--space-2);
  border-radius: var(--radius-pill);
  margin: var(--space-1) 0 0;
  line-height: 1.25;
  text-align: center;
}
.lane-tag--build { background: var(--teal-soft); color: var(--teal-ink); border: 1px solid var(--teal); }
.lane-tag--run { background: var(--amber-soft); color: var(--amber-ink); border: 1px solid var(--amber); }
.lane-tag--none { visibility: hidden; }

/* ---------- Layout ---------- */
.layout > * { min-width: 0; }   /* a wide child must not widen the grid on a phone */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  /* Not sticky when stacked, or it would sit on top of the station */
  .layout .sidebar { position: static; }
}

/* ---------- Sidebar / dials ---------- */
.sidebar {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  position: sticky;
  top: 1rem;
}
.sidebar__intro { font-size: var(--text-md); color: var(--ink-soft); }
.dials { display: flex; flex-direction: column; gap: var(--space-4); }
.dial label { display: block; font-weight: 700; font-family: var(--font-mono); font-size: var(--text-md); }
.dial__help { font-size: var(--text-xs); color: var(--ink-soft); margin: 0 0 var(--space-1); }
.dial__row { display: flex; gap: var(--space-2); align-items: center; }
.dial__row input[type="range"] { flex: 1; accent-color: var(--green); }
.dial__row input[type="number"] {
  width: 5.2rem;
  font: inherit;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.dial__range { font-size: var(--text-xs); color: var(--ink-soft); }
.dials__message { font-size: var(--text-md); color: var(--danger); min-height: 1.4em; margin-top: var(--space-3); }
.dials__message:empty { display: none; }

/* ---------- Station panel ---------- */
.station {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  min-height: 60vh;
}
.station__header { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.station__header h2 { margin: 0; }

/* Explainer panel */
.explainer {
  background: var(--ice);
  border-left: 4px solid var(--green);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-2) var(--space-4);
  margin: var(--space-4) 0 var(--space-4);
}
.explainer summary {
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: bold;
  color: var(--green);
  font-size: var(--text-base);
}
.explainer p { margin: var(--space-2) 0 0; max-width: 70ch; }
.explainer p strong { color: var(--green); }

/* Callout (gold) */
.callout {
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-left-width: 6px;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-3) var(--space-4);
  margin: var(--space-4) 0;
  max-width: 80ch;
}

/* Form bits */
textarea.document-input {
  width: 100%;
  min-height: 18rem;
  font: inherit;
  font-size: var(--text-md);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
}
.toolbar { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin: var(--space-3) 0; }
.toolbar__spacer { flex: 1; }
.count { font-size: var(--text-md); color: var(--ink-soft); }

.button {
  font: inherit;
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--green);
  background: var(--paper);
  color: var(--green);
  cursor: pointer;
}
.button:hover:not(:disabled) { background: var(--ice); }
.button--primary { background: var(--green-fill); border-color: var(--green-fill); color: var(--on-fill); }
.button--primary:hover:not(:disabled) { background: var(--green-fill-hover); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button--file { position: relative; overflow: hidden; }
.button--file input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%;
}
.hint { font-size: var(--text-sm); color: var(--ink-soft); }
.message--error { color: var(--danger); background: var(--danger-soft); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.message--error:empty { display: none; }

/* Stale (downstream artifact invalidated by a dial change) */
.stale { opacity: 0.45; filter: grayscale(1); position: relative; }
.stale-notice {
  background: var(--gold-soft);
  border: 1px dashed var(--gold);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  font-weight: 600;
}

/* ---------- Footer ---------- */
.app-footer {
  padding: var(--space-4) var(--space-6) var(--space-6);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

/* Utility */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* ---------- Station 1: chunk cards ---------- */
.summary { margin: 0; }
.summary .block { display: block; margin-top: var(--space-1); }
.warn-text { color: var(--danger); font-weight: 600; }

.chunk-list {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: var(--space-4);
}
.chunk-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chunk-card--cut { border-color: var(--amber); }
.chunk-card__header {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  flex-wrap: wrap;
  background: var(--ice);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}
.chunk-card__header h3 { margin: 0; font-size: var(--text-base); }
.chunk-card__text {
  margin: 0;
  padding: var(--space-3);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: var(--text-md);
  line-height: 1.45;
  flex: 1;
}
mark.overlap {
  background: var(--teal-soft);
  color: inherit;
  border-bottom: 2px dotted var(--teal);
  padding: var(--space-0) 0;
}
.cut {
  color: var(--danger);
  font-weight: bold;
  margin-left: var(--space-0);
  font-size: 1.1em;
}
.chunk-card__footer {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  text-align: right;
}
.chunk-card__footer--warn { background: var(--amber-soft); color: var(--danger); font-weight: 600; }
.chunk-card__footer--clean { color: var(--teal-ink); }

/* Stepper stale marker */
.step__button--stale::after {
  content: '';
  width: 0.6rem; height: 0.6rem;
  border-radius: 50%;
  background: var(--gold-mark);
  margin-left: auto;
  flex-shrink: 0;
}
.step__hint--stale { color: var(--amber-ink); font-weight: 600; }

/* ---------- Station 2: mode toggle ---------- */
.mode-toggle {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-4) var(--space-3);
  margin: 0 0 var(--space-4);
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.mode-toggle legend { font-weight: 700; color: var(--green); padding: 0 var(--space-1); }
.mode-toggle__option {
  flex: 1 1 240px;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-2);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}
.mode-toggle__option:has(input:checked) { border-color: var(--green); background: var(--ice); }
.mode-toggle__option.is-disabled { opacity: 0.55; cursor: not-allowed; }
.mode-toggle__option input { accent-color: var(--green); grid-row: span 2; }
.mode-toggle__name { font-weight: 600; }
.mode-toggle__help { font-size: var(--text-sm); color: var(--ink-soft); grid-column: 2; }

/* ---------- The map ---------- */
.map-section { margin-top: var(--space-4); }
.map {
  width: 100%;
  max-width: 760px;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
}
.map__background { fill: var(--page); }
.map__point circle { fill: var(--teal-fill); stroke: var(--paper); stroke-width: 1.5; transition: r 0.1s; }
.map__point text { fill: var(--on-fill); font-family: var(--font-mono); font-size: var(--text-svg-sm); font-weight: 700; pointer-events: none; }
.map__point { cursor: pointer; }
.map__point:hover circle, .map__point:focus circle { r: 12; }
.map__point:focus { outline: none; }
.map__point:focus-visible circle { stroke: var(--focus); stroke-width: 3; }
.map__point.is-selected circle { fill: var(--gold-mark); }
.map__point.is-selected text { fill: var(--on-gold); }
.map__point.is-neighbor circle { stroke: var(--gold-mark); stroke-width: 3; }
.map__question polygon { fill: var(--amber-fill); stroke: var(--paper); stroke-width: 1.5; }
.map__question text { fill: var(--on-fill); font-weight: 700; font-size: var(--text-svg); pointer-events: none; }
.map__link { stroke: var(--amber); stroke-width: 2; stroke-dasharray: 4 3; }
.map__readout { font-size: var(--text-md); color: var(--ink-soft); min-height: 1.4em; margin: var(--space-2) 0 0; }

/* ---------- The inspector ---------- */
.inspector-section { margin-top: var(--space-5); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-2) 0 var(--space-4); }
.chip {
  font: inherit;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  cursor: pointer;
}
.chip:hover { border-color: var(--green); }
.chip.is-selected { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 700; }
.inspector {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--paper);
}
.inspector h4 { margin: 0 0 var(--space-2); font-size: var(--text-base); }
.chunk-preview { font-size: var(--text-md); color: var(--ink-soft); }
.bars { list-style: none; margin: var(--space-2) 0; padding: 0; max-width: 620px; }
.bar { display: grid; grid-template-columns: 9rem 1fr 4rem; gap: var(--space-2); align-items: center; margin: var(--space-1) 0; }
.bar__term { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__track { background: var(--ice); height: 1rem; border-radius: var(--radius-sm); overflow: hidden; }
.bar__fill { display: block; height: 100%; background: var(--green); }
.bar__value { text-align: right; font-size: var(--text-sm); }

/* ---------- Station 3: question and results ---------- */
.question-box { margin-bottom: var(--space-4); }
.question-label { font-weight: 700; color: var(--green); display: block; margin-bottom: var(--space-1); }
.question-input {
  flex: 1 1 320px;
  font: inherit;
  font-size: var(--text-base);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.select {
  font: inherit;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  max-width: 100%;
}
.question-note { margin: var(--space-1) 0 0; }
.question-note:empty { display: none; }

.question-words { margin: var(--space-4) 0; }
.word-list { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); vertical-align: middle; }
.word {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  padding: var(--space-0) var(--space-2);
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
}
.word--known { background: var(--teal-soft); border-color: var(--teal); }
.word--unknown { background: var(--danger-soft); border-color: var(--danger); text-decoration: line-through; }
.word--dropped { color: var(--ink-soft); }

.table-section { margin-top: var(--space-5); }
.table-scroll { overflow-x: auto; }
.rank-table { border-collapse: collapse; width: 100%; font-size: var(--text-md); }
.rank-table th, .rank-table td { text-align: left; padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--line); vertical-align: top; }
.rank-table th { background: var(--ice); color: var(--green); font-family: var(--font-heading); }
.rank-table tr.is-topk td { background: var(--gold-soft); font-weight: 600; }
.rank-table tr.is-topk td:first-child { border-left: 4px solid var(--gold-mark); }
.rank-table__preview { color: var(--ink-soft); font-weight: 400 !important; }

.cards-section { margin-top: var(--space-5); }
.chunk-card--retrieved { border-color: var(--gold-mark); }
.badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: var(--space-0) var(--space-2);
  border-radius: var(--radius-pill);
}
.badge--rank { background: var(--gold); color: var(--on-gold); }
.badge--score { background: var(--green-fill); color: var(--on-fill); font-family: var(--font-mono); margin-left: auto; }
.rank-table td:last-child { white-space: nowrap; }

/* ---------- Station 4: prompt assembly ---------- */
.prompt-block {
  border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-4);
}
.prompt-block__title { margin: 0 0 var(--space-1); }
.instruction-input {
  width: 100%;
  font: inherit;
  font-size: var(--text-md);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
}
.passage-list { list-style: none; margin: 0; padding: 0; }
.passage { margin: 0 0 var(--space-3); }
.passage__label { font-weight: 700; color: var(--green); }
.passage__text { margin: var(--space-1) 0 0; white-space: pre-wrap; font-size: var(--text-md); }
.question-display { font-size: var(--text-base); font-weight: 600; margin: 0; }
.prompt-full { margin-top: var(--space-5); }
.prompt-box {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  margin: 0 0 var(--space-2);
  max-height: 32rem;
  overflow: auto;
}
.prompt-box--summary { background: var(--ice); color: var(--ink); border: 1px solid var(--line); }
.copy-status { font-size: var(--text-md); color: var(--teal-ink); font-weight: 600; }
.summary-section { margin-top: var(--space-5); }

/* ---------- Global progress and notices ---------- */
.global-status { padding: var(--space-3) var(--space-6) 0; }
.progress {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-4);
}
.progress__label { margin: 0 0 var(--space-2); font-weight: 600; color: var(--green); }
.progress__track { height: 0.6rem; background: var(--ice); border-radius: var(--radius-pill); overflow: hidden; }
.progress__fill { height: 100%; width: 0; background: var(--teal); transition: width 0.2s; }
.progress__fill.is-indeterminate {
  width: 30%;
  animation: progress-slide 1.2s ease-in-out infinite alternate;
}
@keyframes progress-slide { from { margin-left: 0; } to { margin-left: 70%; } }
@media (prefers-reduced-motion: reduce) {
  .progress__fill.is-indeterminate { animation: none; width: 100%; opacity: 0.5; }
  .progress__fill, .map__point circle { transition: none; }
}
.notice {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-left-width: 6px;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-2) var(--space-4);
}
.notice[hidden] { display: none; }
.notice p { margin: 0; flex: 1; }

/* ---------- Black Box inspector ---------- */
.heat-strip {
  display: grid;
  grid-template-columns: repeat(32, 1fr);
  gap: var(--space-0);
  max-width: 640px;
  margin: var(--space-2) 0;
}
.heat-strip__cell { aspect-ratio: 1; border-radius: var(--radius-sm); background: var(--ice); }
.number-list { font-family: var(--font-mono); font-size: var(--text-md); word-spacing: 0.4em; }

/* ---------- Station 5: answer ---------- */
.answer-form {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  display: grid;
  gap: var(--space-3);
}
.answer-form label { font-weight: 700; color: var(--green); display: block; margin-bottom: var(--space-1); }
.key-input {
  flex: 1 1 320px;
  font: inherit;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  align-items: start;
}
@media (max-width: 900px) { .answer-grid { grid-template-columns: 1fr; } }
.answer-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  background: var(--paper);
}
.answer-panel--reply { border-color: var(--amber); border-left-width: 5px; }
.answer-text { white-space: pre-wrap; font-size: var(--text-base); }
.answer-meta { font-size: var(--text-sm); color: var(--ink-soft); }
.checklist { padding-left: var(--space-4); }
.checklist li { margin: var(--space-1) 0; }

/* ---------- Touch targets ---------- */
.button, .select, .step__button, .chip, .mode-switch a, .theme-switch__select, .palette__button, .skip-link,
input[type="text"], input[type="number"], input[type="date"], input[type="password"], select {
  min-height: var(--target);
}
@media (pointer: coarse) {
  .button, .select, .step__button, .chip, .mode-switch a, .theme-switch__select, .palette__button, .skip-link,
  input[type="text"], input[type="number"], input[type="date"], input[type="password"], select {
    min-height: var(--target-touch);
  }
  input[type="checkbox"], input[type="radio"] { width: 1.4rem; height: 1.4rem; }
}

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  .app-header, .stepper, .layout, .global-status, .app-footer { padding-left: var(--space-4); padding-right: var(--space-4); }
  .station { padding: var(--space-4); }
  .app-header__side { align-items: flex-start; }
}
