:root {
    --bg: #070b14;
    --bg-2: #0d1424;
    --panel: rgba(20, 28, 46, 0.72);
    --border: rgba(120, 150, 210, 0.18);
    --text: #e6ecf8;
    --muted: #8fa2c4;
    --accent: #4ea8ff;
    --explored: #fb923c;
    --frontier: #e879f9;   /* matches the canvas fill; brightened when the dots shrank */
    --path: #22c55e;
    --danger: #f87171;
    --ok: #34d399;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: radial-gradient(1200px 800px at 20% -10%, #16203a 0%, var(--bg) 55%);
    color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
    overflow: hidden;
}

#app { display: grid; grid-template-columns: 340px 1fr; height: 100%; }

/* ------------------------------------------------------------------ panel */
#panel {
    background: var(--panel);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-right: 1px solid var(--border);
    padding: 18px 16px 24px;
    overflow-y: auto;
}
#panel h1 { font-size: 17px; margin: 0 0 2px; letter-spacing: -0.2px; }
#panel .sub { color: var(--muted); font-size: 12px; margin-bottom: 18px; }

.group { margin-bottom: 16px; }
.group > label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--muted);
    margin-bottom: 6px;
}

select, input, button {
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: rgba(10, 16, 30, 0.8);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    width: 100%;
}
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
    font-weight: 500;
}
button:hover:not(:disabled) { background: rgba(78, 168, 255, 0.16); border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: rgba(78, 168, 255, 0.2); border-color: rgba(78, 168, 255, 0.5); }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

.hint { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* ----------------------------------------------------------------- canvas */
#stage { position: relative; overflow: hidden; }
#cv { display: block; width: 100%; height: 100%; cursor: crosshair; }

.overlay {
    position: absolute;
    background: var(--panel);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}
#metrics { top: 14px; right: 14px; min-width: 250px; font-family: var(--mono); font-size: 12px; }
#metrics .m { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
#metrics .m span:first-child { color: var(--muted); }
#metrics .m b { font-weight: 600; }

#legend { bottom: 14px; left: 14px; display: flex; gap: 14px; font-size: 12px; align-items: center; }
#legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; }

#log {
    bottom: 14px; right: 14px;
    max-width: 460px; max-height: 150px; overflow-y: auto;
    font-family: var(--mono); font-size: 11px; color: var(--muted);
    white-space: pre-wrap;
}

#results { max-height: 300px; overflow-y: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11px; }
th, td { text-align: right; padding: 3px 5px; border-bottom: 1px solid rgba(120,150,210,0.1); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--bg-2); }
td.good { color: var(--ok); }
td.bad { color: var(--danger); }
td.dim { color: var(--muted); }

#boot {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    background: var(--bg); z-index: 10;
    text-align: center;
}
#boot.hidden { display: none; }
.spinner {
    width: 34px; height: 34px; margin: 0 auto 14px;
    border: 3px solid rgba(78,168,255,0.2); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
    #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    #panel { max-height: 46vh; border-right: none; border-bottom: 1px solid var(--border); }
    #metrics, #log { display: none; }
}

/* Tile providers require visible attribution; keep it unobtrusive but present
   and always on top of the canvas. */
#attribution {
    position: absolute;
    right: 0;
    bottom: 0;
    padding: 3px 8px;
    font-size: 10px;
    color: #cbd5e8;
    background: rgba(7, 11, 20, 0.72);
    border-top-left-radius: 6px;
    pointer-events: none;
    z-index: 5;
}

/* The CH panel is the headline feature, so it gets a quiet accent rather than
   sitting in the same visual weight as every other control group. */
.group.accent {
    border: 1px solid rgba(78, 168, 255, 0.28);
    background: rgba(78, 168, 255, 0.06);
    border-radius: 10px;
    padding: 12px;
}
.group.accent > label { color: var(--accent); }

optgroup { color: var(--muted); font-style: normal; font-size: 11px; }
optgroup option { color: var(--text); font-size: 13px; }

/* Long station and place names should not stretch the sidebar. */
#panel select { text-overflow: ellipsis; }
