:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e3e8ef;
  --line-strong: #cbd5e1;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --accent-text: var(--accent);
  --ok: #15803d;
  --warn: #b45309;
  --warn-soft: #fff7e6;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 20px rgba(15, 23, 42, .06);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #131b2e;
    --surface-2: #182238;
    --ink: #e8edf6;
    --ink-2: #c3cddd;
    --muted: #8b97ab;
    --line: #243049;
    --line-strong: #33415e;
    --accent-soft: rgba(96, 140, 255, .16);
    --accent-text: color-mix(in srgb, var(--accent) 45%, #fff);
    --warn-soft: rgba(245, 158, 11, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131b2e;
  --surface-2: #182238;
  --ink: #e8edf6;
  --ink-2: #c3cddd;
  --muted: #8b97ab;
  --line: #243049;
  --line-strong: #33415e;
  --accent-soft: rgba(96, 140, 255, .16);
  --accent-text: color-mix(in srgb, var(--accent) 45%, #fff);
  --warn-soft: rgba(245, 158, 11, .12);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); letter-spacing: -.01em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- 頁首 ---------- */
.hero {
  background: var(--accent);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 62%, #0f172a));
  color: #fff;
  padding: 22px 16px 46px;
}
.hero-inner { max-width: 760px; margin: 0 auto; }
.hero .eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; opacity: .78; font-weight: 600; }
.hero h1 { margin: 4px 0 6px; font-size: 24px; line-height: 1.25; font-weight: 800; letter-spacing: -.01em; }
.hero .meta { font-size: 13px; opacity: .85; display: flex; flex-wrap: wrap; gap: 6px 14px; }

.wrap { max-width: 760px; margin: -30px auto 0; padding: 0 12px 132px; }

/* ---------- 步驟卡 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-no {
  flex: none; width: 24px; height: 24px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-text);
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
}
.step-title { font-weight: 700; font-size: 15px; }
.step-hint { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }
.card.is-disabled { opacity: .5; }
.card.is-disabled * { pointer-events: none; }

/* 分段按鈕 */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg.wrap-5 { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); }
.seg button {
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 8px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  min-height: 44px;
}
.seg button small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.seg button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.seg button[aria-pressed="true"] small { color: inherit; opacity: .8; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

/* 機型卡 */
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.model {
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 11px 12px 10px;
  cursor: pointer;
  position: relative;
  min-height: 64px;
  transition: border-color .15s, box-shadow .15s;
}
.model .pn { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.model .desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.model[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.model[aria-pressed="true"]::after {
  content: ""; position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/12px no-repeat;
}
.model:disabled { opacity: .45; cursor: not-allowed; }
.model .tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px;
  background: var(--warn-soft); color: var(--warn); margin-top: 4px; }

/* 開關列 */
.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle-row .txt { flex: 1; min-width: 0; }
.toggle-row .txt b { display: block; font-size: 15px; }
.toggle-row .txt span { font-size: 12.5px; color: var(--muted); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 30px; background: var(--line-strong); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }
.sub { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.radio-list { display: grid; gap: 6px; }
.radio-list button { text-align: left; border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; font-weight: 600; min-height: 44px; }
.radio-list button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

/* ---------- 底部列 ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.dock-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.dock .pick { flex: 1; min-width: 0; }
.dock .pick small { display: block; font-size: 11px; color: var(--muted); }
.dock .pick b { font-family: var(--mono); font-size: 15px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn {
  border: 0; border-radius: 12px; padding: 0 18px; min-height: 46px; font-weight: 750; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }

/* ---------- 結果面板 ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 40; opacity: 0; transition: opacity .2s; }
.sheet-back.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  transform: translateY(102%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet.show { transform: none; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; width: 640px; margin-left: -320px; bottom: 4vh; border-radius: 20px; max-height: 88vh; }
}
.grab { width: 40px; height: 5px; border-radius: 4px; background: var(--line-strong); margin: 4px auto 12px; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet .sub-title { font-size: 12.5px; color: var(--muted); margin: 2px 0 12px; }
.items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.items li { display: flex; gap: 10px; padding: 11px 12px; align-items: flex-start; }
.items li + li { border-top: 1px solid var(--line); }
.items .l { flex: 1; min-width: 0; }
.items .chip { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent-text); background: var(--accent-soft);
  border-radius: 6px; padding: 1px 7px; margin-bottom: 3px; }
.items .pn { font-family: var(--mono); font-weight: 700; font-size: 14px; word-break: break-all; }
.items .d { font-size: 12px; color: var(--muted); line-height: 1.35; }
.items .cost { font-size: 11.5px; color: var(--warn); font-family: var(--mono); }
.items .p { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.total { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 2px 4px; }
.total span { font-size: 13px; color: var(--muted); }
.total b { font-size: 26px; font-weight: 850; color: var(--accent-text); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-top: 10px; background: var(--warn-soft); color: var(--warn); }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet-actions .btn { flex: 1; }

.warranty-cards { display: grid; gap: 10px; }
@media (min-width: 560px) { .warranty-cards { grid-template-columns: 1fr 1fr; } }
.wcard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.wcard h3 { margin: 0 0 8px; font-size: 14px; display: flex; justify-content: space-between; }
.wcard h3 em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--accent-text); background: var(--accent-soft);
  padding: 1px 8px; border-radius: 6px; }
.kv { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; gap: 10px; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; }
.kv.big { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; }
.kv.big b { font-size: 20px; color: var(--accent-text); }

/* 狀態頁 */
.state { max-width: 440px; margin: 18vh auto 0; padding: 0 20px; text-align: center; }
.state .icon { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-text); }
.state h2 { margin: 0 0 6px; font-size: 19px; }
.state p { margin: 0; color: var(--muted); }
.skeleton { height: 92px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 12px; border: 1px solid var(--line); }
@keyframes sk { to { background-position: -200% 0; } }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 9px 16px;
  border-radius: 999px; font-size: 13.5px; z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
