/* 保谷駅南口 ⇔ 天神山 リアルタイムバス時刻表 — Mobile-first Transit PWA */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --header-bg: #0b2545;
  --header-text: #ffffff;
  --seibu: #0068b7;
  --seibu-soft: #e0f0ff;
  --kanto: #d93829;
  --kanto-soft: #fee9e7;
  --ok: #059669;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --delay: #dc2626;
  --delay-soft: #fee2e2;
  --sched: #475569;
  --sched-soft: #e2e8f0;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  --shadow-hero: 0 10px 28px rgba(11, 37, 69, 0.11);
  --radius: 16px;
}

[data-theme="dark"] {
  --bg: #090f1a;
  --surface: #131d2e;
  --surface-muted: #1b283e;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #26354d;
  --header-bg: #07172c;
  --seibu: #3898ff;
  --seibu-soft: rgba(56, 152, 255, 0.16);
  --kanto: #f86153;
  --kanto-soft: rgba(248, 97, 83, 0.16);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.16);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.16);
  --delay: #f87171;
  --delay-soft: rgba(248, 113, 113, 0.18);
  --sched: #94a3b8;
  --sched-soft: rgba(148, 163, 184, 0.16);
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --shadow-hero: 0 12px 30px rgba(0, 0, 0, 0.45);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Header */
.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  color: var(--header-text);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.brand-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.8);
}

.dot {
  opacity: 0.5;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.28);
}

.live-indicator.is-demo .live-dot {
  background: #fbbf24;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.28);
}

.live-indicator.is-error .live-dot {
  background: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.28);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.icon-btn-subtle {
  background: var(--surface-muted);
  color: var(--text);
}

.icon-btn.spinning .refresh-svg {
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Direction Switcher */
.direction-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 13px;
}

.dir-tab {
  border: 0;
  border-radius: 10px;
  padding: 9px 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.dir-tab.active {
  background: #ffffff;
  color: #0b2545;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.dir-main {
  font-size: 0.87rem;
  font-weight: 800;
  white-space: nowrap;
}

.dir-sub {
  font-size: 0.71rem;
  opacity: 0.82;
}

/* Main */
.main-content {
  padding: 12px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Banners */
.banner {
  border-radius: 13px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
}

.banner-demo {
  background: var(--warn-soft);
  color: #92400e;
  border: 1px solid rgba(217, 119, 6, 0.25);
}

[data-theme="dark"] .banner-demo {
  color: #fde68a;
}

.banner-warn {
  background: var(--delay-soft);
  color: #991b1b;
  border: 1px solid rgba(220, 38, 38, 0.25);
}

[data-theme="dark"] .banner-warn {
  color: #fecaca;
}

.banner-body strong {
  display: block;
  font-size: 0.83rem;
}

.banner-body p {
  margin: 2px 0 0;
  opacity: 0.9;
  font-size: 0.76rem;
}

.banner-btn {
  border: 0;
  border-radius: 9px;
  padding: 7px 11px;
  background: #0b2545;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

[data-theme="dark"] .banner-btn {
  background: #fbbf24;
  color: #0b2545;
}

/* Filter Row */
.filter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill.active {
  background: var(--header-bg);
  color: #fff;
  border-color: var(--header-bg);
}

[data-theme="dark"] .filter-pill.active {
  background: #3898ff;
  border-color: #3898ff;
  color: #07172c;
}

/* Hero Card */
.hero-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-hero);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--seibu);
}

.hero-card.op-kanto::before {
  background: var(--kanto);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.hero-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.hero-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.hero-countdown {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.countdown-prefix {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.countdown-num {
  font-size: 3.1rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.countdown-unit {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.countdown-imminent {
  font-size: 1.85rem;
  font-weight: 900;
  color: var(--ok);
  letter-spacing: -0.02em;
}

.hero-times {
  text-align: right;
}

.predicted-clock {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
}

.predicted-clock small {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 2px;
}

.scheduled-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.scheduled-sub .struck {
  text-decoration: line-through;
  opacity: 0.8;
}

/* Route Meta Row */
.route-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.route-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 3px 9px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.88rem;
  color: #fff;
  background: var(--seibu);
}

.route-badge.op-kanto {
  background: var(--kanto);
}

.op-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--seibu-soft);
  color: var(--seibu);
}

.op-pill.op-kanto {
  background: var(--kanto-soft);
  color: var(--kanto);
}

.headsign {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.dest-eta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.79rem;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border-radius: 10px;
  padding: 8px 11px;
  margin-bottom: 12px;
}

.dest-eta-row strong {
  color: var(--text);
}

/* Status Chips */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip-delay {
  background: var(--delay-soft);
  color: var(--delay);
}

.chip-sched {
  background: var(--sched-soft);
  color: var(--sched);
}

/* Visual Stop Approach Track */
.approach-box {
  border-top: 1px dashed var(--border);
  padding-top: 11px;
}

.approach-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.81rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.approach-caption .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ok);
  flex-shrink: 0;
  animation: pulse 1.8s ease-in-out infinite;
}

.approach-caption.is-static .pulse-dot {
  background: var(--text-muted);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.3); }
}

.track-stops {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  padding: 4px 2px 0;
}

.track-stops::before {
  content: "";
  position: absolute;
  top: 11px;
  left: 16px;
  right: 16px;
  height: 3px;
  background: var(--border);
  border-radius: 999px;
}

.track-node {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.node-dot {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: var(--surface);
  border: 3px solid var(--border);
  margin-bottom: 5px;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
}

.track-node.state-passed .node-dot {
  background: var(--seibu);
  border-color: var(--seibu);
}

.track-node.state-current .node-dot,
.track-node.state-approaching .node-dot {
  width: 22px;
  height: 22px;
  margin-top: -3.5px;
  margin-bottom: 1.5px;
  background: var(--ok);
  border: 2px solid #fff;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.25);
}

.track-node.role-board .node-dot {
  border-color: var(--text);
  border-width: 3.5px;
}

.node-name {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.25;
  padding: 0 2px;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.track-node.role-board .node-name {
  font-weight: 800;
  color: var(--text);
}

.track-node.role-alight .node-name {
  font-weight: 700;
  color: var(--seibu);
}

/* Upcoming List */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 2px 6px;
}

.section-header h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.section-note {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.arrival-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.arrival-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 13px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.arrival-card:active {
  transform: scale(0.99);
}

.arrival-summary {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  align-items: center;
  gap: 10px;
}

.arrival-eta-col {
  display: flex;
  flex-direction: column;
}

.eta-min {
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.15;
  color: var(--text);
}

.eta-min.is-imminent {
  color: var(--ok);
}

.eta-clock {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.eta-sched-old {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-decoration: line-through;
}

.arrival-info-col {
  min-width: 0;
}

.arrival-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.route-badge-sm {
  font-size: 0.78rem;
  min-width: 40px;
  padding: 2px 7px;
  border-radius: 6px;
}

.arrival-headsign {
  font-size: 0.85rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrival-loc {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrival-right-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.chevron {
  font-size: 0.72rem;
  color: var(--text-muted);
  transition: transform 0.18s ease;
}

.arrival-card.expanded .chevron {
  transform: rotate(180deg);
}

.arrival-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: none;
}

.arrival-card.expanded .arrival-detail {
  display: block;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* Empty & Skeleton */
.empty-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.skeleton-card {
  height: 190px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-muted) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Footer */
.app-footer {
  margin-top: 8px;
  padding: 12px 4px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.73rem;
}

.feed-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.feed-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.feed-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ok);
}

.feed-dot.err {
  background: var(--delay);
}

.footer-note {
  margin: 0;
  line-height: 1.6;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.58);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.setup-steps {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 0.85rem;
}

.setup-steps p {
  margin: 4px 0 6px;
  color: var(--text-secondary);
}

.setup-steps a {
  color: var(--seibu);
  font-weight: 700;
}

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 10px;
  margin-top: 6px;
}

.code-box code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.77rem;
  word-break: break-all;
}

.copy-btn {
  border: 0;
  border-radius: 7px;
  padding: 4px 9px;
  background: var(--header-bg);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
