:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* header */
.site-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 24px; height: 66px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; font-weight: 800; font-size: 17px;
}
.main-nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.main-nav a:hover, .main-nav a.on { color: var(--primary); }
.header-actions { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.cart-link { position: relative; font-weight: 600; }
.cart-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--primary); color: #fff; border-radius: 9px; font-size: 11px; margin-left: 4px;
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: .15s; font-family: inherit;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-lg { padding: 13px 24px; font-size: 15px; }

/* hero */
.hero {
  background: linear-gradient(135deg, #eef2ff 0%, #faf5ff 100%);
  border-radius: 18px; padding: 54px 40px; margin: 26px 0;
  border: 1px solid #e0e7ff;
}
.hero h1 { margin: 0 0 12px; font-size: 34px; line-height: 1.25; letter-spacing: -.02em; }
.hero p { margin: 0 0 22px; color: var(--muted); font-size: 16px; max-width: 520px; }

/* product grid */
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 34px 0 16px; }
.section-title h2 { margin: 0; font-size: 21px; }
.section-title a { font-size: 13px; color: var(--primary); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: .18s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #cbd5e1; }
.card-media { aspect-ratio: 1/1; background: var(--bg-soft); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-weight: 600; font-size: 15px; }
.price { font-weight: 700; color: var(--primary); font-size: 17px; }
.price-old { color: var(--muted); text-decoration: line-through; font-size: 13px; margin-left: 6px; font-weight: 400; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px;
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
}
.tag.stock-out { background: #fef2f2; color: var(--danger); }

/* product detail */
.detail { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; margin: 26px 0 40px; }
.detail-media { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.detail h1 { margin: 0 0 8px; font-size: 27px; }
.detail .price { font-size: 27px; }
.detail-desc { color: var(--muted); margin: 18px 0; white-space: pre-wrap; }
.qty-box { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.qty-box button { width: 38px; height: 40px; border: 0; background: #fff; cursor: pointer; font-size: 17px; color: var(--muted); }
.qty-box button:hover { background: var(--bg-soft); }
.qty-box input { width: 52px; border: 0; text-align: center; font-size: 15px; font-family: inherit; }
.meta-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 18px; }
.meta-table td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.meta-table td:first-child { color: var(--muted); width: 90px; }

/* cart & forms */
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.layout-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; margin: 26px 0 40px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.table td { padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: 0; }
.summary-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.summary-row.total { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 14px; font-size: 18px; font-weight: 700; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field { margin-bottom: 14px; }
.field-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.alert { padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error, .alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--primary-soft); color: #3730a3; border: 1px solid #c7d2fe; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* footer */
.site-footer { background: #fff; border-top: 1px solid var(--border); margin-top: 60px; padding: 44px 0 24px; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr 1.3fr; gap: 30px; }
.footer-inner h4 { margin: 0 0 12px; font-size: 14px; }
.footer-inner a, .footer-inner p { display: block; font-size: 13px; color: var(--muted); margin: 5px 0; }
.copyright { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--border); }

@media (max-width: 860px) {
  .detail, .layout-2 { grid-template-columns: 1fr; gap: 22px; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .main-nav { display: none; }
  .hero { padding: 34px 22px; }
  .hero h1 { font-size: 26px; }
}

/* ===== 會員 / 認證 ===== */
.auth-wrap { max-width: 460px; margin: 40px auto; }
.auth-card .auth-tabs { display: flex; gap: 0; }
.auth-card .auth-tabs a {
  flex: 1; text-align: center; padding: 14px 10px; font-size: 15px; font-weight: 600;
  background: #fff; color: var(--muted); border: 1px solid var(--border); border-bottom: none;
}
.auth-card .auth-tabs a:first-child { border-radius: 14px 0 0 0; }
.auth-card .auth-tabs a:last-child { border-radius: 0 14px 0 0; border-left: none; }
.auth-card .auth-tabs a.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.member-link { font-size: 13.5px; font-weight: 600; color: var(--primary); }

.account-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; margin: 20px 0 40px; }
.account-nav { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; align-self: start; }
.account-nav a { display: block; padding: 10px 12px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.account-nav a:hover { background: var(--bg-soft); color: var(--text); }
.account-nav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.account-stat { margin-top: 14px; padding: 12px; border-top: 1px solid var(--border); }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bg-soft); color: var(--muted); }
.tag-ok { background: #ecfdf5; color: #065f46; }
.tag-warn { background: #fffbeb; color: #92400e; }

.spinner {
  width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .account-layout { grid-template-columns: 1fr; }
}

/* ===== 多語言 / 主題相關 ===== */
.lang-switch { position: relative; display: inline-block; }
.lang-switch .lang-current {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; cursor: pointer; font-family: inherit; color: inherit;
}
.lang-switch .lang-list {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); min-width: 150px; padding: 6px;
}
.lang-switch.open .lang-list { display: block; }
.lang-switch .lang-list a {
  display: block; padding: 7px 10px; border-radius: 6px; font-size: 13px; white-space: nowrap;
}
.lang-switch .lang-list a:hover { background: var(--bg-soft); }
.lang-switch .lang-list a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.sub-nav { display: flex; gap: 16px; padding: 0 20px 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.sub-nav a:hover { color: var(--primary); }

.cat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.cat-chips .chip { padding: 6px 14px; font-size: 13px; cursor: pointer; }
.cat-chips .chip.on { background: var(--primary); color: #fff; }

.pager { display: flex; gap: 6px; justify-content: center; margin: 34px 0; flex-wrap: wrap; }
.thumb-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.thumb-row div { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; aspect-ratio: 1/1; }
.thumb-row img { width: 100%; height: 100%; object-fit: cover; }
.breadcrumb { margin: 18px 0; }
.breadcrumb a:hover { color: var(--primary); }

/* 規格選擇 */
.variant-options { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.variant-options label {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.variant-options input { margin-right: 6px; }

/* 後台：語系分頁籤 */
.lang-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.lang-tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 12px;
  font-size: 13px; cursor: pointer; color: var(--muted); font-family: inherit;
}
.lang-tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.lang-pane { display: none; }
.lang-pane.on { display: block; }

/* 後台：主題選擇卡 */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.theme-card {
  border: 2px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: pointer; background: #fff;
}
.theme-card.on { border-color: var(--primary); background: var(--primary-soft); }
.theme-card strong { display: block; font-size: 14px; margin-bottom: 4px; }
.theme-card .swatches { display: flex; gap: 5px; margin: 8px 0; }
.theme-card .swatches span { width: 26px; height: 26px; border-radius: 6px; border: 1px solid rgba(0,0,0,.08); }
.theme-card .muted { font-size: 12px; line-height: 1.5; }
