/* Shared look for the simulator and test host pages. No external fonts or libraries: works offline. */
:root {
  --paper: #e9ecee;
  --panel: #f7f8f9;
  --ink: #1f2a30;
  --ink-soft: #55636b;
  --rule: #c3cbd0;
  --action: #0d4e8a;        /* motorway sign blue */
  --action-ink: #ffffff;
  --fault: #c62d1f;
  --ok: #1f7a3d;
  --warn: #9a6200;
  --amber: #ffb21e;         /* LEDs only */
  --gantry: #3a4247;
  --housing: #000000;
  --focus: #f2c500;
  --radius-control: 4px;
  --radius-panel: 2px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b2328;
    --panel: #232d33;
    --ink: #e3e8eb;
    --ink-soft: #9aa8b0;
    --rule: #3b4850;
    --action: #2f7cc4;
    --fault: #ff6b5c;
    --ok: #4cc27a;
    --warn: #e0a640;
    --gantry: #2a3136;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.45 var(--font);
}

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}
.topbar h1 { font-size: 1.15rem; font-weight: 600; margin: 0; letter-spacing: .01em; }
.topbar .where { color: var(--ink-soft); font-size: .93rem; }
.topbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .2rem .7rem; border-radius: 999px;
  border: 1px solid var(--rule); font-size: .9rem; background: var(--paper);
}
.pill::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--ink-soft); }
.pill.ok::before { background: var(--ok); }
.pill.warn::before { background: var(--warn); }
.pill.bad::before { background: var(--fault); }

/* ---------- gantry band with the sign ---------- */
.gantry {
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.035) 0 2px, transparent 2px 46px),
    var(--gantry);
  padding: 1.6rem 1.25rem 1.1rem;
  border-bottom: 6px solid #59636a;
}
.sign-wrap { max-width: 980px; margin: 0 auto; }
.sign {
  position: relative;
  background: #2b3135;
  padding: 14px 54px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px #4a5257, 0 8px 18px rgba(0,0,0,.35);
}
.sign canvas { display: block; width: 100%; height: auto; background: var(--housing); border-radius: 2px; }
.lantern {
  position: absolute; width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #4b4f52, #26292b 70%);
  box-shadow: inset 0 0 0 2px #1b1d1f;
}
.lantern.lit {
  background: radial-gradient(circle at 42% 40%, #fff3c4, var(--amber) 45%, #c47800 100%);
  box-shadow: 0 0 18px 6px rgba(255,178,30,.55), inset 0 0 0 2px #8a5500;
}
.lantern.tl { left: 12px; top: 14px; }   .lantern.tr { right: 12px; top: 14px; }
.lantern.bl { left: 12px; bottom: 14px; } .lantern.br { right: 12px; bottom: 14px; }
.sign-caption {
  display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; justify-content: center;
  margin-top: .8rem; color: #dfe5e8; font-size: .93rem;
}
.sign-caption b { font-weight: 600; color: #ffffff; }

/* ---------- layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 1.1rem 1.25rem 2rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.1rem; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
section.panel {
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-panel);
  padding: .9rem 1rem 1rem;
}
section.panel + section.panel { margin-top: 1.1rem; }
.cols > div > section.panel + section.panel { margin-top: 1.1rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .6rem; }
h3 { font-size: .95rem; font-weight: 600; margin: .9rem 0 .35rem; color: var(--ink-soft); }
p.hint { color: var(--ink-soft); font-size: .9rem; margin: .2rem 0 .6rem; max-width: 70ch; }

/* ---------- controls ---------- */
button, .btn {
  font: inherit; font-size: .95rem; cursor: pointer;
  padding: .42rem .9rem; border-radius: var(--radius-control);
  border: 1px solid var(--action); background: var(--action); color: var(--action-ink);
}
button.secondary { background: transparent; color: var(--action); }
button.danger { border-color: var(--fault); background: transparent; color: var(--fault); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:hover:not(:disabled) { filter: brightness(1.08); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row + .row { margin-top: .55rem; }
label { font-size: .93rem; }
input[type=text], input[type=number], select {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: var(--radius-control); padding: .35rem .5rem;
}
input[type=number] { width: 6.5rem; }
.field { display: grid; gap: .2rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem 1rem; }
.form-grid .field > input, .form-grid .field > select { width: 100%; min-width: 0; }

/* toggle switch rows */
.switch { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .3rem 0; border-bottom: 1px solid var(--rule); }
.switch:last-child { border-bottom: 0; }
.switch input { appearance: none; width: 2.4rem; height: 1.3rem; border-radius: 1rem; background: var(--rule); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; transition: left .12s; }
.switch input:checked { background: var(--fault); }
.switch input:checked::after { left: 1.25rem; }
@media (prefers-reduced-motion: reduce) { .switch input::after { transition: none; } }

/* status line */
.bytes { font-family: var(--mono); font-size: .95rem; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 3px; font-size: .85rem; border: 1px solid currentColor; }
.badge.fault { color: var(--fault); }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; font-size: .95rem; }
dl.facts dt { color: var(--ink-soft); }
dl.facts dd { margin: 0; }

/* ---------- log ---------- */
.log {
  font-family: var(--mono); font-size: .82rem; line-height: 1.4;
  height: 300px; overflow: auto; white-space: pre; padding: .5rem .6rem;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-panel);
}
.log .other { color: var(--ink-soft); }
.log .event { color: var(--action); }
.log .bad { color: var(--fault); }
.log .good { color: var(--ok); }
.log-tools { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }

/* setup screen */
.setup { max-width: 860px; margin: 0 auto; }
.error { color: var(--fault); font-weight: 600; min-height: 1.3em; }
.hidden { display: none !important; }

/* modal */
dialog { border: 1px solid var(--rule); border-radius: var(--radius-panel); background: var(--panel); color: var(--ink); max-width: 520px; }
dialog::backdrop { background: rgba(0,0,0,.45); }

/* narrow screens: smaller lanterns so the matrix keeps its width */
@media (max-width: 600px) {
  .gantry { padding: 1rem .75rem .8rem; }
  .sign { padding: 8px 28px; }
  .lantern { width: 16px; height: 16px; }
  .lantern.tl, .lantern.bl { left: 6px; }
  .lantern.tr, .lantern.br { right: 6px; }
  .lantern.tl, .lantern.tr { top: 8px; }
  .lantern.bl, .lantern.br { bottom: 8px; }
  .topbar { padding: .6rem .75rem; }
  main { padding: .8rem .75rem 1.5rem; }
}

/* wrap long log lines; continuation lines indent past the timestamp */
.log { white-space: pre-wrap; overflow-wrap: anywhere; }
.log > div { padding-left: 14ch; text-indent: -14ch; }
