/* Palette: categorical slots 1-8 and the chrome/ink roles from the project's
   design reference. Both modes are selected, not flipped — the dark column is
   the same eight hues re-stepped for the dark surface. */

:root {
  color-scheme: light;

  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --hairline: rgba(11, 11, 11, 0.10);
  --good: #0ca30c;
  --critical: #d03b3b;
  --warning: #fab219;

  --series-ours: #2a78d6;
  --series-here: #eb6834;
  --series-tomtom: #1baf7a;
  --series-valhalla: #eda100;
  --series-osrm: #e87ba4;
  --series-mapbox: #008300;
  --series-graphhopper: #4a3aa7;
  --series-ors: #e34948;

  --radius: 8px;
  --pad: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --ink-1: #ffffff;
  --ink-2: #c3c2b7;
  --ink-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --hairline: rgba(255, 255, 255, 0.10);

  --series-ours: #3987e5;
  --series-here: #d95926;
  --series-tomtom: #199e70;
  --series-valhalla: #c98500;
  --series-osrm: #d55181;
  --series-mapbox: #008300;
  --series-graphhopper: #9085e9;
  --series-ors: #e66767;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--plane);
  color: var(--ink-1);
  font-size: 14px;
}

.shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-mark {
  width: 10px; height: 28px; border-radius: 3px;
  background: linear-gradient(180deg, var(--series-ours), var(--series-tomtom));
}
.brand h1 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { margin: 1px 0 0; font-size: 11.5px; color: var(--ink-muted); }

.query {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.field { position: relative; display: flex; flex-direction: column; gap: 3px; flex: 1 1 200px; min-width: 0; }
.field.narrow { flex: 0 0 106px; }
.field label { font-size: 11px; color: var(--ink-muted); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }

input[type="text"], input[type="number"], select, textarea {
  font: inherit;
  color: var(--ink-1);
  background: var(--plane);
  border: 1px solid var(--baseline);
  border-radius: var(--radius);
  padding: 7px 9px;
  width: 100%;
  min-width: 0;
}
.field input[type="text"] { padding-right: 30px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--series-ours);
  outline-offset: 1px;
}

.pick {
  position: absolute; right: 5px; bottom: 5px;
  width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--ink-muted); cursor: pointer; font-size: 14px; line-height: 1;
}
.pick:hover, .pick[aria-pressed="true"] { background: var(--gridline); color: var(--series-ours); }

.suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  max-height: 260px; overflow-y: auto;
}
.suggest li { padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--gridline); color: var(--ink-1); }

button { font: inherit; cursor: pointer; }
.primary {
  border: 0; border-radius: var(--radius);
  background: var(--series-ours); color: #fff;
  padding: 8px 18px; font-weight: 620; flex: 0 0 auto;
}
.primary:disabled { opacity: 0.5; cursor: progress; }
.icon-btn {
  border: 1px solid var(--baseline); border-radius: var(--radius);
  background: var(--plane); color: var(--ink-2);
  width: 34px; height: 34px; flex: 0 0 auto; font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: var(--gridline); }
.ghost {
  border: 1px solid var(--baseline); border-radius: 6px;
  background: transparent; color: var(--ink-2);
  padding: 4px 9px; font-size: 12px;
}
.ghost:hover { background: var(--gridline); color: var(--ink-1); }

/* -------------------------------------------------------------- workspace */

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) auto;
  min-height: 0;
}

.sidebar {
  overflow-y: auto;
  background: var(--surface-1);
  border-right: 1px solid var(--hairline);
}
.panel { padding: var(--pad) 14px; border-bottom: 1px solid var(--hairline); }
.panel h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-muted); margin: 0 0 9px; font-weight: 650;
}
.sub { display: block; font-size: 11.5px; color: var(--ink-muted); margin: 8px 0 4px; font-weight: 600; }
.hint { font-size: 11.5px; line-height: 1.45; color: var(--ink-muted); margin: 8px 0 0; }
.row { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.row .sub { margin: 0; }
.row input[type="number"] { width: 76px; }

.engines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.engine {
  display: grid;
  grid-template-columns: 15px 10px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 6px;
  border-radius: 6px;
}
.engine:hover { background: var(--plane); }
.engine.is-off { opacity: 0.45; }
.engine input { margin: 0; accent-color: var(--series-ours); }
.engine .swatch { width: 10px; height: 10px; border-radius: 2px; box-shadow: 0 0 0 1px var(--hairline); }
.engine .name { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.engine .stat { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.engine .stat.err { color: var(--critical); }
.engine .needs { font-size: 10.5px; color: var(--ink-muted); }

.check { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12.5px; }
.check input { accent-color: var(--series-ours); margin: 0; }

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; line-height: 1.45; resize: vertical;
}
#custom-model-error { color: var(--critical); }
.mock-only { display: none; }
.mock-only.on { display: flex; }

/* -------------------------------------------------------------------- map */

.mapwrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

.map-hint {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 5; background: var(--surface-1); color: var(--ink-2);
  padding: 5px 12px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--hairline); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
  pointer-events: none;
}
.map-hint[hidden] { display: none; }

.legend {
  position: absolute; left: 10px; bottom: 10px; z-index: 5;
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 8px 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  display: flex; flex-direction: column; gap: 4px;
  max-width: 260px;
}
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.legend-item i { width: 16px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.legend-item .lg-name { font-weight: 550; }
.legend-item .lg-val { color: var(--ink-2); font-variant-numeric: tabular-nums; margin-left: auto; }

/* ------------------------------------------------------------ native panes */

.panes {
  display: flex; flex-direction: column;
  width: 360px; min-width: 0;
  background: var(--surface-1);
  border-left: 1px solid var(--hairline);
  overflow-y: auto;
}
.panes[hidden] { display: none; }
.pane { display: flex; flex-direction: column; min-height: 300px; flex: 1 1 0; border-bottom: 1px solid var(--hairline); }
.pane[hidden] { display: none; }
.pane > header { display: flex; align-items: baseline; gap: 8px; padding: 9px 12px 7px; }
.pane h2 { font-size: 12px; margin: 0; font-weight: 650; }
.pane-summary { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-left: auto; }
.pane-link { font-size: 12px; color: var(--series-ours); margin-left: auto; }
.pane-body { flex: 1 1 auto; min-height: 220px; background: var(--gridline); }
.pane-body iframe { width: 100%; height: 100%; border: 0; display: block; }
.pane-note { font-size: 10.5px; line-height: 1.45; color: var(--ink-muted); margin: 0; padding: 7px 12px 10px; }

/* ---------------------------------------------------------------- results */

.results { background: var(--surface-1); border-top: 1px solid var(--hairline); max-height: 42vh; display: flex; flex-direction: column; }
.results[hidden] { display: none; }
.results.collapsed .table-scroll { display: none; }
.results-head { display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
.results-head h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); margin: 0; font-weight: 650; }
.baseline { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.baseline select { width: auto; padding: 4px 7px; font-size: 12px; }
.grow { flex: 1 1 auto; }

.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--gridline); white-space: nowrap; }
th { font-size: 11px; color: var(--ink-muted); font-weight: 620; position: sticky; top: 0; background: var(--surface-1); }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--plane); }
tbody tr.is-baseline { background: color-mix(in srgb, var(--series-ours) 7%, transparent); }
.cell-engine { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.cell-engine i { width: 12px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  padding: 1px 5px; border-radius: 4px;
  background: var(--warning); color: #2a2000;
}
.delta-slower { color: var(--critical); }
.delta-faster { color: var(--good); }
.muted { color: var(--ink-muted); }
td.notes { white-space: normal; max-width: 340px; font-size: 11.5px; color: var(--ink-muted); }
td.error { color: var(--critical); white-space: normal; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 100; background: var(--ink-1); color: var(--surface-1);
  padding: 9px 16px; border-radius: 999px; font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}
.toast[hidden] { display: none; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .panes { width: 300px; }
  .workspace { grid-template-columns: 260px minmax(0, 1fr) auto; }
}

@media (max-width: 900px) {
  .shell { height: auto; min-height: 100dvh; }
  .topbar { flex-wrap: wrap; }
  .query { flex-wrap: wrap; }
  .field { flex: 1 1 160px; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--hairline); max-height: none; }
  .mapwrap { height: 60vh; }
  .panes { width: auto; border-left: 0; border-top: 1px solid var(--hairline); }
  .results { max-height: none; }
}

/* MapLibre chrome, tinted to the surface */
.maplibregl-ctrl-group { background: var(--surface-1) !important; }
.maplibregl-ctrl-attrib { font-size: 10px; }
