/* Light and dark are both defined; contrast targets AA for body text. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16202b;
  --ink-soft: #4a5866;
  --line: #d6dce4;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --good: #14633f;
  --good-bg: #e6f4ec;
  --warn: #8a5300;
  --warn-bg: #fdf2e0;
  --draft: #6b3fa0;
  --draft-bg: #f1ebfa;
  --focus: #0b5bd3;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #18202a;
    --ink: #e8edf3;
    --ink-soft: #a9b6c4;
    --line: #2d3946;
    --accent: #7db3e8;
    --accent-ink: #0d1620;
    --good: #7fd6a8;
    --good-bg: #12312a;
    --warn: #f0c07a;
    --warn-bg: #33270f;
    --draft: #c9aef0;
    --draft-bg: #271c38;
    --focus: #8ab4ff;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; z-index: 10;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .wrap {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: space-between; padding-block: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px;
}
.brand-name { margin: 0; font-weight: 650; }
.brand-sub { margin: 0; font-size: 12.5px; color: var(--ink-soft); }
.identity { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.identity label { color: var(--ink-soft); }
select, button { font: inherit; }
select {
  padding: 6px 8px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}

.banner {
  background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.banner .wrap { padding-block: 10px; }
.banner strong { color: inherit; }

main { padding-block: 26px 40px; min-height: 50vh; }
h1 { font-size: 25px; margin: 0 0 6px; line-height: 1.25; }
h2 { font-size: 19px; margin: 26px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
p { margin: 0 0 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.muted { color: var(--ink-soft); font-size: 13.5px; }

.tag {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; margin-right: 6px;
  text-transform: uppercase; letter-spacing: .03em;
}
.tag-draft { background: var(--draft-bg); color: var(--draft); }
.tag-good { background: var(--good-bg); color: var(--good); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }

button {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 550;
}
button.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:hover:not(:disabled) { filter: brightness(1.08); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* Choices are real radio inputs so keyboard and screen-reader behaviour is native. */
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 600; margin-bottom: 10px; }
.choice {
  display: flex; gap: 11px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 14px; margin-bottom: 9px; background: var(--surface); cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice input { margin-top: 5px; flex: none; width: 17px; height: 17px; accent-color: var(--accent); }
.choice-letter { font-weight: 700; margin-right: 5px; }
.choice.is-key { border-color: var(--good); background: var(--good-bg); }
.choice.is-chosen-wrong { border-color: var(--warn); background: var(--warn-bg); }

.facts {
  background: var(--bg); border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: 0 8px 8px 0; margin-bottom: 14px;
}
.rationale { font-size: 14.5px; margin-top: 7px; color: var(--ink-soft); }

.table-wrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; min-width: 320px; font-size: 14.5px; }
caption { text-align: left; font-size: 13px; color: var(--ink-soft); padding-bottom: 6px; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
th { background: var(--bg); font-weight: 600; }

.error {
  background: var(--warn-bg); color: var(--warn);
  border: 1px solid currentColor; border-radius: 9px;
  padding: 12px 16px; margin-bottom: 16px;
}

.meta-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--ink-soft); }
.scorebox { font-size: 21px; font-weight: 650; margin: 4px 0 10px; }
.footer { padding-block: 20px 40px; font-size: 12.5px; color: var(--ink-soft); border-top: 1px solid var(--line); }
.q-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.q-nav button { padding: 5px 11px; font-size: 13px; background: var(--surface); color: var(--ink); border-color: var(--line); }
.q-nav button[aria-current="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.q-nav button.answered { border-color: var(--good); }
.q-nav button.flagged { border-color: var(--warn); border-width: 2px; }

@media (max-width: 600px) {
  .topbar .wrap { flex-direction: column; align-items: flex-start; }
  h1 { font-size: 21px; }
  .wrap { padding: 0 16px; }
}

/* ---- landing page ---- */
.banner-strong { background: var(--draft-bg); color: var(--draft); border-bottom: 1px solid var(--line); }
.brand-link, .btn-link { color: inherit; text-decoration: none; }
.btn-link { color: var(--accent); font-weight: 550; }
.btn-link:hover, .brand-link:hover { text-decoration: underline; }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  text-decoration: none; font-weight: 550; border: 1px solid var(--accent);
}
.btn:hover { filter: brightness(1.08); }
.btn-secondary { background: transparent; color: var(--accent); }

.hero { padding-block: 10px 4px; }
.hero h1 { font-size: 30px; max-width: 18ch; }
.lede { font-size: 17px; color: var(--ink-soft); max-width: 62ch; }
section { margin-bottom: 30px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 680px) { .grid-2 { grid-template-columns: 1fr; } .hero h1 { font-size: 23px; } }

.card-plain { background: transparent; }
.plain-list { margin: 0; padding-left: 20px; }
.plain-list li { margin-bottom: 8px; }

.testform {
  background: var(--warn-bg); color: var(--warn);
  border: 1px solid currentColor; border-radius: 9px;
  padding: 12px 16px; margin-bottom: 14px; font-size: 14px;
}
.testform-label { font-weight: 700; margin: 0 0 6px; letter-spacing: .02em; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 550; margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 9px 11px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.field textarea { resize: vertical; }

.form-result { margin-top: 12px; padding: 11px 14px; border-radius: 8px; font-size: 14.5px; }
.form-result.ok  { background: var(--good-bg); color: var(--good); }
.form-result.err { background: var(--warn-bg); color: var(--warn); }

/* ---- two-question feedback demo ---- */

/* ---- instructional hierarchy ----
   Two heading families, each internally consistent, so the page scans as
   question context -> learning actions -> opened panels -> navigation.

   These are the only two families that get the stronger treatment. Minor
   labels -- Source details, Version details, the selected-answer head, BEST
   ANSWER HERE, YOU SELECTED THIS -- are deliberately left where they are: if
   everything is prominent, nothing is. */

/* 1. Question context: SITUATION / YOUR ROLE AND AUTHORITY / THE DECISION.
      One level stronger, not a heading in its own right — still clearly
      subordinate to the question and the page title. */
.question-card .part-label {
  font-size: 14.5px; font-weight: 750; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink);
  margin: 26px 0 8px;
}
/* `:first-of-type`, not `:first-child`: the card now opens with a visually
   hidden h2 so the h3 labels below it do not skip a level. */
.question-card .part-label:first-of-type { margin-top: 0; }

.selected-card { border-left: 3px solid var(--accent); }
.selected-head { margin-bottom: 6px; font-size: 14px; color: var(--ink-soft); }
.selected-text { font-size: 16px; margin-bottom: 12px; }
.result-line { font-weight: 650; margin-bottom: 10px; }
.result-line.result-good { color: var(--good); }
.result-line.result-other { color: var(--warn); }

/* The three learning actions share one treatment. Opened state is text +
   aria-expanded, never a colour change. */
.learn-row { gap: 10px; }
.learn-action {
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
  display: inline-flex; align-items: center; gap: 8px;
}
.learn-action:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.shown-flag {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

/* Finish is quieter and separated from the learning choices. */
.finish-row { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.quiet-action {
  background: transparent; color: var(--ink-soft); border: 1px solid var(--line);
}
.quiet-action:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-soft); }

.best-answer { font-size: 16px; margin-bottom: 14px; }
.key-distinction { margin-top: 14px; padding: 11px 14px; border-radius: 8px; background: var(--bg); }
.compare-tags { display: inline-flex; gap: 6px; margin-bottom: 6px; }

.source-details, .dev-details { margin-top: 14px; font-size: 14px; }
.source-details summary, .dev-details summary { cursor: pointer; color: var(--accent); font-weight: 550; }
.source-row { margin: 12px 0; padding-left: 12px; border-left: 2px solid var(--line); }
.source-row p { margin-bottom: 4px; word-break: break-word; }

.study-card { background: var(--bg); }
.provider-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.provider-action {
  background: transparent; border: none; padding: 4px 2px;
  color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer;
}
.provider-sep { color: var(--line); }
.link-action {
  background: transparent; border: none; padding: 4px 0;
  color: var(--accent); text-decoration: underline; cursor: pointer; font-size: 14px;
}
/* ---- demo-only: scoped under .study-card / demo containers so the landing
   page and the practice app are untouched by this pass. ---- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Action area sits between the answer and the panels. Clear gaps both sides. */
.learn-actions { margin: 20px 0 24px; }
.learn-actions .learn-row { margin-bottom: 10px; }
.learn-actions .next-row { margin: 14px 0 6px; }
.learn-actions .finish-row { margin-top: 14px; }
/* The navigation region is the last thing in the question, and says so with a
   rule above it rather than by being louder than anything. */
.question-nav { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
/* Three sibling controls: one row when they fit, wrapped when they do not.
   `.actions` already wraps; this stops a wrapped button being squeezed to an
   unreadable width, which is what happens when flex is left to shrink them. */
.learn-row .learn-action { flex: 0 1 auto; min-width: max-content; }
@media (max-width: 560px) {
  .learn-row { flex-direction: column; align-items: stretch; }
  .learn-row .learn-action { width: 100%; justify-content: space-between; }
  .question-nav .next-row { flex-direction: column; align-items: stretch; }
  .question-nav .next-row button { width: 100%; }
}
/* Stronger treatment because it changes activity, not because help was opened. */
.next-action {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer;
}
.next-action:hover { filter: brightness(1.06); }
.help-panel { margin-top: 18px; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
/* 2. The three opened learning panels: Best answer(s) / How the choices
      compare / Explore this question with AI. One shared treatment, including a
      shared left edge, so they read as peers rather than as three unrelated
      boxes that happen to follow each other. */
.panel-head .panel-title {
  margin: 0; font-size: 18px; font-weight: 650; line-height: 1.3;
  padding-left: 11px; border-left: 3px solid var(--accent);
  /* Wrap the words rather than push Hide off the edge: the AI panel's heading
     is the longest of the three and narrow widths are where that shows. */
  flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere;
}
.panel-head .panel-hide { flex: 0 0 auto; }
.panel-head h3 { margin: 0; }
.back-to-actions { margin: 14px 0 0; }
/* Subheading over the reasoning, below the answer it explains. */
.why-heading { margin: 18px 0 6px; font-size: 15px; }
.scenario-toggle { margin: 8px 0 4px; }
.summary-reveal { margin: 12px 0; }
.study-card { margin-top: 24px; }
.study-heading { margin: 0; }
.disclosure-toggle {
  background: transparent; border: none; padding: 2px 0; cursor: pointer;
  font: inherit; color: var(--ink); text-align: left; text-decoration: underline;
}
.disclosure-toggle::before { content: '\25B8 '; }
.disclosure-toggle[aria-expanded="true"]::before { content: '\25BE '; }
.disclosure-note { margin-top: 12px; }
.provider-unavailable { font-style: italic; }
.manual-open { margin-top: 10px; }
.prompt-tools { margin: 6px 0 0; }
/* Guided practice: the shared case exhibit. */
.case-card { margin-bottom: 16px; }
.exhibit-scroll { overflow-x: auto; }
.exhibit { width: 100%; border-collapse: collapse; font-size: 14px; }
.exhibit caption {
  caption-side: top; text-align: left; padding-bottom: 8px;
  color: var(--muted); font-size: 13px;
}
.exhibit th, .exhibit td {
  border: 1px solid var(--line); padding: 7px 9px; text-align: left;
  vertical-align: top; word-break: break-word;
}
.exhibit thead th { background: var(--surface); font-weight: 600; }
.exhibit tbody th { font-weight: 500; width: 58%; }
.select-rule { margin: 4px 0 10px; font-weight: 600; }
.meta-row .muted { margin-left: 8px; }

.prompt-box { margin-top: 10px; }
.prompt-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.prompt-head p { margin: 0; }
/* Icon-only control. Sized for a comfortable target, not just the glyph. */
.icon-action {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  background: transparent; color: var(--accent);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.icon-action:hover { background: var(--surface); }
/* The icon keeps its accessible name from aria-label; this label is visible
   text beside it, so the control reads as "Copy" at a glance. */
.icon-action { width: auto; min-width: 32px; gap: 6px; padding: 0 9px; }
.icon-action-label { font-size: 13px; font-weight: 600; }
/* Focus is the global :focus-visible outline; nothing here may remove it. */
.copy-status { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
.prompt-text {
  width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.5; padding: 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); resize: vertical;
}

/* Pilot only, and used nowhere else.
   `.inline-form` lets the sign-out form sit inline in the header without an
   inline `style=` attribute, which the Content-Security-Policy blocks.
   `button.btn-link` undoes the filled-button chrome that `button` sets: without
   it the accent-coloured label sits on the accent-coloured background and the
   control is unreadable. */
.inline-form { display: inline; }
button.btn-link {
  background: transparent; border-color: transparent; padding: 9px 4px;
}

/* ---------------------------------------------------------------------------
   Stanton Press chrome.
   Served only by the public pilot surface (`jlab/pilot_wsgi.py` substitutes
   `web/partials/sp-header.html` and `web/partials/sp-footer.html` into its
   pages). The development server at /app, /guided and /demo never sees it.

   Everything is prefixed `sp-` so it cannot collide with the Lab's own
   classes, and nothing above this comment was changed.

   The palette is read from stantonpress.com, not guessed: navy #0e213a is the
   site's heading colour, gold #cba052 its button fill, slate #273544 its body
   ink, #f8f9fa its section background. The Lab's own --accent and surfaces are
   untouched, so the application inside the chrome looks exactly as reviewed.
--------------------------------------------------------------------------- */
:root {
  --sp-navy: #0e213a;
  --sp-gold: #cba052;
  --sp-bar-bg: #ffffff;
  --sp-bar-ink: #273544;
  --sp-bar-ink-strong: #0e213a;
  --sp-bar-line: #e3e7ec;
  --sp-foot-bg: #f8f9fa;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* In dark mode the navy stops being a text colour and becomes the bar
       itself, which is what the brand does on its own dark sections. */
    --sp-bar-bg: #0e213a;
    --sp-bar-ink: #c9d4e2;
    --sp-bar-ink-strong: #ffffff;
    --sp-bar-line: #24384f;
    --sp-foot-bg: #0b1a2e;
  }
}

/* The same 860px measure as the Lab's own `.wrap`, so the SP mark, the Lab's
   mark and the first line of every card share one left edge. A wider brand
   container (the Stanton Press site uses one) reads as a misalignment here,
   because the application below it is narrow. */
.sp-wrap {
  max-width: 860px; margin: 0 auto; padding: 0 20px;
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 10px 24px;
}

.sp-bar {
  background: var(--sp-bar-bg);
  border-bottom: 1px solid var(--sp-bar-line);
}
.sp-bar .sp-wrap { padding-block: 12px; }

/* The mark keeps its own navy and gold in both colour schemes: it is a logo,
   not a piece of the interface, and it should not restyle itself. */
.sp-mark { flex: none; display: block; }
.sp-brand {
  display: inline-flex; align-items: center; gap: 11px;
  text-decoration: none; color: var(--sp-bar-ink-strong);
}
.sp-wordmark {
  font-size: 15px; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase;
}
.sp-brand:hover .sp-wordmark { text-decoration: underline; }

.sp-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; }
.sp-nav a {
  color: var(--sp-bar-ink); text-decoration: none;
  font-size: 14.5px; padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.sp-nav a:hover { color: var(--sp-bar-ink-strong); border-bottom-color: var(--sp-gold); }

.sp-footer {
  background: var(--sp-foot-bg);
  border-top: 1px solid var(--sp-bar-line);
  padding-block: 22px 26px;
  color: var(--sp-bar-ink);
}
.sp-footer .sp-wrap { align-items: center; }
.sp-fineprint {
  display: block; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--sp-bar-line);
  font-size: 12.5px; line-height: 1.6;
}
.sp-fineprint p { margin: 0 0 6px; max-width: 78ch; }
.sp-fineprint-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sp-fineprint a { color: inherit; }

/* One breakpoint, and it is the one that matters: the masthead stops being a
   two-column bar and becomes two stacked rows, with the navigation wrapping
   rather than scrolling sideways or hiding behind a control that needs
   JavaScript the Content-Security-Policy would have to be widened for. */
@media (max-width: 720px) {
  .sp-wrap { flex-direction: column; align-items: flex-start; gap: 10px; padding: 0 16px; }
  .sp-bar .sp-wrap { padding-block: 10px; }
  .sp-nav { gap: 2px 16px; }
  .sp-nav a { font-size: 13.5px; }
  .sp-wordmark { font-size: 13.5px; }
  .sp-footer .sp-wrap { align-items: flex-start; }
}

/* The product's own identity, one line above its name: a quiet imprint cue,
   not a second masthead. Requirement: the Lab is still the Lab. */
.brand-eyebrow {
  margin: 0 0 1px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft);
}
