:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #14161a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --err: #b91c1c;
  --soon: #dc2626;
  --seg-active: #ffffff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #eef0f3;
    --muted: #9aa3b0;
    --line: #272b33;
    --accent: #6ea0ff;
    --warn: #fbbf24;
    --warn-bg: #3a2e0c;
    --err: #f87171;
    --soon: #ff6b6b;
    --seg-active: #3a404c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
}

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 10px; align-items: center;
  padding: 12px 0 10px;
  background: var(--bg);
}
.seg {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--line); border-radius: 12px; padding: 3px;
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; padding: 9px 6px; border-radius: 9px; min-height: 44px;
}
.seg button small { font-weight: 500; opacity: .8; margin-left: 2px; }
.seg button[aria-selected="true"] { background: var(--seg-active); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.icon-btn {
  appearance: none; border: 0; background: var(--surface); color: var(--text);
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
}
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { display: grid; gap: 12px; }

.card { background: var(--surface); border-radius: 16px; padding: 14px 14px 6px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.badge {
  flex: none; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 17px;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.02em;
}
.card-title { font-size: 18px; font-weight: 700; line-height: 1.2; }
.card-sub { font-size: 13px; color: var(--muted); }

.group-label {
  margin: 10px 0 0; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em;
}
.card-head + .group-label { border-top: 0; padding-top: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; }
.row + .row { border-top: 1px dashed var(--line); }
.row-main { min-width: 0; }
.dest { font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.via { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }
.eta { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.eta-main { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.eta-main.soon { color: var(--soon); }
.eta-main.text { font-size: 14px; font-weight: 600; max-width: 150px; }
.eta-sub { font-size: 12px; color: var(--muted); }

.notice { padding: 8px 0 12px; font-size: 14px; color: var(--muted); }
.notice.error { color: var(--err); }

.foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 12px; color: var(--muted); text-align: center;
}
.foot.stale { color: var(--warn); }

dialog { border: 0; border-radius: 16px; padding: 20px; background: var(--surface); color: var(--text); width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
dialog p { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
dialog input {
  width: 100%; font: inherit; font-size: 16px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); margin-bottom: 12px;
}
dialog .primary { width: 100%; min-height: 46px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; }
.err { color: var(--err); }

.skeleton { height: 120px; border-radius: 16px; background: linear-gradient(90deg, var(--surface), var(--line), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .skeleton, .icon-btn.spin svg { animation: none; }
}
