:root {
  --bg: #16171c;
  --panel: #1f2026;
  --card: #2a2b32;
  --card-hover: #33343c;
  --border: #3a3b44;
  --text: #ececf1;
  --muted: #9a9ba6;
  --blue: #3b7cf6;
  --blue-soft: #5b93ff;
  --red: #e5483f;
  --green: #22a55b;
  --amber: #f0b429;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }

button { font: inherit; color: inherit; cursor: pointer; }

.muted { color: var(--muted); }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 720px; margin: 0 auto; padding: 16px 16px 12px;
}
.clock {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #101116; font-size: 14px;
}
.clock svg { color: var(--amber); }
.clock.override svg { color: var(--blue-soft); }
.lang { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang button { background: none; border: 0; padding: 6px 10px; font-size: 13px; color: var(--muted); }
.lang button.active { background: var(--card); color: var(--text); }

/* ---- panel ---- */
.panel {
  max-width: 720px; margin: 0 auto 24px; padding: 20px 20px 16px;
  background: var(--panel); border-radius: 16px;
}
section + section, .message + section { margin-top: 22px; }

h2 {
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}

.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.time-ref label { color: var(--muted); }
.link-btn { background: none; border: 0; padding: 2px 0; color: var(--blue-soft); font-size: 14px; }
.link-btn[disabled] { color: var(--muted); cursor: default; }

.slider-row { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.slider-row output { min-width: 3.2em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

input[type=range] { flex: 1; height: 24px; margin: 0; background: none; -webkit-appearance: none; appearance: none; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(var(--blue), var(--blue)) 0/var(--fill, 0%) 100% no-repeat, #3a3b44; }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #3a3b44; }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--blue); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--blue); border: 0; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 0; }

.daytype { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; }
.daytype span { margin-right: 4px; }
.daytype button { background: var(--card); border: 1px solid transparent; border-radius: 999px; padding: 4px 11px; color: var(--muted); }
.daytype button.active { border-color: var(--blue); color: var(--text); }

/* ---- stop pickers ---- */
.stops { display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: end; gap: 12px; }
.field { min-width: 0; }
.field-label { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--muted); }
.ic-start { color: var(--blue-soft); }
.ic-end { color: var(--green); }

.combo { position: relative; }
.combo-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; height: 44px; padding: 0 12px;
  background: var(--card); border: 1px solid transparent; border-radius: 10px; text-align: left; font-weight: 600;
}
.combo-btn:hover { background: var(--card-hover); }
.combo-btn .value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn .placeholder { color: var(--muted); font-weight: 400; }
.combo-btn svg { width: 16px; height: 16px; color: var(--muted); }
.combo-pop {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 6px); min-width: 260px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.45);
  overflow: hidden;
}
.combo-pop input {
  width: 100%; padding: 11px 12px; border: 0; border-bottom: 1px solid var(--border);
  background: #22232a; color: var(--text); font: inherit; outline: none;
}
.combo-pop ul { list-style: none; margin: 0; padding: 4px 0; max-height: 280px; overflow-y: auto; }
.combo-pop li { padding: 8px 12px; cursor: pointer; }
.combo-pop li.active, .combo-pop li:hover { background: var(--blue); color: #fff; }
.combo-pop li.empty { color: var(--muted); cursor: default; background: none; }

.swap-btn {
  display: grid; place-items: center; width: 36px; height: 44px;
  background: none; border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
}
.swap-btn:hover { color: var(--text); }

.save-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px;
  background: var(--blue); border: 0; border-radius: 999px; color: #fff; font-weight: 600; white-space: nowrap;
}
.save-btn svg { width: 16px; height: 16px; }
.save-btn:disabled { opacity: .45; cursor: default; }

.message { margin: 12px 0 0; padding: 9px 12px; border-radius: 8px; background: rgba(240,180,41,.12); color: var(--amber); font-size: 14px; }

/* ---- favourites ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 6px 6px 6px 12px; border: 1px solid transparent; border-radius: 999px; background: var(--card); font-size: 14px;
}
.chip.active { border-color: var(--blue); color: var(--blue-soft); }
.chip .go { display: inline-flex; align-items: center; gap: 6px; min-width: 0; background: none; border: 0; padding: 0; text-align: left; }
.chip .go span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .star { width: 13px; height: 13px; fill: currentColor; stroke: none; color: var(--muted); }
.chip .remove { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.chip .remove:hover { background: var(--border); color: var(--text); }
.chip .remove svg { width: 12px; height: 12px; }

/* ---- departures ---- */
.departures { display: flex; flex-direction: column; gap: 8px; }
.dep {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; background: var(--card); border-radius: var(--radius);
}
.dep.done { opacity: .55; }
.line { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 0 1 auto; }
.badge {
  align-self: flex-start; min-width: 56px; padding: 4px 12px; border-radius: 8px;
  color: #fff; font-weight: 600; font-size: 17px; text-align: center; white-space: nowrap;
}
.badge.bus { background: var(--blue); }
.badge.trolleybus { background: var(--red); }
.badge.intercity { background: var(--green); font-size: 13px; padding: 6px 10px; }
.dir { font-size: 12px; color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.times { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px 18px; margin-left: auto; }
.time { text-align: right; }
.time b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.time small { display: block; color: var(--blue-soft); font-size: 12px; white-space: nowrap; }
.time .note { color: var(--amber); }
.none { color: var(--muted); font-size: 14px; margin-left: auto; text-align: right; }
.flag { font-size: 11px; color: var(--amber); }

.empty-state { padding: 22px 12px; text-align: center; color: var(--muted); background: var(--card); border-radius: var(--radius); }

footer { margin-top: 20px; font-size: 12px; text-align: center; }
footer a { color: var(--muted); }

/* ---- phones ---- */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px 10px; }
  .panel { margin: 0 0 16px; padding: 16px; border-radius: 0; }
  .stops { grid-template-columns: 1fr auto; }
  .stops .field:nth-of-type(1) { grid-column: 1; grid-row: 1; }
  .swap-btn { grid-column: 2; grid-row: 1 / span 2; align-self: center; height: 72px; }
  .stops .field:nth-of-type(2) { grid-column: 1; grid-row: 2; }
  .save-btn { grid-column: 1 / -1; justify-content: center; }
  .combo-pop { min-width: 0; }
  .dep { flex-wrap: wrap; }
  .times { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px 6px; width: 100%; }
  .time b { font-size: 16px; }
  .time small { font-size: 11px; }
}
