:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #161925;
  --muted: #5b6476;
  --border: #e2e7f0;
  --brand: #7b1457;
  --brand-dark: #5b0d40;
  --brand-soft: #f7eaf2;
  --accent: #0f766e;
  --accent-soft: #e6f6f4;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(22, 25, 37, 0.06);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 14px 16px 18px;
}
.topbar-inner, .wrap {
  max-width: 760px;
  margin: 0 auto;
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}
.brand-link:hover { text-decoration: none; opacity: 0.92; }
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  object-fit: contain;
}
.line-pill {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
h1 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 5px 0 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.88);
}

.wrap { padding: 14px 14px 40px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.controls-grid {
  display: grid;
  gap: 12px;
}
.route-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.seg-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #f9fafc;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.seg-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.direction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f9fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.dir-endpoints {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  flex-wrap: wrap;
}
.dir-arrow { color: var(--brand); font-weight: 800; }
.swap-btn {
  appearance: none;
  border: 1px solid var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}
.swap-btn:hover { background: var(--brand); color: #fff; }

.subcontrols {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.group-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.field-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 2px;
}
.chip-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.chip-btn.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}
.date-input {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 0.85rem;
  background: #fff;
  color: var(--text);
}

.next-card {
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-soft) 100%);
  border: 1.5px solid #99d8d0;
  border-radius: var(--radius);
  padding: 15px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.next-kicker {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.next-time-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}
.next-dep {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.next-arr {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}
.next-countdown {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 8px 13px;
  border-radius: 10px;
  text-align: center;
  min-width: 132px;
}
.next-empty-btn {
  appearance: none;
  border: 0;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 9px 14px;
  border-radius: 9px;
  cursor: pointer;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.list-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}
.list-meta {
  font-size: 0.82rem;
  color: var(--muted);
}
.past-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: #f9fafc;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.train-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.train-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}
.train-row.is-next {
  border-color: var(--accent);
  background: #f4fbfa;
  box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.15);
}
.train-row.is-past {
  opacity: 0.52;
  background: #fafbfc;
}
.train-row.is-hidden { display: none; }
.t-dep {
  font-size: 1.32rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.t-mid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.t-arr {
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.t-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
.t-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.t-badge.next { background: var(--accent); color: #fff; }
.t-badge.dur { background: #eef1f6; color: var(--text); }
.t-badge.plus1 { background: var(--brand-soft); color: var(--brand); margin-left: 4px; }

.note-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f9fafc;
  border-left: 3px solid var(--brand);
  font-size: 0.85rem;
  color: var(--muted);
}
.notice-banner {
  margin-bottom: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 0.84rem;
}

.section-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
}
.route-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 8px;
}
.route-card {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfd;
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
}
.route-card.current {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
.route-card small {
  display: block;
  font-weight: 400;
  font-size: 0.77rem;
  color: var(--muted);
  margin-top: 2px;
}

.stations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}
.station-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.84rem;
}
.station-card strong { display: block; margin-bottom: 2px; }

.faq-item { border-top: 1px solid var(--border); padding: 10px 0; }
.faq-item:first-of-type { border-top: 0; padding-top: 0; }
.faq-item summary { font-weight: 600; cursor: pointer; font-size: 0.92rem; }
.faq-item p { margin: 6px 0 0; font-size: 0.86rem; color: var(--muted); }

footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 8px 14px 28px;
  max-width: 760px;
  margin: 0 auto;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

@media (max-width: 520px) {
  h1 { font-size: 1.25rem; }
  .next-dep { font-size: 1.75rem; }
  .next-countdown { width: 100%; }
  .train-row { grid-template-columns: 70px 1fr auto; padding: 10px; }
  .t-dep { font-size: 1.2rem; }
}
