/* Smart Crossing website. Plain CSS, system fonts, light + dark. */
:root {
  --bg: #eef0ec;
  --panel: #fbfcfa;
  --fg: #1c221f;
  --muted: #5b665f;
  --line: #d3d9d3;
  --accent: #1d6f62;
  --accent-ink: #ffffff;
  --chip: #e2e7e1;
  --warn: #b4441c;
  --good: #1d7a3a;
  --pos: #2a7fd4;   /* positive activation / weight */
  --neg: #d9731a;   /* negative activation / weight */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #8a8f8c;
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --panel: #1a1f1c; --fg: #e3e8e4; --muted: #95a39a; --line: #2b332e;
    --accent: #4fbfa9; --accent-ink: #0d1412; --chip: #252c28; --warn: #f08a5d; --good: #5fcf86;
    --pos: #5aa9ff; --neg: #ff9f4a;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #8a948e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121614; --panel: #1a1f1c; --fg: #e3e8e4; --muted: #95a39a; --line: #2b332e;
  --accent: #4fbfa9; --accent-ink: #0d1412; --chip: #252c28; --warn: #f08a5d; --good: #5fcf86;
  --pos: #5aa9ff; --neg: #ff9f4a;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #8a948e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font: 16px/1.55 var(--font-ui);
  padding-inline: 16px; padding-block: 0 40px; overflow-x: hidden;
}
a { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 14px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--fg); text-decoration: none; letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.nav a:hover { color: var(--fg); background: var(--chip); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 1.35rem; margin: 34px 0 10px; letter-spacing: -0.01em; text-wrap: balance; }
h3 { font-size: 1.05rem; margin: 18px 0 6px; }
p { margin: 0 0 12px; max-width: 70ch; }
.lead { font-size: 1.12rem; color: var(--fg); max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
ul.plain { padding-left: 1.2em; margin: 0 0 12px; max-width: 70ch; }
ul.plain li { margin: 4px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 12px; margin: 12px 0; }
.cards a.card { text-decoration: none; color: var(--fg); display: block; }
.cards a.card:hover { border-color: var(--accent); }
.cards a.card b { display: block; margin-bottom: 2px; color: var(--accent); }
.note { border-left: 3px solid var(--accent); background: var(--panel); padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 12px 0; max-width: 72ch; }
.note.warn { border-left-color: var(--warn); }
footer { margin-top: 48px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- live sim */
.sim-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; margin: 14px 0; }
.sim-layout.wide-panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
@media (max-width: 900px) { .sim-layout, .sim-layout.wide-panel { grid-template-columns: minmax(0, 1fr); } }
.stage { display: grid; gap: 10px; min-width: 0; }
.canvas-box { position: relative; width: 100%; max-width: min(640px, calc(100vh - 150px)); min-width: min(100%, 300px); aspect-ratio: 1; justify-self: center; border-radius: 12px; overflow: hidden; background: #3b5640; touch-action: manipulation; }
.canvas-box canvas { display: block; width: 100%; height: 100%; cursor: pointer; }
.canvas-hint { position: absolute; left: 10px; top: 10px; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 13px; padding: 4px 9px; border-radius: 6px; pointer-events: none; transition: opacity 0.4s; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stats .stat:nth-child(n+4) { display: none; } }
.stat { background: var(--panel); padding: 7px 10px; min-width: 0; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font: 600 1.15rem/1.2 var(--font-num); font-variant-numeric: tabular-nums; }
.stat .u { font: 12px var(--font-ui); color: var(--muted); margin-left: 3px; }
.stat.bad .v { color: var(--warn); }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: center; font-size: 14px; }
button { font: inherit; cursor: pointer; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: 5px 12px; border-radius: 6px; font-size: 14px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); min-width: 84px; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 5px 9px; background: var(--panel); border-left: 1px solid var(--line); font-family: var(--font-num); font-size: 13px; cursor: pointer; }
.seg label:first-of-type { border-left: 0; }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
.clock { font: 13px var(--font-num); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 8ch; }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); font-size: 14px; cursor: pointer; }
.panel { display: grid; gap: 12px; min-width: 0; }
.group { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 10px; min-width: 0; }
.group > h3, .group-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0; font-weight: 600; }
.ctl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; font-size: 14px; }
.ctl output { font: 12px var(--font-num); color: var(--muted); font-variant-numeric: tabular-nums; }
.ctl input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 0; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.type { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 4px 8px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); font-size: 14px; }
.type:first-of-type { border-top: 0; padding-top: 0; }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 3px solid; background: transparent; }
.tname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type .row2 { grid-column: 2 / -1; display: flex; align-items: center; gap: 8px; }
.type input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.type output { font: 12px var(--font-num); color: var(--muted); width: 4ch; text-align: right; }
.type .meta { grid-column: 2 / -1; font: 12px var(--font-num); color: var(--muted); }
.legend { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: center; font-size: 14px; }
.key { display: inline-flex; gap: 4px; align-items: center; }
.carkey { width: 22px; height: 10px; border-radius: 3px; display: inline-block; border: 2px solid var(--muted); }
.lamp { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,0.35); vertical-align: -1px; }
.xmark { font: 700 15px var(--font-num); line-height: 1; }
.line-key { display: inline-block; width: 22px; height: 0; border-top: 3px solid; vertical-align: middle; }
.line-key.dash { border-top-style: dashed; }

/* ---------------------------------------------------------------- selected car panels */
.sel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sel-head .carbadge { width: 30px; height: 14px; border-radius: 4px; border: 3px solid; flex: none; }
.sel-head b { font-size: 15px; }
.fate { font-size: 13px; color: var(--muted); min-height: 1.2em; }
.fate.ok { color: var(--good); } .fate.bad { color: var(--warn); }
.obs-grid { display: grid; gap: 10px; }
.obs-group { display: grid; gap: 3px; }
.obs-group .gname { font-size: 13px; font-weight: 650; display: flex; align-items: baseline; gap: 6px; }
.obs-group .gname .n { font: 11px var(--font-num); color: var(--muted); font-weight: 400; }
.orow { display: grid; grid-template-columns: minmax(0, 1fr) 76px 64px; gap: 8px; align-items: center; font-size: 13px; }
.orow .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.orow .val { font: 12px var(--font-num); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini { position: relative; height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; }
.mini i { position: absolute; top: 0; bottom: 0; background: var(--accent); }
.mini::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: 0.6; }
.ntable { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.ntable th, .ntable td { padding: 3px 4px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ntable th:first-child, .ntable td:first-child { text-align: left; color: var(--muted); width: 44%; }
.ntable td { font-family: var(--font-num); font-size: 11.5px; }
.ntable td.none { color: var(--muted); }
.unseen { display: grid; gap: 6px; font-size: 14px; }
.unseen div { display: grid; grid-template-columns: 22px 1fr; gap: 6px; }
.unseen .x { color: var(--warn); font-weight: 700; }

/* output bars */
.outs { display: grid; gap: 14px; }
.out .top-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.out .top-row b { font-weight: 650; }
.out .phys { font: 12px var(--font-num); color: var(--muted); text-align: right; }
.bar { position: relative; height: 22px; background: var(--chip); border-radius: 6px; overflow: hidden; margin-top: 4px; }
.bar i { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 2px; }
.bar::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--fg); opacity: 0.35; }
.bar .tick { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1.5px; background: var(--fg); border-radius: 2px; }
.bar-ends { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.lampbox { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.lampbox .big { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.35); flex: none; }
canvas.hist { width: 100%; height: 120px; display: block; }

/* brain */
.brain-box { position: relative; width: 100%; }
.brain-box canvas { width: 100%; display: block; }
.tip { font: 13px var(--font-num); color: var(--muted); min-height: 1.4em; }

/* charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 12px var(--font-ui); }
.chart .axis { stroke: var(--line); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.chart .sep { stroke: var(--muted); stroke-dasharray: 3 3; opacity: 0.7; }
.chart .sep-label { font-size: 11px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; margin: 6px 0 2px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tablewrap { overflow-x: auto; max-width: 100%; }
table.data { border-collapse: collapse; font-size: 14px; min-width: 100%; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }

/* time travel */
.tt { display: grid; gap: 8px; }
.tt input[type="range"] { width: 100%; accent-color: var(--accent); }
.tt-ticks { display: flex; justify-content: space-between; font: 12px var(--font-num); color: var(--muted); }
.tt-ticks button { border: 0; background: none; color: inherit; padding: 2px; font: inherit; }
.tt-ticks button[aria-pressed="true"] { color: var(--accent); font-weight: 700; }
.tt-now { font-size: 15px; }
.tt-now b { color: var(--accent); }
.method-tabs { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* diagrams */
.diagram { width: 100%; max-width: 640px; height: auto; display: block; margin: 8px 0 14px; }
.diagram text { fill: var(--fg); font: 15px var(--font-ui); }
.diagram .sub { fill: var(--muted); font-size: 12.5px; }
.diagram .box { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.diagram .arrow { stroke: var(--accent); stroke-width: 2.5; fill: none; }
.diagram .head { fill: var(--accent); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }

.chart-wrap { position: relative; }
.chart-tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,0.12); white-space: nowrap; display: none; z-index: 2; }
.chart-tip .row { display: flex; gap: 6px; align-items: center; }
.chart-tip i { width: 10px; height: 3px; display: inline-block; }

.narrow-only { display: none; }
@media (max-width: 560px) { .wide-only { display: none; } .narrow-only { display: block; max-width: 340px; } }
