/* TBUY KSHOP 官網 — 沿用 BVSHOP 版面:粉色頂欄、兩欄商品格、粉色分類摺疊、灰色頁尾 */
:root {
  --pink: #f2c4c4;
  --pink-deep: #e7a9a9;
  --ink: #2b2b2b;
  --ink-2: #555;
  --muted: #8a8f98;
  --line: #ececec;
  --bg: #ffffff;
  --bg-soft: #f6f6f6;
  --btn: #3d3d3d;
  --sale: #d9534f;
  --radius: 6px;
  --maxw: 1180px;
  --hdr-h: 60px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "jf-openhuninn", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px; line-height: 1.6; padding-top: var(--hdr-h);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── 頂欄 ── */
.hdr {
  position: fixed; inset: 0 0 auto 0; height: var(--hdr-h); z-index: 50;
  background: var(--pink); color: #fff; display: flex; align-items: center; padding: 0 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.hdr .logo img { height: 44px; width: auto; border-radius: 3px; }
.hdr-right { margin-left: auto; display: flex; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; background: none; border: 0; color: #fff; }
.badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* ── 側邊選單 ── */
.drawer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer.open { opacity: 1; pointer-events: auto; }
.drawer-panel { position: absolute; inset: 0 auto 0 0; width: min(320px, 86vw); background: #fff; overflow-y: auto; transform: translateX(-100%); transition: transform .25s; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; background: var(--pink); color: #fff; font-weight: 700; }
.nav-item > a, .nav-item > button { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-size: 15px; }
.nav-sub { display: none; background: var(--bg-soft); }
.nav-item.open .nav-sub { display: block; }
.nav-sub a { display: block; padding: 10px 16px 10px 32px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.nav-item .chev { width: 18px; height: 18px; transition: transform .2s; }
.nav-item.open .chev { transform: rotate(180deg); }

/* ── 版面 ── */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 12px; }
.loading { height: 50vh; display: grid; place-items: center; }
.loading::after { content: ""; width: 40px; height: 40px; border: 3px solid var(--line); border-top-color: var(--pink-deep); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.section-title { text-align: center; font-size: 18px; font-weight: 700; margin: 28px 0 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* ── 分類分頁(首頁)── */
.tabs { position: relative; display: flex; align-items: center; border-bottom: 1px solid var(--line); margin: 16px 0 12px; }
.tabs-track { display: flex; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; flex: 1; }
.tabs-track::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; padding: 10px 18px; border: 0; background: none; font-size: 15px; color: var(--ink-2); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.tabs-arrow { flex: 0 0 32px; height: 40px; border: 0; background: #fff; display: grid; place-items: center; }
.tabs-arrow svg { width: 18px; height: 18px; }

/* ── 商品格 ── */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 14px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.card { display: block; text-align: center; }
.card-img { aspect-ratio: 1; background: var(--bg-soft); overflow: hidden; border-radius: 2px; }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.card:hover .card-img img { transform: scale(1.03); }
.card-name { margin: 10px 4px 2px; font-size: 14px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { margin: 0 4px; font-size: 13px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-price { margin-top: 6px; font-weight: 700; font-size: 15px; }
.card-price del { color: var(--muted); font-weight: 400; font-size: 13px; margin-right: 6px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--pink); color: #fff; vertical-align: middle; margin-right: 4px; }
.more-btn { display: block; width: fit-content; margin: 24px auto 8px; padding: 10px 40px; background: var(--btn); color: #fff; border: 0; border-radius: 3px; }

/* ── 首頁輪播、介紹、分類摺疊 ── */
.banner { position: relative; margin-top: 28px; overflow: hidden; border-radius: 2px; aspect-ratio: 16/9; background: var(--bg-soft); }
.banner-track { display: flex; height: 100%; transition: transform .5s ease; }
.banner-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; }
.dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.dots button { width: 22px; height: 4px; border: 0; border-radius: 2px; background: rgba(255,255,255,.55); padding: 0; }
.dots button.on { background: #fff; }
.intro { text-align: center; padding: 20px 8px 8px; color: var(--ink-2); }
.intro p { margin: 0 0 12px; }
.intro strong { color: var(--ink); }
.acc { margin: 12px auto 32px; max-width: 560px; }
.acc-item { margin-bottom: 4px; background: var(--pink); color: #fff; }
.acc-item > button { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border: 0; background: none; color: #fff; font-weight: 700; font-size: 15px; text-align: left; }
.acc-item .chev { width: 26px; height: 26px; padding: 4px; background: rgba(0,0,0,.45); border-radius: 50%; transition: transform .2s; }
.acc-item.open .chev { transform: rotate(180deg); }
.acc-body { display: none; background: #fff; color: var(--ink); padding: 6px 0; border: 1px solid var(--pink); border-top: 0; }
.acc-item.open .acc-body { display: block; }
.acc-body a { display: block; padding: 8px 18px; font-size: 14px; }
.acc-body a:hover { background: var(--bg-soft); }

/* ── 分類頁 ── */
.crumbs { font-size: 13px; color: var(--muted); padding: 12px 0; }
.crumbs a:hover { color: var(--ink); }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.cat-head h1 { font-size: 20px; margin: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 8px; scrollbar-width: none; }
.chip { flex: 0 0 auto; padding: 6px 12px; border: 1px solid var(--line); border-radius: 16px; font-size: 13px; background: #fff; }
.chip.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.sort-sel { border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; background: #fff; font: inherit; font-size: 13px; }

/* ── 商品頁 ── */
.pd { display: grid; gap: 20px; padding-bottom: 90px; }
@media (min-width: 860px) { .pd { grid-template-columns: 1fr 1fr; gap: 36px; padding-top: 12px; } }
.gallery { position: relative; }
.g-main { aspect-ratio: 1; background: var(--bg-soft); overflow: hidden; }
.g-main img { width: 100%; height: 100%; object-fit: contain; }
.g-thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.g-thumbs button { flex: 0 0 64px; height: 64px; padding: 0; border: 2px solid transparent; background: var(--bg-soft); }
.g-thumbs button.on { border-color: var(--ink); }
.g-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.pd-name { font-size: 22px; line-height: 1.4; margin: 0 0 8px; color: var(--ink-2); font-weight: 700; }
.pd-sub { color: var(--ink-2); margin: 0 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.pd-summary h3 { font-size: 15px; margin: 0 0 6px; }
.pd-summary p { margin: 0 0 16px; white-space: pre-line; color: var(--ink-2); }
.pd-note { color: var(--ink-2); font-size: 14px; margin-bottom: 14px; }
.pd-price { font-size: 22px; font-weight: 700; margin: 4px 0 14px; }
.pd-price del { font-size: 15px; color: var(--muted); font-weight: 400; margin-right: 8px; }
.btn { display: block; width: 100%; padding: 11px; border: 0; border-radius: 3px; background: var(--btn); color: #fff; font-size: 15px; text-align: center; }
.btn.light { background: #fff; color: var(--ink); border: 1px solid var(--ink); }
.btn:disabled { background: #bbb; cursor: not-allowed; }
.fav { display: block; margin: 10px auto 0; border: 0; background: none; color: var(--ink-2); font-size: 15px; }
.ptabs { display: flex; border-bottom: 1px solid var(--line); margin: 28px 0 0; }
.ptabs button { padding: 10px 16px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-2); }
.ptabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.rich { padding: 16px 0; overflow-wrap: anywhere; }
.rich img { height: auto; margin: 0 auto; }
.rich p { margin: 0 0 10px; }
.buybar { position: fixed; inset: auto 0 0 0; z-index: 40; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
@media (min-width: 860px) { .buybar { display: none; } }

/* ── 規格選擇面板 ── */
.sheet { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.4); display: none; }
.sheet.open { display: block; }
.sheet-panel { position: absolute; inset: auto 0 0 0; max-height: 86vh; overflow-y: auto; background: #fff; border-radius: 12px 12px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 860px) { .sheet-panel { inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: 480px; border-radius: 10px; } }
.sheet-top { display: flex; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sheet-top img { width: 84px; height: 84px; object-fit: cover; background: var(--bg-soft); }
.sheet-top .pd-price { font-size: 18px; margin: 4px 0 0; }
.sheet-close { margin-left: auto; align-self: flex-start; border: 0; background: none; }
.opt-group h4 { margin: 14px 0 8px; font-size: 14px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { padding: 7px 12px; border: 1px solid var(--line); border-radius: 3px; background: #fff; font-size: 14px; }
.opt.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opt:disabled { color: #bbb; text-decoration: line-through; cursor: not-allowed; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 3px; }
.qty button { width: 36px; height: 36px; border: 0; background: none; font-size: 18px; }
.qty input { width: 48px; height: 36px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; font: inherit; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

/* ── 購物車 ── */
.cart-row { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.cart-row img { width: 72px; height: 72px; object-fit: cover; background: var(--bg-soft); }
.cart-row .nm { font-size: 14px; line-height: 1.45; }
.cart-row .sp { font-size: 13px; color: var(--muted); }
.cart-row .rm { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 4px 0; }
.cart-sum { display: flex; justify-content: space-between; font-size: 17px; font-weight: 700; padding: 16px 0; }

/* ── 頁尾 ── */
.ftr { background: var(--bg-soft); text-align: center; padding: 28px 16px 90px; color: var(--ink-2); font-size: 14px; }
.ftr-col { margin-bottom: 20px; }
.ftr-col h4 { margin: 0 0 8px; color: var(--ink); font-size: 16px; }
.ftr-col a { display: block; line-height: 2; }
.ftr-small { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

/* ── 浮動購物車、提示 ── */
.fab-cart { position: fixed; right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 45; width: 48px; height: 48px; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); display: grid; place-items: center; color: var(--ink); }
.fab-cart .badge { top: -2px; right: -2px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); background: rgba(40,40,40,.92); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 80; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ── 靜態頁、搜尋 ── */
.page { padding-top: 20px; padding-bottom: 40px; }
.page h1 { font-size: 20px; }
.search-box { display: flex; gap: 8px; margin: 16px 0; }
.search-box input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px; font: inherit; }
.hot-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* ── 會員 / 結帳 / 訂單 ── */
.narrow { max-width: 640px; }
.page h2 { font-size: 16px; margin: 24px 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.hint { font-size: 13px; color: var(--ink-2); background: var(--bg-soft); padding: 10px 12px; border-radius: 4px; }
.center { text-align: center; }
.link { color: #2f6fb3; text-decoration: underline; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ink); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.seg a { text-align: center; padding: 9px; }
.seg a.on { background: var(--ink); color: #fff; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 14px; color: var(--ink-2); }
.form input:not([type=checkbox]):not([type=radio]), .form textarea, .form select { width: 100%; padding: 10px 12px; border: 1px solid #d9d9d9; border-radius: 4px; font: inherit; color: var(--ink); background: #fff; }
.form input:focus, .form textarea:focus { outline: 2px solid var(--pink-deep); outline-offset: 0; border-color: transparent; }
.form .check, label.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.form .check input { margin-top: 4px; }
.form.inline { grid-template-columns: 1fr auto; align-items: end; margin-top: 12px; }
.form-err { color: var(--sale); font-size: 14px; margin: 0; }
.btn.small { width: auto; padding: 8px 16px; font-size: 14px; }
.member-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; background: var(--bg-soft); border-radius: 6px; }
.credit { margin-top: 4px; }
.member-links { display: grid; margin: 14px 0; border-top: 1px solid var(--line); }
.member-links a { padding: 14px 4px; border-bottom: 1px solid var(--line); }
.order-row { display: block; padding: 14px 0; border-bottom: 1px solid var(--line); }
.or-top, .or-bot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.or-items { font-size: 13px; color: var(--ink-2); margin: 4px 0 8px; }
.st { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 10px; background: var(--bg-soft); margin-right: 4px; color: var(--ink-2); }
.st.ok { background: #e6f4ea; color: #1e7b3a; }
.st.warn { background: #fdecea; color: #b3261e; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; font-size: 14px; margin: 12px 0; }
.kv > span:nth-child(odd) { color: var(--muted); }
.li-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.li-row .r { text-align: right; white-space: nowrap; }
.sum { margin: 14px 0; display: grid; gap: 6px; font-size: 14px; }
.sum > div { display: flex; justify-content: space-between; }
.sum .total { font-size: 17px; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--line); }
.done-box { text-align: center; padding: 16px; background: #fff7f7; border: 1px solid var(--pink); border-radius: 6px; margin-bottom: 12px; }
.done-box h1 { margin: 4px 0 8px; }
.box { background: var(--bg-soft); padding: 12px 14px; border-radius: 4px; }
.rich.small { font-size: 13px; }
.radios { display: grid; gap: 8px; }
.radio { display: flex !important; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.radio span { flex: 1; display: flex; justify-content: space-between; color: var(--ink); }
.radio em { font-style: normal; color: var(--ink-2); }
.rich h3 { font-size: 15px; margin: 18px 0 6px; }

/* ── 管理後台 ── */
.admin { max-width: 980px; }
.adm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.adm-tabs a { padding: 10px 16px; border-bottom: 3px solid transparent; white-space: nowrap; }
.adm-tabs a.on { border-bottom-color: var(--ink); font-weight: 700; }
.adm-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.adm-filter input, .adm-filter select { padding: 8px 10px; border: 1px solid #d9d9d9; border-radius: 4px; font: inherit; font-size: 14px; background: #fff; }
.adm-filter input { flex: 1 1 200px; }
.adm-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.adm-row .r { text-align: right; }
.adm-row.prod img { width: 52px; height: 52px; object-fit: cover; background: var(--bg-soft); flex: 0 0 52px; }
.adm-row.prod .nm { flex: 1; }
.pager { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.adm-form { padding: 12px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 12px; }
.g3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; }
.adm-form textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.adm-form details summary { cursor: pointer; color: var(--ink-2); font-size: 14px; padding: 4px 0; }
.var-tbl { display: grid; gap: 6px; }
.var-tbl .vh, .var-tbl .vr { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 48px; gap: 6px; align-items: center; font-size: 13px; }
.var-tbl .vh { color: var(--muted); }
.var-tbl input:not([type=checkbox]) { padding: 7px 8px !important; }
.switch { position: relative; width: 44px; height: 24px; flex: 0 0 44px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #ccc; border-radius: 12px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: #3aa856; }
.switch input:checked + span::before { transform: translateX(20px); }
