:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #16191d;
  --muted: #5c6470;
  --line: #dfe3e9;
  --accent: #1f5fa8;
  --accent-ink: #ffffff;
  --met: #1c7a4a;
  --met-bg: #e7f4ec;
  --partial: #97650a;
  --partial-bg: #fdf3df;
  --unmet: #a53030;
  --unmet-bg: #fbeaea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 20, 26, .06), 0 4px 16px rgba(16, 20, 26, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --panel: #1c2026;
    --ink: #e8eaee;
    --muted: #9aa3b0;
    --line: #2c323a;
    --accent: #6aa9ef;
    --accent-ink: #0f1216;
    --met: #6ed49b;
    --met-bg: #14301f;
    --partial: #e8be6a;
    --partial-bg: #33280f;
    --unmet: #ef8b8b;
    --unmet-bg: #331818;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- chrome ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .01em; }
.brand .mark { color: var(--accent); font-size: 15px; }

.stage { max-width: 800px; margin: 0 auto; padding: 22px 20px 64px; }

/* ---------- transcript ---------- */

.transcript { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }

.bubble {
  max-width: 88%;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.bubble.note {
  background: transparent; border-style: dashed; box-shadow: none;
  color: var(--muted); font-size: 14.5px;
}
.bubble.error { border-color: var(--unmet); background: var(--unmet-bg); color: var(--unmet); }

/* ---------- steps ---------- */

.step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.step.center { text-align: center; }
.step-title { margin: 0 0 14px; font-size: 17px; font-weight: 640; }
.hint { margin: -6px 0 16px; color: var(--muted); font-size: 14.5px; }

.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

button { font: inherit; cursor: pointer; }

.choice {
  text-align: left; padding: 15px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
}
.choice:hover, .choice:focus-visible { border-color: var(--accent); outline: none; }
.choice .code { display: block; font-weight: 640; }
.choice .sub { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }

.primary {
  padding: 11px 18px; border: 0; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.primary[disabled] { opacity: .45; cursor: not-allowed; }
.ghost {
  padding: 10px 15px; border: 1px solid var(--line); border-radius: 9px;
  background: transparent; color: var(--ink);
}
.ghost:hover { border-color: var(--accent); }
.back { margin-top: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.actions .back { margin: 0; margin-right: auto; }

/* ---------- fields ---------- */

.field { display: block; margin-bottom: 14px; }
.label { display: block; font-size: 14px; font-weight: 580; margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--muted); }

input[type="search"], input[type="text"], input[type="number"], input[type="url"], textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; }

.field-note { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; }

.grid-2 { display: grid; gap: 0 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- program list ---------- */

.program-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; }
.program-item {
  display: block; width: 100%; text-align: left; padding: 11px 14px;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); color: var(--ink);
}
.program-item:last-child { border-bottom: 0; }
.program-item:hover, .program-item:focus-visible { background: var(--bg); outline: none; }
.program-item .meta { display: block; color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.empty { padding: 16px; color: var(--muted); text-align: center; }

/* ---------- attachments ---------- */

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 26px 18px; text-align: center; color: var(--muted); background: var(--bg);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); outline: none; }
.dropzone .sub { display: block; font-size: 13.5px; margin-top: 5px; }

.paste { margin: 14px 0; }
.paste summary { cursor: pointer; color: var(--accent); font-size: 14.5px; }
.paste textarea { margin-top: 10px; }

.attachments { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.attachments li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  font-size: 14.5px;
}
.attachments .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachments .fsize { color: var(--muted); font-size: 13px; }
.attachments .remove { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 4px; }
.attachments .remove:hover { color: var(--unmet); }

/* ---------- working ---------- */

.spinner {
  width: 30px; height: 30px; margin: 6px auto 14px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 850ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.working-text { color: var(--muted); margin: 0; }

/* ---------- report ---------- */

.report-head { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 18px; }
.report-head h2 { margin: 0 0 4px; font-size: 20px; }
.report-head .sub { color: var(--muted); font-size: 14.5px; }
.refcode {
  display: inline-block; margin-top: 10px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px;
}

.scorecard {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
  padding: 16px; border-radius: var(--radius); background: var(--bg);
  border: 1px solid var(--line); margin-bottom: 8px;
}
.score-num { font-size: 30px; font-weight: 680; line-height: 1.1; }
.score-label { color: var(--muted); font-size: 14px; }
.score-verdict { margin-left: auto; font-weight: 640; }
.score-verdict.pass { color: var(--met); }
.score-verdict.fail { color: var(--unmet); }

.meter { position: relative; height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 14px 0 6px; }
.meter .fill { height: 100%; background: var(--accent); }
.meter .fill.pass { background: var(--met); }
.meter-marks { position: relative; height: 18px; font-size: 12px; color: var(--muted); }
.meter-marks .mark { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.threshold-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); opacity: .55; }

.tally { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.pill { padding: 4px 11px; border-radius: 999px; font-size: 13.5px; font-weight: 580; }
.pill.met { background: var(--met-bg); color: var(--met); }
.pill.partially_met { background: var(--partial-bg); color: var(--partial); }
.pill.unmet { background: var(--unmet-bg); color: var(--unmet); }

.section-title { margin: 26px 0 12px; font-size: 16px; font-weight: 640; }

.outcome {
  border: 1px solid var(--line); border-left-width: 4px;
  border-radius: var(--radius); padding: 15px 16px; margin-bottom: 12px; background: var(--panel);
  break-inside: avoid;
}
.outcome.met { border-left-color: var(--met); }
.outcome.partially_met { border-left-color: var(--partial); }
.outcome.unmet { border-left-color: var(--unmet); }
.outcome-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.outcome-id { font-weight: 680; }
.outcome-title { font-weight: 580; }
.outcome-statement { color: var(--muted); font-size: 14.5px; margin: 0 0 12px; }
.outcome dl { margin: 0; display: grid; gap: 10px; }
.outcome dt { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 620; }
.outcome dd { margin: 3px 0 0; }
.outcome blockquote {
  margin: 3px 0 0; padding: 8px 12px; border-left: 3px solid var(--line);
  background: var(--bg); border-radius: 0 7px 7px 0; font-size: 14.5px;
}
.conf { font-size: 12.5px; color: var(--muted); margin-left: auto; }

.callout {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; background: var(--bg); margin-bottom: 14px;
}
.callout.warn { border-color: var(--partial); background: var(--partial-bg); color: var(--partial); }
.callout h3 { margin: 0 0 6px; font-size: 15px; }
.callout ul { margin: 6px 0 0; padding-left: 20px; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }

.disclaimer {
  margin-top: 26px; padding: 15px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 14px;
}
.disclaimer strong { color: var(--ink); }

/* ---------- print ---------- */

@media print {
  :root { --bg: #fff; --panel: #fff; --ink: #000; --muted: #444; --line: #bbb; --shadow: none; }
  .topbar, .transcript, .no-print, .step.center { display: none !important; }
  .stage { max-width: none; padding: 0; }
  .step { border: 0; box-shadow: none; padding: 0; }
  .outcome { break-inside: avoid; }
}
