:root {
  --red: #E2231A;
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1c1c1e;
  --sub: #6e6e73;
  --line: #e5e5ea;
  --green: #2e9e44;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang HK", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg); color: var(--ink);
}
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  background: var(--red); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
}
#topbar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 700; }
#back {
  background: none; border: none; color: #fff; font-size: 30px; line-height: 1;
  padding: 0 6px; cursor: pointer; visibility: hidden; margin-left: -6px;
}
#back.show { visibility: visible; }
#clock { font-size: 13px; opacity: .85; font-variant-numeric: tabular-nums; }
main { flex: 1; padding: 12px 12px 24px; }
#foot { text-align: center; font-size: 11px; color: var(--sub); padding: 10px; }
#foot a { color: var(--sub); }

.card { background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.sec-title { font-size: 13px; color: var(--sub); margin: 4px 2px 8px; font-weight: 600; }

#searchbox { display: flex; gap: 8px; }
#search {
  flex: 1; font-size: 17px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; outline: none;
}
#search:focus { border-color: var(--red); }
.btn {
  border: none; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; background: var(--red); color: #fff;
}
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn:disabled { opacity: .45; }
.btn.block { display: block; width: 100%; text-align: center; }

.row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--line);
  padding: 12px 4px; text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.row:last-child { border-bottom: none; }
.row:active { background: #f0f0f2; }
.routenum {
  min-width: 56px; text-align: center; font-weight: 800; font-size: 16px;
  background: var(--red); color: #fff; border-radius: 8px; padding: 6px 4px;
}
.routenum.gmb { background: #1a8a4a; }
.rowmain { flex: 1; min-width: 0; }
.rowmain .l1 { font-size: 15px; font-weight: 600; }
.rowmain .l2 { font-size: 12.5px; color: var(--sub); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowright { text-align: right; font-variant-numeric: tabular-nums; }
.arrow { color: var(--sub); font-size: 18px; }

.seq { min-width: 26px; text-align: center; color: var(--sub); font-size: 13px; font-variant-numeric: tabular-nums; }
.dist { font-size: 12px; color: var(--sub); white-space: nowrap; }

.star {
  background: none; border: none; font-size: 20px; cursor: pointer; padding: 6px;
  color: #c7c7cc; line-height: 1;
}
.star.on { color: #f5a623; }

/* ETA */
#eta-head { text-align: center; margin-bottom: 10px; }
#eta-head .rt { font-size: 34px; font-weight: 800; color: var(--red); }
#eta-head .dir { font-size: 14px; color: var(--sub); margin-top: 2px; }
#eta-head .stp { font-size: 20px; font-weight: 700; margin-top: 8px; }
#eta-list { display: flex; flex-direction: column; gap: 8px; }
.eta-item {
  display: flex; align-items: center; background: #fff; border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.eta-min { font-size: 34px; font-weight: 800; min-width: 92px; font-variant-numeric: tabular-nums; }
.eta-min small { font-size: 15px; font-weight: 600; }
.eta-item.soon .eta-min { color: var(--green); }
.eta-sub { flex: 1; font-size: 12.5px; color: var(--sub); }
.eta-rmk { color: var(--red); font-weight: 600; }
.empty { text-align: center; color: var(--sub); padding: 36px 12px; font-size: 15px; }
#refresh-line { text-align: center; font-size: 12px; color: var(--sub); margin-top: 14px; }
#refresh-line button { font-size: 12px; color: var(--red); background: none; border: none; cursor: pointer; font-weight: 600; }

.loading { text-align: center; color: var(--sub); padding: 40px 0; }
.spin {
  display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line);
  border-top-color: var(--red); border-radius: 50%; animation: sp .8s linear infinite;
  vertical-align: middle; margin-right: 8px;
}
@keyframes sp { to { transform: rotate(360deg); } }
.err { background: #fff0f0; color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px; }
.hint { font-size: 12.5px; color: var(--sub); line-height: 1.6; }
.fav-badge { font-size: 13px; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
