/* 版面：手機優先。上方切換「我的花費／賣多少／設定」；「記花費」浮動按鈕打開底部抽屜。
   桌機 (≥900px) 時表單固定在左欄，浮動按鈕隱藏。
   風格：固定淺色的粉嫩可愛風（不跟著手機深色模式變黑），圓角大、陰影帶粉色，標題與數字用圓體。 */
:root {
  --bg: #fff4f7;          /* 草莓牛奶 */
  --dot: #ffdbe6;         /* 背景小圓點 */
  --surface: #ffffff;
  --sunken: #fde8ef;
  --fg: #5a3e4f;          /* 深梅色，不用純黑 */
  --muted: #a3879a;
  --line: #f7d6e2;
  --accent: #ff6f9c;      /* 草莓粉：主要動作 */
  --accent-deep: #e5527f; /* 按鈕底下的立體邊 */
  --accent-soft: #ffe3ec;
  --accent-fg: #ffffff;
  --mint: #4cc3a6;
  --mint-soft: #dcf6ee;
  --lavender: #b7a4ff;
  --butter: #ffe08a;
  --new: #2fb38f;         /* 正向（成功）用薄荷綠 */
  --new-soft: #dcf6ee;
  --used: #e58a2e;
  --used-soft: #fff0d9;
  --danger: #e2507a;
  --shadow: 0 10px 28px rgb(255 111 156 / 0.18);
  --shadow-soft: 0 3px 10px rgb(255 111 156 / 0.12);
  --font-display: 'Huninn', 'Noto Sans TC', system-ui, sans-serif;
  --font-body: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-num: 'Huninn', 'Noto Sans TC', system-ui, sans-serif;
  --r: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
body.sheet-open { overflow: hidden; }
body::before {
  content: ''; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg);
}
h1, h2, p { margin: 0; }
.muted { color: var(--muted); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* 共用 gutter */
.brand, .topbar-inner, .layout {
  max-width: 1080px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---- 標題 ---- */
.brand { display: flex; gap: 12px; align-items: center; padding-block: 18px 10px; }
.brand-mark {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); color: var(--accent-fg); font: 700 13px/1 var(--font-num); letter-spacing: 0.02em;
  transform: rotate(-6deg);
}
.brand h1 { font-size: 22px; font-weight: 900; letter-spacing: 0.04em; text-wrap: balance; }
.brand p { color: var(--muted); font-size: 13px; }

/* ---- 黏著搜尋列 ---- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: grid; gap: 10px; padding-block: 10px; }
.searchbox { position: relative; }
.searchbox svg {
  position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
.searchbox input {
  width: 100%; height: 46px; padding: 0 14px 0 42px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px; /* 16px 避免 iOS 自動放大 */
}
.filters { display: flex; gap: 8px; min-width: 0; }
.seg { display: flex; flex: 1; background: var(--sunken); border-radius: 999px; padding: 3px; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: 999px; padding: 7px 14px; white-space: nowrap; font-size: 14px; color: var(--muted); cursor: pointer;
}
.seg button[aria-checked='true'] { background: var(--surface); color: var(--fg); font-weight: 700; box-shadow: var(--shadow-soft); }
.filters select {
  flex: 1; height: 40px; min-width: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  padding: 0 12px; font-size: 14px;
}

/* ---- 主要區塊 ---- */
.layout { padding-block: 16px 120px; }
.stack { display: grid; gap: 18px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); }
.count { color: var(--muted); font-size: 13px; }
.banner {
  font-size: 13px; padding: 10px 14px; border-radius: var(--r); background: var(--sunken); color: var(--muted);
  border: 1px dashed var(--line);
}
.banner strong { color: var(--fg); }

.badge {
  flex: none; display: inline-block; font-size: 12px; font-weight: 700; line-height: 1; padding: 5px 8px; border-radius: 6px;
}
.badge.is-new { background: var(--new-soft); color: var(--new); }
.badge.is-used { background: var(--used-soft); color: var(--used); }

/* ---- 行情 ---- */
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; }
.lg-iqr { width: 16px; height: 6px; border-radius: 3px; background: var(--muted); opacity: 0.6; }
.lg-med { width: 2px; height: 12px; background: var(--fg); margin-left: 6px; }
.sum-row + .sum-row { margin-top: 18px; }
.sum-head { display: flex; align-items: center; gap: 10px; }
.range { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.range i { font-style: normal; color: var(--muted); margin: 0 2px; font-weight: 500; }
.sum-head .count { margin-left: auto; }
.bar { position: relative; height: 18px; margin: 10px 0 8px; }
.bar::before { content: ''; position: absolute; inset: 8px 0; height: 2px; background: var(--line); border-radius: 1px; }
.bar-line { position: absolute; top: 8px; height: 2px; }
.bar-iqr { position: absolute; top: 3px; height: 12px; border-radius: 6px; min-width: 6px; }
.bar-median { position: absolute; top: 0; width: 3px; height: 18px; margin-left: -1.5px; border-radius: 2px; background: var(--fg); }
.is-new .bar-line { background: var(--new); }
.is-new .bar-iqr { background: var(--new); opacity: 0.55; }
.is-used .bar-line { background: var(--used); }
.is-used .bar-iqr { background: var(--used); opacity: 0.55; }
.sum-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0; }
.sum-stats div { display: grid; gap: 0; }
.sum-stats dt { font-family: var(--font-body); font-size: 11px; color: var(--muted); }
.sum-stats dd { margin: 0; font-size: 15px; font-weight: 500; }
.axis { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 11px; color: var(--muted); }

/* ---- 列表 ---- */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.item { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; padding: 14px 16px; }
.item + .item { border-top: 1px solid var(--line); }
.item-body { min-width: 0; }
.item-name { font-weight: 700; overflow-wrap: anywhere; }
.item-name a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.item-meta { font-size: 13px; color: var(--muted); }
.item-note { font-size: 13px; margin-top: 2px; }
.item-side { display: grid; justify-items: end; gap: 4px; }
.item-price { font-size: 18px; font-weight: 700; white-space: nowrap; }
.item-price small { font-size: 11px; color: var(--muted); margin-right: 2px; font-weight: 500; }
.del { border: 0; background: none; padding: 2px 0; font-size: 12px; color: var(--muted); cursor: pointer; }
.del.armed { color: var(--danger); font-weight: 700; }

/* ---- 備份 ---- */
.backup { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ghost {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.hint { flex-basis: 100%; font-size: 12px; color: var(--muted); }

/* ---- 浮動按鈕 ---- */
.fab {
  position: fixed; z-index: 25;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 6px; height: 54px; padding: 0 20px 0 16px;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-fg);
  font-size: 16px; font-weight: 700; box-shadow: var(--shadow); cursor: pointer;
}
.fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* ---- 底部抽屜（手機） ---- */
.sheet { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(90 62 79 / 0.35); opacity: 0; transition: opacity 0.2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92%; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  transform: translateY(105%); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.open { pointer-events: auto; }
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
@media (prefers-reduced-motion: reduce) { .sheet-panel, .sheet-backdrop { transition: none; } }

.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; padding: 18px 0 12px; background: var(--surface); }
.grabber { position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
.icon-btn { margin-left: auto; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--sunken); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---- 表單 ---- */
.form { display: grid; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; }
.field input, .field select {
  width: 100%; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font-size: 16px;
}
.cond-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cond-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cond-toggle label {
  height: 44px; display: grid; place-items: center; border-radius: 10px; border: 1.5px solid var(--line);
  font-weight: 700; color: var(--muted); cursor: pointer;
}
.cond-toggle input:checked + label.is-new { border-color: var(--new); background: var(--new-soft); color: var(--new); }
.cond-toggle input:checked + label.is-used { border-color: var(--used); background: var(--used-soft); color: var(--used); }
.cond-toggle input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.price-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding-left: 12px; }
.price-input span { font: 500 14px var(--font-num); color: var(--muted); }
.price-input input { border: 0; background: none; height: 52px; font: 700 26px var(--font-num); padding: 0 12px 0 8px; }
.price-input input:focus { outline: none; }
.price-input:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-error { color: var(--danger); font-size: 13px; font-weight: 500; white-space: pre-line; }
.primary {
  height: 50px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-fg);
  font-size: 16px; font-weight: 700; cursor: pointer;
}

/* ---- 分頁（手動 / 煤爐） ---- */
.tabs { display: flex; gap: 4px; background: var(--sunken); border-radius: 999px; padding: 3px; }
.tabs button {
  border: 0; background: none; border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected='true'] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-soft); }
.field-hint { font-size: 12px; color: var(--muted); }
.seg-form { height: 44px; align-items: stretch; }
.seg-form button { padding: 0 8px; }
.ghost.wide { width: 100%; height: 44px; border-style: dashed; color: var(--muted); }
.primary:disabled { opacity: 0.45; cursor: default; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 700; cursor: pointer; }

/* ---- 煤爐結果 ---- */
#m-results { display: grid; gap: 12px; margin-top: 16px; }
#m-results:empty { display: none; }
.m-summary {
  position: sticky; top: 64px; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 12px; border-radius: 12px; background: var(--used-soft);
}
.m-summary .range { font-size: 20px; }
.m-summary .count { flex-basis: 100%; }
.m-tools { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.m-tools .muted { margin-right: auto; }
.m-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; }
.m-list li + li { border-top: 1px solid var(--line); }
.m-item { display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; }
.m-item input { width: 20px; height: 20px; accent-color: var(--used); margin: 0; }
.m-item img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--sunken); }
.m-item:has(input:not(:checked)) .m-body, .m-item:has(input:not(:checked)) .m-price { opacity: 0.45; }
.m-body { display: grid; min-width: 0; }
.m-name { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-meta { font-size: 12px; color: var(--muted); }
.m-price { display: grid; justify-items: end; white-space: nowrap; }
.m-price b { font-size: 15px; }
.m-price small { font-size: 11px; color: var(--muted); }
.m-empty { margin-top: 4px; }
.m-save { display: grid; gap: 12px; padding-top: 4px; }
.m-save h3 { margin: 0; font-size: 15px; }
.settings { margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--line); display: grid; gap: 8px; }
.settings summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 700; }
.settings[open] summary { margin-bottom: 8px; }

/* ---- 提示 ---- */
.toast {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 999px;
  background: var(--fg); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
}

/* ---- 桌機：表單固定在左欄 ---- */
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; padding-bottom: 48px; }
  .sheet { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 140px); inset: auto; z-index: auto; pointer-events: auto; }
  .sheet-backdrop, .grabber, .sheet-close, .fab { display: none; }
  .sheet-panel {
    position: static; transform: none; max-height: none; overflow: visible; border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: none; padding: 0 16px 16px;
  }
  .sheet-head { position: static; }
  .m-summary { position: static; }
  .topbar-inner { grid-template-columns: 1fr auto; align-items: center; }
  .filters select { flex-basis: 160px; }
  .toast { bottom: 24px; }
}

/* ---- 圖搜圖 ---- */
.photo { display: grid; gap: 10px; }
.photo-btn {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-fg);
}
.photo-btn svg { flex: none; width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.photo-btn span { display: grid; }
.photo-btn b { font-size: 17px; }
.photo-btn small { font-size: 12px; opacity: 0.85; }
.photo-result { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.photo-result img { flex: none; width: 64px; height: 64px; border-radius: 10px; object-fit: cover; }
.photo-text { display: grid; min-width: 0; }
.photo-text small { font-size: 12px; color: var(--muted); }
.photo-text b { font-size: 15px; overflow-wrap: anywhere; }
.photo-note { margin-top: 2px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; font-size: 12px; color: var(--muted); }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.field-hint a { color: var(--accent); font-weight: 700; overflow-wrap: anywhere; }

/* ---- 查煤爐行情：三個步驟 ---- */
.step { display: grid; gap: 10px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px dashed var(--line); }
.step-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 900; }
.step-no {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--fg); color: var(--bg); font: 700 12px/1 var(--font-num);
}
.open-btn, .upload-btn {
  display: grid; place-items: center; min-height: 48px; padding: 0 16px; border-radius: 12px;
  font-weight: 700; text-decoration: none; cursor: pointer; text-align: center;
}
.open-btn { background: var(--sunken); color: var(--fg); border: 1.5px solid var(--line); }
.open-btn[aria-disabled='true'] { opacity: 0.5; }
.upload-btn { background: var(--accent); color: var(--accent-fg); }
.m-progress { font-size: 13px; }
#m-results { margin-top: 0; }

/* ---- 沒有紀錄時 ---- */
.empty { display: grid; gap: 6px; padding: 32px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--r); }
.empty-title { font-size: 17px; font-weight: 900; }

/* ---- 認錯時的候選 ---- */
.choices { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.choices small { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.chip[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); }
.photo-text { flex: 1; }

/* ---- 我的花費 ---- */
.spend-hero { display: grid; gap: 4px; }
.spend-big { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.spend-month { margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--muted); }
.spend-month b { color: var(--fg); font-size: 17px; margin-left: 4px; }
.bars { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(5em, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; border-radius: 5px; background: var(--sunken); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.bar-value { font-weight: 700; text-align: right; min-width: 4.5em; }
.spend-total { font: 700 15px var(--font-num); color: var(--accent); }
.spend-total:empty { display: none; }
#spend-form .price-input input { height: 42px; font-size: 20px; }
#spend-view .item { grid-template-columns: 1fr auto; }

/* ---- 金鑰設定視窗 ---- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; }
@media (min-width: 600px) { .modal { place-items: center; } }
.modal-backdrop { position: absolute; inset: 0; background: rgb(90 62 79 / 0.4); }
.modal-panel {
  position: relative; width: min(100%, 460px); max-height: 92%; overflow-y: auto;
  display: grid; gap: 14px; background: var(--surface); box-shadow: var(--shadow);
  border-radius: 20px 20px 0 0;
  padding: 22px max(20px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
}
@media (min-width: 600px) { .modal-panel { border-radius: 20px; } }
.modal-panel h2 { font-size: 20px; font-weight: 900; }
.key-steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 16px; }
.key-steps li { counter-increment: step; display: grid; gap: 8px; padding-left: 34px; position: relative; }
.key-steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--fg); color: var(--bg); font: 700 12px/1 var(--font-num);
}
.key-steps .muted { font-size: 13px; }
.key-input { display: flex; gap: 8px; }
.key-input input {
  flex: 1; min-width: 0; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font: 15px var(--font-num);
}
.key-input .ghost { flex: none; }
.key-status { font-size: 13px; font-weight: 700; min-height: 1.2em; }
.key-status[data-kind='bad'] { color: var(--danger); }
.key-status[data-kind='good'] { color: var(--new); }
.key-skip { justify-self: center; color: var(--muted); }
.lookup-link { justify-self: start; margin-top: -4px; }

/* ---- 頁面切換：我的花費 / 賣多少 ---- */
.views {
  display: flex; gap: 4px; max-width: 1080px; margin: 0 auto 10px;
  margin-left: max(16px, env(safe-area-inset-left, 0px)); margin-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--sunken); border-radius: 999px; padding: 3px;
}
@media (min-width: 1112px) { .views { margin-left: auto; margin-right: auto; } }
.views button {
  flex: 1; border: 0; background: none; border-radius: 999px; padding: 9px 0; font-size: 15px; font-weight: 700;
  color: var(--muted); cursor: pointer;
}
.views button[aria-selected='true'] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-soft); }

/* ---- 賣多少 ---- */
.resale-result { display: grid; gap: 4px; }
.resale-lines { display: grid; gap: 4px; margin: 10px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); }
.resale-lines div { display: flex; justify-content: space-between; }
.resale-lines dt { font-family: var(--font-body); color: var(--muted); }
.resale-lines dd { margin: 0; }
.resale-lines .resale-net { font-weight: 700; font-size: 17px; }
.resale-lines .resale-net dt { color: var(--fg); }
.resale-form { gap: 16px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- 設定頁 ---- */
#settings-view .panel { gap: 12px; }
.settings-desc { font-size: 13px; }
#settings-view .link-btn { justify-self: start; }

/* ================= 可愛風格 ================= */
body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.6px);
  background-size: 20px 20px;
}
h1, h2, h3, .section-title, .empty-title, .tabs button, .views button, .primary, .fab, .chip, .open-btn, .upload-btn, .photo-btn b {
  font-family: var(--font-display);
}

/* 標題：圓圓的招牌 */
.brand h1 { font-family: var(--font-display); font-weight: 400; font-size: 26px; letter-spacing: 0.06em; color: var(--fg); }
.brand p { color: var(--muted); }
.brand-mark {
  width: 50px; height: 50px; border-radius: 50%; transform: rotate(-10deg);
  background: var(--accent); border: 3px solid #fff; box-shadow: var(--shadow);
  font-family: var(--font-display); font-weight: 400; font-size: 13px;
}

/* 卡片 */
.panel, .list, .m-list, .photo-result, .empty, .modal-panel {
  border: 2px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-soft);
}
.panel, .list { background: var(--surface); }
.empty { background: var(--surface); border-style: dashed; }
.section-title { font-weight: 400; font-size: 15px; letter-spacing: 0.04em; color: var(--accent-deep); }

/* 上方切換、抽屜分頁：粉色膠囊 */
.views, .tabs { background: var(--surface); border: 2px solid var(--line); }
.views button[aria-selected='true'], .tabs button[aria-selected='true'] {
  background: var(--accent-soft); color: var(--accent-deep); box-shadow: none;
}
.views button, .tabs button { font-weight: 400; }

/* 搜尋列 */
.topbar { background: color-mix(in srgb, var(--bg) 90%, transparent); border-bottom: 2px dashed var(--line); }
.searchbox input, .filters select { border: 2px solid var(--line); }

/* 按鈕：圓滾滾、有一點立體 */
.primary {
  border-radius: 999px; font-weight: 400; font-size: 17px; letter-spacing: 0.04em;
  box-shadow: 0 4px 0 var(--accent-deep); transition: transform 0.08s, box-shadow 0.08s;
}
.primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-deep); }
.fab {
  font-weight: 400; font-size: 17px; border: 3px solid #fff;
  box-shadow: 0 4px 0 var(--accent-deep), var(--shadow);
}
.ghost, .chip, .open-btn { border: 2px solid var(--line); background: var(--surface); }
.open-btn { border-radius: 999px; color: var(--accent-deep); }
.upload-btn, .photo-btn { border-radius: 20px; box-shadow: 0 4px 0 var(--accent-deep); }
.chip { font-weight: 400; }
.chip[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }
.link-btn { color: var(--accent-deep); }

/* 輸入框 */
.field input, .field select, .price-input, .key-input input, .searchbox input {
  border-width: 2px; border-radius: 14px; background: #fffafc;
}
.field label, .field-label { color: var(--muted); }
.price-input input { font-family: var(--font-num); font-weight: 400; }

/* 金額 */
.spend-big { font-family: var(--font-num); font-weight: 400; color: var(--accent); font-size: 38px; }
.item-price, .bar-value, .range, .m-price b, .spend-month b { font-weight: 400; }
.spend-total { font-family: var(--font-num); font-weight: 400; }

/* 長條圖：粉→紫漸層 */
.bar-track { background: var(--sunken); height: 12px; border-radius: 6px; }
.bar-fill { background: linear-gradient(90deg, var(--accent), var(--lavender)); border-radius: 6px; }

/* 步驟編號、設定視窗編號 */
.step-no, .key-steps li::before { background: var(--accent); color: #fff; font-family: var(--font-display); font-weight: 400; }
.step { border-bottom: 2px dashed var(--line); }

/* 煤爐結果 */
.m-summary { background: var(--butter); background: color-mix(in srgb, var(--butter) 45%, #fff); border-radius: 18px; }
.m-item input { accent-color: var(--accent); }

/* 抽屜、視窗 */
.sheet-panel { border-radius: 28px 28px 0 0; }
.grabber { background: var(--line); width: 48px; height: 5px; }
.icon-btn { background: var(--accent-soft); color: var(--accent-deep); }

/* 提示 */
.toast { background: var(--fg); color: #fff; font-family: var(--font-display); }

/* ---- 安全與隱私 ---- */
.safe-list { display: grid; gap: 10px; }
.safe-list p { font-size: 13px; color: var(--muted); padding: 10px 12px; border-radius: 14px; background: #fffafc; border: 2px solid var(--line); }
.safe-list b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 15px; color: var(--fg); margin-bottom: 2px; }
.safe-steps { border: 2px dashed var(--line); border-radius: 16px; padding: 12px 14px; display: grid; gap: 12px; }
.safe-steps summary { cursor: pointer; font-family: var(--font-display); color: var(--accent-deep); }
.safe-steps[open] summary { margin-bottom: 10px; }
.safe-steps .key-steps { margin-top: 10px; }
#set-referrer { font-family: ui-monospace, 'SF Mono', monospace; font-size: 13px; }
.danger-zone { display: grid; gap: 8px; padding-top: 12px; border-top: 2px dashed var(--line); }
.danger-btn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.danger-btn.armed { background: var(--danger); color: #fff; border-color: var(--danger); }

.open-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch; }
.open-row .ghost { border-radius: 999px; padding: 0 16px; font-family: var(--font-display); color: var(--accent-deep); }

/* ---- 煤爐中轉頁 ---- */
.go-page { max-width: 420px; margin: 20vh auto 0; padding: 0 20px; display: grid; gap: 12px; text-align: center; }

.open-tip summary { cursor: pointer; font-size: 13px; color: var(--accent-deep); font-family: var(--font-display); }
.open-tip[open] summary { margin-bottom: 6px; }
