:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #1f6feb;
  --hot: #e5484d;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b21;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --line: #2a2f37;
    --accent: #4c8dff;
    --hot: #ff6369;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
header, main { max-width: 520px; margin: 0 auto; padding: 0 16px; }
header { padding-top: max(16px, env(safe-area-inset-top)); }
h1 { font-size: 1.4rem; margin: 8px 0; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 16px 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
label { display: block; margin-bottom: 12px; font-size: 0.9rem; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); }
select, input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: 4px;
  padding: 10px 12px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
button {
  width: 100%; padding: 12px; font-size: 1rem; font-weight: 600;
  border: 0; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer;
}
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); margin-top: 8px; }

.train-list { display: grid; gap: 8px; margin-bottom: 4px; }
.train {
  text-align: left; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); font-weight: 400;
}
.train span.muted { display: block; font-size: 0.85rem; }
.train[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

.shares { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.shares li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.shares li.soon { border-color: var(--hot); }

.pill {
  display: inline-block; font-size: 0.75rem; padding: 1px 8px; margin-left: 4px;
  border-radius: 999px; background: var(--line); color: var(--text);
}
.pill.hot { background: var(--hot); color: #fff; }
.banner { background: #fff4d6; color: #7a5b00; padding: 6px 10px; border-radius: 8px; font-size: 0.85rem; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.error { color: var(--hot); }

main > .tabs { margin-top: 8px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row select { margin-top: 0; flex: 1; }
.row button { width: auto; margin-top: 0; white-space: nowrap; }
.big { font-size: 1.1rem; font-weight: 600; }

.row label { flex: 1; }
.notice {
  background: var(--bg); border-left: 3px solid var(--accent);
  padding: 8px 10px; border-radius: 6px; color: var(--muted);
}
.car-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.car-summary .pill { margin-left: 0; }
.shares li.freed { opacity: 0.75; }
.trust-trusted { background: #1a7f37; color: #fff; }
.trust-new { background: var(--line); }
.trust-low { background: #9a6700; color: #fff; }
.actions { display: flex; gap: 6px; margin-top: 8px; }
.actions button { width: auto; padding: 6px 10px; font-size: 0.85rem; font-weight: 500; }
dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); max-width: 360px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgb(0 0 0 / 0.4); }

.login { max-width: 520px; margin: 16px auto; }
a.button {
  display: block; text-align: center; text-decoration: none;
  padding: 12px; border-radius: 10px; font-weight: 600; background: var(--accent); color: #fff;
}
a.button.google { background: #fff; color: #1f1f1f; border: 1px solid var(--line); }
.account { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
button.link { width: auto; padding: 0; background: none; color: var(--accent); font-weight: 400; font-size: inherit; }
a { color: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.wide { max-width: 1100px; }
.table-wrap { overflow-x: auto; }

/* ---------- v2: chips, route, ride view, toast ---------- */
.field-label { font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.line-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  width: auto; padding: 6px 12px; font-size: 0.85rem; font-weight: 600;
  background: var(--bg); color: var(--text); border: 2px solid var(--c); border-radius: 999px;
}
.chip[aria-checked="true"] { background: var(--c); color: #fff; }

.route { display: grid; grid-template-columns: 1fr; gap: 0; position: relative; }
.route .swap {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); z-index: 1;
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  background: var(--card); color: var(--accent); border: 1px solid var(--line); font-size: 1.1rem;
}
#alight-form .route select { padding-right: 52px; }
label.toggle { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 4px 0 12px; }
label.toggle input { margin-top: 4px; width: 18px; height: 18px; }
#a-start { margin-top: 4px; }
button:disabled { opacity: 0.6; }

.ride { border-width: 2px; transition: border-color .3s, background .3s; }
.ride.next { border-color: #f5a524; }
.ride.alight { border-color: var(--hot); background: color-mix(in srgb, var(--hot) 10%, var(--card)); }
.ride.over { opacity: 0.85; }
.ride-head { display: flex; align-items: center; gap: 8px; }
.line-dot {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--c); color: #fff; font-weight: 700; font-size: 0.8rem;
}
.ride-stage { margin: 12px 0 0; font-weight: 600; color: var(--muted); }
.ride.next .ride-stage { color: #b7791f; }
.ride.alight .ride-stage { color: var(--hot); font-size: 1.2rem; }
.ride-dest { font-size: 1.8rem; margin: 2px 0; line-height: 1.2; }
.ride-eta { font-size: 1.1rem; margin: 0 0 12px; }
.ride-share {
  background: var(--bg); border-radius: 10px; padding: 8px 10px; margin-bottom: 12px; font-size: 0.9rem;
}

.stops { list-style: none; margin: 8px 0 4px; padding: 0; }
.stops li { position: relative; padding-left: 26px; }
.stops li::before {
  content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 4px; background: var(--c);
}
.stops li:first-child::before { top: 50%; }
.stops li:last-child::before { bottom: 50%; }
.stops li::after {
  content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border-radius: 50%; background: var(--card); border: 3px solid var(--c);
  box-sizing: border-box;
}
.stops li.past::before, .stops li.past::after { opacity: 0.35; }
.stops li.here::after { background: var(--c); width: 18px; height: 18px; left: 1px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent); }
.stops li.dest::after { border-radius: 4px; }
.stops button {
  display: flex; justify-content: space-between; align-items: center; text-align: left;
  background: none; color: var(--text); font-weight: 400; padding: 9px 4px; border-radius: 8px;
}
.stops button:active { background: var(--bg); }
.stops li.past button { color: var(--muted); }
.stops li.here .name, .stops li.dest .name { font-weight: 700; }
.stops .code { font-size: 0.75rem; color: var(--muted); }
.stops li.here .code { color: var(--c); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 0.9rem; z-index: 10;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}
.toast.error { background: var(--hot); color: #fff; }
.banner { margin: 0 0 8px; }
.row label select { margin-top: 4px; }
