:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #0f172a;
  color: #f8fafc;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}
h1 { font-size: 1.05rem; margin: 0; color: #e2e8f0; font-weight: 600; }
h2 { font-size: 0.85rem; color: #64748b; margin: 1.75rem 0 0.5rem; font-weight: 500; letter-spacing: 0.05em; }
small { color: #64748b; font-size: 0.75rem; }
.status { display: flex; align-items: center; gap: 0.5rem; }

.direction-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.875rem 0.65rem 1rem;
  background: #1e293b;
  border-radius: 999px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #cbd5e1;
}
.swap {
  background: transparent;
  color: #38bdf8;
  border: 1px solid #38bdf8;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.swap:active { transform: scale(0.97); }

.next {
  background: #1e293b;
  border-radius: 1.25rem;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 10px 30px -15px rgba(56, 189, 248, 0.4);
}
.next-mins { font-size: 1.05rem; color: #cbd5e1; }
.next-mins .big {
  font-size: 5rem;
  font-weight: 800;
  color: #38bdf8;
  margin: 0 0.25rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.next-meta { margin-top: 0.75rem; color: #e2e8f0; font-size: 0.95rem; line-height: 1.5; }
/* Source-provenance badge on each arrival. Style by reliability so realtime
   (when Phase 2 lands) naturally dominates the current timetable baseline. */
.src-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.src-badge.src-high   { background: #0ea5e9; color: #0f172a; }   /* realtime — stands out */
.src-badge.src-medium { background: #334155; color: #cbd5e1; }   /* timetable — subdued */
.src-badge.src-low    { background: #78350f; color: #fde68a; }   /* mock — warning */

/* Delay badge — only rendered when GTFS-RT supplied scheduleStatus. Sits
   next to the source badge. Semantic color: late=amber, early=cyan, on-time=muted. */
.delay-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.delay-badge.delay-on-time { background: #1e293b; color: #86efac; border: 1px solid #22c55e; }
.delay-badge.delay-late    { background: #422006; color: #fbbf24; }
.delay-badge.delay-early   { background: #164e63; color: #7dd3fc; }

.actions { margin: 0.75rem 0 0; text-align: center; }
.refresh {
  padding: 0.6rem 1.25rem;
  background: #38bdf8;
  color: #0f172a;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.refresh[disabled] { opacity: 0.5; cursor: default; }
.refresh:active:not([disabled]) { transform: scale(0.97); }

.upcoming { list-style: none; padding: 0; margin: 0; }
.upcoming li {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.875rem 1rem;
  background: #1e293b;
  border-radius: 0.75rem;
  margin-bottom: 0.5rem;
}
.upcoming li.empty { justify-content: center; color: #94a3b8; }
.upcoming .mins {
  font-weight: 700;
  font-size: 1.25rem;
  min-width: 3rem;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
}
.upcoming .mins small { color: #94a3b8; font-weight: 400; }
.upcoming .body { flex: 1; line-height: 1.4; }
.upcoming .body small { color: #94a3b8; }

footer { margin-top: 1.5rem; text-align: center; }
.warn { color: #fbbf24; }
.error { color: #f87171; }

.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #38bdf8;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

.skeleton {
  background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 0.5rem;
  display: inline-block;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line { height: 1.25rem; margin: 0.5rem auto; width: 70%; }
.skeleton-line.big { height: 3rem; width: 40%; }
.skeleton-row {
  list-style: none;
  padding: 0.875rem 1rem;
  background: #1e293b;
  border-radius: 0.75rem;
  margin-bottom: 0.5rem;
}
