/* 剛好：燕麥米色底、鼠尾草綠、圓角膠囊。
 * 重點只有一個：到站時間的膠囊 —— 有車是墨綠、快到站是磚紅、沒車退成淺米色。
 * 顏色對比都實際算過（WCAG）：膠囊文字 ≥ 5:1、一般小字 ≥ 4.5:1，戶外也看得清楚。 */
:root {
  /* 捷運線色（柔和版；色盲模擬與色差已用 dataviz 驗證工具檢查會交會的線） */
  --l-R: #c0544b; --l-O: #e59a55; --l-BR: #7e4128; --l-G: #3f9a84; --l-BL: #5577ad; --l-Y: #cfd25c; --l-LB: #6cb3d6;
  --paper: #f2eee6;        /* 燕麥 */
  --surface: #fcfaf6;      /* 卡片 */
  --field: #eae4d8;        /* 搜尋框、次要底色 */
  --ink: #2e2c27;
  --muted: #6a6458;
  --line: #e6e0d4;
  --accent: #4f6b58;       /* 鼠尾草墨綠 */
  --accent-soft: #e2e8de;
  --accent-ink: #ffffff;
  --pill: #47604f;         /* 有車 */
  --pill-ink: #ffffff;
  --pill-hot: #a9502f;     /* 2 分鐘內 */
  --pill-hot-ink: #ffffff;
  --pill-idle: #ece5d8;    /* 沒車、無資料 */
  --pill-idle-ink: #655f53;
  --warn-bg: #f6e7c8;
  --warn-ink: #5e4510;
  --shadow: 0 6px 20px rgba(70, 58, 35, .08);
  --num: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --tabs-h: 64px;
  --r-card: 20px;
  --r-ctl: 14px;
  color-scheme: light;
}
/* 暗色：跟隨系統（除非在設定裡選了亮色），或在設定裡選了暗色 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --l-R: #e0989c; --l-O: #eab45c; --l-BR: #c0703c; --l-G: #36976a; --l-BL: #7f98d8; --l-Y: #dedd94; --l-LB: #6cc3e6;
    --paper: #1c1a17;
    --surface: #262420;
    --field: #302d28;
    --ink: #ede8de;
    --muted: #a69f92;
    --line: #36322c;
    --accent: #a3bfa8;
    --accent-soft: #2f3a31;
    --accent-ink: #1c1a17;
    --pill: #a3bfa8;
    --pill-ink: #1c1a17;
    --pill-hot: #e58a64;
    --pill-hot-ink: #1c1a17;
    --pill-idle: #34302a;
    --pill-idle-ink: #a69f92;
    --warn-bg: #3b3020;
    --warn-ink: #f0d9a6;
    --shadow: 0 6px 20px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --l-R: #e0989c; --l-O: #eab45c; --l-BR: #c0703c; --l-G: #36976a; --l-BL: #7f98d8; --l-Y: #dedd94; --l-LB: #6cc3e6;
  --paper: #1c1a17;
  --surface: #262420;
  --field: #302d28;
  --ink: #ede8de;
  --muted: #a69f92;
  --line: #36322c;
  --accent: #a3bfa8;
  --accent-soft: #2f3a31;
  --accent-ink: #1c1a17;
  --pill: #a3bfa8;
  --pill-ink: #1c1a17;
  --pill-hot: #e58a64;
  --pill-hot-ink: #1c1a17;
  --pill-idle: #34302a;
  --pill-idle-ink: #a69f92;
  --warn-bg: #3b3020;
  --warn-ink: #f0d9a6;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* 數字字型 Outfit（SIL OFL，見 fonts/OFL-Outfit.txt）：放在自己的主機，不向 Google 載入，使用者 IP 不外流 */
@font-face {
  font-family: "Outfit"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/outfit-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2212;
}
@font-face {
  font-family: "Outfit"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/outfit-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2212;
}
@font-face {
  font-family: "Outfit"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/outfit-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2212;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- 頂部 ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 10px;
  background: var(--paper);
}
.top-text { flex: 1; min-width: 0; }
h1 { font-size: 1.625rem; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: .01em; overflow-wrap: anywhere; }
.fresh { margin: 2px 0 0; font-size: .8125rem; color: var(--muted); min-height: 1.2em; }
.back {
  border: 0; background: var(--surface); padding: 7px; margin-left: -4px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
}
.back svg { width: 24px; height: 24px; }
.gear { margin-left: auto; padding: 8px; border-radius: 50%; color: var(--muted); display: grid; place-items: center; }
.gear svg { width: 22px; height: 22px; }
.star-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 7px 14px 7px 11px; font-size: .875rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.star-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.star-btn[aria-pressed="true"] svg { fill: currentColor; }
.star-btn svg { width: 17px; height: 17px; }

.warn {
  margin: 0 16px 8px; padding: 10px 14px; background: var(--warn-bg); color: var(--warn-ink);
  font-size: .875rem; border-radius: var(--r-ctl);
}

main { outline: none; }

/* ---------- 區塊與卡片 ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 20px 22px 8px;
}
.section-head h2 { font-size: 1.0625rem; margin: 0; font-weight: 700; }
.section-head a, .section-head .meta { font-size: .8125rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.section-head a:hover { text-decoration: underline; }

/* 一個站牌 / 一組結果 = 一張圓角卡片，卡片內用細線分隔 */
.list, .seq {
  list-style: none; margin: 0 16px; padding: 0;
  background: var(--surface); border-radius: var(--r-card); overflow: hidden;
}
.list > li + li { border-top: 1px solid var(--line); }

/* 到站列：路線號 | 方向 | 時間膠囊 */
.arr {
  display: grid; grid-template-columns: 4.5rem 1fr auto auto; align-items: center; gap: 2px 12px;
  padding: 12px 16px; min-height: 66px;
}
.arr .rt { font-family: var(--num); font-weight: 600; font-size: 1.625rem; line-height: 1; letter-spacing: -.01em; overflow-wrap: anywhere; }
.arr .rt a { text-decoration: none; }
.arr .rt.long { font-family: var(--text); font-size: 1rem; font-weight: 700; line-height: 1.25; letter-spacing: 0; }
.arr .hd { font-size: .875rem; color: var(--muted); line-height: 1.35; min-width: 0; }
.arr .hd b { color: var(--ink); font-weight: 600; }

/* 時間膠囊（原本的 .board） */
.board {
  display: inline-block; min-width: 4.75rem; padding: 7px 14px; border-radius: 999px;
  background: var(--pill); color: var(--pill-ink);
  font-family: var(--num); font-weight: 600; font-size: 1.25rem; line-height: 1.1;
  font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap;
}
.board small { font-family: var(--text); font-size: .7em; font-weight: 600; margin-left: 2px; }
.board.hot { background: var(--pill-hot); color: var(--pill-hot-ink); }
.board.word { font-family: var(--text); font-size: .8125rem; font-weight: 600; padding: 9px 12px; background: var(--pill-idle); color: var(--pill-idle-ink); }
.board.word.hot { background: var(--pill-hot); color: var(--pill-hot-ink); }

.pin {
  border: 0; background: none; padding: 8px; margin-right: -8px; border-radius: 50%; cursor: pointer; color: var(--muted);
}
.pin svg { width: 20px; height: 20px; }
.pin[aria-pressed="true"] { color: var(--accent); }
.pin[aria-pressed="true"] svg { fill: currentColor; }

/* 收藏頁：沒有車的路線縮成一行，但列出是哪幾條 */
.idle-line { padding: 10px 16px 12px; font-size: .8125rem; line-height: 1.55; color: var(--muted); }
.idle-line + .idle-line { padding-top: 0; border-top: 0 !important; }
.idle-k {
  display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--pill-idle); color: var(--pill-idle-ink); font-weight: 600; font-size: .75rem;
}
.idle-line b { color: var(--ink); font-weight: 600; }

/* 收藏頁：路線卡（路線號＋起訖＋★，下面兩個方向） */
.section-head.sub { padding-top: 14px; }
.section-head.sub + .section-head.sub, .section-head + .section-head.sub { padding-top: 4px; }
.section-head h3 { font-size: .9375rem; margin: 0; font-weight: 700; }
.rcard { padding: 12px 16px 8px; }
.rc-head { display: flex; align-items: center; gap: 12px; }
.rc-head .rt { font-family: var(--num); font-weight: 600; font-size: 1.625rem; line-height: 1; text-decoration: none; }
.rc-head .rt.long { font-family: var(--text); font-size: 1rem; font-weight: 700; }
.rc-head .ends { flex: 1; min-width: 0; font-size: .875rem; color: var(--muted); }
.rc-star { border: 0; background: none; color: var(--accent); font-size: 1.25rem; line-height: 1; padding: 8px; margin: -8px -8px -8px 0; cursor: pointer; border-radius: 50%; }
.rc-dir { display: flex; align-items: center; gap: 12px; padding: 8px 0; text-decoration: none; }
.rc-dir + .rc-dir { border-top: 1px solid var(--line); }
.rc-dir .hd { flex: 1; min-width: 0; font-size: .9375rem; line-height: 1.35; }
.rc-dir .hd b { font-weight: 600; }
.rc-dir .hd small { display: block; font-size: .75rem; color: var(--muted); }
.rc-dir .board { font-size: 1.125rem; min-width: 4.25rem; padding: 6px 12px; }
.rc-dir .board.word { font-size: .75rem; padding: 7px 10px; }
.routerow .favmark { margin-left: 4px; }

/* 路線規劃 */
.plan-entry { margin: 0; padding: 0 22px 4px; font-size: .875rem; }
.plan-entry a { color: var(--accent); font-weight: 600; text-decoration: none; }
.planform { position: relative; margin: 8px 16px 0; padding: 8px 16px 16px; background: var(--surface); border-radius: var(--r-card); }
.pf-row { display: flex; align-items: center; gap: 12px; padding: 8px 44px 8px 0; border-bottom: 1px solid var(--line); }
.pf-k { flex: none; width: 2.5rem; font-size: .8125rem; font-weight: 700; color: var(--muted); }
.pf-row input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 1rem; padding: 8px 0; color: var(--ink); }
.pf-row input:focus { outline: none; }
.pf-swap { position: absolute; right: 12px; top: 38px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--field); color: var(--ink); font-size: 1.125rem; cursor: pointer; }
.pf-go { margin-top: 14px; width: 100%; }
.planrecent { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 16px; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.planrecent .grow { flex: 1; min-width: 0; }
.planrecent .nm { font-weight: 700; }
.planrecent .rts { font-size: .8125rem; color: var(--muted); }

/* 搜尋結果最上方：規劃怎麼到這個地點 */
.planrow { display: flex; align-items: center; gap: 10px; margin: 12px 16px 0; padding: 12px 16px; border-radius: var(--r-card);
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .9375rem; text-decoration: none; }

/* 站牌列（附近、搜尋） */
.stoprow { display: flex; gap: 12px; align-items: center; padding: 13px 16px; text-decoration: none; }
.stoprow .nm { font-weight: 700; font-size: 1.0625rem; }
.stoprow .hds { font-size: .8125rem; font-weight: 600; color: var(--accent); line-height: 1.45; }
.stoprow .rts { color: var(--muted); font-size: .8125rem; line-height: 1.45; overflow-wrap: anywhere; }
.stoprow .dist { margin-left: auto; font-family: var(--num); font-size: 1rem; color: var(--muted); white-space: nowrap; }
.stoprow .grow { flex: 1; min-width: 0; }

/* 路線列（搜尋） */
.routerow { display: flex; align-items: center; gap: 14px; padding: 13px 16px; text-decoration: none; }
.routerow .rt { font-family: var(--num); font-weight: 600; font-size: 1.5rem; line-height: 1; min-width: 3.5rem; }
.routerow .rt.long { font-family: var(--text); font-size: 1rem; font-weight: 700; line-height: 1.25; }
.routerow .ends { font-size: .875rem; color: var(--muted); }
.routerow .city { margin-left: auto; font-size: .75rem; color: var(--muted); white-space: nowrap; }

/* 路線頁：方向切換（分段膠囊）+ 站序 */
.seg { display: flex; gap: 4px; margin: 8px 16px 4px; padding: 4px; background: var(--field); border-radius: 999px; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 999px;
  padding: 8px 10px; cursor: pointer; font-size: .875rem; line-height: 1.3; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 4px rgba(70, 58, 35, .1); }
.route-info { padding: 6px 22px 2px; font-size: .8125rem; color: var(--muted); }

.seq { margin-top: 10px; }
.seq li { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 16px 10px 46px; min-height: 58px; }
/* 站序是真的順序：用一條路線縱線串起來（不用分隔線，線本身就是結構） */
.seq li::before { content: ""; position: absolute; left: 23px; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .3; }
/* 圓點固定在第一行的高度，展開按鈕時才不會跑到中間 */
.seq li:first-child::before { top: 29px; }
.seq li:last-child::before { bottom: calc(100% - 29px); }
.seq li::after { content: ""; position: absolute; left: 18px; top: 29px; width: 13px; height: 13px; margin-top: -6.5px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.seq li.near::after { background: var(--accent); }
.seq a { text-decoration: none; font-size: 1rem; }
.seq > li { cursor: pointer; }
.seq > li.open { background: var(--accent-soft); }
.seq > li.me .sname { font-weight: 700; }
.sname { min-width: 0; }
.favmark { color: var(--accent); font-size: .8125rem; }
.metag { display: block; font-size: .75rem; font-weight: 600; color: var(--accent); }
.rowpanel { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; }
.rowpanel .primary, .rowpanel .secondary { padding: 8px 14px; font-size: .875rem; }
.seq .board { min-width: 4.25rem; font-size: 1.125rem; padding: 6px 12px; }
.seq .board.word { font-size: .75rem; padding: 7px 10px; }

/* 搜尋框：填色、不加框線，左側放大鏡 */
.searchbar { position: relative; padding: 4px 16px 6px; }
.searchbar::before {
  content: ""; position: absolute; left: 30px; top: 50%; width: 18px; height: 18px; margin-top: -9px; background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.searchbar input {
  width: 100%; padding: 12px 14px 12px 42px; border: 1.5px solid transparent; border-radius: var(--r-ctl); background: var(--field);
  font-size: 1rem;
}
.searchbar input::placeholder { color: var(--muted); }
.searchbar input:focus { border-color: var(--accent); background: var(--surface); outline: none; }

/* 文字按鈕（例如「清除」） */
.linkbtn { border: 0; background: none; padding: 4px 0; color: var(--muted); font-size: .8125rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* 空狀態與提示 */
.empty { padding: 28px 22px; color: var(--muted); max-width: 34rem; }
.empty h2 { color: var(--ink); font-size: 1.125rem; margin: 0 0 6px; }
.empty p { margin: 0 0 14px; }
.primary {
  display: inline-block; border: 0; border-radius: 999px; padding: 11px 20px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
}
.secondary {
  display: inline-block; border: 0; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 11px 18px; cursor: pointer; font-weight: 600; text-decoration: none;
}
.note { padding: 12px 22px 24px; font-size: .8125rem; color: var(--muted); }
.navlinks { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 16px 8px; }

/* 路線色標籤（捷運線）：用該線顏色的淡色底 */
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; line-height: 1.2; color: var(--ink); font-weight: 600;
  padding: 3px 9px 3px 7px; border-radius: 999px; background: color-mix(in srgb, var(--c) 16%, var(--surface));
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* ---------- 停車場 ---------- */
.parkrow { display: flex; gap: 12px; align-items: center; padding: 13px 16px; text-decoration: none; }
.parkrow .grow { flex: 1; min-width: 0; }
.parkrow .nm { font-weight: 700; font-size: 1rem; }
.parkrow .rts { color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.spaces { display: flex; gap: 6px; }
.space { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.space-k { font-size: .6875rem; color: var(--muted); }
.space .board { min-width: 3.75rem; font-size: 1.125rem; padding: 6px 10px; }
.space .board.word { font-size: .6875rem; padding: 7px 8px; }
.parkline { grid-template-columns: 4.5rem 1fr auto; }
.facts { margin: 8px 16px 0; padding: 14px 16px; display: grid; grid-template-columns: 4.5rem 1fr; gap: 10px 12px; font-size: .9375rem; background: var(--surface); border-radius: var(--r-card); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- 捷運地圖 ---------- */
.metro-wrap { position: relative; height: 56dvh; min-height: 300px; margin: 4px 16px 0; background: var(--surface); border-radius: var(--r-card); overflow: hidden; }
#mmap { stroke: none; stroke-width: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
/* 線：固定像素粗細（放大縮小都一樣粗） */
#mmap .ln { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#mmap.detail .ln { stroke-width: 7; }
#mmap .ln.walk { stroke: var(--muted); stroke-width: 2.5; stroke-dasharray: 3 4; }
#mmap .trip { fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#mmap .trip.walk { stroke: var(--ink); stroke-width: 3; stroke-dasharray: 3 4; }
#mmap.has-trip .ln { opacity: .2; }
#mmap.has-trip .stn:not(.onpath) { opacity: .3; }
/* 站：白底圓圈＋線色外框；轉乘站黑框；起點實心綠、終點實心黑 */
#mmap .c { fill: var(--surface); stroke-width: 2.6; vector-effect: non-scaling-stroke; }
#mmap .major .c { stroke-width: 3; }
#mmap:not(.detail) .c { stroke-width: 1.8; }
#mmap .halo { fill: none; }
#mmap .preview .halo { fill: var(--accent); opacity: .2; }
#mmap .origin .c { fill: var(--accent); stroke: var(--accent) !important; }
#mmap .dest .c { fill: var(--ink); stroke: var(--ink) !important; }
#mmap .nodata .c, #mmap .untimed .c { fill: var(--field); }
#mmap text { pointer-events: none; }
#mmap .n { display: none; fill: var(--ink); font-family: var(--num); font-weight: 700; font-size: 1.05em; text-anchor: middle; dominant-baseline: central; }
#mmap.detail .n { display: inline; }
#mmap .dest .n { fill: var(--surface); }
#mmap .lbl { display: none; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: calc(3px * var(--u, 1)); stroke-linejoin: round; }
#mmap.detail .lbl, #mmap.mid .major .lbl, #mmap.mid .term .lbl, #mmap .origin .lbl, #mmap .dest .lbl, #mmap .preview .lbl { display: inline; }
#mmap .major .lbl, #mmap .origin .lbl, #mmap .dest .lbl { font-weight: 700; }
/* 地圖下緣：說明＋定位／縮放 */
.mbar {
  position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 12px; border-radius: 16px; background: color-mix(in srgb, var(--paper) 94%, transparent);
  font-size: .75rem; color: var(--ink);
}
.mbar span { flex: 1; min-width: 0; }
.mbar button { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 0; background: var(--surface); color: var(--ink); font-size: 1.125rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.mbar button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.sheet-hint.small { font-size: .8125rem; padding-top: 0; }

.msheet { margin: 12px 16px 0; padding: 4px 0 8px; background: var(--surface); border-radius: var(--r-card); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 4px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; line-height: 1.25; }
.kicker { font-size: .8125rem; color: var(--muted); }
.sheet-hint { margin: 0; padding: 8px 16px; font-size: .875rem; color: var(--muted); }
.sheet-hint b { color: var(--ink); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 8px 16px; }
.sheet-actions.pad { padding: 14px 16px 4px; }
.trip-sum { display: flex; align-items: center; gap: 14px; padding: 8px 16px; }
.trip-sum .board { font-size: 1.75rem; min-width: 6rem; padding: 9px 16px; }
.trip-facts { font-size: .9375rem; line-height: 1.5; }
.trip-facts .meta { color: var(--muted); font-size: .8125rem; }
.legs { list-style: none; margin: 4px 16px; padding: 0; }
.legs li { position: relative; padding: 4px 0 4px 18px; font-size: .9375rem; }
.legs li::before { content: ""; position: absolute; left: 3px; top: 6px; bottom: 6px; width: 5px; border-radius: 3px; background: var(--c); }
.legs .toward { display: inline-block; margin-left: 6px; padding: 0 9px; border-radius: 999px; background: color-mix(in srgb, var(--c) 18%, var(--surface)); font-weight: 700; font-size: .875rem; }
.legs li { padding-top: 6px; padding-bottom: 6px; line-height: 1.5; }
.legs .meta, .lineinfo .meta { color: var(--muted); font-size: .8125rem; }
.lineinfo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.lineinfo .chip { font-size: .875rem; padding: 4px 11px 4px 9px; }

/* 捷運站出口 */
.exit { padding: 13px 16px; }
.exit-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.exit-no { font-weight: 700; font-size: 1.0625rem; }
.exit-d { margin: 2px 0 0; font-size: .875rem; }
.exit-d .meta { color: var(--muted); }
.buses { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bus { font-size: .8125rem; padding: 4px 10px; border-radius: 999px; background: var(--field); text-decoration: none; }
a.bus { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- 底部分頁：浮在底部的圓角列 ---------- */
.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: var(--tabs-h);
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; font-size: .75rem; color: var(--muted);
}
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 700; }
.tabs a[aria-current="page"] svg { stroke-width: 2.3; fill: var(--accent-soft); }

@media (min-width: 640px) {
  body { max-width: 560px; margin: 0 auto; }
  .tabs { max-width: 536px; margin: 0 auto; }
}

/* 捷運站：站內設施（說明文字保留原本的換行） */
/* 站內設施：一項一列；出口編號是標籤；「付費區」字樣已在伺服器端拿掉 */
.fac-tabs { margin: 0 16px 8px; }
.fac-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.fac-tabs i { width: 8px; height: 8px; border-radius: 50%; }
.fc { margin: 0 16px; padding: 2px 16px; background: var(--surface); border-radius: var(--r-card); }
.fr { display: flex; gap: 12px; padding: 12px 0; }
.fr + .fr, .fmore .fr:first-of-type { border-top: 1px solid var(--line); }
.fl { flex: none; width: 4.75rem; font-weight: 700; font-size: .9375rem; line-height: 1.6; }
.fv { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; font-size: .875rem; line-height: 1.6; }
.frow { display: flex; gap: 8px; align-items: baseline; }
.frow em { flex: none; font-style: normal; font-size: .75rem; color: var(--muted); min-width: 2.25rem; }
.fsegs { display: inline; overflow-wrap: anywhere; }
.ex { display: inline-block; margin: 1px 4px 1px 0; padding: 0 7px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8125rem; line-height: 1.6; white-space: nowrap; }
.fsegs span:not(.ex):not(.yes) + .ex { margin-left: 4px; }
.yes { color: var(--accent); font-weight: 700; }
.fmore { border-top: 1px solid var(--line); }
.fmore summary { padding: 12px 0; font-size: .875rem; font-weight: 600; color: var(--accent); cursor: pointer; }
.fmore[open] summary { padding-bottom: 4px; }
/* 出口：右上角標籤顯示電梯／手扶梯；可只看有電梯的出口 */
.exit-h { align-items: center; }
.exit-n { font-family: var(--num); font-size: 1.25rem; }
.badges { display: inline-flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; border: 1.5px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.elev { background: #2f5fa8; border-color: #2f5fa8; color: #fff; }
.maplink { margin-left: 6px; font-size: .8125rem; color: var(--muted); }
.buses .extra { display: none; }
.buses.all .extra { display: inline-block; }
button.bus { border: 0; font: inherit; font-size: .8125rem; cursor: pointer; background: var(--pill-idle); color: var(--pill-idle-ink); font-weight: 600; }
.exits > li[hidden] { display: none; }
.chipseg { display: inline-flex; gap: 6px; }
.chipseg button { border: 0; font: inherit; font-size: .8125rem; font-weight: 600; padding: 4px 11px; border-radius: 999px; background: var(--field); color: var(--muted); cursor: pointer; }
.chipseg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* 車站頁「跳到」列：黏在頁首下方，可橫向滑動 */
.jump {
  position: sticky; top: var(--top-h, 64px); z-index: 4;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 4px 0 0; padding: 8px 16px; background: var(--paper);
}
.jump::-webkit-scrollbar { display: none; }
.jump button {
  flex: none; border: 0; font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: 999px; background: var(--field); color: var(--muted);
}
.jump button[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.jump-target { scroll-margin-top: calc(var(--top-h, 64px) + 52px); }
