:root {
  --bg: #f5f2ea;
  --card: #ffffff;
  --card2: #faf7f0;
  --text: #1d2433;
  --sub: #6b7280;
  --line: #e5e0d3;
  --accent: #b98a2f;
  --accent2: #7c5cff;
  --good: #1a7f4b;
  --warn: #b45309;
  --bad: #b91c1c;
  --chip: #efe9dc;
  --bar-bg: #e8e2d4;
  --nav-bg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420;
    --card: #182130;
    --card2: #1f2a3c;
    --text: #e9edf4;
    --sub: #98a3b5;
    --line: #2a3548;
    --accent: #e0b25c;
    --accent2: #a48bff;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --chip: #243044;
    --bar-bg: #243044;
    --nav-bg: #141c2b;
  }
}
html[data-theme="light"] {
  --bg:#f5f2ea;--card:#fff;--card2:#faf7f0;--text:#1d2433;--sub:#6b7280;--line:#e5e0d3;
  --accent:#b98a2f;--accent2:#7c5cff;--good:#1a7f4b;--warn:#b45309;--bad:#b91c1c;--chip:#efe9dc;--bar-bg:#e8e2d4;--nav-bg:#fff;
}
html[data-theme="dark"] {
  --bg:#0e1420;--card:#182130;--card2:#1f2a3c;--text:#e9edf4;--sub:#98a3b5;--line:#2a3548;
  --accent:#e0b25c;--accent2:#a48bff;--good:#4ade80;--warn:#fbbf24;--bad:#f87171;--chip:#243044;--bar-bg:#243044;--nav-bg:#141c2b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
/* 自帶字型（離線驗收：不依賴外部 CDN）——僅覆蓋拉丁字母與符號，
   中文仍走系統字體（PingFang TC 等內建字型本来就離線可用）。 */
@font-face { font-family: "Inter Q"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/Inter-Regular.woff2") format("woff2"); }
@font-face { font-family: "Inter Q"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/Inter-Medium.woff2") format("woff2"); }
@font-face { font-family: "Inter Q"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/Inter-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Inter Q"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/Inter-Bold.woff2") format("woff2"); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Inter Q", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  max-width: 520px;
  margin: 0 auto;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
}
#topTitle { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#backBtn {
  border: 1px solid var(--line); background: var(--chip);
  border-radius: 10px; padding: 4px 12px; font-size: 15px; font-weight: 600;
}
#pkgChip {
  font-size: 12px; font-weight: 700; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}

main { padding: 12px 12px calc(76px + env(safe-area-inset-bottom)); }

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; margin: 0 auto; max-width: 520px;
  background: var(--nav-bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar .tab {
  flex: 1; padding: 9px 2px 7px; background: none; border: none;
  color: var(--sub); font-size: 13px; font-weight: 600;
}
#tabbar .tab.active { color: var(--accent); }

/* chips & rows */
.chipbar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chipbar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600; color: var(--sub);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
html:not([data-theme]) .chip.active { color: #161616; }
.chip.ghost { background: var(--chip); border-style: dashed; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; margin: 0 0 10px;
}
.card.tap { cursor: pointer; }
.card.tap:active { transform: scale(.99); }

.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.item-en { font-weight: 700; font-size: 16px; }
.item-zh { font-size: 14px; color: var(--sub); }
.item-note { font-size: 12.5px; color: var(--accent2); }
.tagline { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag { font-size: 11.5px; background: var(--chip); border-radius: 6px; padding: 1px 7px; color: var(--sub); }
.tag.warn { color: var(--warn); background: transparent; border: 1px solid var(--warn); }
.tag.lang { color: var(--accent2); border: 1px solid var(--accent2); background: transparent; }

/* package cells */
.pkgrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.cell { border-radius: 10px; padding: 5px 6px; text-align: center; background: var(--card2); border: 1px solid var(--line); }
.cell .cl { font-size: 11px; color: var(--sub); font-weight: 700; }
.cell .cv { font-size: 13px; font-weight: 700; }
.cell.inc .cv { color: var(--good); }
.cell.pay .cv { color: var(--warn); }
.cell.no .cv { color: var(--bad); }
.cell.ask .cv { color: var(--sub); }
.cell.on { outline: 2px solid var(--accent); }

/* price bar */
.pbar-wrap { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.price { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.price .fee { color: var(--warn); font-weight: 600; }
.pbar { flex: 1; height: 8px; background: var(--bar-bg); border-radius: 999px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; }
.pbar i.over { background: var(--bad); }
.capmark { font-size: 11px; color: var(--sub); white-space: nowrap; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
select, input[type="search"] {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%;
}
.searchwrap { position: relative; margin-bottom: 8px; }
.searchwrap .clearx { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: none; color: var(--sub); font-size: 18px; padding: 4px 8px; }
.count { font-size: 12.5px; color: var(--sub); margin: 2px 2px 8px; }

/* decks */
.deckgroup { margin: 0 0 14px; }
.decklabel {
  display: inline-block; font-size: 13px; font-weight: 800; color: var(--accent);
  background: var(--chip); border-radius: 8px; padding: 2px 10px; margin-bottom: 6px;
}
.bar-card { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.bar-name { font-weight: 700; }
.bar-en { color: var(--sub); font-size: 13px; }
.pkgbadge { font-size: 12px; font-weight: 700; border-radius: 8px; padding: 2px 8px; white-space: nowrap; }
.pkgbadge.ok { color: var(--good); background: var(--chip); }
.pkgbadge.q { color: var(--warn); background: var(--chip); }
.pkgbadge.no { color: var(--bad); background: var(--chip); }
.sigline { font-size: 12.5px; color: var(--sub); margin-top: 4px; }

/* detail */
.detail h2 { margin: 2px 0 0; font-size: 22px; line-height: 1.3; }
.detail .zh { font-size: 17px; color: var(--sub); margin: 2px 0 0; }
.orderline {
  margin: 12px 0 0; padding: 10px 12px; background: var(--card2); border: 1px dashed var(--accent);
  border-radius: 12px; font-size: 15px; font-style: italic;
}
.orderline .zh { font-style: normal; font-size: 13px; }
.bigbtn {
  display: block; width: 100%; margin: 14px 0 4px; padding: 18px 12px;
  font-size: 19px; font-weight: 800; border: none; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #d9a94f); color: #1c1508;
  box-shadow: 0 4px 14px rgba(185,138,47,.35);
}
html[data-theme="dark"] .bigbtn, .bigbtn { }
.sec { margin-top: 16px; }
.sec h3 { margin: 0 0 6px; font-size: 14px; color: var(--accent); }
.where-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.where-row:last-child { border-bottom: none; }
.where-row .wname { font-weight: 600; }
.where-row .wdeck { font-size: 12px; color: var(--sub); }
.hint { font-size: 12.5px; color: var(--sub); }
.kv { font-size: 14px; }
ul.plain { margin: 4px 0; padding-left: 20px; }
ul.plain li { margin: 3px 0; }

/* order full screen (card 3 stub button lives here visually) */
.stub-note { text-align: center; color: var(--sub); font-size: 13px; margin-top: 6px; }

/* toast */
#toast {
  position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px;
  font-size: 14px; z-index: 50; max-width: 90vw;
}
.picks-head { font-size: 15px; font-weight: 800; margin: 14px 2px 6px; color: var(--accent); }
.howline { font-size: 12.5px; color: var(--sub); margin-top: 4px; }
button.linkish { border: none; background: none; color: var(--accent2); font-weight: 700; padding: 2px 4px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--sub); }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ============ 卡 3：記錄／杯數／隨機挑／全螢幕點餐／首問／安裝 ============ */
.chip.small { padding: 5px 11px; font-size: 13px; }
.brow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.brow:last-child { border-bottom: none; }
.brow .hint { text-align: right; }
.tapline { cursor: pointer; text-decoration: underline dotted var(--sub) 1px; text-underline-offset: 3px; }
textarea#noteTa, textarea#impTa { width: 100%; margin-top: 8px; font: inherit; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 64px; }
textarea.mono, #impTa { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace !important; }
.star { border: none; background: none; font-size: 24px; color: var(--chip); padding: 0 2px; }
.star.on { color: var(--accent); }
select { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
#cupsCard .crow { display: flex; align-items: center; gap: 8px; margin-top: 10px; position: relative; }
#cupsCard .cupwrap { flex: 1; min-width: 0; }
#cupsCard .pname { width: 72px; font: inherit; font-weight: 700; background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
#cupsCard .cnum { font-size: 15px; white-space: nowrap; }
#cupsCard .cnum .hint { font-weight: 400; }
#cupsCard .btns { display: flex; gap: 5px; }
.cbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--chip); font-size: 19px; font-weight: 800; }
.cbtn.dbl { background: var(--card2); color: var(--accent); font-size: 15px; }
.cbtn:active { transform: scale(.93); }
.warnline { width: 100%; font-size: 13px; font-weight: 700; color: var(--bad); margin-top: 6px; }
.warnline.soft { color: var(--warn); }
/* 今日杯數進度條 */
#cupsCard .cupwrap { flex: 1; height: 8px; background: var(--bar-bg); border-radius: 999px; overflow: hidden; min-width: 30px; }
#cupsCard .cupfill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; }
/* 全螢幕點餐（SPEC 4.5） */
#orderModal { position: fixed; inset: 0; z-index: 100; background: #0a0f18; color: #f4f6fa; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); }
#orderModal .o-top { font-size: 14px; color: #93a0b5; letter-spacing: .12em; }
#orderModal .o-en { font-size: clamp(26px, 8.4vw, 40px); font-weight: 800; line-height: 1.28; margin-top: 12px; }
#orderModal .o-brand { color: #e0b25c; text-decoration: underline; text-decoration-color: rgba(224,178,92,.45); text-underline-offset: 6px; overflow-wrap: anywhere; }
#orderModal .o-zh { font-size: clamp(20px, 6vw, 26px); color: #c7d0df; margin-top: 10px; font-weight: 700; }
#orderModal .o-sub { font-size: 14px; color: #93a0b5; margin-top: 8px; }
#orderModal .obtns { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); margin-top: 26px; }
#orderModal .bigbtn { margin: 0; }
#orderModal .chip { border-color: #33405a; background: #141c2b; color: #dfe6f2; }
#orderModal .o-hint { font-size: 12.5px; color: #6c7a92; margin-top: 16px; }
html[data-theme="light"] #orderModal { background: #101725; } /* 遞給服務生看：一律深色底高對比 */
/* 首次詢問 */
#frModal { position: fixed; inset: 0; z-index: 90; background: rgba(6,10,18,.72); display: flex; align-items: center; justify-content: center; padding: 20px; }
.fr-box { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px 18px; width: min(420px, 100%); }
.fr-q { font-size: 19px; font-weight: 800; }
.fr-btns { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.fr-b { border: 1px solid var(--line); background: var(--card2); border-radius: 12px; padding: 11px 14px; text-align: left; font-size: 16px; }
.fr-b b { display: block; }
.fr-b .fr-s { display: block; font-size: 12.5px; color: var(--sub); margin-top: 2px; font-weight: 400; }
.fr-b:active { border-color: var(--accent); }
/* 隨機挑 */
.randres { border-color: var(--accent); }
/* 安裝步驟 */
ol.steps { margin: 6px 0; padding-left: 22px; font-size: 14.5px; }
ol.steps li { margin: 5px 0; }
.kbd { display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; background: var(--chip); }
