:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e2e5ea;
  --fg: #14181d;
  --muted: #646d79;
  --accent: #ffd34d;      /* fills: selected chip, primary button */
  --accent-ink: #9a5800;  /* text: countdowns, links (readable on white) */
  --urgent: #d42a1f;
  --live: #0d8a48;
  --shadow: 0 1px 2px rgba(20, 24, 29, 0.06), 0 2px 8px rgba(20, 24, 29, 0.05);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.big-pad { padding: 32px 0; text-align: center; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.from-line {
  font: inherit;
  font-size: 18px;
  color: var(--fg);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.caret { color: var(--muted); font-size: 14px; }
.link {
  font: inherit;
  color: var(--accent-ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}
#origin-places { margin-bottom: 4px; }
#origin-status { min-height: 18px; }
.actions { display: flex; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font-size: 18px;
  cursor: pointer;
}
.icon-btn.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.to-line { display: flex; align-items: center; gap: 10px; margin: 14px 0 18px; font-size: 18px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
}
.chip.on { background: var(--accent); border-color: #e9b928; color: #14181d; font-weight: 600; }

.hero {
  background: var(--card);
  border-radius: 20px;
  padding: 22px 20px;
  text-align: center;
  margin-bottom: 18px;
  min-height: 120px;
  box-shadow: var(--shadow);
}
.leave-label { color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; }
.leave-count { font-size: 64px; font-weight: 700; line-height: 1.05; margin: 4px 0 6px; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.leave-count.urgent { color: var(--urgent); }
.leave-at { font-size: 17px; margin-bottom: 12px; }
.hero-route { margin-bottom: 10px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.arrow { color: var(--muted); margin: 0 4px; }

.live {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--live);
  border: 1px solid var(--live);
  border-radius: 4px;
  padding: 0 4px;
  vertical-align: 1px;
}
.sched { font-size: 12px; color: var(--muted); }

.opt {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--card);
}
.opt.pref { border-color: #f0d27c; background: #fffbea; }
.opt header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }

.deps { list-style: none; margin: 10px 0 0; padding: 0; }
.deps li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.dep-leave { font-weight: 600; font-variant-numeric: tabular-nums; }
.dep-leave.urgent { color: var(--urgent); }
.dep-cd { color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.dep-cd.urgent { color: var(--urgent); }
.dep-arr { font-size: 14px; }

.err { color: var(--urgent); padding: 20px 0; }

footer { text-align: center; margin-top: 18px; }

dialog {
  width: min(92vw, 420px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--fg);
  padding: 20px;
  box-shadow: 0 12px 40px rgba(20, 24, 29, 0.18);
}
dialog::backdrop { background: rgba(20, 24, 29, 0.35); }
dialog h2 { margin: 0 0 12px; font-size: 20px; }
dialog label { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
dialog input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font-size: 16px; /* 16px stops iOS zooming on focus */
}
dialog .note { font-size: 14px; }
dialog a { color: var(--accent-ink); }
.row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.row button { padding: 10px 18px; border-radius: 10px; font-size: 15px; border: 1px solid var(--line); cursor: pointer; }
.ghost { background: transparent; color: var(--fg); }
.primary { background: var(--accent); color: #14181d; border-color: #e9b928 !important; font-weight: 600; }
