:root {
  --bg-primary: #f4f4f5;
  --bg-secondary: #fff;
  --bg-tertiary: #e5e7eb;
  --text-primary: #111;
  --text-secondary: #555;
  --text-tertiary: #777;
  --text-muted: #888;
  --border-light: #d1d5db;
  --border-subtle: #f0f0f0;
  --border-muted: #ddd;
  --header-bg: #003688;
  --header-nav-bg: #002a6e;
  --accent-red: #DC241F;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --error-border: #fca5a5;
  --success-bg: #f0fdf4;
  --success-text: #166534;
  --success-border: #bbf7d0;
  --warning-bg: #fff7ed;
  --warning-text: #9a3412;
  --warning-border: #fed7aa;
  --info-bg: #eff6ff;
  --info-text: #1d4ed8;
  --info-border: #bfdbfe;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --danger-border: #fecaca;
}

:root.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #444;
  --text-primary: #e5e5e5;
  --text-secondary: #b0b0b0;
  --text-tertiary: #999;
  --text-muted: #777;
  --border-light: #444;
  --border-subtle: #333;
  --border-muted: #555;
  --error-bg: #4a1f1f;
  --error-text: #ff8080;
  --error-border: #6b3434;
  --success-bg: #1f3a1f;
  --success-text: #80ff80;
  --success-border: #3a5a3a;
  --warning-bg: #4a3820;
  --warning-text: #ffb366;
  --warning-border: #6b5a3a;
  --info-bg: #1f2e4a;
  --info-text: #80b3ff;
  --info-border: #3a4a6b;
  --danger-bg: #4a1f2e;
  --danger-text: #ff8080;
  --danger-border: #6b3a4a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

header {
  background: var(--header-bg);
  color: #fff;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

header .roundel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

header svg { flex-shrink: 0; }

header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
header .updated { font-size: 0.8rem; opacity: 0.75; margin-left: auto; }

nav {
  background: var(--header-nav-bg);
  display: flex;
  gap: 0.25rem;
  padding: 0 1rem;
}

nav a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.6rem 0.85rem;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

nav a:hover { color: #fff; }

nav a.active {
  color: #fff;
  border-bottom-color: var(--accent-red);
}

.dark-mode-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 1.2rem;
  padding: 0.25rem;
  margin-left: auto;
  display: flex;
  align-items: center;
}

.dark-mode-toggle:hover { opacity: 0.8; }

main { max-width: 700px; margin: 2rem auto; padding: 0 1rem; }

.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  color: var(--error-text);
  margin-bottom: 1.5rem;
}

.empty {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 8px;
  padding: 1.5rem 1.25rem;
  color: var(--success-text);
  text-align: center;
  font-size: 0.95rem;
  font-weight: 500;
}

footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

footer a { color: var(--text-muted); }

/* ── Shared pill ──────────────────────────────────── */

.pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
}

.line-swatch {
  width: 10px;
  flex-shrink: 0;
}

/* ── Index — line cards ───────────────────────────── */

.lines { display: flex; flex-direction: column; gap: 0.6rem; }

.line-card {
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  transition: box-shadow 0.2s;
}

.line-body {
  flex: 1;
  background: var(--bg-secondary);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.line-name {
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 160px;
}

.line-name .pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
}

.statuses { display: flex; flex-wrap: wrap; gap: 0.4rem; flex: 1; }

.status-badge {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 500;
}

.status-badge.good {
  background: #dcfce7;
  color: #166534;
}

.status-badge.disrupted {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.reason-trigger {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
}

.reason-popover {
  max-width: 380px;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-muted);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-primary);
}

.toggle-link {
  display: block;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  text-decoration: none;
}

.toggle-link:hover { text-decoration: underline; }

.section-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin: 1.25rem 0 0.4rem;
}

.section-heading:first-child { margin-top: 0; }

/* ── Closures — closure cards ─────────────────────── */

.closures { display: flex; flex-direction: column; gap: 0.8rem; }

.closure-card {
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.closure-body {
  flex: 1;
  background: var(--bg-secondary);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.closure-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.severity-badge {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 500;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.category-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-weight: 500;
}

.category-badge.planned {
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}

.category-badge.unplanned {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.reason {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── Journey planner ──────────────────────────────── */

.journey-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.journey-form input[type="text"] {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.journey-form input[type="text"]:focus {
  outline: none;
  border-color: var(--header-bg);
  box-shadow: 0 0 0 2px rgba(0,54,136,.15);
}

.journey-form button {
  padding: 0.5rem 1.1rem;
  background: var(--header-bg);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.journey-form button:hover { background: var(--header-nav-bg); }

.journey-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  margin-bottom: 1rem;
  overflow: hidden;
}

.journey-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: var(--header-bg);
  color: #fff;
  flex-wrap: wrap;
}

.journey-summary .time {
  font-weight: 700;
  font-size: 1rem;
}

.journey-summary .arrow { opacity: 0.7; }

.journey-summary .duration {
  margin-left: auto;
  font-size: 0.85rem;
  opacity: 0.85;
}

.legs { display: flex; flex-direction: column; }

.leg {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border-subtle);
}

.leg-mode {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 1px;
}

.leg-mode.tube     { background: #DC241F; color: #fff; }
.leg-mode.walking  { background: #6b7280; color: #fff; }
.leg-mode.dlr      { background: #00AFAD; color: #fff; }
.leg-mode.overground { background: #EE7C0E; color: #fff; }
.leg-mode.elizabeth-line { background: #7156A5; color: #fff; }
.leg-mode.bus      { background: #DC241F; color: #fff; }

.leg-detail { flex: 1; }

.leg-summary {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.45;
}

.leg-times {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 0.2rem;
}

.leg-disruption {
  font-size: 0.78rem;
  color: var(--warning-text);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* ── Arrivals board ───────────────────────────────── */

.arrivals-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.arrivals-form input[type="text"] {
  flex: 1;
  min-width: 160px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.arrivals-form input[type="text"]:focus {
  outline: none;
  border-color: var(--header-bg);
  box-shadow: 0 0 0 2px rgba(0,54,136,.15);
}

.arrivals-form select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
}

.arrivals-form select:focus {
  outline: none;
  border-color: var(--header-bg);
  box-shadow: 0 0 0 2px rgba(0,54,136,.15);
}

.arrivals-form button {
  padding: 0.5rem 1.1rem;
  background: var(--header-bg);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.arrivals-form button:hover { background: var(--header-nav-bg); }

.arrivals-stop-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.arrivals-board {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  overflow: hidden;
}

.arrival-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.arrival-row:last-child { border-bottom: none; }

.arrival-towards {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arrival-platform {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  text-align: right;
}

.arrival-due {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--header-bg);
  white-space: nowrap;
  min-width: 3.5rem;
  text-align: right;
}

.arrival-due.due-now {
  color: #dc2626;
}
