:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f5f2, #161615);
  --surface: light-dark(#ffffff, #222220);
  --ink: light-dark(#1b1b1a, #f1f0ec);
  --muted: light-dark(#5b5a56, #b4b2ab);
  --line: light-dark(#d9d7d0, #3a3936);
  --accent: light-dark(#0b5d4f, #6fd3bd);
  --on-accent: light-dark(#ffffff, #0d1f1b);
  --danger: light-dark(#b3261e, #ffb4ab);
  --radius: 14px;
  --tap: 48px;
  font-family: system-ui, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 1.0625rem;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 1rem;
  max-width: 34rem;
  margin: 0 auto;
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }
.bar nav { display: flex; gap: 0.25rem; }
.bar nav a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 0.875rem;
  border-radius: 999px; color: var(--ink); text-decoration: none;
}
.bar nav a[aria-current="page"] { background: var(--surface); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }

main { max-width: 34rem; margin: 0 auto; padding: 0.5rem 1rem 4rem; }
section { display: grid; gap: 1rem; margin-block-end: 2rem; }
section[hidden] { display: none; }

h1, h2 { margin: 0.75rem 0 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h1:focus, h2:focus { outline: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
  margin: 0;
}

.field { display: grid; gap: 0.375rem; font-weight: 600; }
input, select, button { font: inherit; color: inherit; }
input, select {
  min-height: var(--tap);
  padding: 0 0.875rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 400;
  width: 100%;
}
input:user-invalid { border-color: var(--danger); }

.pair { display: grid; grid-template-columns: 1fr; gap: 0.5rem; position: relative; }
.pair .icon { justify-self: end; margin-block: -0.25rem; }

button { cursor: pointer; border-radius: 10px; min-height: var(--tap); }
.primary {
  border: 0; background: var(--accent); color: var(--on-accent);
  font-weight: 700; padding: 0 1.25rem; width: 100%;
}
.icon {
  min-width: var(--tap); border: 1px solid var(--line); background: var(--surface);
  font-size: 1.25rem; line-height: 1;
}
.back {
  justify-self: start; border: 0; background: none; color: var(--accent);
  padding: 0 0.25rem; min-height: var(--tap); display: inline-flex; align-items: center;
  text-decoration: underline; text-underline-offset: 3px;
}

.muted { color: var(--muted); margin: 0; }
.error { color: var(--danger); margin: 0; font-weight: 600; }
.error:empty { display: none; }

.trips { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.trip {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.25rem 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem;
}
.trip p { margin: 0; }
.trip .time { font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.trip .time strong { font-size: 1.375rem; }
.trip .meta { color: var(--muted); grid-column: 1; }
.trip .choose {
  grid-column: 2; grid-row: 1 / span 2; border: 1px solid var(--accent); background: none;
  color: var(--accent); font-weight: 700; padding: 0 1.125rem;
}
.trip .choose:disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stepper label { font-weight: 600; display: grid; }
.price { color: var(--muted); font-weight: 400; font-size: 0.9375rem; }
.ctrl { display: flex; align-items: center; gap: 0.25rem; }
.ctrl input { width: 3.5rem; text-align: center; padding: 0; -moz-appearance: textfield; }
.ctrl input::-webkit-inner-spin-button, .ctrl input::-webkit-outer-spin-button { -webkit-appearance: none; }
.total { margin: 0; display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 1rem; }
.total output { font-weight: 700; font-variant-numeric: tabular-nums; }

.summary { grid-template-columns: auto 1fr; gap: 0.5rem 1rem; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }

.code-label { margin: 0; color: var(--muted); }
.code { margin: 0; font-size: 2.25rem; font-weight: 800; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }

.rules { display: table; border-collapse: separate; border-spacing: 0; width: 100%; padding: 0; overflow: hidden; }
.rules th, .rules td { text-align: start; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.rules tr:last-child td { border-bottom: 0; }
.rules th { color: var(--muted); font-weight: 600; font-size: 0.9375rem; }
.rules td:last-child { font-weight: 600; white-space: nowrap; }

@media (min-width: 30rem) {
  .pair { grid-template-columns: 1fr auto 1fr; align-items: end; }
  .pair .icon { margin: 0; justify-self: center; }
}
.stack { display: grid; gap: 1rem; }
