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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f7fa;
  min-height: 100vh;
  color: #1d3557;
}

/* Main page area sits below the sticky nav */
.page-body { padding: 20px; }

/* ---- Navigation bar (mirrors the home page) ---- */
.main-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #000000;
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.nav-logo {
  font-size: 1.8em;
  font-weight: 800;
  text-decoration: none;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-logo:hover {
  transform: translateY(-3px) scale(1.02);
  filter: drop-shadow(0 6px 12px rgba(102, 126, 234, 0.4));
}
.nav-logo .logo-icon { width: 32px; height: 28px; flex-shrink: 0; }
.nav-center {
  display: flex;
  align-items: center;
  gap: 40px;
  flex: 1;
  justify-content: center;
}
.nav-links { display: flex; gap: 32px; align-items: center; }
.nav-links a {
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  font-size: 1.05em;
  position: relative;
  padding: 10px 16px;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 2px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-links a:hover { transform: translateY(-2px); }
.nav-links a:hover::after,
.nav-links a.active::after { width: calc(100% - 32px); }
.nav-links a.active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
}

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}
.hamburger-btn:hover { background: rgba(255, 255, 255, 0.1); }
.hamburger-btn span {
  display: block;
  width: 24px;
  height: 3px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger-btn span:nth-child(1) { margin-bottom: 5px; }
.hamburger-btn span:nth-child(3) { margin-top: 5px; }
.hamburger-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 6px); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -6px); }

.mobile-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #000;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  padding: 12px 0;
}
.mobile-nav.show { display: block; animation: slideDown 0.3s ease-out; }
.mobile-nav a {
  display: block;
  padding: 14px 24px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  font-size: 1.1em;
  border-left: 4px solid transparent;
}
.mobile-nav a:hover {
  background: linear-gradient(90deg, rgba(255,255,255,0.1), transparent);
  color: #fff;
  border-left-color: rgba(255,255,255,0.8);
}
.mobile-nav a.active { border-left-color: #667eea; background: rgba(255,255,255,0.06); }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .nav-container { padding: 12px 16px; gap: 8px; }
  .nav-logo { font-size: 1.3em; gap: 6px; }
  .nav-center { display: none; }
  .hamburger-btn { display: flex; }
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 20px auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 40px 50px;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.back-link {
  display: inline-block;
  margin-bottom: 20px;
  color: #667eea;
  text-decoration: none;
  font-size: 0.95em;
  font-weight: 600;
  transition: color 0.2s;
}
.back-link:hover { color: #764ba2; text-decoration: underline; }

/* Line header card with line-colour gradient overlay */
.line-header {
  border-radius: 16px;
  padding: 28px 32px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.25);
  position: relative;
  overflow: hidden;
}
.line-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  pointer-events: none;
}
.line-header h1 {
  margin: 0 0 6px;
  font-size: 1.8em;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}
.line-header .subtitle {
  margin: 0;
  font-size: 1.05em;
  opacity: 0.92;
  font-weight: 400;
}

/* Meta info row */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 0.9em;
  color: #555;
  margin-bottom: 24px;
  padding: 14px 18px;
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #eef0f3;
}
.meta strong { color: #1d3557; font-weight: 700; }

/* Pill control groups */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.btn {
  border: 2px solid #e8e8e8;
  background: #fff;
  color: #1d3557;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn:hover {
  border-color: #667eea;
  color: #667eea;
  transform: translateY(-1px);
}
.btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.btn:focus { outline: none; box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2); }

/* Departures table */
table.departures {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid #eef0f3;
  border-radius: 16px;
  overflow: hidden;
  font-size: 0.95em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
table.departures th,
table.departures td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #eef0f3;
}
table.departures th {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  font-weight: 700;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1d3557;
}
table.departures tbody tr {
  transition: background 0.15s;
}
table.departures tbody tr:hover { background: rgba(102, 126, 234, 0.04); }
table.departures tbody tr:last-child td { border-bottom: none; }
table.departures td.time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #1d3557;
  font-size: 1.02em;
}
table.departures td.none { color: #9ca3af; font-style: italic; font-weight: 400; }

/* Approximation banner */
.approx-banner {
  margin-bottom: 20px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-left: 4px solid #f59e0b;
  border-radius: 12px;
  font-size: 0.9em;
  color: #78350f;
  line-height: 1.55;
}
.approx-banner strong { color: #78350f; }
.approx-banner em { font-style: italic; font-weight: 600; }
.approx-banner code {
  background: rgba(0,0,0,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}

/* Info notes */
.note {
  margin-top: 22px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 12px;
  font-size: 0.88em;
  color: #78350f;
  line-height: 1.55;
}
.note em { font-style: italic; font-weight: 600; }

/* Source line above CTA */
.source-line {
  margin-top: 14px;
  font-size: 0.82em;
  color: #777;
  text-align: right;
}
.source-line strong { color: #555; font-weight: 600; }

/* Bottom CTA */
.cta-card {
  margin-top: 28px;
  padding: 28px 28px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0f172a 0%, #1d3557 100%);
  color: #fff;
  text-align: center;
  box-shadow: 0 8px 24px rgba(29, 53, 87, 0.25);
}
.cta-card h2 {
  margin: 0 0 8px;
  font-size: 1.3em;
  font-weight: 800;
  color: #fff;
}
.cta-card p {
  margin: 0 0 18px;
  font-size: 0.95em;
  opacity: 0.92;
  line-height: 1.5;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 14px 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1em;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 44px;
}
.cta-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(102, 126, 234, 0.45); }
.cta-btn:active { transform: translateY(0); }

@media (max-width: 700px) {
  .cta-card { padding: 22px 18px; }
  .cta-card h2 { font-size: 1.15em; }
}

.error {
  padding: 16px 20px;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
  border-radius: 12px;
  font-weight: 500;
}

/* Line index list */
.line-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.line-list a {
  display: flex;
  align-items: center;
  padding: 16px 18px;
  border: 2px solid #eef0f3;
  border-radius: 14px;
  text-decoration: none;
  color: #1d3557;
  background: #fff;
  font-weight: 700;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}
.line-list a:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.15);
}
.line-list .swatch {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 4px;
  margin-right: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

h1.page-title {
  color: #1d3557;
  font-size: 1.8em;
  font-weight: 800;
  margin-bottom: 12px;
}
p.page-lede {
  color: #555;
  font-size: 1.05em;
  margin-bottom: 28px;
  opacity: 0.9;
}
p.footer-note {
  margin-top: 28px;
  color: #777;
  font-size: 0.85em;
}
p.footer-note code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}

/* ---- Mobile (iPhone / Android) ---- */
@media (max-width: 700px) {
  .page-body { padding: 12px; }
  .container {
    padding: 20px 16px;
    border-radius: 16px;
    margin: 12px auto;
  }
  .line-header { padding: 20px 18px; border-radius: 14px; }
  .line-header h1 { font-size: 1.35em; line-height: 1.25; }
  .line-header .subtitle { font-size: 0.95em; }

  .page-title { font-size: 1.5em; }
  .page-lede { font-size: 0.98em; }

  .meta {
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    font-size: 0.85em;
  }

  /* Stack controls into wrap-friendly rows; thumb-sized targets */
  .controls { gap: 6px; }
  .btn {
    padding: 11px 16px;
    font-size: 0.92em;
    min-height: 44px;        /* Apple HIG touch target */
    -webkit-tap-highlight-color: transparent;
  }
  .btn:hover { transform: none; }   /* hover lift is awkward on touch */
  .btn:active { transform: scale(0.97); }

  /* Table: keep two columns side-by-side; tight padding + tabular numbers */
  table.departures { font-size: 0.93em; border-radius: 12px; }
  table.departures th { font-size: 0.7em; padding: 10px 10px; }
  table.departures td { padding: 12px 10px; }
  table.departures td.time { font-size: 1em; }
  table.departures tbody tr:hover { background: transparent; }

  /* Line tile grid -> single column on phones */
  .line-list { grid-template-columns: 1fr; gap: 8px; }
  .line-list a {
    padding: 14px 16px;
    min-height: 56px;
    border-radius: 12px;
  }
  .line-list a:hover { transform: none; box-shadow: 0 2px 4px rgba(0,0,0,0.04); }

  .approx-banner, .note { font-size: 0.85em; padding: 12px 14px; }
  .back-link { margin-bottom: 14px; }
}

/* iPhone notch / Dynamic Island safe area */
@supports (padding: max(0px)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .main-nav { padding-top: env(safe-area-inset-top); }
}

/* Prevent iOS from zooming on focus of buttons (no inputs here but future-proof) */
@media (max-width: 700px) {
  input, select, textarea, button { font-size: 16px; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
