:root {
  --ink: #152022;
  --muted: #657174;
  --line: #d9e1df;
  --surface: #f7f6f0;
  --panel: #ffffff;
  --accent: #0e7c66;
  --accent-strong: #075a4b;
  --warn: #b8631d;
  --danger: #b42318;
  --sky: #dbeaf5;
  --gold: #f6d36b;
  --shadow: 0 18px 50px rgba(21, 32, 34, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.train-intro,
.confetti-layer {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
}

.train-intro {
  left: -72px;
  bottom: 22px;
  font-size: 2.8rem;
  filter: drop-shadow(0 10px 18px rgba(21, 32, 34, 0.22));
  animation: train-pass 3600ms ease-in-out 300ms both;
}

.confetti-layer {
  inset: 0;
  overflow: hidden;
}

.emoji-drop {
  position: absolute;
  top: -32px;
  left: var(--x);
  font-size: var(--size);
  animation: emoji-fall var(--duration) cubic-bezier(0.2, 0.72, 0.24, 1) forwards;
  transform: translateY(-40px) rotate(0deg);
}

@keyframes train-pass {
  0% {
    transform: translateX(0) rotate(0deg);
    opacity: 0;
  }

  12%,
  88% {
    opacity: 1;
  }

  100% {
    transform: translateX(calc(100vw + 140px)) rotate(360deg);
    opacity: 0;
  }
}

@keyframes emoji-fall {
  0% {
    opacity: 0;
    transform: translateY(-40px) rotate(-12deg);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(42vh) rotate(var(--rotate));
  }
}

@media (prefers-reduced-motion: reduce) {
  .train-intro,
  .emoji-drop {
    display: none;
  }
}

button,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.rail {
  background: #102623;
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1rem;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
}

.rail .brand p,
.rail label {
  color: #b7c6c2;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost-button,
.primary-button,
.icon-button,
.seg {
  border: 0;
  cursor: pointer;
  border-radius: 8px;
}

.nav-item {
  color: #d6e4e0;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
}

.nav-item.active {
  background: #24453f;
  color: #fff;
}

.station-picker {
  display: grid;
  gap: 12px;
}

label {
  font-size: 0.8rem;
  font-weight: 700;
}

select {
  width: 100%;
  border: 1px solid #31504a;
  border-radius: 8px;
  padding: 12px;
  color: #fff;
  background: #17332f;
}

.direction-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #17332f;
}

.service-toggle {
  width: min(360px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 auto 24px;
  padding: 4px;
  border-radius: 8px;
  background: #e7ebe9;
}

.seg {
  padding: 10px;
  color: #c9d7d3;
  background: transparent;
}

.seg.active,
.day-seg.active {
  color: #102623;
  background: var(--gold);
}

.day-seg {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.ghost-button {
  padding: 11px 13px;
  color: var(--accent-strong);
  background: #e4f2ed;
  font-weight: 700;
}

.rail .ghost-button {
  color: #fff;
  background: #31504a;
}

main {
  min-width: 0;
  padding: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.icon-button {
  min-height: 42px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.25rem;
}

.alert-strip {
  display: none;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  background: #fff3df;
  color: #5b3511;
  font-weight: 700;
}

.alert-strip.visible {
  display: block;
}

.commute-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(260px, 0.7fr);
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel,
.compact-panel,
.station-results {
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-header h3 {
  font-size: 1.25rem;
}

.status-pill,
.train-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e8f4ef;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.timeline,
.train-list,
.coffee-grid,
.schedule-list {
  display: grid;
  gap: 12px;
}

.leave-buffer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.leave-buffer span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.buffer-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(38px, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #e7ebe9;
}

.buffer-seg {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 850;
}

.buffer-seg::after {
  content: "m";
  font-weight: 750;
}

.buffer-seg.active {
  color: #102623;
  background: var(--gold);
}

.train-card {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.schedule-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.schedule-controls {
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.route-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr);
  align-items: end;
  gap: 16px;
}

.route-picker label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.route-picker select {
  min-height: 56px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #f0f2f1;
  font-size: 1.2rem;
  font-weight: 850;
}

.swap-button {
  width: 52px;
  height: 56px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 900;
}

.schedule-list {
  gap: 0;
}

.schedule-row {
  display: grid;
  grid-template-columns: 130px minmax(220px, 1fr) 170px 120px;
  align-items: center;
  gap: 20px;
  min-height: 116px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(45deg, #fbfbfb 0, #fbfbfb 8px, #f3f5f4 8px, #f3f5f4 14px);
}

.schedule-row:last-child {
  border-bottom: 0;
}

.schedule-number {
  font-size: 1.7rem;
  font-weight: 900;
}

.schedule-time {
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  font-weight: 850;
}

.schedule-duration,
.schedule-eta {
  font-size: 1.08rem;
  font-weight: 850;
}

.schedule-kind,
.schedule-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.train-time {
  font-size: 1.45rem;
  font-weight: 850;
}

.train-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.delay {
  color: var(--warn);
  font-weight: 850;
}

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

.stats {
  display: grid;
  gap: 14px;
  margin: 0;
}

.stats div {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.stats div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  gap: 18px;
  min-height: 660px;
}

#stationMap {
  min-height: 660px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.coffee-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.coffee-card h3 {
  font-size: 1.05rem;
}

.coffee-card p {
  color: var(--muted);
}

.coffee-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bites-layout {
  display: grid;
  gap: 18px;
}

.bites-hero {
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  padding: 28px;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(16, 38, 35, 0.88), rgba(16, 38, 35, 0.26)),
    url("https://images.unsplash.com/photo-1517486808906-6ca8b3f04846?auto=format&fit=crop&w=1600&q=80") center/cover;
  box-shadow: var(--shadow);
}

.bites-hero .eyebrow {
  color: #f6d36b;
}

.bites-hero h3 {
  max-width: 680px;
  margin-top: 8px;
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  line-height: 1.1;
}

.bites-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.bite-card {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.bite-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #102623;
  background: var(--gold);
  font-size: 1.2rem;
  font-weight: 900;
}

.bite-card p {
  color: var(--muted);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 14px;
    gap: 14px;
  }

  .brand p {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(5, 1fr);
  }

  .direction-toggle {
    grid-template-columns: repeat(2, 1fr);
  }

  .station-picker {
    grid-template-columns: 1fr;
  }

  main {
    padding: 18px;
  }

  .topbar {
    margin-bottom: 14px;
  }

  .topbar h2 {
    font-size: 1.45rem;
    line-height: 1.15;
  }

  .panel-header h3 {
    font-size: 1.05rem;
  }

  .commute-grid,
  .map-layout,
  .coffee-grid,
  .bites-grid,
  .route-picker {
    grid-template-columns: 1fr;
  }

  .swap-button {
    width: 100%;
  }

  .schedule-row {
    grid-template-columns: 1fr 1fr;
    min-height: 0;
    gap: 12px;
    padding: 16px;
  }

  .schedule-number {
    font-size: 1.35rem;
  }

  .schedule-time {
    font-size: 1.35rem;
  }

  .schedule-duration,
  .schedule-eta {
    font-size: 1rem;
  }

  #stationMap,
  .map-layout {
    min-height: 440px;
  }
}

@media (max-width: 620px) {
  .topbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .train-card {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }

  .leave-buffer {
    align-items: stretch;
    flex-direction: column;
  }

  .train-time {
    font-size: 1.2rem;
  }

  .schedule-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px;
  }

  .schedule-controls {
    padding: 16px;
  }

  .route-picker {
    gap: 10px;
  }

  .route-picker select {
    min-height: 48px;
    font-size: 1rem;
  }

  .service-toggle {
    margin-bottom: 16px;
  }

  .day-seg {
    min-height: 38px;
  }

  .schedule-number {
    font-size: 1.2rem;
  }

  .schedule-time {
    font-size: 1.18rem;
  }

  .schedule-kind,
  .schedule-label,
  .train-meta {
    font-size: 0.82rem;
  }

  .schedule-duration,
  .schedule-eta {
    font-size: 0.95rem;
  }

  .hero-panel,
  .compact-panel,
  .station-results {
    padding: 14px;
  }

  .bites-hero {
    min-height: 180px;
    padding: 18px;
  }

  .train-intro {
    bottom: 14px;
    font-size: 2.2rem;
  }
}
