/* Page chrome. The .stage rules at the bottom are the CSS twin of the function in layout.js. */
:root {
  --ink: #16181d;
  --mute: #5b616e;
  --line: #d9dce3;
  --paper: #fbfaf7;
  --card: #ffffff;
  --accent: #2554c7;
  --ok: #1f8a4c;
  --bad: #c62f2f;
  --unk: #d99a1e;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", "Liberation Mono", monospace;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
.top, main, .foot { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 28px; }
.kicker { margin: 0; font: 600 12px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 4px 0 8px; font-size: 30px; line-height: 1.15; }
h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.25; }
h3 { margin: 0; font-size: 15px; }
.lead { margin: 0 0 10px; font-size: 17px; }
.status { margin: 0 0 12px; font: 13px/1.5 var(--mono); color: var(--mute); }
.jump { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.jump a { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: 14px; background: #fff; }
.screen { padding: 28px 0 8px; border-top: 1px solid var(--line); margin-top: 20px; }
.screen > p { margin: 0 0 12px; }
.note { color: var(--mute); font-size: 14px; }
a { color: var(--accent); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 0 12px; }
.fact { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.fact b { display: block; font: 600 22px/1.2 var(--mono); }
.fact span { font-size: 13px; color: var(--mute); }
details.gk-accordion { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
details.gk-accordion summary { cursor: pointer; padding: 10px 12px; font-weight: 600; }
.src { margin: 0; max-height: 360px; overflow: auto; padding: 10px 12px; border-top: 1px solid var(--line); font: 11px/1.45 var(--mono); white-space: pre; }

/* Control panels */
.gk-controls { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.gk-controls-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.gk-control { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; padding: 8px 0; border-top: 1px solid #eef0f4; margin: 0; min-width: 0; }
fieldset.gk-control { border-left: 0; border-right: 0; border-bottom: 0; padding: 8px 0; }
.gk-control > label, .gk-control > .lbl, .gk-control > legend { font-size: 14px; font-weight: 600; grid-column: 1; }
fieldset.gk-control > legend { float: left; padding: 0; }
.gk-control > .gk-help { grid-column: 2; grid-row: 1; justify-self: end; }
.gk-control > input[type="range"] { grid-column: 1; width: 100%; min-height: 32px; accent-color: var(--accent); }
.gk-control > output { grid-column: 2; font: 600 14px var(--mono); min-width: 64px; text-align: right; }
.gk-control > .btn { grid-column: 1 / -1; justify-self: start; }
.gk-control > .checks { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 2px 12px; }
.checks label { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 15px; }
.checks input { width: 20px; height: 20px; accent-color: var(--accent); }
.gk-help { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: #f4f5f8; font: 700 15px/1 system-ui, sans-serif; color: var(--ink); cursor: pointer; }
.gk-help[aria-expanded="true"] { background: var(--ink); color: #fff; }
.gk-help-text { grid-column: 1 / -1; margin: 4px 0 0; padding: 8px 10px; background: #f1f4fb; border-left: 3px solid var(--accent); border-radius: 6px; font-size: 14px; }
.gk-key-toggle, .btn { min-height: 40px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: #f4f5f8; color: var(--ink); font: 600 15px system-ui, sans-serif; cursor: pointer; }
.gk-key-toggle[aria-expanded="true"] { background: var(--ink); color: #fff; }
.btn-main { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.gk-key { margin: 0 0 6px; padding: 8px 10px; background: #f7f7f4; border-radius: 8px; font-size: 14px; }
.gk-key div { display: grid; grid-template-columns: 9.5em 1fr; gap: 8px; padding: 3px 0; }
.gk-key dt { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.gk-key dd { margin: 0; }
.mk { display: inline-block; width: 16px; height: 12px; border-radius: 3px; flex: none; }
.mk-card { background: #fff; border: 1px solid #8d93a1; }
.mk-pred { border: 2px dashed var(--accent); }
.mk-cut { background: #fde8e8; border: 1px solid var(--bad); }
.mk-ok { background: var(--ok); }
.mk-bad { background: var(--bad); }
.mk-unk { background: var(--unk); }
.mk-dot { border: 2px solid var(--ink); border-radius: 50%; width: 12px; }
.mk-chg { background: var(--ink); width: 6px; }
.mk-line { height: 3px; background: var(--ink); }
.mk-col { width: 3px; height: 14px; background: var(--accent); }
.mk-wrap { width: 3px; height: 7px; background: var(--unk); }

/* Readouts */
.agree, .verdict { margin: 0 0 8px; font: 14px/1.5 var(--mono); }
.verdict b, .agree b { font-weight: 700; }
.rules { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px; }
.rules li { padding: 6px 10px; border-radius: 8px; font-size: 14px; color: #fff; }
.rules li.ok { background: var(--ok); }
.rules li.bad { background: var(--bad); }
.rules li span { font-family: var(--mono); float: right; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.tbl th, .tbl td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.tbl td.n, .tbl th.n { text-align: right; font-family: var(--mono); }
.tbl td.chg { font-weight: 800; }
.log { list-style: none; padding-left: 0; font: 13px/1.5 var(--mono); }
.log li { margin: 0 0 6px; }
.log .ok { color: var(--ok); font-weight: 700; }
.log .bad { color: var(--bad); font-weight: 700; }
.map, .plot { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; touch-action: manipulation; }
.map { cursor: crosshair; }
.axis { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--mute); margin: 2px 0 8px; }
.jlist { padding-left: 22px; font-size: 14px; max-height: 360px; overflow: auto; }
.jlist li { margin: 0 0 4px; }
.jlist button { all: unset; cursor: pointer; color: var(--accent); text-decoration: underline; font-family: var(--mono); }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 8px 10px; border-radius: 8px; margin: 0 0 6px; background: #fff; border: 1px solid var(--line); border-left-width: 5px; font-size: 14px; }
.checklist li.ok { border-left-color: var(--ok); }
.checklist li.bad { border-left-color: var(--bad); }
.checklist li.neg { border-left-color: var(--ink); }
.checklist b { font-family: var(--mono); }
.plain { padding-left: 20px; }
.plain li { margin-bottom: 6px; }
.foot { color: var(--mute); font-size: 13px; padding-bottom: 40px; border-top: 1px solid var(--line); margin-top: 24px; }

/* The stage: a real page at the chosen screen width, scaled down to fit. */
.stage-frame { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #eceef2; }
.stage-scroll { max-height: 75vh; overflow-y: auto; border-radius: 10px; -webkit-overflow-scrolling: touch; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: var(--paper); }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay div { position: absolute; border: 2px dashed var(--accent); }

/* The CSS twin of buildLayout(). Change one, change the other. */
.wrap { max-width: calc(var(--maxW) * 1px); margin: 0 auto; padding: calc(var(--pp) * 1px); box-sizing: border-box; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(calc(var(--mc) * 1px), 100%), 1fr));
  gap: calc(var(--gap) * 1px);
  align-items: start;
}
.card {
  border: 1px solid #8d93a1;
  padding: calc(var(--cp) * 1px);
  box-sizing: border-box;
  min-width: 0;
  background: var(--card);
  font-family: var(--mono);
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  letter-spacing: 0;
  word-spacing: 0;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: manual;
  white-space: normal;
}
.card.cut { background: #fde8e8; border-color: var(--bad); }
.card h4 { margin: 0; font-size: calc(17px * var(--s)); line-height: calc(24px * var(--s)); font-weight: 700; }
.card p {
  margin: 8px 0 0;
  font-size: calc(15px * var(--s));
  line-height: calc(22px * var(--s));
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}
.probe { position: absolute; left: -9999px; top: 0; white-space: pre; font-family: var(--mono); font-kerning: none; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
