:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #14181f;
  --muted: #5c6b7a;
  --line: #e4e9ef;
  --accent: #0b57d0;
  --accent-text: #ffffff;
  --danger: #8d1d1d;
  --chip: #e8eef5;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1218;
    --card: #171d27;
    --text: #f3f6fa;
    --muted: #aeb9c7;
    --line: #2a3340;
    --accent: #9dc2ff;
    --accent-text: #071426;
    --danger: #ffb4ab;
    --chip: #243041;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
}

button { font: inherit; color: inherit; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.app {
  max-width: 40rem;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  flex: 1;
}

#clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.15rem;
}

#relocate {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  padding: 0;
}

#relocate svg { width: 22px; height: 22px; }

.subline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.radius {
  display: flex;
  background: var(--chip);
  border-radius: 12px;
  padding: 3px;
}

.radius button {
  min-height: 40px;
  min-width: 72px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-weight: 650;
  padding: 0 10px;
}

.radius button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

#accuracy {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

#compass {
  margin-left: auto;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  background: var(--chip);
  font-weight: 650;
}

#compass[hidden] { display: none; }

#status {
  margin: 6px 0 0;
  min-height: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

#status:empty { display: none; }

#actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 12px 0;
}

#actions[hidden] { display: none; }

#actions button {
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

#actions #install {
  background: var(--chip);
  color: var(--text);
  font-weight: 650;
}

#actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

#ios-install { flex: 1; }

#geo-help { flex-basis: 100%; }

main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px 0;
}

.stop {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 4px 8px 2px;
}

.stop-toggle {
  width: 100%;
  min-height: 52px;
  border: 0;
  background: transparent;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  padding: 4px 2px;
  border-radius: 10px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  padding: 0 8px 0 4px;
  border-radius: 12px;
  background: var(--chip);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
}

.arrow {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.arrow svg {
  width: 18px;
  height: 18px;
  transform: rotate(calc(var(--rot) * 1deg));
}

@media (prefers-reduced-motion: reduce) {
  .arrow svg { transition: none; }
}

.stop-name {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modes {
  display: flex;
  gap: 3px;
  color: var(--muted);
}

.modes svg, .badge-icon { width: 16px; height: 16px; display: block; }

.chev {
  width: 28px;
  text-align: center;
  font-size: 1.25rem;
  color: var(--muted);
}

.deps {
  list-style: none;
  margin: 0;
  padding: 0 2px 4px;
}

.deps li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 44px;
  border-top: 1px solid var(--line);
}

.line-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.line {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 28px;
  padding: 0 6px;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.badge-icon { width: 14px; height: 14px; }

.headsign {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.times {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.times b { font-weight: 800; }

.times span { color: var(--muted); font-weight: 650; }

.empty {
  grid-column: 1 / -1;
  color: var(--muted);
  padding: 8px 0;
}

.message { margin: 8px 4px; color: var(--muted); }
.message.error { color: var(--danger); }

footer {
  padding: 14px 12px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

footer a { color: inherit; }
footer p { margin: 0 0 6px; }

#locate[hidden],
#install[hidden],
#ios-install[hidden],
#geo-help[hidden] { display: none; }
