:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --needs_you: #f2b84b;
  --failed: #f0645c;
  --working: #4fd1a5;
  --idle: #7f9cc9;
  --on_call: #a99bdc;
  --unknown: #c9a560;
  --resting: #5c6370;
  --blueprint: #5c6370;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 84px);
}
#app { max-width: 560px; margin: 0 auto; }
h1, h2 { font-weight: 600; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 19px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
a { color: var(--idle); }
button {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; cursor: pointer;
}
button:disabled { opacity: 0.6; }

.top { padding: 16px 0 8px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.meta, .small, .legend { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.warn { color: var(--failed); font-size: 13px; margin: 6px 0 0; }

.pill, .chip { font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid currentColor; }
.chip { font-size: 11px; padding: 1px 8px; }

/* one colour per status, used by pills, chips, dots and hexes */
.status-needs_you { --c: var(--needs_you); }
.status-failed { --c: var(--failed); }
.status-working { --c: var(--working); }
.status-idle { --c: var(--idle); }
.status-on_call { --c: var(--on_call); }
.status-unknown { --c: var(--unknown); }
.status-resting { --c: var(--resting); }
.status-blueprint { --c: var(--blueprint); }
.pill, .chip { color: var(--c, var(--muted)); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }

.map { margin: 8px 0 4px; }
.hexmap { width: 100%; height: auto; display: block; overflow: visible; }
.district { cursor: pointer; outline: none; }
.district .hex { fill: var(--surface); stroke: var(--c); stroke-width: 1.5; transition: fill 0.15s; }
.district:hover .hex, .district:focus-visible .hex { fill: var(--surface-2); }
.district.status-resting .hex { stroke-opacity: 0.7; }
.district.status-blueprint .hex { fill: transparent; stroke-dasharray: 5 4; }
.district .halo { fill: none; stroke: var(--c); stroke-width: 2; opacity: 0.5; animation: pulse 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.hex-name { fill: var(--text); font-size: 13px; font-weight: 600; text-anchor: middle; }
.hex-status { fill: var(--c); font-size: 11px; text-anchor: middle; }
.district.status-resting .hex-name, .district.status-blueprint .hex-name { fill: var(--muted); }
.agent-dot { fill: var(--c); }
.agent-dot.status-working { animation: blink 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.2; transform: scale(0.98); } 50% { opacity: 0.8; transform: scale(1.03); } }
@keyframes blink { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .halo, .agent-dot { animation: none !important; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.notice { margin-top: 16px; }
.notice p { color: var(--muted); }
.back { display: inline-block; margin: 4px 0 10px; text-decoration: none; color: var(--muted); }
.district-head { margin-bottom: 12px; }
.agents { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.agent-row { display: flex; align-items: center; gap: 8px; }
.agent-row b { flex: 1; font-weight: 600; }
.reason { margin: 6px 0 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 10px 0 0; }
.metrics div { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.metrics dt { color: var(--muted); font-size: 11px; }
.metrics dd { margin: 0; font-size: 15px; font-weight: 600; }

.actions { display: flex; justify-content: center; margin: 16px 0; }

.command {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: linear-gradient(transparent, var(--bg) 30%);
}
.command input {
  display: block; width: 100%; max-width: 560px; margin: 0 auto;
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px;
}
.suggestions { max-width: 560px; margin: 0 auto 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.suggestions a { display: flex; justify-content: space-between; padding: 10px 14px; color: var(--text); text-decoration: none; border-top: 1px solid var(--border); }
.suggestions a:first-child { border-top: 0; }
.suggestions span { color: var(--muted); font-size: 13px; }
