/* 派車工作站 — 長時間盯著看的工具：雪青淡紫底、深紫墨字，主要動作與選取才用強紫。
   深色模式：把同一套語意 token 換一組值，元件規則都只讀 token，不寫死顏色。
   emoji 字型放在字型堆疊最後，客人打的 emoji 才會用系統彩色字型畫出來。 */
:root {
  /* 一定要明講：只靠 <meta name="color-scheme" content="light dark">，使用者手動選淺色時
     系統仍偏好深色，瀏覽器就會把原生控制項（select 之類）畫成深色，變成白底配黑色下拉。 */
  color-scheme: light;
  --paper: #ecebf6;         /* 雪青系的淡底：比原本再深一點，白色卡片才浮得起來（0911 使用者要求） */
  --surface: #ffffff;
  --topbar-bg: #ecebf6;     /* 標題列跟著淡紫（0911 使用者要求） */
  --topbar-ink: #1e1b2e;    /* 標題列上的字：深色模式標題列是飽和紫，要換成白字 */
  --topbar-ink-2: #565073;
  --topbar-hover: #e0ddef;
  --field: #ffffff;         /* 輸入框、下拉、次要按鈕底 */
  --hover: #f6f4fd;
  --selected: #ebe8f8;
  --ink: #1e1b2e;
  --ink-2: #565073;
  --muted: #7d7799;
  --on-ink: #ffffff;        /* 疊在 --ink 底上的字 */
  --line: #e4e1ef;
  --line-strong: #cbc6de;
  --act: #6750c4;           /* 主要動作：雪青加深到白字看得清楚 */
  --act-ink: #ffffff;
  --act-soft: #ebe8f8;      /* 選中的膠囊、淡底 */
  --open: #b0761c;          /* 待接單 */
  --open-bg: #fdf2df;
  --accepted: #1f7a5a;      /* 已接單 */
  --accepted-bg: #e2f3ec;
  --done: #565073;
  --done-bg: #eceaf4;
  --cancel: #7d7799;
  --cancel-bg: #f0eef7;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --warn: #86683a;          /* 需留意（欠款、已接未上車）：低飽和琥珀，跟待接單的 --open 分開 */
  --warn-bg: #f4eee2;
  --focus: #6750c4;
  --bubble: #ffffff;        /* 客人來訊泡泡 */
  --bubble-line: #e4e1ef;
  --out-bubble: #ece8fa;    /* 我們發出去的泡泡 */
  --out-bubble-line: #d7cff3;
  --out-bubble-ink: #1e1b2e; /* 泡泡裡的字；深色模式泡泡是亮紫，字要白 */
  --out-cap: #7d7799;       /* 泡泡裡「系統發給客人」那行小字 */
  --pick: #46765f;          /* 上車：低飽和的綠 */
  --pick-bg: #eaf2ee;
  --pick-line: #c8ded3;
  --drop: #566590;          /* 下車：低飽和的藍 */
  --drop-bg: #ebeef7;
  --drop-line: #ccd4e9;
  --reply: #4f6f79;         /* 客服親手回覆：跟系統通知的灰分得出來，但一樣不搶眼 */
  --overlay: rgba(22, 19, 34, 0.88);   /* 上車照片全螢幕的底 */
  --ok-dot: #1f7a5a;        /* 今日車趟的照片狀態點 */
  --shadow: 0 6px 24px rgba(37, 26, 74, 0.16);
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol";
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif, var(--emoji);
  --sans: -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif, var(--emoji);
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace, var(--emoji);
  --r-ctl: 10px;            /* 輸入框、按鈕、下拉 */
  --r-sm: 8px;              /* 小按鈕 */
  --r-card: 12px;           /* 卡片、表單、表格 */
  --focus-ring: rgba(103, 80, 196, 0.18);
  --list-w: 380px;
  --side-w: 380px;
  --topbar-h: 52px;
}

/* 沒有手動選過就跟著系統 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
  :root:not([data-theme="light"]) {
    --paper: #14121c;
    --surface: #1c1a27;
    --topbar-bg: #4a2a94;             /* 飽和紫標題列（0916 使用者參考圖） */
    --topbar-ink: #ffffff;
    --topbar-ink-2: rgba(255, 255, 255, 0.74);
    --topbar-hover: rgba(255, 255, 255, 0.14);
    --field: #232030;
    --hover: #232030;
    --selected: #2e2945;
    --ink: #e9e7f3;
    --ink-2: #b3aecb;
    --muted: #8f8aa8;
    --on-ink: #14121c;
    --line: #2a2638;
    --line-strong: #3f3958;
    --act: #cfc0f5;
    --act-ink: #241a3d;
    --act-soft: #2e2945;
    --open: #e0a94a;
    --open-bg: #3a2f16;
    --accepted: #4fbf94;
    --accepted-bg: #16332a;
    --done: #b3aecb;
    --done-bg: #2a2638;
    --cancel: #8f8aa8;
    --cancel-bg: #262233;
    --danger: #ef6a5c;
    --danger-bg: #3a1d1a;
    --warn: #cdb489;
    --warn-bg: #302a20;
    --focus: #b9a7f0;
    --focus-ring: rgba(185, 167, 240, 0.24);
    --bubble: #28234a;                /* 客人來訊：深靛藍 */
    --bubble-line: #342e5c;
    --out-bubble: #6a4fd8;            /* 我們發出去的：亮紫、白字 */
    --out-bubble-line: #6a4fd8;
    --out-bubble-ink: #ffffff;
    --out-cap: rgba(255, 255, 255, 0.72);
    --pick: #83bda3;
    --pick-bg: #1c2b25;
    --pick-line: #2d4539;
    --drop: #9ba9d4;
    --drop-bg: #1f2338;
    --drop-line: #343b59;
    --reply: #ffffff;                 /* 亮紫泡泡上只有白色讀得清楚；靠粗體跟系統通知區分 */
    --overlay: rgba(0, 0, 0, 0.9);
    --ok-dot: #4fbf94;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  }
}

/* 手動選深色 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #14121c;
  --surface: #1c1a27;
  --topbar-bg: #4a2a94;             /* 飽和紫標題列（0916 使用者參考圖） */
  --topbar-ink: #ffffff;
  --topbar-ink-2: rgba(255, 255, 255, 0.74);
  --topbar-hover: rgba(255, 255, 255, 0.14);
  --field: #232030;
  --hover: #232030;
  --selected: #2e2945;
  --ink: #e9e7f3;
  --ink-2: #b3aecb;
  --muted: #8f8aa8;
  --on-ink: #14121c;
  --line: #2a2638;
  --line-strong: #3f3958;
  --act: #cfc0f5;
  --act-ink: #241a3d;
  --act-soft: #2e2945;
  --open: #e0a94a;
  --open-bg: #3a2f16;
  --accepted: #4fbf94;
  --accepted-bg: #16332a;
  --done: #b3aecb;
  --done-bg: #2a2638;
  --cancel: #8f8aa8;
  --cancel-bg: #262233;
  --danger: #ef6a5c;
  --danger-bg: #3a1d1a;
  --warn: #cdb489;
  --warn-bg: #302a20;
  --focus: #b9a7f0;
  --focus-ring: rgba(185, 167, 240, 0.24);
  --bubble: #28234a;                /* 客人來訊：深靛藍 */
  --bubble-line: #342e5c;
  --out-bubble: #6a4fd8;            /* 我們發出去的：亮紫、白字 */
  --out-bubble-line: #6a4fd8;
  --out-bubble-ink: #ffffff;
  --out-cap: rgba(255, 255, 255, 0.72);
  --pick: #83bda3;
  --pick-bg: #1c2b25;
  --pick-line: #2d4539;
  --drop: #9ba9d4;
  --drop-bg: #1f2338;
  --drop-line: #343b59;
  --reply: #ffffff;                 /* 亮紫泡泡上只有白色讀得清楚；靠粗體跟系統通知區分 */
  --overlay: rgba(0, 0, 0, 0.9);
  --ok-dot: #4fbf94;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: 0.01em; }
.error { color: var(--danger); margin: 0; }

/* ---------- 登入 ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 360px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 28px 24px; display: grid; gap: 14px; }
.login-card h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 26px; letter-spacing: 0.02em; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.login-card input { padding: 10px 12px; border: 1px solid var(--line-strong); background: var(--field); border-radius: var(--r-ctl); font-size: 16px; }

/* ---------- 版面 ---------- */
/* 手機瀏覽器的網址列會伸縮：用 dvh 讓整個 App 剛好等於「看得到的高度」，
   標題列（第一列）才不會被推到畫面外，只有下面的清單 / 對話在捲。 */
.app { height: 100%; height: 100dvh; display: grid; grid-template-rows: var(--topbar-h) auto minmax(0, 1fr); }
/* 三列一定要「指名」放在第幾列，不能靠出場順序：客人沒有備註時 #note-strip 是 hidden（不佔格），
   main 就會掉到第 2 列的 auto，高度只剩內容那麼高 —— 訊息少的時候，釘在底部的回覆列
   就會停在畫面中間，下面空一大片。 */
.topbar { grid-row: 1; }
.note-strip { grid-row: 2; }
.main { grid-row: 3; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--topbar-bg); border-bottom: 1px solid var(--line); }
.topbar-fleet { font-family: var(--serif); font-weight: 700; font-size: 17px; white-space: nowrap; color: var(--topbar-ink); }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tabs a { padding: 6px 12px; border-radius: var(--r-sm); color: var(--topbar-ink-2); font-size: 14px; }
.tabs a[aria-selected="true"] { background: var(--act); color: var(--act-ink); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--open); color: var(--act-ink); font-family: var(--mono); font-size: 11px; text-align: center; line-height: 18px; vertical-align: 1px; }
.topbar-me { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--topbar-ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--accepted); box-shadow: 0 0 0 3px var(--accepted-bg); }
.dot-off { background: var(--muted); }
.dot-warn { background: var(--open); }
.topbar-back, .topbar-title, .bottom-tabs { display: none; }
#btn-theme, #btn-logout { display: none; }        /* 一律收進右上角的 ⋯ */
.topbar-more { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: none; color: var(--topbar-ink-2); font-size: 20px; line-height: 1; cursor: pointer; }
.topbar-more:hover { background: var(--topbar-hover); color: var(--topbar-ink); }
.more-menu { display: grid; position: fixed; top: calc(var(--topbar-h) + 6px); right: 12px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 6px; min-width: 148px; }
.more-item { border: 0; background: none; color: var(--ink); text-align: left; padding: 10px 12px;
  border-radius: var(--r-sm); font-size: 15px; cursor: pointer; }
.more-item:hover { background: var(--hover); }
.btn-text { background: none; border: 0; padding: 4px 6px; color: var(--ink-2); cursor: pointer; }
.btn-text:hover { color: var(--ink); }

.main { display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr); min-height: 0; }
.main.has-side { grid-template-columns: var(--list-w) minmax(0, 1fr) var(--side-w); }
.pane { min-height: 0; overflow: auto; }
.pane-list { background: var(--surface); border-right: 1px solid var(--line); }
.pane-detail { padding: 24px 28px 48px; }
/* 派車功能自己一欄，訊息再多也不會把它推走 */
.pane-side { background: var(--surface); border-left: 1px solid var(--line); padding: 18px 18px 40px; display: grid; gap: 18px; align-content: start; }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h3 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.side-close { display: none; }
.pane-side .form { border: 0; padding: 0; background: none; }
.pane-side .card { padding: 14px 16px; }
.side-scrim { display: none; }

/* 客人備註：一句話標籤，放在對話最上面 */
.note-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* 釘在標題列正下方，對話捲多遠都看得到 */
.note-strip { padding: 7px 16px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 13px; }
.note-bar.is-editing { gap: 6px; }
.note-tag { display: inline-block; background: var(--open-bg); color: var(--open); border-radius: 999px;
  padding: 2px 10px; font-size: 12.5px; font-weight: 600; line-height: 1.6; }
.crow-name .note-tag { margin-left: 6px; vertical-align: 1px; font-size: 11.5px; padding: 1px 8px; }
.note-edit { font-size: 12.5px; text-decoration: underline; }
.note-input { flex: 1 1 180px; min-width: 0; padding: 7px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); background: var(--field); font-size: 16px; }   /* 16px：iOS 聚焦時才不會整頁自動放大 */
.note-input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }

/* 對話欄 */
.chat { display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.chat-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; position: sticky; top: -24px; z-index: 1; background: var(--paper); padding: 4px 0 10px; margin-top: -4px; }
.chat-head h2 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 24px; }
.chat-head .sub { color: var(--muted); font-size: 13px; }
.chat .msgs { margin-top: auto; }
.chat-empty { padding: 24px 0; }

/* 對話頁把詳情欄的底部留白收掉：sticky 只能貼到 .chat 的下緣，
   留著 48px 的話回覆列就會浮在半空、底下透出一條底色。 */
.pane-detail:has(.chat) { padding-bottom: 0; }

/* 回覆列：釘在對話捲動容器最底下。左邊窄鍵開派車面板，右邊打字回覆客人（一則就是一則 LINE Push）。
   左右用負 margin 撐滿詳情欄，訊息捲過去時不會從邊緣露出來。 */
.composer { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: nowrap; gap: 8px; align-items: flex-end;
  margin: 0 -28px; padding: 10px 28px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line); }
/* 用 .composer 前綴壓過 .btn-primary 的大 padding：這兩顆是工具鍵，不是頁面主要動作 */
.composer .btn { flex: 0 0 auto; padding: 10px 12px; font-size: 13.5px; }
.composer .composer-ride { min-width: 58px; position: relative; }
/* 這位客人有進行中的車趟：鍵的右上角一個小點 */
.composer .composer-ride.has-ride::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--act-ink); }
/* 送出是圖示不是字：正圓、圖示置中，不吃 .composer .btn 的左右 padding */
.composer .composer-send { width: 38px; height: 38px; padding: 0; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; }
.composer-send svg { display: block; margin-left: 2px; }   /* 三角形的視覺重心偏左，往右挪一點才置中 */
.composer-input { flex: 1 1 60px; min-width: 0; width: auto; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--field); color: var(--ink);
  font-size: 15px; line-height: 1.45; resize: none; overflow-y: auto;
  max-height: calc(7.25em + 18px); }   /* 約 5 行，再長就自己捲 */
.composer-input:hover { border-color: var(--ink-2); }
.composer-input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }
.composer-input:disabled { background: var(--hover); color: var(--muted); cursor: not-allowed; }

/* ---------- 清單通用 ---------- */
.list-head { position: sticky; top: 0; z-index: 1; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.list-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.list-head .spacer { flex: 1; }
.list-head select { border: 1px solid var(--line-strong); background: var(--field); padding: 4px 8px; border-radius: var(--r-ctl); font-size: 13px; }
.empty { padding: 40px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; }

/* 客人列：像通訊軟體的聊天清單 — 名字是主角，最後一句話當摘要 */
.crow { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.crow:hover { background: var(--hover); }
.crow[aria-current="true"] { background: var(--selected); }
.crow[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--act); }
.crow.is-new::after { content: ""; position: absolute; right: 12px; top: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--act); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--paper); border: 1px solid var(--line); object-fit: cover; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; color: var(--ink-2); font-size: 15px; }
.crow-name { font-size: 16px; font-weight: 600; line-height: 1.35; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-msg { font-size: 13.5px; line-height: 1.4; color: var(--ink-2); margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.crow.is-new .crow-msg { color: var(--ink); }
.crow-msg.is-unsent { color: var(--muted); font-style: italic; }
.crow-time { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 3px; }
.crow > div:nth-child(2) { min-width: 0; }

/* 訂單列 */
.orow { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.orow:hover { background: var(--hover); }
.orow[aria-current="true"] { background: var(--selected); }
.orow-route { font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.35; grid-column: 1 / -1; }
.orow-route .arrow { color: var(--muted); font-family: var(--sans); font-weight: 400; margin: 0 6px; }
.orow-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.orow-side { display: grid; justify-items: end; gap: 4px; }

/* 狀態籤 */
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.chip-OPEN { background: var(--open-bg); color: var(--open); }
.chip-ACCEPTED { background: var(--accepted-bg); color: var(--accepted); }
.chip-COMPLETED { background: var(--done-bg); color: var(--done); }
.chip-CANCELLED { background: var(--cancel-bg); color: var(--cancel); }
.chip-notify { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2); font-weight: 500; }
.chip-notify.is-failed { border-color: var(--danger); color: var(--danger); }
.chip-notify.is-ok { border-color: var(--accepted); color: var(--accepted); }
.chip-sched { background: var(--selected); color: var(--ink-2); font-weight: 500; }
.chip-late { background: var(--danger-bg); color: var(--danger); }
/* 聊天狀態條上的司機：淡紫底，點了到司機詳情 */
.chip-driver { background: var(--act-soft); color: var(--ink); font-weight: 500; }
a.chip-driver:hover, .note-strip a.chip:hover { filter: brightness(0.97); }
.chip .timer.mono { font-size: 0.95em; }
.mono .timer.mono { font-size: 1em; }          /* 訂單列「車牌 · 計時器」外層已經縮過一次，不要再縮 */

/* ---------- 計時器：到點倒數 / 遲到（每秒只改字，不重排） ---------- */
.timer { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timer.is-late { color: var(--danger); font-weight: 600; }
.count-late { background: var(--danger); }
.hint { font-size: 12.5px; color: var(--muted); }
.link { color: var(--act); }
.link:hover { text-decoration: underline; }
.dd-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.timer-big .timer { font-size: 18px; font-weight: 500; }
.timer-big .timer.is-late { font-weight: 600; }

/* 司機監控 */
.orow-route .plate { font-family: var(--mono); font-weight: 400; font-size: 13px; margin-left: 8px; }
.orow-route .chip { font-family: var(--sans); font-size: 11px; font-weight: 500; padding: 1px 8px; margin-left: 8px; vertical-align: 2px; }
.ride-head { display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; }
.ride-code { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.today-list { display: grid; }
.today-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 -8px; padding: 8px;
  border-top: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px; }
.today-row:first-child { border-top: 0; }
.today-row:hover { background: var(--hover); }
.detail-head .push { margin-left: auto; align-self: center; }
#driver-extra:empty { display: none; }

/* ---------- 上車照片（APK①） ---------- */
.photo-slot { display: grid; gap: 8px; justify-items: start; }
.photo-slot.is-mini { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.photo-open { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--r-sm); line-height: 0; }
.photo-thumb { display: block; max-width: min(240px, 100%); height: auto; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--paper); }
.photo-mini { display: block; height: 56px; width: auto; max-width: 96px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--paper); }
.photo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12.5px; }
.photo-meta .chip, .photo-slot .chip { font-weight: 500; }
.photo-fail { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.photo-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.photo-dot.is-uploaded { background: var(--ok-dot); }
.photo-dot.is-pending { background: var(--warn); }
.photo-dot.is-missing { background: var(--danger); }
.photo-dot.is-purged { background: var(--line-strong); }
/* 全螢幕：<dialog> 在最上層，底半透明，照片等比縮到畫面內 */
.photo-overlay { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--overlay); color: #fff; cursor: zoom-out; }
.photo-overlay[open] { display: grid; place-items: center; }
.photo-overlay::backdrop { background: var(--overlay); }
.photo-overlay img { display: block; max-width: 100vw; max-height: 100vh; max-height: 100dvh; object-fit: contain;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }

/* ---------- 參考車資與暫下（APK②） ---------- */
.kv dd.fare-total { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 18px; letter-spacing: 0.01em; }
.fare-amt { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.chip-wait.timer { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
/* summary 設成 flex 在 Chromium 會沒有 ::marker，展開指示自己畫（CSS 箭頭，不用字元），各瀏覽器一致 */
.fare-waits summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; cursor: pointer; list-style: none; }
.fare-waits summary::-webkit-details-marker { display: none; }
.fare-waits summary::before { content: ""; width: 5px; height: 5px; margin: 0 2px 0 1px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform 120ms ease-out; }
.fare-waits[open] summary::before { transform: rotate(45deg); }
.fare-waits[open] summary { margin-bottom: 4px; }
.wait-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 13px; }
.wait-row .chip { font-weight: 500; font-size: 11.5px; padding: 1px 8px; }
.rule-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; color: var(--ink-2); }
.form label select { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--field); font-size: 15px; width: 100%; }

/* ---------- 客服 ↔ 司機訊息（D.3） ---------- */
.unread-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--act); margin-left: 8px; vertical-align: 3px; }
.tab-dot { margin-left: 4px; vertical-align: 2px; }
.tabs a[aria-selected="true"] .tab-dot { background: var(--act-ink); }
.bottom-tabs .tab-dot { margin-left: 0; vertical-align: 0; }
.driver-msgs { gap: 12px; }
.driver-msgs .dm-new { justify-self: center; }
.toast.is-link { cursor: pointer; }
.driver-msgs .msgs.dm-list { max-height: 420px; overflow-y: auto; overscroll-behavior: contain; gap: 8px; padding-right: 2px; }
.dm-list .msg .t { font-size: 14.5px; line-height: 1.5; }
.dm-list .msg-bubble { padding: 7px 12px; max-width: min(480px, 80%); }
.dm-list .msg-cap a { text-decoration: underline; text-underline-offset: 2px; }
.dm-body .empty { padding: 16px 0; }
.driver-composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.driver-composer .composer-input { font-size: 14.5px; }
.driver-composer .composer-send { flex: 0 0 auto; width: 36px; height: 36px; padding: 0; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; }

/* ---------- 懲罰、反省區、鎖定（P2a） ---------- */
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-wait { background: var(--open-bg); color: var(--open); }
.chip .timer { font-weight: inherit; }
.lock-since { color: var(--danger); font-weight: 600; }
.lock-since .timer { font-size: 12.5px; }
.orow-side .chip { font-weight: 500; }
.detail-head .chip { align-self: center; }
/* 附車趟：一列左右捲的選擇籤（手機往右滑返回在這列不作用，data-no-swipe） */
.penalty-attach { display: grid; gap: 6px; }
.chip-scroll { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 2px; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-select { font: inherit; font-size: 12.5px; font-weight: 500; border: 1px solid var(--line-strong); background: var(--field); color: var(--ink-2); cursor: pointer; }
.chip-select:hover { border-color: var(--ink-2); }
.chip-select.is-on { background: var(--act-soft); color: var(--act); border-color: var(--act); font-weight: 600; }
.penalty-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head h3 { margin: 0; }
.card-head .btn { margin-left: auto; }
.pen-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.card-head + .pen-row { border-top: 0; }
.pen-title { font-weight: 600; font-size: 14.5px; }
.pen-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: 12.5px; color: var(--muted); }
.pen-meta .chip { font-weight: 500; font-size: 11.5px; padding: 1px 8px; }
.pen-done { display: grid; }
.pen-row.is-done { grid-template-columns: minmax(0, 1fr); padding: 5px 0; opacity: 0.72; }
.pen-row.is-done .pen-meta { font-size: 12px; }
.audit-list { display: grid; gap: 2px; padding-top: 4px; border-top: 1px solid var(--line); }
.audit-row { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; color: var(--muted); }
.check-label { display: inline-flex !important; align-items: center; gap: 8px; align-self: end; padding: 11px 0; }
.check-label input { margin: 0; width: 16px; height: 16px; accent-color: var(--act); }
.mono-input { font-family: var(--mono); letter-spacing: 0.02em; }
.nowrap { white-space: nowrap; }

/* ---------- 詳情 ---------- */
.detail { max-width: 720px; display: grid; gap: 22px; }
.detail-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 24px; }
.detail-head .sub { color: var(--muted); font-size: 13px; }
.back { display: none; margin-bottom: 8px; }

/* 訊息串：做成聊天泡泡。客人打什麼就顯示什麼（pre-wrap 保留換行，emoji 交給系統彩色字型） */
.msgs { display: flex; flex-direction: column; gap: 10px; }
.msgs h3, .form h3, .card h3, .stats h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.msg-day { align-self: center; font-size: 12px; color: var(--muted); background: var(--selected); border-radius: 999px; padding: 3px 12px; margin: 6px 0 2px; }
.msg { display: flex; align-items: flex-end; gap: 8px; }
.msg-bubble { background: var(--bubble); border: 1px solid var(--bubble-line); border-radius: 16px 16px 16px 5px; padding: 9px 14px; max-width: min(560px, 76%); min-width: 0; }
.msg .t { font-size: 16px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .t.is-unsent { color: var(--muted); font-style: italic; }
/* 來訊左側的頭像；連續來訊只有第一則有，後面用同寬的空位對齊 */
.msg-avatar { width: 34px; height: 34px; flex: 0 0 34px; align-self: flex-start; font-size: 13px; }
.msg-avatar.is-blank { border: 0; background: none; }
.msg-side { display: grid; gap: 4px; justify-items: start; }
/* 我們發給客人的（靠右，像自己送出的訊息） */
.msg.is-out { justify-content: flex-end; }
.msg.is-out .msg-side { justify-items: end; text-align: right; }
.msg-bubble.is-out { background: var(--out-bubble); border-color: var(--out-bubble-line); border-radius: 16px 16px 5px 16px; color: var(--out-bubble-ink); }
/* 泡泡裡的小字跟著泡泡換色（深色模式泡泡是亮紫，灰字會糊掉）；客服回覆那行要壓過去，所以選擇器寫到一樣具體 */
.msg-bubble.is-out .msg-cap { color: var(--out-cap); }
.msg-bubble.is-out .msg-cap.is-reply { color: var(--reply); }
.msg-bubble.is-out .msg-cap a { color: inherit; }
.msg-cap { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; display: flex; gap: 6px; }
/* 客服親手打的回覆，跟系統自動發的通知一眼分得出來 */
.msg-cap.is-reply { color: var(--reply); font-weight: 600; }
.msg-status { font-size: 11px; color: var(--muted); }
.msg-status.is-bad { color: var(--danger); }
.msg time { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.msg-fill { display: flex; gap: 4px; opacity: 0; transition: opacity 120ms ease-out; }
.msg:hover .msg-fill, .msg:focus-within .msg-fill { opacity: 1; }
@media (hover: none) { .msg-fill { opacity: 1; } }
/* LINE 表情貼與貼圖 */
.sticon { width: 1.4em; height: 1.4em; vertical-align: -0.3em; }
.sticon-fallback { font-size: 0.86em; color: var(--muted); }
.sticker { display: block; width: 132px; height: auto; }
.msg-bubble.is-sticker { background: none; border: 0; padding: 0; }
.btn-fill { font: inherit; font-size: 12px; line-height: 1; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.btn-fill.is-pick { color: var(--pick); border-color: var(--pick-line); background: var(--pick-bg); }
.btn-fill.is-drop { color: var(--drop); border-color: var(--drop-line); background: var(--drop-bg); }
/* 勾起來 = 這句話已經填進建單欄位 */
.btn-fill.is-on { color: var(--on-ink); font-weight: 600; }
.btn-fill.is-pick.is-on { background: var(--pick); border-color: var(--pick); }
.btn-fill.is-drop.is-on { background: var(--drop); border-color: var(--drop); }
.btn-fill.is-on::after { content: " ✓"; }
.btn-fill:hover { border-color: currentColor; filter: brightness(0.97); }
.btn-fill:active { background: var(--ink); color: var(--on-ink); }
.msgs-more { align-self: flex-start; }

.form { display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; }
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
/* 用 :not() 排除選項鈕，不要一個一個列 type：漏列一種（例如 tel）那格就完全沒有樣式，
   會變成瀏覽器預設的裸輸入框，跟旁邊高矮不一 */
.form input:not([type="radio"]):not([type="checkbox"]), .form textarea { padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--field); font-size: 16px; width: 100%; }
/* 計費「每［ ］分［ ］元」是一句話：要壓過上一條的 width: 100%，所以權重較高且寫在它後面 */
.form .rule-line input:not([type="radio"]):not([type="checkbox"]) { width: 6.5em; flex: 0 0 auto; }
.form textarea { min-height: 64px; resize: vertical; }
.form .req::after { content: " *"; color: var(--act); }
/* 狀態要分得出來：閒置 / 滑過 / 聚焦 / 停用 / 錯誤。
   錯誤用 :user-invalid，使用者還沒填完就不會先被標紅（避免「過早驗證」）。 */
.form input:not([type="radio"]):not([type="checkbox"]):hover, .form textarea:hover,
.login-card input:hover, select:hover, .radios label:hover { border-color: var(--ink-2); }
.form input:focus, .form textarea:focus, .login-card input:focus, select:focus,
.form input:focus-visible, .form textarea:focus-visible, .login-card input:focus-visible, select:focus-visible {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring);
}
.form input:disabled, .form textarea:disabled, .btn:disabled { background: var(--hover); color: var(--muted); cursor: not-allowed; }
/* Chrome 的自動填入會硬蓋一層底色（深色模式下是一塊墨綠），把它蓋回自己的色票 */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--field) inset;
  transition: background-color 9999s ease-out 0s; }
.form input:user-invalid, .form textarea:user-invalid { border-color: var(--danger); }
.form input:user-invalid:focus, .form textarea:user-invalid:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
.field-hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.btn:hover { border-color: var(--ink-2); }
.btn-primary:hover { filter: brightness(0.94); }
.radios { display: flex; gap: 6px; flex-wrap: wrap; }
.radios label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); cursor: pointer; font-size: 14px; color: var(--ink); background: var(--field); }
.radios input { margin: 0; }
.radios label:has(input:checked) { background: var(--act-soft); color: var(--act); border-color: var(--act); font-weight: 600; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn { padding: 8px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line-strong); background: var(--field); cursor: pointer; font-size: 14px; line-height: 1.35; white-space: nowrap; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--act); color: var(--act-ink); border-color: var(--act); font-weight: 600; padding: 10px 22px; }
.btn-primary:hover:not(:disabled) { filter: brightness(0.94); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.result { padding: 12px 14px; border-left: 3px solid var(--accepted); background: var(--accepted-bg); }
.result.is-error { border-color: var(--danger); background: var(--danger-bg); }
.result strong { display: block; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px 20px; display: grid; gap: 10px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv dd.big { font-family: var(--serif); font-weight: 600; font-size: 18px; }
.events { font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }
.events time { font-family: var(--mono); color: var(--muted); margin-right: 8px; }

/* 管理表 */
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td:last-child { width: 1%; white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; }
.table input[type="text"], .table input[type="number"] { width: 100%; padding: 6px 10px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; }
.table input[type="text"]:focus, .table input[type="number"]:focus { outline: none; border-color: var(--line-strong); background: var(--field); }
.table input[type="text"]:hover, .table input[type="number"]:hover { border-color: var(--line); }
.table input[type="number"] { min-width: 88px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--act); }
.table td.td-amount { width: 110px; }
.table td.td-amount input { -moz-appearance: textfield; appearance: textfield; }
.table td.td-amount input::-webkit-outer-spin-button,
.table td.td-amount input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.table select { border: 1px solid var(--line-strong); background: var(--field); color: var(--ink); padding: 5px 8px; border-radius: var(--r-ctl); font-size: 13px; }
.table tr.is-inactive td { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.code-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.link-big { font-family: var(--mono); font-size: 17px; color: var(--act); overflow-wrap: anywhere; }
.row-actions { display: inline-flex; gap: 6px; white-space: nowrap; }
.row-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.row-fields label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.sample { margin: 0; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); font-family: var(--sans); font-size: 14px; white-space: pre-wrap; line-height: 1.6; }

/* ---------- 統計：這個月發了幾則 LINE、跑了幾趟 ---------- */
/* minmax(0, 1fr)：表格再寬也只撐破自己那一格，不會把上面的數字卡一起拉寬 */
.stats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; max-width: 880px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 14px 16px; display: grid; gap: 2px; align-content: start; }
/* 大數字用等寬：兩張卡上下對齊時位數一眼比得出來 */
.stat-n { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 500;
  line-height: 1.25; color: var(--ink); }
.stat-l { font-size: 12.5px; color: var(--ink-2); }
.stat-sub { font-size: 12px; line-height: 1.5; color: var(--muted); }
.stats-note { margin: -8px 0 0; font-size: 12.5px; line-height: 1.6; }

.stats-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.stats-table th, .stats-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stats-table thead th { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted);
  border-bottom: 1px solid var(--line-strong); }
.stats-table tbody tr:hover { background: var(--hover); }
.stats-table tbody tr:last-child td { border-bottom: 0; }
/* 第一欄是月份 / 名稱，其餘當數字：右對齊 + 等寬，才好比大小 */
.stats-table th:not(:first-child), .stats-table td:not(:first-child) { text-align: right; }
.stats-table td:not(:first-child) { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }
/* 中間夾文字欄（司機姓名之類）就掛 .txt 退回一般樣式 —— 特異度要壓得過上面的 :not(:first-child) */
.stats-table td.is-bad { color: var(--danger); font-weight: 600; }
.stats-table tbody tr.is-current { background: var(--hover); }
.stats-table tbody tr.is-current td { font-weight: 600; }

/* LINE 登入 / 加入碼 */
.btn-line { background: #06c755; color: #fff; border-color: #06c755; font-weight: 600; padding: 11px 18px; font-size: 15px; }
.btn-line:hover:not(:disabled) { filter: brightness(0.94); }
.cred-toggle { justify-self: center; font-size: 12px; color: var(--muted); opacity: 0.7; }
.cred-toggle:hover { opacity: 1; }
#cred-login { display: grid; gap: 12px; padding-top: 8px; border-top: 1px dashed var(--line); }
.code { font-family: var(--mono); font-size: 26px; letter-spacing: 0.12em; font-weight: 500; }
.joincode { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.joincode-main { flex: 1 1 240px; }
.joincode-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; margin-bottom: 2px; }
.joincode-hint { margin: 10px 0 0; font-size: 13px; max-width: 46em; }
.joincode-actions { display: flex; gap: 8px; }
.req-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.req-row .who { font-weight: 600; }
.req-row .meta { font-size: 13px; color: var(--muted); }
.req-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; }
.req-actions select { border: 1px solid var(--line-strong); background: var(--field); padding: 5px 8px; border-radius: var(--r-ctl); font-size: 13px; }
.status-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* toast */
/* z-index 要比底部分頁（20）、抽屜（30）、⋯ 選單（40）都高，不然會被蓋掉看不到 */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: var(--r-ctl); font-size: 14px; max-width: min(92vw, 480px); box-shadow: var(--shadow); }

/* ---------- 手機：兩層 ---------- */
@media (max-width: 767px) {
  :root { --topbar-h: 50px; }
  .topbar-fleet { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* ---- 手機標題列：一行放得下 ---- */
  .topbar { gap: 6px; padding: 0 8px; }
  .tabs { display: none; }                       /* 分頁改放底部 */
  .topbar-me #staff-name, #theme-mode { display: none; }
  .more-menu { right: 8px; }
  .topbar-back { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    margin-left: -2px; border: 0; border-radius: 50%; background: none; color: var(--topbar-ink); font-size: 20px; line-height: 1; cursor: pointer; }
  .topbar-back:active { background: var(--topbar-hover); }
  .topbar-title { display: flex; align-items: center; gap: 9px; min-width: 0; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; color: var(--topbar-ink); }
  .topbar-title .tt-name { overflow: hidden; text-overflow: ellipsis; }
  /* 聊天室左上角一直掛著客人頭像（0916 使用者要求） */
  .topbar-title .avatar { width: 30px; height: 30px; flex: 0 0 auto; font-size: 13px; }
  .app[data-level="detail"] .topbar-fleet { display: none; }

  /* ---- 底部分頁 ---- */
  .bottom-tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); }
  .bottom-tabs a { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
    padding: 12px 4px; font-size: 13px; color: var(--muted); }
  .bottom-tabs a[aria-selected="true"] { color: var(--act); font-weight: 600; box-shadow: inset 0 2px 0 var(--act); }
  .app[data-level="list"] .pane-list { padding-bottom: 56px; }   /* 清單捲到底不要被底部分頁蓋住 */
  .app[data-level="detail"] .bottom-tabs { display: none; }      /* 看詳情時讓位給底部的回覆列 */
  /* 手機底部不是分頁列就是回覆列，提示訊息要浮在它們上面，不然只看得到半截 */
  .toast { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  /* 計費頁「第一次之後 每［ ］分［ ］元」手機要擠在同一行：數字最多 4 位，框縮窄、左右 padding 收小 */
  .form .rule-line { gap: 6px 5px; }
  .form .rule-line input:not([type="radio"]):not([type="checkbox"]) { width: 4.2em; padding-left: 8px; padding-right: 8px; }
  .back { display: none; }                                       /* 返回改放標題列 */

  .main, .main.has-side { grid-template-columns: 1fr; }
  .pane-list { border-right: 0; }
  .pane-detail { padding: 16px 14px 40px; }
  .app[data-level="detail"] .pane-list { display: none; }
  .app[data-level="list"] .pane-detail { display: none; }
  /* 往右滑返回 / 進出場動畫：清單和詳情疊在同一格，詳情跟著 --peek-x 移動，清單從左邊 28% 帶回來。
     這組規則要寫在上面兩條 display:none 之後才蓋得過去。 */
  .app[data-peek] .pane-list { display: block; grid-area: 1 / 1; transform: translateX(calc(-28% * (1 - var(--peek-p, 0)))); }
  .app[data-peek] .pane-detail { display: block; grid-area: 1 / 1; z-index: 2; background: var(--paper);
    transform: translateX(var(--peek-x, 0)); box-shadow: -10px 0 28px rgba(0, 0, 0, 0.14); }
  .app[data-peek] .note-strip { transform: translateX(var(--peek-x, 0)); }
  .app.peek-anim .pane-list, .app.peek-anim .pane-detail, .app.peek-anim .note-strip {
    transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1); }
  .chat-head { display: none; }                 /* 客人名字已經在標題列，不再重複一次 */

  /* 派車功能收成底部抽屜：訊息一直長，功能永遠在同一個地方 */
  .side-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.4); }
  .pane-side { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30; max-height: 86vh; overflow: auto;
    border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 14px 14px 0 0;
    padding: 14px 14px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
    /* 只讓 transform 有動畫；visibility 立刻切換，動畫卡住也不會變成打不開的抽屜 */
    transform: translateY(102%); visibility: hidden; transition: transform 180ms ease-out; }
  .app[data-side="open"] .pane-side { transform: none; visibility: visible; }
  .side-close { display: inline-flex; }
  .pane-side .form { padding: 0; }
  .sticker { width: 116px; }
  .crow-msg { font-size: 17px; }
  .btn-fill { font-size: 12.5px; padding: 7px 9px; }
  .form { padding: 14px; }
  .btn-primary { width: 100%; padding: 12px; font-size: 15px; }
  .kv { grid-template-columns: 80px 1fr; }
  .table input[type="text"], .table input[type="number"] { font-size: 16px; }   /* iOS 聚焦不放大 */
  .card-head .btn, .pen-row .btn { width: auto; }

  /* 回覆列：貼齊螢幕左右，底部留 iPhone 手勢條的距離。
     兩顆鍵要 width: auto 蓋掉上面 .btn-primary 的滿版，不然回覆框會被擠沒。 */
  .composer { margin: 0 -14px; gap: 6px; padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .composer .btn { width: auto; padding: 9px 10px; font-size: 13px; }
  .composer .composer-ride { min-width: 52px; }
  .composer-input { padding: 8px 11px; font-size: 16px; }   /* 16px：iOS 聚焦時才不會整頁自動放大 */
  .driver-composer .composer-input { font-size: 16px; }
  .driver-composer .btn { width: 36px; padding: 0; }        /* 蓋掉手機 .btn-primary 的滿版 */
  .driver-msgs .msgs.dm-list { max-height: 55vh; }
  .photo-thumb { max-width: min(240px, 100%); }
  .form label select { font-size: 16px; }                                    /* iOS 聚焦不放大 */
  .kv dd .btn-sm, .kv dd a.btn-sm { width: auto; }

  /* 統計：欄位多到塞不下時，靠 nowrap 把表格自己撐開、在外層 .table-wrap 裡左右捲，整頁不動；
     欄位少的表（司機那張）就乖乖佔滿寬度，不必逼使用者橫捲 */
  .stats { gap: 16px; }
  .stat-cards { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-n { font-size: 22px; }
  .stats-table { font-size: 13px; }
  .stats-table th, .stats-table td { padding: 7px 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  .crow.is-new { animation: rise 240ms ease-out; }
  @keyframes rise { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }
}
