:root {
  color-scheme: light dark;
  --primary: #2563eb;
  --primary-soft: #e5ecfd;
  --surface: #ffffff;
  --surface-muted: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.1);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
  --stop-end: #1d1d1f;
  --danger: #b42318;
  --rail: #7a3fc4;
  --rail-soft: #f0e8fa;
  --ferry: #0b7283;
  --ferry-soft: #dff2f5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #6b9bff;
    --primary-soft: #1f2f52;
    --surface: #1c1c1f;
    --surface-muted: #2a2a2e;
    --text: #f5f5f7;
    --muted: #a1a1a8;
    --line: rgba(255, 255, 255, 0.14);
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    --stop-end: #f5f5f7;
    --danger: #ff8a7a;
  --rail: #b98cff;
  --rail-soft: #35264d;
  --ferry: #3fc4d6;
  --ferry-soft: #143a42;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font: 15px/1.4 "Inter Variable", Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
}

#map { position: fixed; inset: 0; }

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 372px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 18px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }

h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
h1 span { color: var(--primary); }

button { font: inherit; color: inherit; cursor: pointer; }
.link { padding: 4px 0; border: 0; background: none; color: var(--primary); font-size: 14px; }
:is(button, input, summary):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.modes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 12px; padding: 4px; border-radius: 16px; background: var(--surface-muted); }
.mode { display: grid; justify-items: center; gap: 2px; padding: 7px 2px 6px; border: 0; border-radius: 12px; background: none; color: var(--muted); font-size: 11px; }
.mode svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mode[aria-checked="true"] { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }

.stops { display: grid; gap: 8px; }
.stop { position: relative; display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; }

.badge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--surface);
  font-size: 13px;
  font-weight: 650;
}
.badge.end { background: var(--stop-end); }

.stop input, .fields input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
  color: inherit;
  font: inherit;
}

.remove { width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 18px; }

.suggestions {
  grid-column: 2 / -1;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.suggestions li { padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.suggestions li.active, .suggestions li:hover { background: var(--primary-soft); }
.suggestions small { display: block; color: var(--muted); font-size: 12.5px; }

.stop-links { display: flex; justify-content: space-between; margin: 6px 0 2px 34px; }

.vehicle { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.vehicle summary { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; cursor: pointer; list-style: none; color: var(--muted); }
.vehicle summary::-webkit-details-marker { display: none; }
.vehicle summary strong { color: var(--text); font-weight: 550; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.fields label { font-size: 12.5px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.message { margin: 12px 0 0; color: var(--muted); }
.message.error { color: var(--danger); }
.message:empty { display: none; }

.results { display: grid; gap: 8px; margin-top: 12px; }
.results:empty { display: none; }

.option { width: 100%; padding: 14px; border: 1.5px solid var(--line); border-radius: 16px; background: none; text-align: left; }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.option-top b { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.option-top span { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tags:empty { display: none; }
.tag { padding: 2px 9px; border-radius: 999px; background: var(--surface-muted); font-size: 12px; font-weight: 600; }
.tag.fast { background: var(--primary); color: var(--surface); }
.tag.rail { background: var(--rail-soft); color: var(--rail); }
.tag.ferry { background: var(--ferry-soft); color: var(--ferry); }
.bar { display: flex; gap: 2px; height: 6px; margin-top: 8px; border-radius: 3px; overflow: hidden; }
.bar i { min-width: 5px; background: var(--primary); }
.bar i.rail { background: var(--rail); }
.bar i.ferry { background: var(--ferry); }
.option .note { display: none; margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }
.option.selected .note { display: block; }
.option dt small { display: block; font-size: 12.5px; }
.option dt b { color: var(--text); font-weight: 550; }
.option .roads { margin-top: 2px; color: var(--muted); font-size: 13.5px; }
.option dl { display: none; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; }
.option.selected dl { display: grid; }
.option dt { color: var(--muted); }
.option dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.marker { border: 3px solid var(--surface); width: 32px; height: 32px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); cursor: grab; }

@media (prefers-color-scheme: dark) {
  .maplibregl-ctrl-group { background: var(--surface); }
  .maplibregl-ctrl-group button + button { border-color: var(--line); }
  .maplibregl-ctrl-icon { filter: invert(1); }
  .maplibregl-ctrl-attrib, .maplibregl-ctrl-scale { background: rgba(28, 28, 31, 0.75) !important; color: var(--muted); border-color: var(--muted); }
}

@media (max-width: 720px) {
  .panel { top: auto; bottom: 0; left: 0; width: 100%; max-height: 62%; border-radius: 22px 22px 0 0; padding-bottom: 28px; }
}
