:root {
  --green: #1DB446;
  --green-ink: #12863A;
  --green-soft: #E7F7EC;
  --blue: #0056A4;
  --blue-soft: #E6EFF8;
  --ink: #18201B;
  --ink-2: #3D4741;
  --muted: #6C7670;
  --line: #E2E7E4;
  --bg: #F3F5F4;
  --card: #FFFFFF;
  --red: #C62828;
  --red-soft: #FDECEA;
  --amber: #8A5300;
  --amber-soft: #FFF3D9;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .05);
  --tabbar-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--blue); }
button { font: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 40px; height: 40px; flex: none; display: block; }
.logo-lg { width: 96px; height: 96px; margin: 0 auto 14px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 16px; }
.brand-text small { font-size: 12px; color: var(--muted); }
.who { font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ---------- cards & type ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 4px 10px; font-size: 15px; font-weight: 700; color: var(--ink-2);
}
.section-title small { font-weight: 400; color: var(--muted); }
h1 { font-size: 22px; margin: 4px 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- notices ---------- */
.notice { border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; border: 1px solid transparent; }
.notice b { display: block; font-size: 16px; margin-bottom: 4px; }
.notice p { margin: 2px 0; font-size: 15px; }
.notice.stop { background: var(--red-soft); color: #7A1A14; border-color: #F5C6C1; }
.notice.warn { background: var(--amber-soft); color: var(--amber); border-color: #F2DDA8; }
.notice.info { background: var(--blue-soft); color: #0B3D6E; border-color: #C5D8EC; }

/* ---------- next trip hero ---------- */
.hero { padding: 0; overflow: hidden; }
.hero-head {
  background: var(--green); color: #fff; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.hero-head .label { font-size: 13px; opacity: .9; }
.hero-head .count { font-size: 20px; font-weight: 700; }
.hero-head .ord { font-size: 13px; opacity: .9; text-align: right; }
.hero-body { padding: 16px 18px 18px; }
.when { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.service-chip {
  display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-ink); margin-left: 6px; vertical-align: 2px;
}
.route { list-style: none; padding: 0; margin: 14px 0; }
.route li { position: relative; padding: 0 0 12px 26px; font-size: 16px; }
.route li::before {
  content: ""; position: absolute; left: 6px; top: 8px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--green);
}
.route li.end::before { background: var(--red); }
.route li.via::before { background: #F0A500; }
.route li.hours::before { background: var(--blue); }
.route li:not(:last-child)::after {
  content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 2px; background: var(--line);
}
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 6px 0 14px; }
.fact { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.fact span { display: block; font-size: 12px; color: var(--muted); }
.fact b { font-size: 16px; word-break: break-all; }
.fact.wide { grid-column: 1 / -1; }
.money { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.money .m { flex: 1 1 30%; min-width: 96px; background: var(--green-soft); border-radius: 12px; padding: 10px 12px; }
.money .m span { display: block; font-size: 12px; color: var(--green-ink); }
.money .m b { font-size: 19px; color: var(--ink); }
.money .m small { display: block; font-size: 11px; color: var(--muted); }

/* ---------- buttons ---------- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 0;
  font-size: 16px; font-weight: 700; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green); color: #fff; }
.btn.secondary { background: var(--blue); color: #fff; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.wide { grid-column: 1 / -1; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.locked {
  grid-column: 1 / -1; display: flex; gap: 10px; align-items: center;
  background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--ink-2);
}
.locked svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.trip-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  margin-bottom: 10px; text-decoration: none; color: inherit;
}
.trip-row .date { flex: none; width: 66px; text-align: center; border-right: 1px solid var(--line); padding-right: 10px; }
.trip-row .date b { display: block; font-size: 17px; }
.trip-row .date span { font-size: 13px; color: var(--muted); }
.trip-row .mid { flex: 1; min-width: 0; }
.trip-row .mid b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-row .mid span { font-size: 13px; color: var(--muted); }
.trip-row .amt { flex: none; text-align: right; font-weight: 700; }
.trip-row .amt small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.chev { width: 18px; height: 18px; flex: none; fill: none; stroke: #A9B2AD; stroke-width: 2; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: #E6EAE8; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: transparent; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- wallet ---------- */
.balance { text-align: center; padding: 26px 18px; }
.balance .k { font-size: 15px; color: var(--muted); }
.balance .v { font-size: 38px; font-weight: 800; letter-spacing: .5px; margin: 4px 0; }
.balance.pos .v { color: var(--green-ink); }
.balance.neg .v { color: var(--red); }
.balance .note { font-size: 13px; color: var(--muted); }
.rows { list-style: none; padding: 0; margin: 0; }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li div span { display: block; font-size: 13px; color: var(--muted); }
.rows li .a { font-weight: 700; white-space: nowrap; }
.rows li .a.plus { color: var(--green-ink); }
.rows li .a.minus { color: var(--red); }

/* ---------- me ---------- */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; margin-left: 6px; }
.chip.ok { background: var(--green-soft); color: var(--green-ink); }
.chip.soon { background: var(--amber-soft); color: var(--amber); }
.chip.expired, .chip.missing { background: var(--red-soft); color: var(--red); }

/* ---------- detail ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 12px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.tel { color: var(--blue); font-weight: 700; text-decoration: none; }

/* ---------- login ---------- */
.login { text-align: center; padding: 34px 22px; }
.login h1 { margin-bottom: 6px; }
.login p { color: var(--ink-2); margin: 0 0 20px; }
.login .btn { width: 100%; margin-bottom: 10px; }
.line-btn { background: #06C755; color: #fff; }
.msg { margin-top: 12px; font-size: 15px; }
.msg.ok { color: var(--green-ink); }
.msg.err { color: var(--red); }

/* ---------- misc ---------- */
.splash { display: grid; place-items: center; gap: 10px; padding: 80px 0; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  background: rgba(24, 32, 27, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); z-index: 30;
}

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line);
  backdrop-filter: saturate(1.4) blur(8px);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--green-ink); }

@media (min-width: 700px) {
  main { padding: 24px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .btn { transition: none; }
}
