/* Header Hops: "two-track transit logbook". Teal ring = header hop, copper square = Exchange trace.
   Loaded after styles.css; the template's structural rules (.ad-slot height, consent, footer) are
   restyled here, never resized. Contrast ratios noted beside text tokens (against --surface). */

:root {
  color-scheme: light dark;

  /* Palette, light */
  --bg: #f5f3ee;
  --surface: #ffffff;
  --raised: #faf8f4;
  --text: #1a1e23;            /* 16.5:1 */
  --muted: #4f5660;           /* 7.3:1 */
  --border: #dcd8cf;
  --border-strong: #b3ada1;
  --accent: #0b6158;          /* header colour; white on it 7.0:1 */
  --accent-hover: #084f48;
  --accent-active: #063e38;
  --accent-text: #0a5c53;     /* links 7.4:1 */
  --accent-tint: #e3f1ee;
  --on-accent: #ffffff;
  --trace: #a44d12;           /* trace marker */
  --trace-text: #8c3f0c;      /* 7.4:1 */
  --trace-tint: #f8ebe0;
  --success: #1c6b37;         /* 6.6:1 */
  --success-tint: #e5f3e9;
  --warning: #7a4c00;         /* 7.1:1 on its tint */
  --warning-edge: #d99a1e;    /* edges only, never text */
  --warning-tint: #fcf0d4;
  --danger: #b0231a;          /* 6.3:1 */
  --danger-tint: #fcebe9;
  --focus: #0b6158;

  /* Type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-1: 13px;
  --fs-2: 15px;
  --fs-3: 17px;
  --fs-4: 20px;
  --fs-5: 24px;
  --fs-6: clamp(30px, 5.5vw, 42px);

  /* Space */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Shape */
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --shadow-1: 0 1px 2px rgb(26 30 35 / 0.06), 0 6px 20px rgb(26 30 35 / 0.06);
  --shadow-2: 0 10px 32px rgb(26 30 35 / 0.18);

  /* Motion */
  --fast: 160ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Layout */
  --wide: 68rem;
  --prose: 42rem;
  --line: var(--border);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111416;
    --surface: #191d20;
    --raised: #20252a;
    --text: #e9e7e2;          /* 14.6:1 */
    --muted: #a8aeb5;         /* 7.6:1 */
    --border: #31373d;
    --border-strong: #4a525a;
    --accent: #5cc8b8;        /* #062420 on it 8.9:1 */
    --accent-hover: #78d6c8;
    --accent-active: #4ab3a4;
    --accent-text: #6fd2c3;   /* 9.4:1 */
    --accent-tint: #15302c;
    --on-accent: #062420;
    --trace: #e8955a;
    --trace-text: #f0a774;    /* 8.4:1 */
    --trace-tint: #33241a;
    --success: #79d293;       /* 9.6:1 */
    --success-tint: #183022;
    --warning: #f2c467;       /* 9.8:1 on its tint */
    --warning-edge: #c98d1c;
    --warning-tint: #33290f;
    --danger: #ff8f84;        /* 7.4:1 */
    --danger-tint: #3a1c1a;
    --focus: #78d6c8;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.25);
    --shadow-2: 0 10px 32px rgb(0 0 0 / 0.5);
  }
}

/* ---------- Base ---------- */
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs-3)/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
header, main, footer { max-width: var(--wide); padding-inline: var(--s5); }
@media (max-width: 52rem) { header, main, footer { padding-inline: var(--s4); } }

header { border-bottom: 1px solid var(--border); padding-block: var(--s2); }
.brand {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 44px; line-height: 1.2;
  font-weight: 750; font-size: var(--fs-3); letter-spacing: -0.01em; color: var(--text);
}
.brand::before {
  content: ""; width: 26px; height: 26px; flex: none;
  background: url("icons/favicon.svg") center / contain no-repeat;
}
header nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding-inline: var(--s3);
  border-radius: var(--r-s); color: var(--muted); font-size: var(--fs-2); font-weight: 600; text-decoration: none;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
header nav a:hover { background: var(--raised); color: var(--text); }

main > h1, main > .lede, main > h2, main > h3, main > p, main > ol, main > ul { max-width: var(--prose); }
h1 {
  font-size: var(--fs-6); line-height: 1.1; letter-spacing: -0.02em; font-weight: 800;
  margin: var(--s7) 0 var(--s3);
}
.lede { font-size: var(--fs-4); line-height: 1.5; color: var(--muted); margin: 0 0 var(--s6); }
h2 { font-size: var(--fs-5); line-height: 1.25; letter-spacing: -0.01em; margin: var(--s7) 0 var(--s3); }
h3 { font-size: var(--fs-3); margin: var(--s5) 0 var(--s1); }
main p, main li { line-height: 1.6; }
main ol, main ul { padding-left: 1.4em; }
main li + li { margin-top: var(--s2); }
main li::marker { color: var(--accent-text); font-weight: 700; }

a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd { font-family: var(--font-mono); font-size: 0.9em; }

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

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

/* ---------- Tool panel ---------- */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  padding: var(--s6);
  margin-bottom: var(--s7);
}
@media (max-width: 52rem) { .tool { padding: var(--s4); border-radius: var(--r-m); } }

.inputs { display: grid; grid-template-columns: 3fr 2fr; gap: var(--s5); align-items: stretch; }
@media (max-width: 52rem) { .inputs { grid-template-columns: 1fr; gap: var(--s5); } }

.field { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.field-label {
  display: flex; align-items: center; gap: var(--s2);
  font-size: var(--fs-1); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text);
}
.hint { margin: 0; font-size: var(--fs-2); line-height: 1.45; color: var(--muted); }

/* Step badges: the two-lane markers */
.badge { width: 14px; height: 14px; flex: none; }
.badge-hop { border: 3px solid var(--accent); border-radius: 50%; background: var(--surface); }
.badge-trace { background: var(--trace); border-radius: 3px; }

/* Textarea, and any plain input the builder adds */
textarea, input[type="text"], input[type="search"], select {
  width: 100%;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-m);
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
textarea {
  min-height: 15rem; padding: var(--s3) var(--s4);
  font: 14px/1.55 var(--font-mono);
  resize: vertical; flex: 1;
  overflow-wrap: anywhere;
}
input[type="text"], input[type="search"], select { min-height: 44px; padding: 0 var(--s3); font: inherit; }
textarea::placeholder { color: var(--muted); }
textarea:hover, input[type="text"]:hover, select:hover { border-color: var(--muted); }
textarea:focus-visible, input[type="text"]:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--accent); background: var(--surface);
}
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

.meter {
  margin: 0; min-height: 1.4em;
  font: var(--fs-1)/1.4 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--muted);
}
.meter.is-over { color: var(--danger); font-weight: 700; }

/* Dropzone */
.dropzone {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: var(--s1);
  min-height: 15rem; padding: var(--s5);
  background: var(--raised);
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-m);
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
@media (max-width: 52rem) { .dropzone { min-height: 9rem; } }
.dropzone:hover { border-color: var(--trace); background: var(--trace-tint); }
.dropzone:active { background: var(--trace-tint); border-style: solid; }
.dropzone.is-over { border-color: var(--trace); border-style: solid; background: var(--trace-tint); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone-icon { width: 32px; height: 32px; color: var(--trace); margin-bottom: var(--s2); transition: transform var(--fast) var(--ease); }
.dropzone:hover .dropzone-icon, .dropzone.is-over .dropzone-icon { transform: translateY(-2px); }
.dropzone-title { font-weight: 700; font-size: var(--fs-3); color: var(--text); min-width: 11ch; }
.dropzone-sub { font-size: var(--fs-2); color: var(--muted); }
.dropzone .hint { margin-top: var(--s3); max-width: 26ch; }

/* Chosen file */
.file-chip {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s4);
  background: var(--trace-tint);
  border: 1px solid var(--border);
  border-left: 4px solid var(--trace);
  border-radius: var(--r-m);
}
.file-chip[hidden] { display: none; }
.file-chip-icon { width: 24px; height: 24px; color: var(--trace); flex: none; }
.file-name {
  flex: 1 1 10rem; min-width: 0;
  font: 600 var(--fs-2)/1.3 var(--font-mono); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-size { font: var(--fs-1)/1.3 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Buttons ---------- */
.actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s2);
  margin: var(--s5) 0 var(--s3);
}
.actions-hint { margin-left: auto; font-size: var(--fs-2); color: var(--muted); }
@media (max-width: 52rem) {
  .actions .btn.btn-primary { flex: 1 1 100%; }
  .actions .btn-secondary, .actions .btn-quiet { flex: 1 1 0; }
  .actions-hint { margin-left: 0; flex-basis: 100%; }
}

.btn, .actions button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5);
  font: 650 var(--fs-3)/1 var(--font-ui);
  border-radius: var(--r-m);
  border: 1px solid transparent;
  background: transparent; color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active, .actions button:active { transform: translateY(1px); }
.btn[hidden], .actions button[hidden] { display: none; }

/* Variants doubled (.btn.btn-x) so they outrank the template's `.actions button` rule. */
.btn.btn-primary {
  min-height: 48px; min-width: 9.5rem; padding: 0 var(--s6);
  background: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-1);
}
.btn.btn-primary:hover { background: var(--accent-hover); }
.btn.btn-primary:active { background: var(--accent-active); }
.btn.btn-primary:disabled {
  background: var(--raised); color: var(--muted); box-shadow: none;
  border: 1px dashed var(--border-strong); cursor: not-allowed; transform: none;
}

.btn.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.btn-secondary:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-tint); }
.btn.btn-secondary:active { background: var(--accent-tint); border-color: var(--accent-active); }

.btn.btn-quiet { background: transparent; color: var(--muted); padding: 0 var(--s4); }
.btn.btn-quiet:hover { color: var(--text); background: var(--raised); }
.btn.btn-quiet:active { background: var(--border); }
.btn.btn-small { min-height: 44px; padding: 0 var(--s3); font-size: var(--fs-2); }

.btn:disabled:not(.btn-primary) { opacity: 0.55; cursor: not-allowed; }

/* ---------- Status line ---------- */
#status, .status {
  display: flex; align-items: center; gap: var(--s2);
  min-height: 1.6em; margin: 0 0 var(--s4);
  font-size: var(--fs-2); font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#status:empty { visibility: hidden; }
#status.is-busy { color: var(--text); }
#status.is-busy::before {
  content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: hh-spin 0.8s linear infinite;
}
#status.is-done { color: var(--success); }
#status.is-done::before {
  content: ""; width: 12px; height: 7px; flex: none; margin-top: -3px;
  border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(-45deg);
}
#status.is-error, #status.error { color: var(--danger); }
@keyframes hh-spin { to { transform: rotate(360deg); } }

/* ---------- Output area ---------- */
.output, #output { min-height: 14rem; }

/* Empty */
.empty {
  display: flex; align-items: center; gap: var(--s5);
  min-height: 14rem; padding: var(--s6);
  border: 1px dashed var(--border-strong); border-radius: var(--r-m);
  background: var(--raised);
}
.empty svg { width: 40px; height: 96px; flex: none; }
.empty-title { margin: 0 0 var(--s1); font-size: var(--fs-4); font-weight: 700; color: var(--text); }
.empty p { margin: 0; max-width: 56ch; color: var(--muted); font-size: var(--fs-2); }
.empty p.empty-title { color: var(--text); font-size: var(--fs-4); }
@media (max-width: 52rem) { .empty { padding: var(--s4); gap: var(--s4); } }

/* Loading phases */
.phases {
  list-style: none; margin: 0; padding: var(--s6);
  display: flex; flex-wrap: wrap; gap: var(--s3) var(--s6);
  min-height: 14rem; align-content: center;
  border: 1px solid var(--border); border-radius: var(--r-m); background: var(--raised);
}
.phases li {
  display: flex; align-items: center; gap: var(--s2); margin: 0;
  font-weight: 600; color: var(--muted);
}
.phases li::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none;
}
.phases li[aria-current="step"] { color: var(--text); }
.phases li[aria-current="step"]::before { border-color: var(--accent); background: var(--accent); animation: hh-pulse 1.2s ease-in-out infinite; }
.phases li.is-done { color: var(--success); }
.phases li.is-done::before {
  width: 10px; height: 5px; border-radius: 0; border-width: 0 0 2.5px 2.5px; border-color: var(--success);
  transform: rotate(-45deg); margin: 0 1px 3px;
}
@keyframes hh-pulse { 50% { opacity: 0.45; } }

/* Error and notices */
.notice {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s3);
  padding: var(--s5);
  border-radius: var(--r-m);
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--raised);
  animation: hh-rise 180ms var(--ease) both;
}
.notice > svg { grid-row: 1 / span 3; width: 24px; height: 24px; margin-top: 2px; }
.notice p { margin: 0; max-width: 64ch; overflow-wrap: anywhere; }
.notice-title { font-weight: 700; font-size: var(--fs-4); line-height: 1.3; }
.notice-fix { font-weight: 600; margin-top: var(--s2) !important; }
.notice-error { border-left-color: var(--danger); background: var(--danger-tint); }
.notice-error > svg, .notice-error .notice-title { color: var(--danger); }
.notice-warning { border-left-color: var(--warning-edge); background: var(--warning-tint); }
.notice-warning .notice-title { color: var(--warning); }

/* ---------- Result ---------- */
.result {
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  animation: hh-rise 180ms var(--ease) both;
}
.result:focus { outline: none; }
.result:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@keyframes hh-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.result-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s3) var(--s5);
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--border);
}
.result-head > div { min-width: 0; flex: 1 1 24rem; }
.result-head h2 { margin: 0 0 var(--s2); font-size: var(--fs-5); }
.join { margin: 0; font-size: var(--fs-2); font-weight: 600; color: var(--text); }
.join-id {
  display: inline-block; margin-left: var(--s1); padding: 2px var(--s2);
  font: 500 var(--fs-1)/1.5 var(--font-mono); color: var(--accent-text);
  background: var(--accent-tint); border-radius: var(--r-s);
  overflow-wrap: anywhere; word-break: break-all;
}

.tally {
  display: flex; flex-wrap: wrap; gap: var(--s4) var(--s7);
  margin: 0; padding: var(--s4) var(--s5);
  background: var(--raised); border-bottom: 1px solid var(--border);
}
.tally > div { display: flex; flex-direction: column-reverse; gap: 2px; }
.tally dt, .tally .tally-label {
  font-size: var(--fs-1); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.tally dd, .tally .tally-figure {
  margin: 0; font: 650 var(--fs-5)/1.15 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text);
}
.tally .is-hop dd, .tally .is-hop .tally-figure { color: var(--accent-text); }
.tally .is-trace dd, .tally .is-trace .tally-figure { color: var(--trace-text); }

.legend {
  display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5);
  margin: 0; padding: var(--s3) var(--s5) 0; list-style: none;
  font-size: var(--fs-2); font-weight: 600;
}
.legend li { display: flex; align-items: center; gap: var(--s2); margin: 0; }
.legend .badge { width: 12px; height: 12px; }

.gap-note {
  display: flex; gap: var(--s2); align-items: flex-start;
  margin: var(--s2) var(--s5) var(--s4); max-width: 70ch;
  font-size: var(--fs-2); line-height: 1.5; color: var(--muted);
}
.gap-note svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--muted); }

/* Timeline table */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
#output table.timeline, .timeline {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-2); font-variant-numeric: tabular-nums;
}
.timeline thead th {
  position: sticky; top: 0; z-index: 1;
  padding: var(--s3) var(--s3);
  background: var(--raised);
  border-bottom: 1px solid var(--border-strong);
  font-size: var(--fs-1); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text); text-align: left; vertical-align: bottom; line-height: 1.3;
}
.timeline thead th:last-child { text-align: right; }
#output .timeline td, .timeline td {
  padding: var(--s3) var(--s3);
  border-bottom: 1px solid var(--border);
  vertical-align: top; text-align: left; line-height: 1.45;
}
.timeline tbody tr { transition: background-color var(--fast) var(--ease); }
.timeline tbody tr:hover { background: var(--raised); }
.timeline tbody tr:last-child td { border-bottom: 0; }

.timeline td:nth-child(2) { font-family: var(--font-mono); font-size: 14px; white-space: nowrap; }
.timeline .raw { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: var(--fs-1); color: var(--muted); white-space: normal; overflow-wrap: anywhere; }
.timeline .obs { font-family: var(--font-mono); font-size: 14px; overflow-wrap: anywhere; max-width: 46ch; }
.timeline .obs strong, .timeline .event { font-weight: 700; color: var(--trace-text); }
.timeline .unspecified { font-family: var(--font-ui); font-style: italic; color: var(--muted); }
.timeline .recipient { font-family: var(--font-mono); font-size: 14px; overflow-wrap: anywhere; }
.timeline .none { color: var(--muted); }

/* Gap column */
.timeline td.gap, .timeline td:last-child { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.gap-human { display: block; font-family: var(--font-ui); font-size: var(--fs-1); color: var(--muted); }
.timeline td.gap-max {
  background: var(--warning-tint);
  box-shadow: inset 3px 0 0 var(--warning-edge);
  color: var(--warning); font-weight: 700;
}
.gap-max-label {
  display: block; font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--warning);
}
.timeline td.gap-max .gap-human { color: var(--warning); font-weight: 500; }

/* Source chips */
.src {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 2px var(--s2); border-radius: 999px;
  font-size: var(--fs-1); font-weight: 700;
}
.src::before { content: ""; width: 9px; height: 9px; flex: none; }
.src-hop { color: var(--accent-text); background: var(--accent-tint); }
.src-hop::before { border: 2px solid var(--accent); border-radius: 50%; width: 5px; height: 5px; }
.src-trace { color: var(--trace-text); background: var(--trace-tint); }
.src-trace::before { background: var(--trace); border-radius: 2px; }

/* Signature: the two-lane rail */
.timeline th:first-child, .timeline td.rail, #output .timeline td.rail { width: 44px; min-width: 44px; padding: 0; }
.timeline td.rail { position: relative; border-bottom-color: transparent; }
.timeline td.rail::before {         /* the continuous hairline */
  content: ""; position: absolute; top: 0; bottom: -1px; left: 50%;
  width: 2px; margin-left: -1px; background: var(--border-strong);
}
.timeline tbody tr:first-child td.rail::before { top: 22px; }
.timeline tbody tr:last-child td.rail::before { bottom: calc(100% - 22px); }
.timeline td.rail::after {          /* the marker */
  content: ""; position: absolute; top: 16px; width: 12px; height: 12px; box-sizing: border-box;
}
.row-hop td.rail::after { left: 8px; border: 3px solid var(--accent); border-radius: 50%; background: var(--surface); }
.row-trace td.rail::after { right: 8px; background: var(--trace); border-radius: 3px; }
.is-untimed td.rail::before { background: repeating-linear-gradient(to bottom, var(--border-strong) 0 4px, transparent 4px 8px); }
.is-untimed td.rail::after { opacity: 0.6; }
.is-untimed td:nth-child(2) { font-family: var(--font-ui); font-weight: 600; color: var(--muted); }

.timeline tr.divider td {
  padding: var(--s4) var(--s3) var(--s2);
  background: var(--raised);
  font-size: var(--fs-1); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--border-strong);
}

/* Backward clock */
.has-anomaly td { background: var(--warning-tint); }
.has-anomaly td.rail::after { box-shadow: 0 0 0 3px var(--warning-tint), 0 0 0 5px var(--warning-edge); }
.anomaly {
  display: flex; gap: 6px; align-items: flex-start;
  margin-top: var(--s2); font-family: var(--font-ui); font-size: var(--fs-1); font-weight: 650; line-height: 1.4;
  color: var(--warning);
}
.anomaly svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* Phone: rows become cards; the rail becomes the left edge */
@media (max-width: 52rem) {
  .table-wrap { overflow: visible; }
  .timeline, .timeline tbody, .timeline tr, .timeline td { display: block; width: auto; }
  .timeline thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .timeline tbody tr {
    position: relative; padding: var(--s3) var(--s4) var(--s3) var(--s5);
    border-bottom: 1px solid var(--border);
  }
  .timeline tbody tr.row-hop { box-shadow: inset 4px 0 0 var(--accent); }
  .timeline tbody tr.row-trace { box-shadow: inset 4px 0 0 var(--trace); }
  #output .timeline td, .timeline td { padding: var(--s1) 0; border: 0; text-align: left; white-space: normal; }
  .timeline td.rail { display: none; }
  .timeline td[data-label]::before {
    content: attr(data-label); display: block;
    font-family: var(--font-ui); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  }
  .timeline td.gap, .timeline td:last-child { text-align: left; }
  .timeline td.gap-max { padding: var(--s2) var(--s3); border-radius: var(--r-s); }
  .timeline .obs { max-width: none; }
  .timeline tr.divider { padding: var(--s3) var(--s4); background: var(--raised); }
  .timeline tr.divider td::before { content: none; }
  .result-head, .tally { padding-inline: var(--s4); }
  .legend { padding-inline: var(--s4); }
  .gap-note { margin-inline: var(--s4); }
}

/* ---------- Template parts, restyled not resized ---------- */
.ad-slot {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
}
.ad-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); opacity: 1; }
.house-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-m);
  transition: border-color var(--fast) var(--ease);
}
.house-card:hover { border-color: var(--accent); }
.house-card strong { color: var(--accent-text); }
.house-card span { color: var(--muted); }

.consent {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-l);
  box-shadow: var(--shadow-2);
}
.consent button {
  border: 1px solid var(--border-strong); border-radius: var(--r-m);
  background: var(--surface); color: var(--text); font-weight: 600;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.consent button:hover { border-color: var(--accent); background: var(--accent-tint); }
.consent button:active { background: var(--accent-tint); border-color: var(--accent-active); }

footer {
  margin-top: var(--s8);
  border-top: 1px solid var(--border);
  padding-block: var(--s5) var(--s6);
  color: var(--muted); font-size: var(--fs-2); opacity: 1;
}

/* ---------- Motion off ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
