:root {
  --bg: #f6f2ec;
  --surface: #fffdf9;
  --ink: #2b2620;
  --ink-2: #6d655b;
  --line: #e4ddd2;
  --accent: #8a5a3c;
  --accent-ink: #fff;
  --bubble-me: #2b2620;
  --bubble-bot: #efe8dd;
  --radius: 14px;
  --serif: 'Noto Serif TC', serif;
  --sans: 'Noto Sans TC', -apple-system, 'PingFang TC', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

.notice {
  background: var(--ink); color: #f6f2ec;
  font-size: 12px; text-align: center; padding: 6px 16px;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px; max-width: 1080px; margin: 0 auto;
}
.logo { font: 700 22px/1 var(--serif); letter-spacing: .04em; }
.logo span { font: 500 13px var(--sans); color: var(--ink-2); letter-spacing: .12em; margin-left: 6px; }
.cart {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 14px;
}
.cart b { display: inline-block; min-width: 1.4em; margin-left: 4px; color: var(--accent); }

main { max-width: 1080px; margin: 0 auto; padding: 0 16px 120px; }

/* ── 首頁 ── */
.hero { padding: 24px 0 28px; }
.hero h1 { font: 700 clamp(26px, 6vw, 40px)/1.25 var(--serif); margin: 0 0 8px; }
.hero p { margin: 0; color: var(--ink-2); }

.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 16px; scrollbar-width: none; }
.filters button {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 14px; font-size: 14px;
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 12px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 28px 20px; } }
.card .pic { aspect-ratio: 3 / 4; border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; }
.card .pic svg { width: 62%; height: auto; }
.card h3 { font-size: 15px; font-weight: 500; margin: 10px 0 2px; }
.card .meta { font-size: 13px; color: var(--ink-2); display: flex; justify-content: space-between; }

/* ── 商品頁 ── */
.back { display: inline-block; margin: 4px 0 16px; color: var(--ink-2); font-size: 14px; }
.pdp { display: grid; gap: 24px; }
@media (min-width: 820px) { .pdp { grid-template-columns: 1fr 1fr; gap: 48px; } .pdp .pic { aspect-ratio: 4 / 5; } }
.pdp .pic svg { max-height: 80%; }
.pdp .pic { aspect-ratio: 16 / 10; border-radius: var(--radius); display: grid; place-items: center; }
.pdp .pic svg { width: 55%; height: auto; }
.pdp h1 { font: 700 26px/1.3 var(--serif); margin: 0 0 4px; }
.price { font-size: 20px; margin: 0 0 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tags span { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; color: var(--ink-2); background: var(--surface); }
.fitnote { background: var(--surface); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 18px; }

.sizes { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 6px; }
.sizes button {
  min-width: 52px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 500;
}
.sizes button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.sizes button:disabled { color: #b8b0a5; text-decoration: line-through; cursor: not-allowed; }
.sizes button.recommended { position: relative; }
.sizes button.recommended::after {
  content: '推薦'; position: absolute; top: -9px; right: -6px;
  background: var(--accent); color: var(--accent-ink); font-size: 10px; padding: 1px 5px; border-radius: 6px;
}
.label { font-size: 13px; color: var(--ink-2); }
.askbtn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; margin-bottom: 18px; }

.buy {
  width: 100%; padding: 14px; border: 0; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-weight: 700; font-size: 16px;
}
.buy:disabled { opacity: .4; cursor: not-allowed; }

details.chart { margin-top: 22px; background: var(--surface); border-radius: var(--radius); padding: 4px 14px; }
details.chart summary { padding: 10px 0; cursor: pointer; font-weight: 500; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; margin-bottom: 8px; }
th, td { text-align: center; padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
.small { font-size: 12px; color: var(--ink-2); }

/* ── 小幫手 ── */
.fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 13px 20px; font-weight: 700; box-shadow: 0 6px 20px rgba(60, 40, 20, .25); z-index: 20;
}
.chat {
  position: fixed; z-index: 30; background: var(--surface);
  display: flex; flex-direction: column;
  inset: auto 0 0 0; height: min(82vh, 640px); border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(60, 40, 20, .18);
}
@media (min-width: 720px) {
  .chat { inset: auto 24px 24px auto; width: 380px; height: 580px; border-radius: 18px; }
}
.chat[hidden], .fab[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-head small { display: block; color: var(--ink-2); font-size: 12px; }
.chat-close { background: none; border: 0; font-size: 26px; line-height: 1; padding: 0 4px; color: var(--ink-2); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; }
.msg.bot { background: var(--bubble-bot); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: var(--bubble-me); color: var(--bg); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.typing { color: var(--ink-2); }
.msg .act {
  display: block; margin-top: 8px; width: 100%; padding: 9px; border-radius: 10px; border: 0;
  background: var(--ink); color: var(--bg); font-weight: 700;
}
.msg .act:disabled { opacity: .5; }
.chat-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px; }
.chat-chips:not(:empty) { padding-bottom: 8px; }
.chat-chips button { border: 1px solid var(--accent); color: var(--accent); background: none; border-radius: 999px; padding: 5px 12px; font-size: 14px; }
.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-input input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px;
  font: 16px var(--sans); background: var(--bg); color: var(--ink);
}
.chat-input button { border: 0; border-radius: 999px; padding: 0 16px; background: var(--ink); color: var(--bg); font-weight: 700; }
.chat-privacy { margin: 0; padding: 0 16px calc(10px + env(safe-area-inset-bottom)); font-size: 11px; color: var(--ink-2); }

.toast {
  position: fixed; left: 50%; top: 20px; transform: translate(-50%, -80px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; transition: transform .25s; z-index: 40; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }
