:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #22201c;
  --muted: #6b665c;
  --border: #d9d4c8;
  --accent: #8a5a12;
  --ok: #2f8f4e;
  --mid: #c98a12;
  --low: #c2402e;
  --route: #2b6cd4;
  --node-roads: #8a5a12;
  --node-black: #22201c;
  --node-red: #b23a2b;
  --node-yellow: #c9a227;
  --node-safe: #3a78b5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17161a;
    --surface: #222127;
    --text: #ece8df;
    --muted: #a39e93;
    --border: #3a3842;
    --accent: #e0a94a;
    --ok: #4fbf72;
    --mid: #e2a93a;
    --low: #ec6a55;
    --route: #6aa2ff;
    --node-roads: #e0a94a;
    --node-black: #c9c4ba;
    --node-red: #ec6a55;
    --node-yellow: #e6c84f;
    --node-safe: #6aa2ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17161a;
  --surface: #222127;
  --text: #ece8df;
  --muted: #a39e93;
  --border: #3a3842;
  --accent: #e0a94a;
  --ok: #4fbf72;
  --mid: #e2a93a;
  --low: #ec6a55;
  --route: #6aa2ff;
  --node-roads: #e0a94a;
  --node-black: #c9c4ba;
  --node-red: #ec6a55;
  --node-yellow: #e6c84f;
  --node-safe: #6aa2ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}
h1 { font-size: 16px; margin: 0; letter-spacing: .02em; }
h2 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
a { color: var(--accent); }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.spacer { flex: 1; }

button, .button, select, input {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
}
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--accent); }
button[type="submit"], .button { background: var(--accent); color: var(--surface); border-color: var(--accent); }
input, select { width: 100%; }
.bar select { width: auto; }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: 0;
}
#graph { min-height: 0; }
#panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 16px;
  overflow-y: auto;
}
#panel > section:not([hidden]) ~ #p-help { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
form { display: grid; gap: 8px; }
label { display: grid; gap: 3px; color: var(--muted); font-size: 13px; }

.legend { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.sw { display: inline-block; width: 22px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.sw.ok { background: var(--ok); }
.sw.mid { background: var(--mid); }
.sw.low { background: var(--low); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.list { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 6px; }
.list li { display: flex; justify-content: space-between; gap: 8px; }
.tag { font-size: 12px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--border); white-space: nowrap; }
.left-ok { color: var(--ok); }
.left-mid { color: var(--mid); }
.left-low { color: var(--low); }
code { display: block; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 6px; margin: 4px 0 8px; font-size: 12px; }
#route-steps { padding-left: 20px; }
#route-steps li { margin: 4px 0; }

#signin {
  margin: 15vh auto 0;
  max-width: 360px;
  padding: 24px 16px;
  text-align: center;
}

#signin-password { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#signin-password input { flex: 1 1 180px; }
#signin-password p { flex-basis: 100%; margin: 0; }

@media (max-width: 760px) {
  main { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  #panel { border-left: 0; border-top: 1px solid var(--border); }
}
