:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --text: #16181a;
  --muted: #5b6168;
  --line: #d9dbdd;
  --accent: #b3261e;
  --accent-text: #ffffff;
  --ok: #1d6b3a;
  --warn-bg: #fff1c2;
  --warn-text: #4a3500;
  --error-bg: #fde2e0;
  --error-text: #7a1610;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --surface: #1c1f22;
    --text: #f1f2f3;
    --muted: #a3a9b0;
    --line: #33383d;
    --accent: #ff6b5e;
    --accent-text: #111315;
    --ok: #6fd394;
    --warn-bg: #3d3110;
    --warn-text: #ffe39a;
    --error-bg: #431b18;
    --error-text: #ffc2bc;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.top, .tabs, .banners, main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top);
}

.top h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

button { font: inherit; }

.link-button {
  min-height: 48px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

dialog {
  width: min(36rem, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h2 { margin-bottom: 8px; }
dialog label { display: block; margin-top: 14px; font-weight: 600; }
dialog input, dialog select {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
.form-error { min-height: 1.45em; margin: 12px 0 0; color: var(--error-text); }
.actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.actions button {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.actions .primary { border-color: var(--accent); background: var(--accent); color: var(--accent-text); font-weight: 700; }

main { padding-bottom: max(24px, env(safe-area-inset-bottom)); }

h2 { margin: 0; font-size: 1.15rem; line-height: 1.25; }

a { color: inherit; }

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

.banner {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-text);
}
.banner.error { background: var(--error-bg); color: var(--error-text); }
.banner.info { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }

.section-title {
  margin: 24px 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.card {
  margin: 12px 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card.next {
  padding: 18px 18px 20px;
  border: 2px solid var(--accent);
}
.card.next h2 { font-size: 1.6rem; }
.card.next .when { font-size: 1.1rem; }

.card.uncommitted:not(.next) { opacity: 0.7; }
.card.cancelled h2 { text-decoration: line-through; }

.when { margin: 0 0 4px; font-weight: 600; }
.relative { color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.tag {
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.tag.committed { border-color: var(--ok); color: var(--ok); font-weight: 600; }
.tag.cancelled { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.stops { margin: 12px 0 0; padding: 0; list-style: none; }
.stops > li + li { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.stop-name { font-weight: 600; }
.stop p { margin: 2px 0; }

.description { margin: 10px 0 0; white-space: pre-line; }

.links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; font-size: 0.95rem; }
.links a { display: inline-block; padding: 6px 0; min-height: 48px; line-height: 36px; }

details { margin-top: 8px; }
summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  margin-top: 14px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}
.card.next .nav-button { min-height: 64px; font-size: 1.3rem; }
.nav-button:active { filter: brightness(0.9); }
.card:not(.next) .nav-button { background: transparent; color: var(--accent); border: 2px solid var(--accent); }

.no-place { margin: 10px 0 0; color: var(--muted); font-style: italic; }

.tabs { display: flex; gap: 8px; }
.tabs a {
  flex: 1;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.tabs a[aria-current="page"] { border-color: var(--text); color: var(--text); }

.route, .areas ul { margin: 6px 0 0; padding-left: 1.3em; }
.route li, .areas li { margin: 4px 0; }
.areas { margin-top: 10px; }
.point-label { font-weight: 600; margin: 0; }
.point-link {
  display: inline-block;
  margin-left: 8px;
  padding: 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.notes { margin: 10px 0 0; }

.following { margin: 4px 4px 0; color: var(--muted); font-size: 0.95rem; }
details.all { margin-top: 16px; }
details.all > summary { justify-content: center; font-weight: 600; }

.origin { margin: 10px 0 0; color: var(--muted); font-size: 0.85rem; }
.assign-button { min-height: 44px; font-size: 0.9rem; }
