:root {
  --bg: #ffffff;
  --bg2: #f6f5f1;
  --ink: #1d1d1b;
  --ink2: #5f5d57;
  --line: #e6e3da;
  --accent: #f5b700;
  --accent-ink: #3a2c00;
  --soon: #12a150;
  --later: #2b6fd6;
  --later-ink: #2563c9; /* 藍色當小字用：淺底對比 ≥4.5 */
  --done: #a3a09a;
  --off: #d9d6cf;
  --truck: #ff6a00;
  --danger: #d43c2f;
  --warn-bg: #fff6dc; --warn-ink: #5c4300; --warn-line: #f0d98a;
  --stop-bg: #fdeceb; --stop-ink: #8f1f16; --stop-line: #f3c2bd;
  --shadow: 0 8px 30px rgba(20, 18, 10, .16);
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1b19; --bg2: #252522; --ink: #f1efe8; --ink2: #b3b0a7; --line: #36352f;
    --done: #77746d; --off: #46443e; --later-ink: #6f9fe8; --shadow: 0 8px 30px rgba(0, 0, 0, .5); color-scheme: dark;
    --warn-bg: #2f2915; --warn-ink: #f2dc9a; --warn-line: #5a4a1c; --stop-bg: #34201d; --stop-ink: #f6b8b0; --stop-line: #6a2f28;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1b19; --bg2: #252522; --ink: #f1efe8; --ink2: #b3b0a7; --line: #36352f;
  --done: #77746d; --off: #46443e; --later-ink: #6f9fe8; --shadow: 0 8px 30px rgba(0, 0, 0, .5); color-scheme: dark;
    --warn-bg: #2f2915; --warn-ink: #f2dc9a; --warn-line: #5a4a1c; --stop-bg: #34201d; --stop-ink: #f6b8b0; --stop-line: #6a2f28;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; }
button, select, input { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; }

/* ---------- 上方列 ---------- */
.topbar {
  position: fixed; top: 10px; left: 10px; right: 10px; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--bg); border-radius: var(--r); box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 6px; font-size: 17px; white-space: nowrap; }
.brand-name { font-size: inherit; font-weight: 700; margin: 0; line-height: inherit; }
.logo { font-size: 22px; display: inline-block; animation: drive 3s ease-in-out infinite; }
@keyframes drive { 0%,100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
.cities { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.cities button, .mode {
  border: 1px solid var(--line); background: var(--bg2); padding: 5px 12px; border-radius: 999px;
  cursor: pointer; white-space: nowrap;
}
.cities button[aria-pressed="true"], .mode[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.modes { display: flex; gap: 4px; }

/* ---------- 面板 ---------- */
.panel {
  position: fixed; z-index: 4; top: 76px; left: 10px; bottom: 10px; width: 390px;
  display: flex; flex-direction: column; background: var(--bg); border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden;
}
.grip { display: none; }
.panel-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.clock { display: flex; justify-content: space-between; color: var(--ink2); font-size: 13px; }
.notice { position: relative; margin-top: 8px; padding: 8px 30px 8px 10px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); font-size: 13px; line-height: 1.5; }
.notice.off { background: var(--stop-bg); color: var(--stop-ink); border-color: var(--stop-line); }
.notice.ok { background: var(--bg2); color: var(--ink2); border-color: var(--line); }
.notice ul { margin: 0; padding: 0; list-style: none; }
.notice li + li { margin-top: 4px; }
.notice a { color: inherit; font-weight: 700; white-space: nowrap; }
.notice-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border: 0; background: transparent; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; border-radius: 6px; }
.notice-x:hover { background: rgba(0, 0, 0, .06); }
.clock #now { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.controls { display: flex; gap: 8px; }
.controls select { flex: 1; min-width: 0; }
select, input[type="search"] {
  border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 8px 10px; min-height: 40px;
}
input[type="search"] { width: 100%; }
.primary {
  border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; border-radius: 10px;
  padding: 8px 14px; cursor: pointer; white-space: nowrap; min-height: 40px;
}
.primary:active { transform: translateY(1px); }
.dayrow { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink2); }
.dayrow select { min-height: 32px; padding: 4px 8px; margin-left: 6px; }
.live-badge { color: var(--soon); font-weight: 700; animation: blink 2s infinite; }
@keyframes blink { 50% { opacity: .45; } }

.filters { font-size: 13px; color: var(--ink2); }
.filters[open] { display: grid; gap: 6px; }
.filters summary { cursor: pointer; font-weight: 600; color: var(--ink); padding: 2px 0; list-style-position: inside; }
.filters summary b { color: var(--later-ink); }
.frow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.frow > label { min-width: 2.5em; }
.frow select { min-height: 32px; padding: 4px 6px; }
.frow input[type="range"] { flex: 1; min-width: 120px; accent-color: var(--accent); }
.distval { color: var(--ink); min-width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--bg2); border-radius: 999px; padding: 3px 9px; cursor: pointer; font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.onecheck { gap: 4px; cursor: pointer; }
.panel-body { flex: 1; overflow-y: auto; padding: 6px 0 12px; overscroll-behavior: contain; }
.panel-foot { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 12px; color: var(--ink2); }
.panel-foot a { color: inherit; }

h2.sec { font-size: 13px; letter-spacing: .04em; color: var(--ink2); margin: 12px 14px 6px; font-weight: 700; }
.hint { margin: 10px 14px; padding: 12px; background: var(--bg2); border-radius: 10px; color: var(--ink2); font-size: 14px; }
.hint b { color: var(--ink); }
.hint ul { margin: 6px 0 0; padding-left: 18px; }

.stop {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 2px 10px; align-items: start;
  padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.stop:hover, .stop:focus-visible { background: var(--bg2); outline: none; }
.stop .time { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stop .time small { display: block; font-size: 11px; font-weight: 600; color: var(--ink2); }
.stop .addr { font-weight: 600; word-break: break-word; }
.stop .meta { grid-column: 2 / 4; font-size: 12px; color: var(--ink2); }
.stop .when { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.when.soon { background: color-mix(in srgb, var(--soon) 15%, transparent); color: var(--soon); }
.when.later { background: color-mix(in srgb, var(--later) 14%, transparent); color: var(--later); }
.when.done { background: var(--bg2); color: var(--done); }
.when.off { background: var(--bg2); color: var(--ink2); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; grid-column: 2 / 4; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--bg2); color: var(--ink2); border: 1px solid var(--line); }
.tag.g { background: #fff4cc; color: #6b5200; border-color: #f2df9b; }
.tag.r { background: #e3f0ff; color: #1f4f96; border-color: #bcd6f7; }
.tag.f { background: #e6f6ea; color: #1d6b37; border-color: #bfe4c8; }
.tag.ap { background: transparent; border-style: dashed; }
.tag.stop-off { background: var(--stop-bg); color: var(--stop-ink); border-color: var(--stop-line); font-weight: 700; }
.tag.added { background: #e6f6ea; color: #1d6b37; border-color: #bfe4c8; font-weight: 700; }
.tag.live { background: #fff0e5; color: #b04800; border-color: #ffd0ad; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag.g { background: #3d3311; color: #f5d777; border-color: #5b4b17; }
  :root:not([data-theme="light"]) .tag.r { background: #15283f; color: #9cc6ff; border-color: #22406a; }
  :root:not([data-theme="light"]) .tag.f { background: #15301d; color: #94e0a9; border-color: #21492c; }
  :root:not([data-theme="light"]) .tag.live { background: #3a2210; color: #ffb37d; border-color: #5c3415; }
}

/* 詳細頁 */
.detail { padding: 6px 14px 14px; }
.back { border: 0; background: none; color: var(--later); cursor: pointer; padding: 8px 0; font-weight: 600; }
.detail h3 { margin: 4px 0 2px; font-size: 19px; }
.detail .sub { color: var(--ink2); font-size: 13px; }
.bigtime { display: flex; align-items: baseline; gap: 10px; margin: 10px 0; }
.bigtime b { font-size: 38px; font-variant-numeric: tabular-nums; line-height: 1; }
.week { display: grid; grid-template-columns: auto repeat(7, 1fr); gap: 3px; font-size: 12px; text-align: center; margin: 10px 0; }
.week div { padding: 4px 0; border-radius: 6px; }
.week .h { color: var(--ink2); }
.week .lab { text-align: left; color: var(--ink2); padding-right: 6px; }
.week .y { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.week .n { background: var(--bg2); color: var(--off); }
.week .today { outline: 2px solid var(--ink); outline-offset: -2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions button, .actions a {
  border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 7px 12px; cursor: pointer;
  text-decoration: none; font-size: 14px;
}
.livebox { margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: #fff0e5; color: #6b2c00; font-size: 14px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .livebox { background: #3a2210; color: #ffd1b0; } }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; border-left: 3px solid var(--line); }
.timeline li { position: relative; padding: 5px 0 5px 14px; font-size: 14px; cursor: pointer; }
.timeline li::before { content: ""; position: absolute; left: -7.5px; top: 11px; width: 12px; height: 12px; border-radius: 50%; background: var(--off); border: 2px solid var(--bg); }
.timeline li.done::before { background: var(--done); }
.timeline li.next::before { background: var(--soon); box-shadow: 0 0 0 4px color-mix(in srgb, var(--soon) 25%, transparent); }
.timeline li.me { font-weight: 800; }
.timeline li.me::before { background: var(--accent); }
.timeline li span { font-variant-numeric: tabular-nums; color: var(--ink2); margin-right: 8px; }
.truckhere { color: var(--truck); font-weight: 700; font-size: 12px; margin-left: 4px; }

/* 圖例 */
.legend {
  position: fixed; z-index: 3; right: 10px; bottom: 34px; display: flex; gap: 10px; flex-wrap: wrap;
  background: var(--bg); padding: 6px 10px; border-radius: 10px; box-shadow: var(--shadow); font-size: 12px;
}
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; border: 1.5px solid #fff; }
.dot.soon { background: var(--soon); } .dot.later { background: var(--later); } .dot.done { background: var(--done); }
.dot.off { background: var(--off); } .dot.truck { background: var(--truck); }

.toast {
  position: fixed; z-index: 10; left: 50%; top: 80px; transform: translateX(-50%) translateY(-10px);
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: .25s; max-width: calc(100vw - 32px); font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.maplibregl-popup-content { background: var(--bg); color: var(--ink); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.maplibregl-popup-tip { display: none; }
.maplibregl-ctrl-group { background: var(--bg); }
.loading { padding: 16px 14px; color: var(--ink2); }

/* 桌機：搜尋列、地圖按鈕列、抽屜按鈕列這三個外框不佔位置，排版跟以前一樣（手機版才用到它們） */
.searchbar, .mapchips, .chiprow { display: contents; }
.topbar .langsel { order: 5; }
/* 手機版（仿 Google 地圖）在檔案最後面 */
@media (prefers-reduced-motion: reduce) { .logo, .live-badge { animation: none; } .panel { transition: none; } }

/* ---------- 縣市／行政區下拉（可打字） ---------- */
.place { position: relative; flex: 1; min-width: 0; max-width: 360px; }
.place input {
  width: 100%; border: 1px solid var(--line); background: var(--bg2); border-radius: 999px;
  padding: 6px 30px 6px 14px; min-height: 36px; font-weight: 700;
}
.place input:focus { outline: 2px solid var(--accent); outline-offset: 0; font-weight: 400; }
.place-caret { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink2); pointer-events: none; font-size: 12px; }
#placeList {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: max(100%, 280px); max-height: 60vh; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
#placeList li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
#placeList li small { color: var(--ink2); white-space: nowrap; }
#placeList li.city { font-weight: 700; border-top: 1px solid var(--line); margin-top: 2px; }
#placeList li.city:first-child { border-top: 0; margin-top: 0; }
#placeList li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 22%, transparent); }
#placeList li.none { color: var(--ink2); cursor: default; }
.controls .primary { flex: 1; }

/* ---------- 行政區清單分頁 ---------- */
.tabs { display: flex; gap: 6px; margin: 8px 14px 2px; }
.tab { flex: 1; border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 7px 8px; cursor: pointer; font-size: 14px; }
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.route-row .time { font-size: 22px; }
.route-row .time small { display: inline; font-size: 12px; margin-left: 2px; }
details.more { margin: 8px 0; }
details.more > summary { cursor: pointer; padding: 8px 14px; color: var(--ink2); font-size: 13px; font-weight: 600; }

/* ---------- 路線資訊頁 ---------- */
.rhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.linkbtn { border: 0; background: none; color: var(--later); font-weight: 700; cursor: pointer; padding: 2px 0; font-size: 13px; }
.rstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0 8px; }
.rstats div { background: var(--bg2); border-radius: 10px; padding: 8px 6px; text-align: center; display: grid; gap: 2px; align-content: center; }
.rstats b { font-size: 15px; font-variant-numeric: tabular-nums; line-height: 1.25; word-break: keep-all; }
.rstats span { font-size: 11px; color: var(--ink2); }
.seg { display: flex; margin: 12px 0 8px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--bg2); padding: 7px; cursor: pointer; font-size: 14px; }
.seg button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.rtable-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.rtable { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.rtable th { background: #2f4a8a; color: #fff; font-weight: 600; font-size: 12px; padding: 6px 2px; line-height: 1.2; position: sticky; top: 0; }
.rtable th:nth-child(1) { width: 30px; } .rtable th:nth-child(3) { width: 46px; }
.rtable th:nth-child(4), .rtable th:nth-child(5), .rtable th:nth-child(6) { width: 56px; }
.rtable td { padding: 6px 3px; border-top: 1px solid var(--line); vertical-align: top; }
.rtable tbody tr { cursor: pointer; }
.rtable tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg2) 60%, transparent); }
.rtable tbody tr:hover, .rtable tbody tr:focus-visible { background: var(--bg2); outline: none; }
.rtable .num { text-align: center; color: var(--ink2); font-variant-numeric: tabular-nums; }
.rtable .pt { word-break: break-word; font-weight: 600; }
.rtable .pt small { display: block; font-weight: 400; color: var(--ink2); font-size: 11px; }
.rtable .tm { font-variant-numeric: tabular-nums; font-weight: 700; text-align: center; }
.rtable .dd { text-align: center; font-size: 10.5px; padding: 6px 1px; color: var(--ink2); letter-spacing: -.03em; word-break: break-all; }
.rtable .dd.on { background: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--ink); font-weight: 700; }
.rtable tr.done td { color: var(--done); }
.rtable tr.done .pt { font-weight: 400; }
.rtable tr.off td { opacity: .5; }
.rtable tr.next { box-shadow: inset 4px 0 0 var(--soon); }
.rtable tr.next .tm { color: var(--soon); }
.rtable tr.me .pt { text-decoration: underline 2px var(--accent); }
.dim { color: var(--ink2); font-weight: 400; }

/* 路線圖：每排 3 站來回蛇行 */
.rdiag { list-style: none; margin: 8px 0 0; padding: 0; }
.drow { position: relative; display: flex; justify-content: space-between; padding: 4px 0 22px; }
.drow.rev { flex-direction: row-reverse; }
.drow::before { content: ""; position: absolute; left: 16.6%; right: 16.6%; top: 36px; border-top: 3px solid var(--line); }
.drow:not(.last)::after { content: ""; position: absolute; right: 16.6%; top: 36px; bottom: -36px; border-right: 3px solid var(--line); }
.drow.rev:not(.last)::after { right: auto; left: 16.6%; border-right: 0; border-left: 3px solid var(--line); }
.dnode { position: relative; z-index: 1; width: 33.3%; border: 0; background: none; cursor: pointer; display: grid; justify-items: center; gap: 3px; padding: 0 2px; color: inherit; }
.dnode .dt { font-size: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.dnode b { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); border: 3px solid var(--later); font-size: 13px; }
.dnode .da { font-size: 12px; line-height: 1.3; background: #fff4cc; color: #6b5200; border-radius: 8px; padding: 2px 6px; word-break: break-word; max-width: 100%; }
.dnode.done b { border-color: var(--done); color: var(--done); }
.dnode.done .da { background: var(--bg2); color: var(--done); }
.dnode.off { opacity: .45; }
.dnode.next b { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 30%, transparent); }
.dnode.me .da { outline: 2px solid var(--accent); }
.dnode:hover .da, .dnode:focus-visible .da { outline: 2px solid var(--later); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dnode .da { background: #3d3311; color: #f5d777; }
  :root:not([data-theme="light"]) .rtable th { background: #22345f; }
}
@media (max-width: 760px) {
  .rstats { grid-template-columns: repeat(2, 1fr); }
}

/* 等車小遊戲入口 */
.gamebtn { display: block; width: 100%; margin: 10px 0; padding: 11px 12px; border: 2px dashed var(--accent); border-radius: var(--r);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--ink); font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.gamebtn:hover { background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }

/* 單一輸入框：清除鍵、搜尋選項 */
.place-clear { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); border: 0; background: var(--line); color: var(--ink2);
  width: 22px; height: 22px; border-radius: 50%; font-size: 11px; line-height: 22px; padding: 0; cursor: pointer; }
.place-clear:not([hidden]) ~ .place-caret { display: none; }
.place-clear:not([hidden]) { right: 8px; }
#placeList li.srch { font-weight: 700; color: var(--later); }

/* 贊助入口 */
.sponsorbtn { margin-top: 8px; border: 0; background: none; padding: 0; color: var(--ink2); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; text-align: left; }
.sponsorbtn:hover { color: var(--ink); }

/* ---------- 多語系：語言選單、切換提示、倒垃圾規則卡 ---------- */
.langsel { position: relative; display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--bg2);
  border-radius: 999px; padding: 5px 10px; white-space: nowrap; cursor: pointer; font-size: 14px; }
.langsel select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; border: 0; min-height: 0; padding: 0; }
.langsel:focus-within { outline: 2px solid var(--accent); }
.langsug { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); top: 72px; display: flex; gap: 4px;
  background: var(--bg); border-radius: 999px; box-shadow: var(--shadow); padding: 4px; max-width: calc(100vw - 32px); }
.langsug button { border: 0; border-radius: 999px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.langsug .go { background: var(--accent); color: var(--accent-ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.langsug .x { background: var(--bg2); color: var(--ink2); }
.rulesbtn { display: block; width: calc(100% - 28px); margin: 8px 14px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg));
  color: var(--ink); border-radius: 12px; padding: 10px 12px; font-weight: 700; text-align: left; cursor: pointer; }
.rules-back { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.rules { background: var(--bg); color: var(--ink); border-radius: 18px; box-shadow: var(--shadow); width: min(100%, 460px);
  max-height: calc(100dvh - 32px); overflow-y: auto; padding: 20px; }
.rules h2 { margin: 0 0 10px; font-size: 20px; }
.rules h3 { margin: 16px 0 8px; font-size: 15px; }
.rules ul { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.rules li { line-height: 1.6; font-size: 14px; }
.rules-words { display: flex; flex-wrap: wrap; gap: 6px; }
.rules-words span { display: inline-flex; flex-direction: column; border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 6px 10px; font-size: 12px; color: var(--ink2); }
.rules-words b { font-size: 17px; color: var(--ink); }
.rules-note { color: var(--ink2); font-size: 13px; margin: 14px 0 12px; }
.rules-close { display: block; width: 100%; border: 0; border-radius: 999px; padding: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 800; cursor: pointer; }
@media (max-width: 760px) {
  .langsel { padding: 4px 8px; font-size: 13px; }
  .langsug { top: 62px; }
}
.rules:focus { outline: none; }

/* ---------- 車快到時叫我、加到主畫面 ---------- */
.alarm { margin: 10px 0; }
.alarmbtn { display: block; width: 100%; padding: 11px 12px; border: 2px solid var(--accent); border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.alarm.set .alarmbtn { background: color-mix(in srgb, var(--accent) 14%, var(--bg)); color: var(--ink); }
.alarm-pick { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg2); }
.alarm-q { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.alarm-leads { display: flex; flex-wrap: wrap; gap: 6px; }
.alarm-leads button { min-height: 40px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg);
  color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.alarm-leads button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.alarm-leads button.off { color: #b3261e; border-color: currentColor; }
.alarm-notes { margin: 10px 0 0; padding-left: 18px; color: var(--ink2); font-size: 12.5px; line-height: 1.5; }
.alarm-install { display: block; width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px dashed var(--accent); border-radius: var(--r);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; text-align: left; cursor: pointer; }
.big .alarm-install { font-size: 17px; padding: 12px; }
.alarm-list { margin: 6px 12px 10px; font-size: 13px; color: var(--ink2); }
.alarm-list a { color: var(--ink); }
.installbtn:not([hidden]) { display: block; font-weight: 700; color: var(--ink); }

/* ---------- 大字模式（長輩用）：html.big ---------- */
.bigbtn { font-weight: 700; }
html.big, html.big body { font-size: 19px; line-height: 1.55; }
/* 平面地圖固定，2D/3D 切換、行事曆檔、小遊戲都收起來，按鈕少一點 */
.big .modes, .big #icsBtn, .big .gamebtn, .big .chips { display: none !important; }
.big .mode, .big .langsel { font-size: 17px; padding: 7px 14px; min-height: 44px; }
.big .bigbtn { min-height: 44px; }
.big .place input { min-height: 46px; font-size: 18px; }
.big #placeList li { padding: 12px; font-size: 18px; }
.big .panel { top: 86px; width: 440px; }
.big .clock, .big .dayrow, .big .filters, .big .notice { font-size: 17px; }
.big .dayrow select, .big .frow select { min-height: 44px; font-size: 17px; }
.big .primary { min-height: 56px; font-size: 21px; }
.big h2.sec { font-size: 17px; }
.big .hint { font-size: 18px; }
.big .stop { grid-template-columns: 84px 1fr auto; padding: 14px; gap: 4px 12px; }
.big .stop .time, .big .route-row .time { font-size: 28px; }
.big .stop .time small { font-size: 14px; }
.big .stop .meta, .big .stop .when, .big .tag { font-size: 15px; }
.big .tab, .big .seg button { font-size: 18px; padding: 10px; min-height: 48px; }
.big .back { font-size: 19px; padding: 12px 0; }
.big .detail h3 { font-size: 24px; }
.big .detail .sub { font-size: 16px; }
.big .bigtime b { font-size: 52px; }
.big .week { font-size: 16px; gap: 4px; }
.big .week div { padding: 7px 0; }
.big .actions button, .big .actions a { font-size: 18px; padding: 12px 16px; min-height: 52px; flex: 1 1 40%; text-align: center; }
.big .alarmbtn { font-size: 19px; padding: 14px; }
.big .alarm-leads button { min-height: 50px; font-size: 18px; }
.big .livebox { font-size: 17px; }
.big .timeline li { font-size: 17px; padding: 9px 0 9px 16px; }
.big .timeline li::before { top: 15px; }
.big .linkbtn { font-size: 17px; }
.big .rtable { font-size: 16px; }
.big .rtable .pt small { font-size: 13px; }
.big .legend { font-size: 15px; }
.big .dot { width: 13px; height: 13px; }
.big .toast { font-size: 18px; padding: 12px 18px; }
.big .maplibregl-popup-content { font-size: 17px; }
.big .rules li { font-size: 17px; }
@media (max-width: 760px) {
  .big .topbar { gap: 6px; }
  .big .brand { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } /* 讓出寬度給搜尋框（只藏畫面，h1 留給螢幕閱讀器） */
  .big .mode, .big .langsel { font-size: 16px; padding: 6px 10px; }
  .big .place { min-width: 120px; }
  .big .panel { top: auto; width: auto; height: 60vh; }
  .big .panel.min { height: 210px; }
  .big .panel.max { height: calc(100vh - 76px); }
  .big .stop { grid-template-columns: 74px 1fr auto; }
}

/* ---------- 舊衣回收箱（clothes.js） ---------- */
.controls .clothes-btn {
  border: 1px solid var(--line); background: var(--bg2); color: var(--ink); border-radius: 10px;
  padding: 8px 12px; min-height: 40px; cursor: pointer; white-space: nowrap; font-weight: 600;
}
.controls .clothes-btn[aria-pressed="true"] { background: #8e44ad; border-color: #8e44ad; color: #fff; }
.dot.clothes { background: #8e44ad; }
.clothes-near { padding: 6px 14px 4px; border-bottom: 1px solid var(--line); }
.clothes-near .sec { margin: 4px 0 6px; }
.clothes-row {
  display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; border-top: 1px solid var(--line); padding: 8px 0; color: var(--ink); font: inherit;
}
.clothes-row:first-of-type { border-top: 0; }
.clothes-row b { color: var(--clothes, #8e44ad); white-space: nowrap; font-weight: 700; }
.clothes-pop { line-height: 1.5; }
.clothes-pop small { color: var(--ink2); }
.clothes-pop .clothes-ap { color: var(--warn-ink); }
.big .controls .clothes-btn { min-height: 56px; font-size: 19px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --clothes: #c39bd3; } }
:root[data-theme="dark"] { --clothes: #c39bd3; }

/* 搜尋建議：路名在哪個區 */
#placeList li.road span { display: flex; flex-direction: column; color: var(--ink); }
#placeList li.road em { font-style: normal; font-weight: 400; font-size: 12px; color: var(--ink2); }
.roadjump { display: flex; justify-content: space-between; gap: 10px; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.roadjump small { color: var(--ink2); font-weight: 400; white-space: nowrap; }

/* ---------- 手機版：仿 Google 地圖 ----------
   上面：一條大搜尋框＋一排小按鈕（2D/3D、大字），浮在地圖上
   下面：抽屜三段高度（app.js setPanel／initSheet 用 px 控制，可用手指拖），平常縮到最小讓地圖最大 */
@media (max-width: 760px) {
  .topbar { top: calc(8px + env(safe-area-inset-top)); left: 10px; right: 10px; padding: 0; gap: 8px;
    display: flex; flex-direction: column; align-items: stretch; flex-wrap: nowrap;
    background: none; box-shadow: none; border-radius: 0; pointer-events: none; }
  .topbar > * { pointer-events: auto; }
  .searchbar { display: flex; align-items: center; gap: 4px; height: 50px; padding: 0 6px 0 12px;
    background: var(--bg); border-radius: 25px; box-shadow: 0 2px 6px rgba(0, 0, 0, .2), 0 1px 2px rgba(0, 0, 0, .1); }
  .brand { flex: none; }
  /* 手機讓出寬度給搜尋框：標題只藏畫面、留給螢幕閱讀器（不用 display:none，不然頁面就沒有 h1） */
  .brand .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  /* iPhone 對字級 < 16px 的表單元件會自動放大整頁 */
  select { font-size: 16px; }
  .logo { font-size: 20px; }
  .place { flex: 1; max-width: none; }
  /* 16px 以上 iPhone 點輸入框才不會自動放大整頁 */
  .place input { border: 0; background: transparent; min-height: 44px; padding: 0 30px 0 4px; font-size: 16px; font-weight: 600; }
  .place input:focus { outline: none; font-weight: 400; }
  .place-caret { display: none; }
  .place-clear:not([hidden]) { right: 2px; width: 26px; height: 26px; line-height: 26px; }
  .langsel { border: 0; padding: 6px 9px; font-size: 13px; flex: none; }
  #placeList { position: fixed; left: 10px; right: 10px; top: calc(64px + env(safe-area-inset-top)); width: auto; max-height: 60dvh; }
  #placeList li { padding: 11px 10px; }
  .mapchips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 0 2px 6px; margin: 0 -2px;
    pointer-events: none; }
  .mapchips::-webkit-scrollbar { display: none; }
  .mapchips > *, .modes > * { pointer-events: auto; }
  .modes { gap: 6px; }
  .mapchips .mode { border: 0; background: var(--bg); box-shadow: 0 1px 4px rgba(0, 0, 0, .22); padding: 6px 14px; font-size: 14px; min-height: 34px; }
  .mapchips .mode[aria-pressed="true"] { background: var(--accent); }

  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 50dvh; border-radius: 16px 16px 0 0;
    transition: height .25s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -2px 12px rgba(0, 0, 0, .18); padding-bottom: env(safe-area-inset-bottom); }
  .panel.min { height: 120px; }
  .panel.max { height: calc(100dvh - 70px); }
  .grip { display: block; flex: none; border: 0; background: none; padding: 8px 0 8px; cursor: grab; width: 100%; touch-action: none; }
  .grip span { display: block; margin: 0 auto; width: 36px; height: 4px; border-radius: 2px; background: var(--done); }
  /* 標題列可以上下拖（touch-action: pan-x 讓直向手勢交給程式，橫向還能捲按鈕列） */
  .panel-head { padding: 0 0 8px; gap: 6px; touch-action: pan-x; }
  .clock { padding: 0 14px; font-size: 12px; }
  .notice { margin: 0 12px; }
  .chiprow { display: flex; gap: 8px; align-items: center; overflow-x: auto; scrollbar-width: none; padding: 0 12px; touch-action: pan-x; }
  .chiprow::-webkit-scrollbar { display: none; }
  .chiprow:has(.filters[open]) { flex-wrap: wrap; }
  .controls, .dayrow { display: contents; }
  .dayrow label { display: flex; flex: none; }
  .dayrow label > span { display: none; }
  .dayrow select { margin: 0; min-height: 38px; padding: 0 8px; border-radius: 999px; }
  .controls .primary, .controls .clothes-btn { flex: none; min-height: 38px; border-radius: 999px; padding: 0 14px; }
  .live-badge { flex: none; white-space: nowrap; font-size: 12px; }
  .filters { flex: none; }
  .filters summary { display: flex; align-items: center; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); background: var(--bg2);
    border-radius: 999px; white-space: nowrap; list-style: none; max-width: 62vw; overflow: hidden; text-overflow: ellipsis; }
  .filters summary::-webkit-details-marker { display: none; }
  .filters[open] { flex-basis: 100%; }
  .filters[open] summary { display: inline-flex; max-width: none; }
  .panel.min .clock, .panel.min .notice { display: none; }
  .panel.min .panel-body { overflow: hidden; }
  .legend { display: none; }
  .panel-foot { display: none; }
  .panel.max .panel-foot { display: block; }
  /* 地圖的放大縮小鈕跟著抽屜上緣走 */
  .maplibregl-ctrl-bottom-right { bottom: calc(var(--sheet, 50dvh) + 4px); }
  .toast { top: calc(104px + env(safe-area-inset-top)); }
  .langsug { top: calc(104px + env(safe-area-inset-top)); }
  .big .place input { font-size: 18px; }
  .big .controls .primary { min-height: 48px; font-size: 19px; }
  .big #placeList { top: calc(64px + env(safe-area-inset-top)); }
}

/* ---------- 我的位置（me.js）：藍點、方向扇形、定位鈕 ---------- */
.me-dot { position: relative; width: 22px; height: 22px; pointer-events: none; }
.me-dot b { position: absolute; inset: 0; border-radius: 50%; background: #1a73e8; border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35); z-index: 1; }
.me-dot::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; background: rgba(26, 115, 232, .28); animation: mepulse 2s ease-out infinite; }
@keyframes mepulse { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
/* 走動時朝前進方向的扇形 */
.me-cone { display: none; position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-50%, -100%) rotate(var(--hd, 0deg));
  transform-origin: 50% 100%; border-left: 14px solid transparent; border-right: 14px solid transparent; border-bottom: 30px solid rgba(26, 115, 232, .35); }
.me-dot.dir .me-cone { display: block; }
.me-ctrl .me-btn { width: 36px; height: 36px; display: grid; place-items: center; color: #5f6368; cursor: pointer; }
.me-ctrl .me-btn[data-state="wait"] { color: #1a73e8; animation: blink 1.2s infinite; }
.me-ctrl .me-btn[data-state="on"] { color: #1a73e8; }
.me-ctrl .me-btn[data-state="follow"] { color: #fff; background: #1a73e8; }
.medist { margin: 6px 0 2px; font-weight: 700; color: #1a73e8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .me-ctrl .me-btn { color: #c8c6bf; } :root:not([data-theme="light"]) .medist { color: #8ab4f8; } }
:root[data-theme="dark"] .me-ctrl .me-btn { color: #c8c6bf; }
:root[data-theme="dark"] .medist { color: #8ab4f8; }
.big .me-ctrl .me-btn { width: 48px; height: 48px; }
.big .medist { font-size: 19px; }
@media (prefers-reduced-motion: reduce) { .me-dot::before, .me-ctrl .me-btn[data-state="wait"] { animation: none; } }
.medist { display: grid; gap: 6px; }
.medist-act { display: flex; flex-wrap: wrap; gap: 6px; }
.medist-act button, .medist-act a { border: 1px solid #1a73e8; background: var(--bg); color: #1a73e8; border-radius: 999px; padding: 6px 12px;
  font: inherit; font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer; min-height: 36px; display: inline-flex; align-items: center; }
.medist-act a { background: #1a73e8; color: #fff; }
.big .medist-act button, .big .medist-act a { font-size: 18px; min-height: 48px; padding: 8px 16px; }
