:root {
  --fog: #eef2f3;
  --paper: #ffffff;
  --ink: #172033;
  --graphite: #5b6475;
  --hair: #d9e0e3;
  --signal: #3d5afe;
  --ok: #1e9e5a;
  --bad: #d64545;
  --warn: #b7791f;
  /* one colour per road, like transit lines */
  --r-fetch: #0f9d8a;
  --r-cf: #f08c00;
  --r-crew: #3d5afe;
  --r-proxy: #8f3fd8;
  --r-mobile: #d6336c;
  --r-fc: #6b7385;
  --r-api: #2b8a3e;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
  --radius-lg: 18px;
  --radius-sm: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fog); color: var(--ink); font: 16px/1.55 var(--body); font-variant-numeric: tabular-nums; }
a { color: var(--signal); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- frame ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 26px 18px; border-right: 1px solid var(--hair); background: var(--fog); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 22px/1 var(--display); letter-spacing: -0.02em; }
.spider { width: 34px; height: 34px; color: var(--ink); flex: none; }
.spider .l { transform-box: fill-box; }
.crawling .spider .l1, .crawling .spider .r2, .crawling .spider .l3, .crawling .spider .r4 { animation: step 0.42s ease-in-out infinite alternate; }
.crawling .spider .r1, .crawling .spider .l2, .crawling .spider .r3, .crawling .spider .l4 { animation: step 0.42s ease-in-out infinite alternate-reverse; }
@keyframes step { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a { color: var(--graphite); text-decoration: none; padding: 9px 12px; border-radius: var(--radius-sm); font-weight: 550; }
.rail nav a:hover { color: var(--ink); background: #e3e9eb; }
.rail nav a[aria-current="page"] { color: var(--ink); background: var(--paper); box-shadow: inset 3px 0 0 var(--signal); }
.mode { margin-top: auto; font-size: 14px; color: var(--graphite); }
.mode p { margin: 0 0 8px; }
.mode .live { color: var(--ok); font-weight: 600; }

main { padding: 40px clamp(20px, 4vw, 56px) 80px; max-width: 1240px; width: 100%; }
main:focus { outline: none; }

/* ---------- type ---------- */
h1 { font: 760 clamp(32px, 4.4vw, 54px)/1.02 var(--display); letter-spacing: -0.035em; margin: 0 0 10px; max-width: 18ch; }
h2 { font: 700 22px/1.2 var(--display); letter-spacing: -0.015em; margin: 0 0 14px; }
h3 { font: 650 17px/1.3 var(--display); margin: 0 0 6px; }
.lede { color: var(--graphite); font-size: 18px; max-width: 62ch; margin: 0 0 28px; }
.muted { color: var(--graphite); }
.small { font-size: 14px; }

/* ---------- surfaces: one big canvas, quiet lists ---------- */
.canvas { background: var(--paper); border-radius: var(--radius-lg); padding: 24px 24px 18px; border: 1px solid var(--hair); }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 36px; margin-top: 40px; }
.stack > * + * { margin-top: 12px; }

/* stats as a sentence-like row, not cards */
.stats { display: flex; flex-wrap: wrap; gap: 10px 40px; margin: 26px 0 0; padding: 0; list-style: none; }
.stats li { display: flex; flex-direction: column; }
.stats b { font: 700 30px/1.1 var(--display); letter-spacing: -0.02em; }
.stats span { color: var(--graphite); font-size: 14px; }

/* ---------- route map ---------- */
.map { width: 100%; height: auto; display: block; overflow: visible; }
.map .line { fill: none; stroke-width: 10; stroke-linecap: round; }
.map .station circle.ring { fill: var(--paper); stroke-width: 4; }
.map .station text { font: 600 14px var(--display); fill: var(--ink); }
.map .station text.count { font: 700 22px var(--display); }
.map .station text.sub { font: 500 12px var(--body); fill: var(--graphite); }
.map .station.dim { opacity: 0.32; transition: opacity 0.3s; }
.map .station.tried circle.ring { stroke-dasharray: 5 4; }
.map .station.won circle.ring { stroke-width: 7; }
.map .dot { r: 5; }
.map .x { stroke: var(--bad); stroke-width: 3; stroke-linecap: round; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--graphite); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--hair); }
.list li:last-child { border-bottom: 0; }
.chip { width: 12px; height: 12px; border-radius: 50%; }
.host { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.why { color: var(--graphite); font-size: 14px; }
.t { color: var(--graphite); font-size: 14px; text-align: right; white-space: nowrap; }
.fail .chip { background: transparent !important; border: 2px solid var(--bad); }

/* ---------- forms ---------- */
form.run { display: grid; gap: 14px; }
label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 6px; }
input[type=text], input[type=url], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper); border: 1.5px solid var(--hair); border-radius: 12px; padding: 12px 14px;
}
input:focus, textarea:focus, select:focus { border-color: var(--signal); outline: none; box-shadow: 0 0 0 4px #3d5afe22; }
textarea { min-height: 96px; resize: vertical; }
.bigfield { display: flex; gap: 10px; }
.bigfield input { font-size: 18px; padding: 15px 18px; border-radius: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center; }
.row.end { justify-content: flex-end; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; margin: 0; }
.check input { width: 18px; height: 18px; accent-color: var(--signal); }
button { font: 600 15px var(--body); border-radius: 12px; padding: 12px 20px; cursor: pointer; border: 1.5px solid transparent; }
.primary { background: var(--ink); color: #fff; }
.primary:hover { background: #26324d; }
.primary[disabled] { opacity: 0.55; cursor: progress; }
.ghost { background: transparent; color: var(--ink); border-color: var(--hair); }
.ghost:hover { border-color: var(--graphite); }
.err { color: var(--bad); font-size: 14px; min-height: 1em; margin: 6px 0 0; }

/* ---------- result ---------- */
.result { margin-top: 28px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 24px; margin: 18px 0; }
.facts div span { display: block; color: var(--graphite); font-size: 13px; }
.facts div b { font: 650 17px var(--display); word-break: break-word; }
.tabs { display: flex; gap: 6px; margin: 8px 0 10px; }
.tabs button { padding: 7px 14px; border-radius: 999px; background: transparent; border-color: var(--hair); font-size: 14px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
pre.out { background: #f6f8f9; border: 1px solid var(--hair); border-radius: 12px; padding: 16px; max-height: 460px; overflow: auto; font: 13.5px/1.55 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; word-break: break-word; margin: 0; }

/* answers & papers */
.answer { font-size: 17px; max-width: 70ch; white-space: pre-wrap; }
.answer sup a { text-decoration: none; font-weight: 700; }
.sources { margin-top: 16px; padding-left: 20px; color: var(--graphite); font-size: 14px; }
.paper { padding: 16px 0; border-bottom: 1px solid var(--hair); }
.paper h3 a { color: var(--ink); text-decoration: none; }
.paper h3 a:hover { color: var(--signal); }
.paper p { margin: 4px 0; max-width: 78ch; }
.paper .meta { color: var(--graphite); font-size: 14px; display: flex; gap: 16px; flex-wrap: wrap; }

/* watches */
.watch { display: grid; grid-template-columns: 1fr 120px 110px auto; gap: 18px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--hair); }
.watch .price { font: 700 22px var(--display); }
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.in { background: #e3f5ea; color: #13703f; }
.pill.out { background: #fbe7e7; color: #a52a2a; }
.pill.na { background: #eceff1; color: var(--graphite); }
.spark { width: 120px; height: 34px; }
.spark path { fill: none; stroke: var(--signal); stroke-width: 2; }

/* health */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-weight: 600; color: var(--graphite); font-size: 13px; padding: 8px 6px; border-bottom: 1px solid var(--hair); }
td { padding: 10px 6px; border-bottom: 1px solid var(--hair); vertical-align: top; }
.okt { color: var(--ok); font-weight: 650; }
.badt { color: var(--bad); font-weight: 650; }

.empty { color: var(--graphite); padding: 18px 0; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 15px; z-index: 20; }

dialog { border: 0; border-radius: var(--radius-lg); padding: 28px; width: min(460px, 92vw); color: var(--ink); }
dialog::backdrop { background: #17203366; }
dialog h2 { margin-bottom: 6px; }
dialog p { color: var(--graphite); margin: 0 0 18px; }

/* ---------- small screens ---------- */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--hair); }
  .rail nav { flex-direction: row; overflow-x: auto; gap: 2px; width: 100%; order: 3; }
  .rail nav a { white-space: nowrap; padding: 7px 10px; }
  .rail nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--signal); }
  .mode { margin: 0 0 0 auto; display: flex; gap: 10px; align-items: center; }
  .mode p { display: none; }
  .split { grid-template-columns: 1fr; gap: 28px; }
  .watch { grid-template-columns: 1fr auto; }
  .watch .spark { display: none; }
  .bigfield { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
