:root {
  --bg: #0e1418;
  --bg-elevated: #1c262e;
  --bg-panel: #161e24;
  --text: #e8eef2;
  --muted: #94a3b8;
  --accent: #2dd4bf;
  --accent-2: #14b8a6;
  --warn: #f59e0b;
  --danger: #f87171;
  --ink: #042f2e;
  --border: #2a3640;
  --track-idle: #3d4b57;
  --radius: 14px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1000px 520px at 8% -12%, rgba(20, 184, 166, 0.12), transparent), var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin-inline: auto;
}

.container.narrow {
  width: min(760px, calc(100% - 2rem));
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(14, 20, 24, 0.88);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-2);
  color: var(--ink);
  font-size: 0.8rem;
}

.brand-icon {
  flex-shrink: 0;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(45, 212, 191, 0.2);
}

.brand-text .muted {
  color: var(--muted);
  font-weight: 500;
}

.nav {
  display: flex;
  gap: 1rem;
}

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

.site-main {
  padding-block: 2rem 3rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.hero {
  padding-block: 1rem 2rem;
}

.hero-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1.2fr 0.8fr;
}

.hero-grid--single {
  grid-template-columns: 1fr;
  max-width: 42rem;
}

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--accent-2);
  font-weight: 600;
}

h1,
h2,
h3,
.brand-text {
  font-family: var(--display);
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.15;
  margin: 0.4rem 0 0.75rem;
  letter-spacing: -0.02em;
}

.lead {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 52ch;
}

.search-card {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding: 0.5rem;
  border-radius: calc(var(--radius) + 4px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.search-card input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 600 1.1rem var(--mono);
  padding: 0.85rem 1rem;
  outline: none;
}

.search-card button,
.btn,
.btn.ghost {
  border: 0;
  border-radius: 12px;
  padding: 0.8rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.search-card button,
.btn {
  background: var(--accent);
  color: var(--ink);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
  display: inline-block;
  text-decoration: none;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.chip {
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--bg-elevated);
}

.hero-panel {
  display: grid;
  gap: 0.75rem;
}

.stat {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin: 0.2rem 0;
}

.stat p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.section {
  margin-top: 2rem;
}

.train-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
}

.train-card {
  display: block;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  color: inherit;
  text-decoration: none;
}

.train-card h3 {
  margin: 0.35rem 0;
  font-size: 1.05rem;
}

.train-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge.ok {
  background: rgba(45, 212, 191, 0.14);
  color: var(--accent);
}

.badge.late {
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
}

.mono,
code.inline {
  font-family: var(--mono);
}

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

.tiny {
  font-size: 0.8rem;
  color: var(--muted);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.train-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
  white-space: nowrap;
}

.live-pill.on .dot {
  background: var(--accent-2);
}

.live-pill.off .dot {
  background: var(--muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head {
  margin-bottom: 1rem;
}

.section-head.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.section-head h2 {
  margin: 0;
}

@media (max-width: 800px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .train-head {
    flex-direction: column;
    align-items: stretch;
  }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.panel.highlight {
  background: linear-gradient(160deg, rgba(45, 212, 191, 0.1), var(--bg-panel));
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 1rem;
  margin: 0;
}

.kv div {
  display: grid;
  gap: 0.15rem;
}

.kv dt {
  font-size: 0.75rem;
  color: var(--muted);
}

.kv dd {
  margin: 0;
  font-weight: 600;
}

.position {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.coach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.coach {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.route-panel {
  position: relative;
}

.track-wrap {
  position: relative;
  padding: 0.25rem 0 0.5rem;
}

.track-spine {
  position: absolute;
  left: 11px;
  top: 0.75rem;
  bottom: 0.75rem;
  width: 18px;
  pointer-events: none;
  z-index: 0;
}

.track-bed {
  position: absolute;
  inset: 0;
}

.track-bed-done {
  clip-path: inset(0 0 calc(100% - var(--track-progress, 0%)) 0);
}

.track-rail {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--track-idle);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.track-bed-done .track-rail {
  background: linear-gradient(180deg, #0f766e, var(--accent));
}

.track-rail-left {
  left: 2px;
}

.track-rail-right {
  right: 2px;
}

.track-ties {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0,
    transparent 12px,
    rgba(90, 70, 45, 0.55) 12px,
    rgba(90, 70, 45, 0.55) 15px,
    transparent 15px,
    transparent 20px
  );
  opacity: 0.65;
  mask-image: linear-gradient(90deg, transparent, black 15%, black 85%, transparent);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 1;
}

.stop {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.75rem;
  padding: 0.55rem 0;
  min-height: 3.1rem;
}

.rail {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100%;
}

.rail i {
  display: none;
}

.rail::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  position: absolute;
  top: 0.45rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--track-idle);
  border: 2px solid var(--bg-panel);
  z-index: 2;
}

.stop.passed .rail::before {
  background: var(--accent-2);
}

.stop.upcoming .rail::before {
  background: var(--track-idle);
}

.stop.train-marker {
  border-bottom: 0;
  padding: 0.25rem 0 1rem;
}

.stop.train-marker .train-live-body {
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.28);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
}

.train-live-msg {
  margin: 0.35rem 0 0;
  color: var(--text);
  font-size: 0.95rem;
}

.live-badge {
  font-size: 0.68rem !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rail-train::before {
  display: none;
}

.train-icon {
  position: absolute;
  left: 50%;
  top: 0.45rem;
  transform: translate(-50%, -20%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-2);
  z-index: 2;
  animation: train-pulse 1.8s ease-in-out infinite;
}

.train-icon::before {
  content: "";
  position: absolute;
  inset: 6px 5px 8px;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23042f2e'%3E%3Cpath d='M4 16c0 .88.39 1.67 1 2.22V20a1 1 0 001 1h1a1 1 0 001-1v-1h8v1a1 1 0 001 1h1a1 1 0 001-1v-1.78c.61-.55 1-1.34 1-2.22V9c0-2.76-2.24-5-5-5H8C5.24 4 3 6.24 3 9v7zm3.5-9a1.5 1.5 0 100 3 1.5 1.5 0 000-3zm9 0a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM8 14h8v2H8v-2z'/%3E%3C/svg%3E");
}

@keyframes train-pulse {
  0%,
  100% {
    transform: translate(-50%, -20%) scale(1);
  }
  50% {
    transform: translate(-50%, -20%) scale(1.08);
  }
}

.stop-title {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.code-block {
  background: #0a1014;
  border-radius: 12px;
  padding: 1rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

.form-grid {
  display: grid;
  gap: 0.9rem;
}

.form-grid .field {
  display: grid;
  gap: 0.35rem;
}

.form-grid .field span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.form-grid input {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
}

.station-combobox-wrap {
  position: relative;
}

.station-combobox-wrap input {
  width: 100%;
}

.station-combobox-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  max-height: min(280px, 50vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.station-combobox-list [role="option"] {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: baseline;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}

.station-combobox-list [role="option"].active,
.station-combobox-list [role="option"]:hover {
  background: rgba(45, 212, 191, 0.12);
}

.station-combobox-code {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-2);
}

.station-combobox-name {
  font-size: 0.92rem;
  color: var(--muted);
}

.error-panel {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
  margin-top: 1rem;
}

.train-result-card h3 {
  margin: 0.3rem 0;
}

.seat-class-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.seat-link {
  display: inline-block;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--bg-elevated);
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* —— Mobile —— */
.nav-toggle {
  display: none;
}

.btn.small {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

html {
  overflow-x: hidden;
}

.board-cards {
  display: none;
}

.board-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.board-card.panel {
  margin-bottom: 0;
}

.board-time {
  margin: 0.35rem 0;
}

.board-live-link {
  margin-top: 0.65rem;
  display: inline-block;
}

@media (max-width: 768px) {
  .container,
  .container.narrow {
    width: min(1100px, calc(100% - 1.25rem));
  }

  .hero-grid--single {
    max-width: none;
  }

  .site-main {
    padding-block: 1.15rem 2rem;
  }

  .header-inner {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    min-height: 56px;
    padding-block: 0.5rem;
  }

  .brand {
    flex: 1;
    min-width: 0;
  }

  .brand-text {
    font-size: 0.95rem;
  }

  .nav-toggle {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    flex-shrink: 0;
  }

  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    position: relative;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    content: "";
    position: absolute;
    left: 0;
  }

  .nav-toggle-bars::before {
    top: -6px;
  }

  .nav-toggle-bars::after {
    top: 6px;
  }

  .site-header.nav-open .nav-toggle-bars {
    background: transparent;
  }

  .site-header.nav-open .nav-toggle-bars::before {
    top: 0;
    transform: rotate(45deg);
  }

  .site-header.nav-open .nav-toggle-bars::after {
    top: 0;
    transform: rotate(-45deg);
  }

  .nav {
    display: none;
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.35rem 0 0.25rem;
    border-top: 1px solid var(--border);
    margin-top: 0.15rem;
  }

  .site-header.nav-open .nav {
    display: flex;
  }

  .nav a {
    padding: 0.7rem 0.15rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.98rem;
    text-decoration: none;
  }

  .nav a:last-child {
    border-bottom: 0;
  }

  .search-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.65rem;
  }

  .search-card input {
    font-size: 1rem;
    padding: 0.75rem 0.85rem;
  }

  .search-card button {
    width: 100%;
    padding: 0.85rem 1rem;
  }

  .form-grid .btn {
    width: 100%;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .toolbar .btn.ghost {
    text-align: center;
    width: 100%;
  }

  .live-pill {
    white-space: normal;
    align-self: flex-start;
    max-width: 100%;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .section-head.inline {
    flex-direction: column;
    align-items: flex-start;
  }

  .train-grid {
    grid-template-columns: 1fr;
  }

  .train-card-top {
    flex-wrap: wrap;
  }

  .chip-row {
    gap: 0.4rem;
  }

  .chip {
    font-size: 0.78rem;
    padding: 0.32rem 0.55rem;
  }

  .panel {
    padding: 0.9rem;
  }

  .data-table {
    font-size: 0.8rem;
    min-width: 520px;
  }

  .table-wrap {
    margin: 0 -0.25rem;
    -webkit-overflow-scrolling: touch;
  }

  .stop {
    grid-template-columns: 36px 1fr;
    gap: 0.55rem;
  }

  .stop-body {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .train-live-msg {
    font-size: 0.88rem;
  }

  .times {
    gap: 0.35rem 0.65rem;
    font-size: 0.8rem;
  }

  .site-footer {
    font-size: 0.88rem;
    padding-bottom: 2rem;
  }

  .site-footer p {
    margin: 0 0 0.5rem;
  }

  .board-table {
    display: none;
  }

  .board-cards {
    display: grid;
    gap: 0.65rem;
  }
}