/* `hidden` must actually hide. The browser's default `[hidden] { display: none }`
   is the lowest-specificity rule there is, so ANY author rule setting `display`
   on the same element beats it and the attribute silently does nothing. This has
   bitten this app twice, both times on a flex container, and both times a
   passing assertion said the element was hidden while it was on screen.
   `!important` is deliberate: `hidden` means "not present", and nothing in a
   stylesheet should be able to overrule that. Pinned by test/hidden-guard.js. */
[hidden] { display: none !important; }
/* The runnable demo.
   Palette follows the marketing page (paper/ink/orange) and the theme mechanism
   follows public/shared/base.css: light on bare :root, dark redefined twice so
   that an explicit toggle wins in BOTH directions and the system default still
   works when data-theme is absent. Every colour is defined in the light block
   first; the dark blocks only redefine. */

:root {
  --paper: #fbfaf7;
  --paper-2: #f4f2ec;
  --surface: #ffffff;
  --ink: #14161a;
  --ink-2: #3d4450;
  --ink-3: #6b7280;
  --line: #e2e0da;
  --line-2: #d3d0c8;
  --accent: #d9541b;
  --good: #17703f;
  --good-bg: #eaf5ee;
  --bad: #a32a1c;
  --bad-bg: #fbeeeb;
  --flat: #5b6472;
  --flat-bg: #eef0f3;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1115;
    --paper-2: #14171d;
    --surface: #171b22;
    --ink: #e8ecf1;
    --ink-2: #b9c2ce;
    --ink-3: #8d97a6;
    --line: #2a313c;
    --line-2: #3a424f;
    --accent: #f27a3f;
    --good: #6ede9f;
    --good-bg: #12291d;
    --bad: #ff9384;
    --bad-bg: #2d1714;
    --flat: #9aa6b8;
    --flat-bg: #1d222a;
  }
}

:root[data-theme="dark"] {
  --paper: #0f1115;
  --paper-2: #14171d;
  --surface: #171b22;
  --ink: #e8ecf1;
  --ink-2: #b9c2ce;
  --ink-3: #8d97a6;
  --line: #2a313c;
  --line-2: #3a424f;
  --accent: #f27a3f;
  --good: #6ede9f;
  --good-bg: #12291d;
  --bad: #ff9384;
  --bad-bg: #2d1714;
  --flat: #9aa6b8;
  --flat-bg: #1d222a;
}

* { box-sizing: border-box; }

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

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 22px; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(30px, 4.6vw, 46px); font-weight: 680; max-width: 23ch; }
h2 { font-size: clamp(21px, 2.6vw, 27px); font-weight: 660; }
h3 { font-size: 18.5px; font-weight: 650; }
p { margin: 0; }

.eyebrow {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent); font-weight: 600;
}
.muted { color: var(--ink-3); font-size: 14.5px; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }

/* ── chrome ─────────────────────────────────────────────────────────────── */

.topbar { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.bar { display: flex; align-items: center; gap: 22px; height: 60px; }
.brand {
  display: flex; align-items: center; gap: 9px; font-weight: 680;
  letter-spacing: -0.02em; font-size: 17.5px; text-decoration: none; color: inherit;
}
.brand svg { display: block; flex: none; }
nav { margin-left: auto; display: flex; gap: 18px; align-items: center; }
nav a { color: var(--ink-2); text-decoration: none; font-size: 14.5px; }
nav a:hover { color: var(--ink); }
/* Below this the three nav items push the bar past the viewport and the whole
   PAGE scrolls sideways, which is the one thing a wide table inside .scroll-x is
   arranged not to do. The report link is the one worth keeping. */
@media (max-width: 560px) {
  .bar { gap: 14px; }
  nav { gap: 12px; }
  nav .hide-sm { display: none; }
}

.btn {
  display: inline-block; text-decoration: none; font-size: 14.5px; font-weight: 560;
  padding: 9px 16px; border-radius: 7px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); cursor: pointer;
  font-family: inherit; line-height: 1.4;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary[disabled] { opacity: .5; cursor: progress; filter: none; }
.ghost {
  background: transparent; border: 1px solid var(--line-2); color: var(--ink-2);
  border-radius: 7px; padding: 6px 12px; font-size: 13.5px; cursor: pointer; font-family: inherit;
}
.ghost:hover { color: var(--ink); }

footer.foot {
  display: flex; gap: 20px; flex-wrap: wrap; align-items: baseline;
  border-top: 1px solid var(--line); margin-top: 56px; padding-top: 24px;
  padding-bottom: 40px; color: var(--ink-3); font-size: 12.5px;
}
footer.foot span:last-child { max-width: 62ch; }

/* ── blocks ─────────────────────────────────────────────────────────────── */

.hero { padding: 54px 0 34px; }
.hero .lede { margin-top: 18px; font-size: clamp(16px, 1.8vw, 19px); color: var(--ink-2); max-width: 68ch; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px;
}
.panel > .eyebrow + h2, .panel > .eyebrow + h3 { margin-top: 8px; }
.panel > h3 + p { margin-top: 8px; }

.subject-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.subject-head > div { flex: 1 1 22rem; }
#dwg-name { margin-top: 8px; font-family: var(--mono); font-size: 22px; letter-spacing: -0.01em; }
#dwg-prov { margin-top: 6px; }

.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; margin: 18px 0 0;
}
.facts div { background: var(--surface); padding: 12px 14px; }
.facts dt { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.facts dd { margin: 3px 0 0; font-size: 19px; font-weight: 650; font-family: var(--mono); letter-spacing: -0.02em; }

/* ── the picker ─────────────────────────────────────────────────────────── */

.slots { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; margin-top: 14px; }
.slot label { display: block; font-size: 13.5px; color: var(--ink-3); margin-bottom: 6px; }
.slot select {
  width: 100%; font: inherit; font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--paper-2); color: var(--ink);
}
.slot input[type="file"] { margin-top: 10px; width: 100%; font-size: 13.5px; color: var(--ink-2); }
.slot-note { margin-top: 8px; font-size: 13px; color: var(--ink-3); min-height: 1.2em; }
.slot-note.bad { color: var(--bad); }
.versus {
  align-self: center; font-family: var(--mono); font-size: 12px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3); padding-top: 26px;
}
@media (max-width: 720px) {
  .slots { grid-template-columns: 1fr; }
  .versus { padding-top: 0; }
}

.run-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 20px; }
.run-row .btn.primary { font-size: 16px; padding: 11px 22px; }
#run-hint { flex: 1 1 24rem; }

/* ── progress ───────────────────────────────────────────────────────────── */

.steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 7px; }
.steps li {
  display: grid; grid-template-columns: 1.4rem 1fr auto; gap: 10px; align-items: baseline;
  font-size: 14.5px; color: var(--ink-3); opacity: 0; transform: translateY(3px);
  transition: opacity .18s ease, transform .18s ease;
}
.steps li.on { opacity: 1; transform: none; color: var(--ink-2); }
.steps li .tick { color: var(--good); font-weight: 700; }
.steps li .ms { font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); }
@media (prefers-reduced-motion: reduce) {
  .steps li { transition: none; }
}

/* ── the verdict line ───────────────────────────────────────────────────── */

.verdict {
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  background: var(--surface); border-radius: var(--radius);
  padding: 20px 24px; margin-bottom: 18px;
}
.verdict h2 { margin-bottom: 8px; }
.verdict p { color: var(--ink-2); max-width: 74ch; }

/* ── the two score columns ──────────────────────────────────────────────── */

/* The two cards exist to be read against each other, so the score in one has to
   sit level with the score in the other — and their titles and notes are
   different lengths, so left to themselves they do not. `subgrid` makes both
   cards share the container's rows, which is the only version of this that
   survives a standard nobody has seen yet putting a four-line name in the slot.
   Where subgrid is unsupported the min-heights below still get it close. */
.scores {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px;
  grid-template-rows: auto auto auto auto auto auto auto;
}
@media (max-width: 760px) { .scores { grid-template-columns: 1fr; } }

.score {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px;
  display: grid; grid-row: span 7; grid-template-rows: subgrid; align-content: start;
}
.score .sname { font-weight: 650; font-size: 17px; letter-spacing: -0.01em; min-height: 3.2em; }
.score .sbasis { color: var(--ink-3); font-size: 13px; margin-top: 4px; min-height: 4.8em; }
.score .big {
  font-family: var(--mono); font-size: clamp(38px, 7vw, 56px); font-weight: 680;
  letter-spacing: -0.04em; line-height: 1.05; margin-top: 14px;
}
.score .big.good { color: var(--good); }
.score .big.bad { color: var(--bad); }
/* Mid band. Deliberately the accent and not a grey: a score that is neither
   good nor catastrophic still needs somebody to act, and grey reads as "nothing
   measured", which is the one thing it does not mean. */
.score .big.flat { color: var(--accent); }
.score .bigsub { font-size: 13.5px; color: var(--ink-3); margin-top: 2px; }
.score .bar { height: 8px; border-radius: 4px; background: var(--flat-bg); overflow: hidden; margin-top: 14px; display: flex; }
.score .bar i { display: block; height: 100%; background: var(--good); }
/* The "could be anywhere in here" half of a bounded score. */
.score .bar i.band {
  background: repeating-linear-gradient(135deg,
    var(--accent) 0 3px, transparent 3px 7px);
  opacity: .45;
}
.score .bar i.bad { background: var(--bad); }
.score .bar i.flat { background: var(--accent); }
.score dl { margin: 16px 0 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.score dl > div { background: var(--surface); display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 8px 12px; font-size: 14px; }
.score dt { color: var(--ink-3); }
.score dd { margin: 0; font-family: var(--mono); font-weight: 620; }
.score dd .was { color: var(--ink-3); font-weight: 400; }

.tagline {
  display: inline-block; justify-self: start; align-self: start;
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 100px; margin-bottom: 10px;
}
.tagline.match { background: var(--good-bg); color: var(--good); }
/* Present but invisible, so the card below it starts at the same height in both
   columns whether or not there is a badge to show. */
.tagline.empty { visibility: hidden; }

/* ── the delta ──────────────────────────────────────────────────────────── */

.deltas { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 14px; }
.deltas div { background: var(--surface); padding: 14px 16px; }
.deltas .n { font-family: var(--mono); font-size: 25px; font-weight: 680; letter-spacing: -0.03em; }
.deltas .n.bad { color: var(--bad); }
.deltas .n.good { color: var(--good); }
.deltas .l { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* ── the object-layer pairing table ─────────────────────────────────────── */

.scroll-x { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pairs th, .pairs td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pairs th { font-family: var(--mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.pairs td.l { font-family: var(--mono); }
.pairs tr:last-child td { border-bottom: 0; }
.pairs tr.differ td { background: var(--bad-bg); }
.pairs tr.differ td.l { color: var(--bad); }

/* ── the moved-layer list ───────────────────────────────────────────────── */

details.panel summary { cursor: pointer; font-weight: 620; font-size: 16px; }
details.panel summary::marker { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip {
  font-family: var(--mono); font-size: 12.5px; padding: 3px 9px; border-radius: 5px;
  background: var(--bad-bg); color: var(--bad); border: 1px solid transparent;
}
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.n { background: var(--flat-bg); color: var(--flat); }
.moved-group + .moved-group { margin-top: 20px; }
.moved-group h4 { margin: 0; font-size: 14.5px; font-weight: 620; }
.moved-group p { margin-top: 4px; }

/* ── honesty ────────────────────────────────────────────────────────────── */

.honest { background: var(--paper-2); }
.honest h3 { margin-bottom: 10px; }
.honest ul { margin: 12px 0 0; padding-left: 1.1rem; color: var(--ink-2); font-size: 15px; }
.honest li { margin-bottom: 8px; }
.honest li:last-child { margin-bottom: 0; }
.honest b { font-weight: 640; color: var(--ink); }

.next .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.next p { color: var(--ink-2); margin-top: 8px; max-width: 74ch; }

.error { border-color: var(--bad); }
.error h2 { color: var(--bad); }
.error p { margin-top: 10px; color: var(--ink-2); }

/* Save-to-library row. Hidden until an upload has parsed.
   `display:flex` beats the browser's default `[hidden] { display: none }`,
   so without the guard below the row shows on every slot regardless of the
   attribute — which is exactly what it did, on a bundled standard that cannot
   be saved. A passing assertion would not have caught it; a screenshot did. */
.saverow { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.saverow input[type="text"] {
  font: inherit; padding: 7px 9px; border-radius: 6px; flex: 1 1 20ch; min-width: 0;
  background: var(--surface, #fff); color: inherit; border: 1px solid var(--line, #d8d5cd);
}
.btn.small { padding: 7px 12px; font-size: 14px; }

/* Swap the subject drawing for one of your own. */
.subject-swap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.subject-swap[hidden] { display: none !important; }
.subject-swap label.btn { cursor: pointer; }
.subject-swap .small { flex: 1 1 30ch; min-width: 0; }
