@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url(fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url(fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap; src: url(fonts/barlow-semi-condensed-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url(fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); }

/* Signal-box palette: enamel panel, dark mimic board, three signal lamps, one route colour. */
:root {
  --enamel: #DCE1DA;
  --surface: #EFF2ED;
  --ink: #1E2B33;
  --ink-2: #4E5C61;
  --rule: #B9C2BA;
  --board: #24332F;
  --board-line: #5F726B;
  --board-text: #D7DED8;
  --green: #2C8A4B;
  --green-lamp: #42B36A;
  --amber: #B97A08;
  --amber-lamp: #F0B43A;
  --red: #B03A2C;
  --red-lamp: #E8553F;
  --route: #F4F1E4;
  --cobalt: #2A5DB0;
  --condensed: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--enamel); }
body { margin: 0; color: var(--ink); font: 400 16px/1.5 "Barlow", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
a { color: var(--cobalt); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
h1, h2 { font-family: var(--condensed); font-weight: 600; letter-spacing: 0.01em; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px clamp(16px, 4vw, 40px);
       border-bottom: 1px solid var(--rule); }
.brand { display: flex; gap: 12px; align-items: center; }
.wordmark { font-family: var(--condensed); font-weight: 600; font-size: 24px; line-height: 1.1; }
.tagline { color: var(--ink-2); font-size: 14px; }
.top-links a { font-weight: 500; white-space: nowrap; }

main { max-width: 1240px; margin: 0 auto; padding: 20px clamp(16px, 4vw, 40px) 8px; }
.demo-note { margin: 0 0 16px; color: var(--ink-2); max-width: 78ch; }

/* ---------- mimic board ---------- */
.mimic { background: var(--board); color: var(--board-text); border-radius: 10px; padding: 20px 22px 16px; }
.mimic-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.mimic h1 { color: #fff; }
.last-route { margin: 0; color: var(--board-text); font-size: 15px; }
.diagram-wrap { overflow-x: auto; }
#diagram { min-width: 720px; width: 100%; height: auto; display: block; margin: 8px 0 6px; }
#diagram .track { stroke: var(--board-line); stroke-width: 4; fill: none; stroke-linecap: round; transition: stroke 250ms; }
#diagram .track.lit { stroke: var(--route); stroke-width: 5; }
#diagram .track.failed { stroke: var(--red-lamp); stroke-dasharray: 7 7; }
#diagram .node rect { fill: #2D3E39; stroke: var(--board-line); stroke-width: 1.5; }
#diagram .node.lit rect { stroke: var(--route); }
#diagram .node text, #diagram .label { fill: var(--board-text); font: 500 15px var(--condensed); }
#diagram .node .sub, #diagram .sub { fill: #9DB0A8; font: 400 12.5px "Barlow", sans-serif; }
#diagram .stub { fill: #9DB0A8; font: 600 13px var(--condensed); }
#diagram .stub.lit { fill: var(--red-lamp); }
#diagram .lamp { stroke: #0E1715; stroke-width: 2; }
#diagram .halo { fill: none; stroke-width: 2; opacity: 0; }
#diagram .halo.pulse { animation: pulse 900ms ease-out 1; }
@keyframes pulse { from { opacity: 0.9; r: 11; } to { opacity: 0; r: 26; } }
#diagram .fault { fill: var(--amber-lamp); font: 500 12.5px "Barlow", sans-serif; }
.swipe { display: none; margin: 0 0 8px; font-size: 13px; color: #B5C3BD; }
@media (max-width: 760px) { .swipe { display: block; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: #B5C3BD; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .lamp { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.legend .seg { width: 22px; height: 0; display: inline-block; border-top: 4px solid var(--route); }
.legend .seg.failed { border-top: 4px dashed var(--red-lamp); }
.lamp.closed { background: var(--green-lamp); }
.lamp.half-open { background: var(--amber-lamp); }
.lamp.open { background: var(--red-lamp); }

/* ---------- counters ---------- */
.counters { margin: 18px 0 4px; }
.counters dl { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin: 0; border: 1px solid var(--rule);
               border-radius: 8px; background: var(--surface); overflow: hidden; }
.counters div { padding: 12px 14px; border-left: 1px solid var(--rule); }
.counters div:first-child { border-left: 0; }
.counters dt { font-size: 13px; color: var(--ink-2); }
.counters dd { margin: 2px 0 0; font: 600 24px/1.2 var(--condensed); }
.counters dd small { font: 400 13px "Barlow", sans-serif; color: var(--ink-2); margin-left: 4px; }
.since { margin: 6px 2px 0; font-size: 13px; color: var(--ink-2); }

/* ---------- panels ---------- */
.desk { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 18px 20px; }
.log-panel, .code { margin-top: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hint { color: var(--ink-2); font-size: 14.5px; margin: 6px 0 14px; max-width: 70ch; }
.hint-inline { color: var(--ink-2); font-size: 13.5px; }

button { font: 600 15px var(--condensed); letter-spacing: 0.01em; border: 1px solid var(--ink); background: var(--ink); color: #fff;
         border-radius: 6px; padding: 8px 16px; cursor: pointer; }
button:hover:not(:disabled) { background: #33434C; }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: var(--surface); color: var(--ink); }
button.secondary:hover:not(:disabled) { background: #E2E8E1; }

.providers { display: grid; gap: 10px; }
.provider { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
            padding: 12px 14px; border: 1px solid var(--rule); border-radius: 8px; background: #F8FAF6; }
.provider .lamp { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0,0,0,0.18); justify-self: center; }
.provider .name { font: 600 17px var(--condensed); }
.provider .name small { font: 400 13px "Barlow", sans-serif; color: var(--ink-2); margin-left: 6px; }
.provider .state { font-size: 13.5px; color: var(--ink-2); grid-column: 2; }
.provider .state b { font-weight: 600; }
.provider .state .bad { color: var(--red); }
.provider .state .warn { color: var(--amber); }
.switch { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; grid-row: 1 / span 2; grid-column: 3; }
.switch button { background: transparent; color: var(--ink); border: 0; border-left: 1px solid var(--rule); border-radius: 0;
                 padding: 6px 10px; font-size: 14px; }
.switch button:first-child { border-left: 0; }
.switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.switch button[aria-pressed="true"].fault-btn { background: var(--red); }

.ask label { display: block; font-size: 14.5px; color: var(--ink-2); margin: 10px 0 6px; }
.ask-row { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; font: inherit; padding: 8px 12px; border: 1px solid var(--rule); border-radius: 6px; background: #fff; color: var(--ink); }
.answer { margin-top: 12px; padding: 12px 14px; border-left: 3px solid var(--cobalt); background: #fff; border-radius: 0 6px 6px 0; font-size: 15px; }
.answer .meta { display: block; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.answer.err { border-left-color: var(--red); }
.bursts { display: grid; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--rule); }
.burst { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: start; }
.burst p { margin: 0; font-size: 14px; color: var(--ink-2); }
.burst-status { min-height: 22px; margin: 12px 0 0; font-size: 14px; font-weight: 500; }

/* ---------- log ---------- */
.table-wrap { overflow-x: auto; margin: 12px -20px -18px; }
table.log { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
.log th { text-align: left; font: 600 13px var(--condensed); color: var(--ink-2); padding: 8px 12px; border-bottom: 1px solid var(--rule); background: #E6EBE5; }
.log td { padding: 8px 12px; border-bottom: 1px solid #DDE3DC; vertical-align: top; }
.log tbody tr { cursor: pointer; }
.log tbody tr:hover, .log tbody tr.selected { background: #E3EAF4; }
.log th:first-child, .log td:first-child { padding-left: 20px; }
.log th:last-child, .log td:last-child { padding-right: 20px; }
.log .num { text-align: right; white-space: nowrap; }
.log .q { max-width: 340px; }
.log .nowrap { white-space: nowrap; }
.log .empty { color: var(--ink-2); cursor: default; padding: 18px 20px; }
.hop { white-space: nowrap; }
.hop.ok { color: var(--green); font-weight: 600; }
.hop.err { color: var(--red); text-decoration: line-through; text-decoration-thickness: 1px; }
.hop.skip { color: var(--ink-2); }
.hop.cache { color: var(--cobalt); font-weight: 600; }
.status { font-weight: 600; }
.status.s429, .status.s503 { color: var(--red); }

.code p { color: var(--ink-2); font-size: 14.5px; max-width: 78ch; margin: 6px 0 12px; }
pre { margin: 0; padding: 14px 16px; background: var(--board); color: var(--board-text); border-radius: 6px; overflow-x: auto;
      font: 13.5px/1.55 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

.foot { max-width: 1240px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 36px; color: var(--ink-2); font-size: 13.5px; }
.foot p { max-width: 90ch; }

@media (max-width: 1000px) {
  .desk { grid-template-columns: minmax(0, 1fr); }
  .counters dl { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .counters div:nth-child(5) { border-left: 0; }
  .counters div:nth-child(n+5) { border-top: 1px solid var(--rule); }
}
@media (max-width: 640px) {
  .top { flex-direction: column; align-items: flex-start; }
  .counters dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .counters div:nth-child(odd) { border-left: 0; }
  .counters div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .provider { grid-template-columns: 22px minmax(0, 1fr); }
  .switch { grid-row: auto; grid-column: 1 / -1; justify-self: start; margin-top: 6px; }
  .burst { grid-template-columns: minmax(0, 1fr); }
  .mimic { padding: 16px 14px 12px; }
  .last-route { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
