:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --soft: #f1f4f8;
  --text: #101318;
  --muted: #657181;
  --line: #e1e6ee;
  --green: #00a676;
  --blue: #1769e0;
  --ink: #172033;
  --warn: #b15d00;
  --bad: #bf1d2d;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.12);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  overflow: hidden;
  height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% -4%, rgba(0, 166, 118, 0.17), transparent 36%),
    radial-gradient(circle at 94% 8%, rgba(23, 105, 224, 0.13), transparent 30%),
    var(--bg);
  color: var(--text);
}

button {
  font: inherit;
  touch-action: manipulation;
}

.shell {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  width: min(560px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 3px;
  font-size: clamp(2rem, 10vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.route-line {
  overflow: hidden;
  max-width: 100%;
  margin: 0;
  color: var(--ink);
  font-size: clamp(0.82rem, 3.5vw, 1rem);
  font-weight: 820;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  margin-bottom: 0;
  font-size: 0.98rem;
}

.status {
  display: grid;
  place-items: center;
  min-width: 64px;
  min-height: 34px;
  border: 1px solid rgba(225, 230, 238, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  padding: 6px 8px;
  font-size: 0.78rem;
  font-weight: 780;
  backdrop-filter: blur(18px);
}

.hero-panel {
  overflow: hidden;
  min-height: 0;
  border: 1px solid rgba(225, 230, 238, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 8px;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.segmented button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  background: var(--soft);
  color: var(--blue);
  font-size: 1.22rem;
  transition: background 160ms ease, color 160ms ease, opacity 160ms ease;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button.is-loading {
  background: #dff8f0;
  color: var(--green);
  animation: pulse 900ms ease-in-out infinite;
}

.location-button {
  font-size: 1.18rem;
}

.icon-button:disabled {
  opacity: 0.88;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 12px 8px;
}

.segmented button {
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 9px;
  font-size: 0.9rem;
}

.segmented button.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), #008f9a);
  color: #fff;
  box-shadow: 0 10px 24px rgba(0, 166, 118, 0.24);
}

.state {
  min-height: 22px;
  color: var(--muted);
  padding: 2px 12px 6px;
  font-size: 0.84rem;
}

.state:empty {
  display: none;
}

.state.error {
  color: var(--bad);
  font-weight: 800;
}

.departure-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.departure-card {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 68px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.departure-card:last-child {
  border-bottom: 0;
}

.departure-card.has-warning {
  background: #fff8ec;
}

.line-badge {
  display: grid;
  place-items: center;
  width: 46px;
  min-height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), #0a3f9f);
  color: #fff;
  font-size: 1.08rem;
  font-weight: 950;
  box-shadow: 0 8px 16px rgba(23, 105, 224, 0.2);
}

.destination {
  overflow: hidden;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.countdown {
  display: grid;
  justify-items: end;
  gap: 2px;
  min-width: 48px;
  white-space: nowrap;
  font-weight: 900;
}

.countdown span:first-child {
  color: var(--green);
  font-size: 1.1rem;
}

.delay {
  color: var(--warn);
  font-size: 0.76rem;
}

.cancelled {
  color: var(--bad);
  font-size: 0.76rem;
}

.warning-list {
  display: grid;
  gap: 2px;
  margin-top: 5px;
  color: #8a4b00;
  font-size: 0.76rem;
  font-weight: 760;
}

.warning-list div::before {
  content: "!";
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-right: 5px;
  border-radius: 50%;
  background: #ffc761;
  color: #261600;
  font-size: 0.68rem;
  font-weight: 950;
}

.noscript {
  margin: 14px;
  color: var(--bad);
  font-weight: 850;
}

.loading-bar {
  position: fixed;
  right: 12px;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 12px;
  z-index: 10;
  display: grid;
  place-items: center;
  min-height: 26px;
  border-radius: 8px;
  background: rgba(23, 32, 51, 0.9);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.loading-bar.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(0, 166, 118, 0.34);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(0, 166, 118, 0);
  }
}

@media (max-width: 380px) {
  .shell {
    padding-left: 9px;
    padding-right: 9px;
  }

  h1 {
    font-size: 2rem;
  }

  .route-line {
    font-size: 0.8rem;
  }

  .departure-card {
    grid-template-columns: 48px 1fr auto;
    min-height: 66px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .line-badge {
    width: 42px;
  }
}
