:root {
  --ground: #eef1f5; --app: #ffffff; --panel: #f6f8fb; --panel-2: #eef2f7;
  --line: #dce3ec; --ink: #151a21; --muted: #5c6673; --faint: #8b95a3;
  --accent: #e8501f; --accent-ink: #ffffff; --accent-soft: #fdeae2;
  --live: #12a257; --live-soft: #e2f5ea; --danger: #cf3b3b;
  --shadow: 0 1px 2px rgba(16,22,30,.06), 0 8px 24px rgba(16,22,30,.06);
  --tile-filter: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0b0f14; --app: #10151c; --panel: #161d26; --panel-2: #1c242f;
    --line: #273140; --ink: #e9edf3; --muted: #95a1b0; --faint: #66727f;
    --accent: #ff6434; --accent-soft: #35190f; --live: #2bc06f; --live-soft: #11291c; --danger: #f26a6a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45);
    --tile-filter: invert(1) hue-rotate(185deg) brightness(.85) contrast(.9) saturate(.75);
  }
}
:root[data-theme="dark"] {
  --ground: #0b0f14; --app: #10151c; --panel: #161d26; --panel-2: #1c242f;
  --line: #273140; --ink: #e9edf3; --muted: #95a1b0; --faint: #66727f;
  --accent: #ff6434; --accent-soft: #35190f; --live: #2bc06f; --live-soft: #11291c; --danger: #f26a6a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45);
  --tile-filter: invert(1) hue-rotate(185deg) brightness(.85) contrast(.9) saturate(.75);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}
.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  background: var(--app); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; color: var(--ink); }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.nav .spacer { margin-left: auto; }
.nav a.navlink { color: var(--muted); font-weight: 600; font-size: 14px; }
.nav a.navlink:hover { color: var(--ink); text-decoration: none; }

.wrap { max-width: 960px; margin: 0 auto; padding: 26px 20px 60px; }
.wrap.narrow { max-width: 440px; }

h1 { font-size: 26px; font-weight: 800; letter-spacing: -.3px; margin: 0 0 4px; text-wrap: balance; }
h2 { font-size: 18px; font-weight: 700; margin: 26px 0 12px; }
.sub { color: var(--muted); margin: 0 0 22px; }
.eyebrow { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--faint); font-weight: 700; }

.card { background: var(--app); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.card.pad { padding: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--app); color: var(--ink);
  font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  padding: 10px 16px; border-radius: 11px; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--panel); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 6px; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--panel); color: var(--ink); font-family: inherit; font-size: 15px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.alert { padding: 11px 14px; border-radius: 11px; font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.alert.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.between { justify-content: space-between; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--app); }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 700; font-size: 15px; }
.item .meta { font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.pill.on { background: var(--live-soft); color: var(--live); }

.linkbox { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.linkbox input { border: 0; background: transparent; padding: 0; font-size: 12.5px; }
.linkbox input:focus { outline: none; }

.empty { text-align: center; padding: 34px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }

.map { width: 100%; height: 340px; border-radius: 13px; overflow: hidden; border: 1px solid var(--line); }
.leaflet-layer img.leaflet-tile, .leaflet-tile-pane img { filter: var(--tile-filter); }
.leaflet-container { background: var(--panel-2); font-family: inherit; }

.stops-edit { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stops-edit li { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stops-edit .idx { width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.stops-edit input { flex: 1; }
.stops-edit .x { border: 0; background: transparent; color: var(--faint); cursor: pointer; font-size: 18px; padding: 0 6px; }
.edit-stop { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 5px rgba(0,0,0,.35); cursor: grab; }
.edit-stop:active { cursor: grabbing; }
.stops-edit .grip { cursor: grab; color: var(--faint); font-size: 15px; line-height: 1; user-select: none; padding: 0 2px; flex: none; }
.stops-edit .grip:active { cursor: grabbing; }
.stops-edit li.dragging { opacity: .45; }
.stops-edit li.over { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
