:root {
  --bg: #f6f4ef;
  --card: #fffdf9;
  --text: #1c1b19;
  --muted: #6f6a63;
  --accent: #2f5d50;
  --accent-hover: #24483f;
  --border: #e6dfd4;
  --warn: #9a6b00;
  --success: #2f6b3a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
main.container {
  flex: 1;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: min(1080px, 92vw); margin: 0 auto; padding: 1rem 0 2rem; }

.site-header, .site-footer {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.site-footer {
  border-top: 1px solid var(--border);
  border-bottom: none;
  margin-top: auto;
}
.site-footer .container {
  padding-top: 1.5rem;
  padding-bottom: 0.5rem;
}
.site-header .container {
  padding-top: 1rem;
  padding-bottom: 0.5rem;
}
.header-inner { display: flex; justify-content: space-between; align-items: center; }
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: calc(1.6rem + 10px);
  line-height: 1;
  color: var(--text);
  text-decoration: none;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
  align-self: center;
}
.logo-wordmark {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.logo-reg {
  font-size: 0.55em;
  font-weight: 600;
  line-height: 1;
  position: relative;
  top: -0.35em;
}

.hero { margin: 1rem 0 1.5rem; }
.category-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.chip {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  align-items: stretch;
}
.product-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s ease;
}
.product-card:hover {
  transform: scale(1.02);
}
.product-card a {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.product-card a:hover {
  text-decoration: none;
}
.product-card a:hover h2 {
  text-decoration: underline;
}
.product-card a:hover .muted,
.product-card a:hover .price-sale,
.product-card a:hover .price-badge,
.product-card a:hover .price-sale-only {
  text-decoration: none;
}
.product-card a:hover .price-compare {
  text-decoration: line-through;
}
.product-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.product-card h2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 1rem;
  line-height: 1.45;
  min-height: calc(1.45em * 2);
  margin: 0.75rem 0.75rem 0.25rem;
  overflow: hidden;
}
.product-card .muted { margin: 0 0.75rem 0.75em; }
.product-card .price-promo,
.product-card .price-sale-only {
  margin: auto 0.75rem 0.75rem;
}
.price { color: var(--accent); font-weight: 700; }
.muted { color: var(--muted); }

.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.product-gallery {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  max-width: min(100%, 480px);
  justify-self: start;
}
.gallery-carousel {
  --gallery-frame-height: min(70vh, 520px);
  position: relative;
  height: var(--gallery-frame-height);
  max-height: var(--gallery-frame-height);
}
.gallery-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  transform: translateY(-50%);
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--card) 70%, transparent);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.gallery-prev { left: 0.75rem; }
.gallery-next { right: 0.75rem; }
.gallery-nav:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--card) 70%, transparent);
}
.gallery-nav:disabled { opacity: 0.35; cursor: default; }
.gallery-main {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 8px;
}
.gallery-main .product-hero {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  margin: 0;
  border-radius: 8px;
  display: block;
  object-fit: contain;
}
.gallery-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 1.25rem;
}
.gallery-counter { font-size: 0.85rem; color: var(--muted); }
.gallery-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}
.gallery-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.gallery-dot.is-active {
  background: var(--accent);
  transform: scale(1.15);
}
.gallery-hint { margin: 0; font-size: 0.85rem; text-align: center; }
.product-hero { width: 100%; border-radius: 8px; }

.variation-picker { display: grid; gap: 0.5rem; }
.variation-picker-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}
.variation-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.variation-option {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.variation-option:hover { border-color: var(--accent); }
.variation-option.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.variant-price-block { margin: 0.75em 0 0.15rem; }
.variant-price-block .price-promo,
.variant-price-block .price-sale-only {
  margin-top: 0;
}
.variant-stock-line { margin: 0 0 0.75rem; font-size: 0.9rem; }
.price-promo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin: 0;
}
.price-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: #c0392b;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.price-compare {
  text-decoration: line-through;
  color: var(--muted);
  font-size: 1rem;
}
.price-sale {
  color: #c0392b;
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.1;
}
.price-sale-only {
  color: var(--accent);
  font-weight: 700;
  margin: 0.25rem 0;
}
.product-card .price-sale { font-size: 1.35rem; }
.product-card .price-compare { font-size: 0.85rem; }
.product-card .price-badge { font-size: 0.72rem; }

body.lightbox-open { overflow: hidden; }
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0, 0, 0, 0.82);
  cursor: zoom-out;
}
.lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(92vw, 1100px);
  max-height: 92vh;
  display: grid;
  place-items: center;
  padding: 2.5rem 3rem;
}
.lightbox-image {
  max-width: 100%;
  max-height: calc(92vh - 5rem);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.lightbox-close {
  top: 0.5rem;
  right: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.4rem;
}
.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.6rem;
}
.lightbox-prev { left: 0; }
.lightbox-next { right: 0; }
.lightbox-prev:disabled,
.lightbox-next:disabled { opacity: 0.35; cursor: default; }
.lightbox-caption {
  position: absolute;
  bottom: 0.25rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.9rem;
}
.buy-form, .checkout-form { display: grid; gap: 0.75rem; margin-top: 1rem; }
.buy-form label, .checkout-form label { display: grid; gap: 0.35rem; font-weight: 600; }
input, select, textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.btn {
  display: inline-block;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-small { padding: 0.35rem 0.6rem; font-size: 0.9rem; }
.inline-form { display: inline-flex; gap: 0.35rem; align-items: center; }

.cart-table { width: 100%; border-collapse: collapse; background: var(--card); }
.cart-table th, .cart-table td { border-bottom: 1px solid var(--border); padding: 0.75rem; text-align: left; }
.cart-summary-line { margin: 0.35rem 0; font-size: 0.95rem; }
.cart-total { font-size: 1.1rem; margin: 0.75rem 0 1rem; }
.qty-input { width: 4rem; }
.cart-row-over-stock { background: #fff8eb; }
.cart-stock-warn {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--warn);
  font-weight: 600;
}
#cart-checkout.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.pay-panel, .checkout-summary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
.checkout-summary {
  list-style: none;
  margin: 0 0 1rem;
}
.pay-amount { font-size: 1.4rem; }
.pay-breakdown { margin: 0.25rem 0 0.75rem; font-size: 0.9rem; }
.payment-fx-amount {
  margin: 0.65rem 0 0;
  font-size: 1.05rem;
  color: var(--text);
  text-align: center;
}
.qr-image {
  display: block;
  width: 100%;
  max-width: min(320px, 80vw);
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.alert {
  padding: 0.75rem 1rem;
  background: #fff4d6;
  border: 1px solid #f0d58b;
  border-radius: 8px;
  color: var(--warn);
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: #eee;
  font-size: 0.85rem;
}
.badge-warn { background: #fff0c2; color: var(--warn); }
.badge-success { background: #dff3e5; color: var(--success); }
.admin-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.payment-qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.payment-qr-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.payment-qr-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  min-height: 2.6em;
}
.payment-qr-card .qr-image {
  flex: 0 0 auto;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.checkbox-row input { width: auto; }

@media (max-width: 720px) {
  .product-detail { grid-template-columns: 1fr; }
  .cart-table { font-size: 0.9rem; }
}
