:root {
  --ink: #1d2b45;
  --ink-soft: #55607a;
  --line: #e3dccb;
  --bg: #fbf6ec;
  --card: #ffffff;
  --navy: #1f3c6e;
  --navy-deep: #152a4f;
  --sea: #2a9fb0;
  --sea-soft: #e3f4f6;
  --bun: #f29b2c;
  --bun-deep: #d97c0e;
  --bun-soft: #fff1dc;
  --ok: #2f9e5b;
  --ok-soft: #e4f5ea;
  --warn: #c9821a;
  --warn-soft: #fff4dd;
  --bad: #d2493c;
  --bad-soft: #fde9e6;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(29, 43, 69, .07);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.shell { max-width: 980px; margin: 0 auto; padding: 0 16px 120px; }

/* ---------- 頁首 ---------- */
.hero {
  background: var(--navy);
  color: #fff;
  border-radius: 0 0 28px 28px;
  margin: 0 -16px 18px;
  padding: 18px 20px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; right: -40px; bottom: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.hero-mascot { width: 76px; height: 76px; border-radius: 50%; background: #fff; object-fit: contain; padding: 6px; flex: none; }
.hero-text { flex: 1; min-width: 0; z-index: 1; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: .18em; color: #ffd28e; font-weight: 700; }
.hero h1 { margin: 2px 0 0; font-size: 24px; line-height: 1.25; }
.hero .version { margin: 2px 0 0; font-size: 12px; opacity: .65; }
.hero-actions { z-index: 1; }

/* ---------- 共用元件 ---------- */
.btn {
  border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  font-weight: 700; line-height: 1.2; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--bun); color: #fff; }
.btn-primary:hover { background: var(--bun-deep); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; }
.btn-line { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 1.5px var(--navy); }
.btn-soft { background: var(--sea-soft); color: var(--navy); }
.btn-danger { background: #fff; color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.btn-wide { width: 100%; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 14px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.kicker { margin: 0; color: var(--sea); font-size: 13px; font-weight: 800; letter-spacing: .06em; }
.card h2 { margin: 2px 0 12px; font-size: 19px; line-height: 1.35; }
.muted { color: var(--ink-soft); font-size: 14px; }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #fff; padding: 6px;
  border-radius: 999px; box-shadow: var(--shadow); margin-bottom: 16px; position: sticky; top: 8px; z-index: 20;
}
.tab { border: 0; background: transparent; border-radius: 999px; padding: 10px; font-weight: 700; cursor: pointer; color: var(--ink-soft); min-height: 44px; }
.tab.is-active { background: var(--navy); color: #fff; }

.notice { border-radius: 12px; padding: 12px 14px; font-size: 15px; margin-bottom: 14px; }
.notice-info { background: var(--sea-soft); color: var(--navy); }
.notice-warn { background: var(--warn-soft); color: #7a4c06; }
.notice-bad { background: var(--bad-soft); color: #8b2a20; }
.notice-ok { background: var(--ok-soft); color: #1d6a3c; }

label.field { display: grid; gap: 4px; font-size: 14px; color: var(--ink-soft); }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff;
  font-size: 16px; color: var(--ink); min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sea); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }

/* ---------- 訂購重點 ---------- */
.quick { display: grid; gap: 6px; }
.quick-deadline { font-size: 17px; font-weight: 800; color: var(--navy); }
.quick p { margin: 0; font-size: 14.5px; }
.quick b { color: var(--bun-deep); }
.rules { white-space: pre-line; font-size: 14px; color: var(--ink-soft); margin-top: 8px; }

/* ---------- 商品 ---------- */
.overview-btn { border: 0; padding: 0; background: none; cursor: zoom-in; width: 100%; border-radius: 14px; overflow: hidden; margin-bottom: 12px; }
.overview-btn img { width: 100%; }
.chart-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.progress-chip {
  display: inline-block; background: var(--bun-soft); color: #8a4d00; border-radius: 999px; padding: 6px 12px;
  font-size: 13.5px; font-weight: 700; margin-bottom: 12px;
}
.progress-chip.is-on { background: var(--ok-soft); color: #1d6a3c; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.product { background: #fff; border-radius: 14px; border: 1.5px solid var(--line); overflow: hidden; display: flex; flex-direction: column; }
.product.has-qty { border-color: var(--bun); box-shadow: 0 0 0 2px var(--bun-soft); }
.product.is-open { grid-column: 1 / -1; }
@media (min-width: 720px) { .product.is-open { grid-column: span 2; } }
.product-img { border: 0; padding: 0; background: #f3f0e8; cursor: zoom-in; aspect-ratio: 1; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 10px 12px 12px; display: grid; gap: 8px; }
.product-name { margin: 0; font-size: 16px; font-weight: 800; }
.product-name small { display: block; font-size: 12px; font-weight: 600; color: var(--sea); }
.product-qty { font-size: 13px; color: var(--bun-deep); font-weight: 700; min-height: 1em; }
.size-toggle { width: 100%; }
.size-list { display: grid; gap: 6px; }
.product.is-open .size-list { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.size-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 6px; background: #faf8f3; border-radius: 10px; padding: 6px 8px; }
.size-name { font-weight: 800; }
.size-price { font-size: 13.5px; color: var(--ink-soft); }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); font-size: 18px; font-weight: 700; cursor: pointer; color: var(--navy); }
.stepper input { width: 44px; min-height: 34px; padding: 4px; text-align: center; border-radius: 8px; font-weight: 700; }

/* ---------- 訂購人／試算 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.form-grid .span-all { grid-column: 1 / -1; }

.picked { display: grid; gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; }
.picked li { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; border-bottom: 1px dashed var(--line); padding: 5px 0; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.total-box { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.total-box span { display: block; font-size: 13px; color: var(--ink-soft); }
.total-box strong { font-size: 24px; color: var(--navy); }

.sticky-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255,255,255,.96); box-shadow: 0 -4px 18px rgba(29,43,69,.12);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.sticky-inner { max-width: 980px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.sticky-sum { flex: 1; min-width: 0; line-height: 1.3; }
.sticky-sum b { font-size: 20px; color: var(--navy); }
.sticky-sum span { display: block; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- 成功頁／查詢 ---------- */
.success-hero { text-align: center; }
.success-hero img { width: 150px; margin: 0 auto 6px; }
.success-hero h2 { margin: 0 0 4px; }
.info-list { display: grid; gap: 8px; margin: 12px 0; }
.info-row { display: grid; grid-template-columns: 92px 1fr; gap: 8px; font-size: 15px; }
.info-row > span:first-child { color: var(--ink-soft); }
.message-box { white-space: pre-line; background: var(--bun-soft); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.query-row { display: flex; gap: 8px; }
.query-row input { flex: 1; }
.order-card { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 12px; background: #fff; }
.order-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.order-head strong { font-size: 16px; }
.tag { display: inline-block; font-size: 12.5px; font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.tag-ok { background: var(--ok-soft); color: #1d6a3c; }
.tag-warn { background: var(--warn-soft); color: #7a4c06; }
.tag-bad { background: var(--bad-soft); color: #8b2a20; }
.tag-info { background: var(--sea-soft); color: var(--navy); }
.tag-mute { background: #eee; color: #666; }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.empty-state { text-align: center; padding: 10px 0; }
.empty-state img { width: 140px; margin: 0 auto 4px; }

.replace-banner { background: var(--warn-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---------- 遮罩／彈窗 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(21, 42, 79, .55);
  display: grid; place-items: center; padding: 20px;
}
.overlay-card { background: #fff; border-radius: 22px; padding: 20px 22px 22px; width: min(360px, 100%); text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.25); }
.overlay-card img { width: 170px; height: 170px; object-fit: contain; margin: 0 auto 6px; }
.overlay-card img.bob { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }
.overlay-card strong { display: block; font-size: 18px; }
.overlay-card p { margin: 6px 0 0; color: var(--ink-soft); font-size: 14.5px; white-space: pre-line; }
.overlay-card .btn { margin-top: 14px; }
.dots::after { content: ""; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "．"; } 50% { content: "．．"; } 75% { content: "．．．"; } }
@media (prefers-reduced-motion: reduce) { .overlay-card img.bob, .dots::after { animation: none; } }

.img-dialog { border: 0; padding: 0; border-radius: 16px; max-width: min(96vw, 1100px); background: #fff; }
.img-dialog::backdrop { background: rgba(0,0,0,.7); }
.img-dialog img { max-height: 82vh; width: auto; margin: 0 auto; }
.img-dialog p { margin: 0; padding: 8px 14px 12px; text-align: center; font-weight: 700; }
.img-dialog .close { position: absolute; right: 8px; top: 8px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 22px; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--navy-deep); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 120; font-size: 15px;
  transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
