:root {
  --bg: #84592B; --card: #E8D1A7; --dark: #442D1C; --accent: #743014; --assist: #9D9167;
  --cream: #F5EBD8; --card-shade: #D6BC8E; --muted: #6B5440; --line: rgba(255,255,255,.22);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: #fff; font-family: 'Noto Sans TC', system-ui, sans-serif; font-size: 15px; line-height: 1.6; min-height: 100vh; }
a { color: #fff; }
a:hover { color: var(--cream); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--cream); opacity: .9; font-size: 13px; }
.hidden { display: none !important; }

/* 公告列 */
.announce { display: block; background: var(--accent); color: #fff; text-align: center; font-size: 13px; padding: 8px 12px; text-decoration: none; }

/* 頁首 */
.site-header { border-bottom: 1px solid var(--line); }
.hdr-row { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 12px; }
.logo img { height: 24px; width: auto; }
.icon-btn { position: relative; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: none; border: 0; cursor: pointer; text-decoration: none; }
.badge { position: absolute; top: 4px; right: 0; background: var(--card); color: var(--dark); font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 6px; }
.tabs { display: flex; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0 8px; font-size: 12px; text-decoration: none; color: var(--cream); border-bottom: 3px solid transparent; }
.tabs a.on { color: #fff; font-weight: 700; border-bottom-color: #fff; }
.tab-icon { width: 28px; height: 28px; border-radius: 50%; object-fit: contain; }
.tab-icon.ph { border: 1.5px dashed var(--card); }
@media (min-width: 768px) {
  .logo img { height: 30px; }
  .tabs { justify-content: center; gap: 32px; }
  .tabs a { flex: 0 0 auto; flex-direction: row; font-size: 15px; gap: 8px; padding: 6px 4px 10px; }
}

/* 頁尾 */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 18px 0 28px; font-size: 13px; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }

/* 按鈕與表單 */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px; border-radius: 12px; border: 0; font-weight: 700; cursor: pointer; text-decoration: none; font-size: 15px; }
.btn-dark { background: var(--dark); color: #fff; }
.btn-light { background: var(--card); color: var(--dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=month], select, textarea {
  width: 100%; min-height: 44px; border: 1px solid #B8996B; border-radius: 10px; padding: 8px 12px; font-size: 15px; background: #fff; color: var(--dark);
}
textarea { min-height: 96px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* 淺色面板（黃色卡片） */
.panel { background: var(--card); color: var(--dark); border-radius: var(--radius); padding: 16px; }
.panel a { color: var(--accent); }
.panel .muted { color: var(--muted); }
.chip { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--card); color: #fff; background: transparent; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.chip.on { background: var(--cream); color: var(--dark); font-weight: 700; border-color: var(--cream); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }

.page { padding-top: 20px; padding-bottom: 20px; }
.page-title { font-size: 24px; margin-bottom: 16px; }

/* 首頁三大框 */
.doors { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; padding-bottom: 16px; height: calc(100svh - 110px); min-height: 520px; }
.door { position: relative; flex: 1 1 0; border-radius: 18px; padding: 10px; text-decoration: none; display: block; min-height: 150px; }
.door-inner { position: absolute; inset: 10px; border-radius: 12px; overflow: hidden; background: var(--cream); }
.door-inner img { width: 100%; height: 100%; object-fit: cover; }
.door-label { position: absolute; left: 22px; bottom: 20px; color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .5px; text-shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 0 1px rgba(0, 0, 0, .35); }
.door-soon { position: absolute; right: 20px; top: 20px; background: var(--accent); color: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
@media (min-width: 768px) {
  .doors { flex-direction: row; gap: 20px; height: auto; min-height: 0; padding-top: 16px; }
  .door { flex: 1 1 0; aspect-ratio: 3 / 4; padding: 14px; }
  .door-inner { inset: 14px; }
  .door-label { left: 30px; bottom: 28px; font-size: 17px; }
  .door-soon { right: 28px; top: 28px; }
}

/* 商品列表 */
.products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
@media (min-width: 768px) { .products { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; } }
@media (min-width: 1100px) { .products { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pcard { position: relative; background: var(--card); color: var(--dark); border-radius: 12px; overflow: hidden; text-decoration: none; display: flex; flex-direction: column; }
.pcard:hover { color: var(--dark); }
.pcard .thumb { aspect-ratio: 1; background: var(--card-shade); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.pcard .thumb img { width: 100%; height: 100%; object-fit: cover; }
.pcard .info { padding: 10px 12px 12px; }
.pcard .name { font-size: 14px; font-weight: 500; }
.price { font-weight: 700; color: var(--accent); }
.pcard .price { font-size: 16px; }
.soldout-tag { position: absolute; left: 8px; top: 8px; background: var(--dark); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.pcard.soldout .thumb { opacity: .6; }
.lookup-bar { margin-top: 16px; background: var(--assist); color: #2A1B10; border-radius: 12px; padding: 12px 14px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.lookup-bar a { color: #2A1B10; font-weight: 700; }

/* 商品頁 */
.product-layout { display: grid; gap: 20px; }
@media (min-width: 900px) { .product-layout { grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; } }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 14px; background: var(--card); aspect-ratio: 1; }
.gallery > * { flex: 0 0 100%; scroll-snap-align: start; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; color: var(--dark); }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.gallery { scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery-col { min-width: 0; }
.gallery-wrap { position: relative; }
.gal-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(68, 45, 28, .6); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding-bottom: 4px; }
.gal-nav:hover { background: rgba(68, 45, 28, .85); }
.gal-nav.prev { left: 10px; }
.gal-nav.next { right: 10px; }
.gal-dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.gal-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .4); }
.gal-dots span.on { background: #fff; }
.gal-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 2px; }
.gal-thumbs button { flex: 0 0 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; padding: 0; background: var(--card-shade); cursor: pointer; opacity: .65; }
.gal-thumbs button.on { border-color: #fff; opacity: 1; }
.gal-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.qty { display: inline-flex; align-items: center; border: 1px solid #B8996B; border-radius: 10px; }
.qty button { width: 44px; height: 44px; border: 0; background: transparent; color: inherit; font-size: 20px; cursor: pointer; }
.qty span { min-width: 28px; text-align: center; font-weight: 700; }
.qty.sm button { width: 32px; height: 34px; font-size: 16px; }

/* 購物車／結帳 */
.two-col { display: grid; gap: 14px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; } }
.progress { height: 8px; border-radius: 4px; background: var(--card-shade); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }
.cart-line { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--card-shade); }
.cart-line:last-child { border-bottom: 0; }
.cart-line .thumb { width: 54px; height: 54px; border-radius: 8px; background: var(--card-shade); flex-shrink: 0; overflow: hidden; }
.cart-line .thumb img { width: 100%; height: 100%; object-fit: cover; }
.summary { background: var(--dark); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.summary .line { display: flex; justify-content: space-between; color: var(--cream); font-size: 14px; }
.summary .total { display: flex; justify-content: space-between; font-size: 19px; font-weight: 700; }
.radio-line { display: flex; align-items: center; gap: 10px; min-height: 42px; cursor: pointer; }
.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { display: flex; gap: 12px; padding-bottom: 14px; }
.timeline .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--card-shade); flex-shrink: 0; margin-top: 3px; }
.timeline li.done .dot { background: var(--dark); }
.timeline li.cancel .dot { background: var(--accent); }
.qr-box { width: 220px; height: 220px; border: 2px dashed var(--bg); border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--bg); font-size: 13px; overflow: hidden; }
.qr-box img { width: 100%; height: 100%; object-fit: contain; }
.notice { background: var(--cream); color: var(--dark); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.7; }
.err { color: #fff; background: var(--accent); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.panel .err { color: #fff; }

/* About / News */
.about-img { border-radius: 16px; overflow: hidden; background: var(--assist); aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; color: #2A1B10; }
.about-img img { width: 100%; height: 100%; object-fit: cover; }
.prose { white-space: pre-line; line-height: 1.9; color: var(--cream); }
.panel .prose { color: var(--dark); }
.news-issue { margin-bottom: 24px; }
.news-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 12px 0; }
.news-imgs img { border-radius: 10px; width: 100%; }

/* Toast / Modal */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); opacity: 0; background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 12px; transition: .25s; z-index: 1000; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 實體結帳 POS ===== */
.pos { display: flex; flex-direction: column; min-height: 100vh; }
.pos-top { background: var(--dark); display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.pos-top select { width: auto; min-width: 180px; }
.pos-body { flex: 1; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .pos-body { grid-template-columns: 1fr 400px; } }
.pos-products { padding: 16px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { position: relative; min-height: 110px; border-radius: 14px; border: 0; background: var(--card); color: var(--dark); padding: 14px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; }
.tile .t-name { font-size: 17px; font-weight: 700; }
.tile .t-price { font-size: 20px; font-weight: 700; color: var(--accent); }
.tile:disabled { background: var(--card-shade); cursor: not-allowed; }
.tile:active:not(:disabled) { transform: scale(.98); }
.pos-side { background: var(--dark); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.pos-line { display: flex; align-items: center; gap: 8px; }
.pos-line .qty { border-color: #A88B62; }
.change { background: var(--assist); color: #2A1B10; border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; }
.change b { font-size: 30px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { min-height: 48px; border-radius: 10px; border: 1px solid var(--card); background: transparent; color: #fff; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--dark); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick button { min-height: 40px; border-radius: 8px; border: 1px solid #A88B62; background: transparent; color: #fff; cursor: pointer; }

/* ===== 後台 ===== */
.admin { display: flex; flex-wrap: wrap; min-height: 100vh; }
.admin-nav { flex: 1 1 220px; max-width: 240px; background: var(--dark); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.admin-nav img { height: 18px; width: auto; margin: 0 10px 18px; }
.admin-nav a { color: var(--cream); padding: 11px 10px; text-decoration: none; border-radius: 8px; }
.admin-nav a.on { background: var(--card); color: var(--dark); font-weight: 700; }
.admin-main { flex: 999 1 560px; min-width: 0; padding: 24px; }
@media (max-width: 760px) {
  .admin-nav { max-width: none; flex-basis: 100%; flex-direction: row; overflow-x: auto; padding: 10px; align-items: center; }
  .admin-nav img { display: none; }
  .admin-nav a { white-space: nowrap; }
  .admin-main { padding: 16px; }
}
.admin h1 { font-size: 24px; }
.table-wrap { background: var(--card); border-radius: 12px; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; color: var(--dark); }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid #C9AE80; white-space: nowrap; }
.tbl td { font-size: 14px; padding: 10px 12px; border-bottom: 1px solid var(--card-shade); vertical-align: middle; }
.tbl td.nowrap { white-space: nowrap; }
.status { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; white-space: nowrap; }
.st-pending { background: var(--accent); color: #fff; }
.st-reported { background: #B5462A; color: #fff; }
.st-paid { background: var(--bg); color: #fff; }
.st-shipped, .st-completed { background: var(--assist); color: #2A1B10; }
.st-cancelled { background: #C9AE80; color: var(--dark); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--card); color: var(--dark); border-radius: 12px; padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .muted { color: var(--muted); opacity: 1; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.settings-grid h2 { font-size: 18px; margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; background: var(--cream); border-radius: 8px; padding: 6px 10px; }
.upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.upload .pv { width: 72px; height: 72px; border-radius: 8px; background: var(--card-shade); overflow: hidden; position: relative; }
.upload .pv img { width: 100%; height: 100%; object-fit: cover; }
.upload .pv button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--dark); color: #fff; font-size: 12px; cursor: pointer; line-height: 1; }
.upload label.add { width: 72px; height: 72px; border-radius: 8px; border: 2px dashed var(--bg); display: flex; align-items: center; justify-content: center; color: var(--bg); font-size: 26px; cursor: pointer; }
.upload input[type=file] { display: none; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 20px; height: 20px; }
.swatch { width: 40px; height: 40px; border-radius: 8px; border: 1px solid #B8996B; padding: 0; }
.login-box { max-width: 380px; margin: 10vh auto; }
.demo-flag { background: var(--accent); color: #fff; font-size: 12px; text-align: center; padding: 4px; }
