:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: #24211f;
  background: #f7f4ef;
  --accent: #7a5747;
  --accent-dark: #5f4033;
  --line: #ded6ce;
  --muted: #6d6762;
  --paper: #ffffff;
  --soft: #eee7e0;
  --success: #26724f;
  --danger: #a12f2f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fff 0, #f7f4ef 440px);
}

button,
input,
select { font: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(122 87 71 / 28%);
  outline-offset: 2px;
}

.preview-banner {
  padding: 10px 20px;
  background: #fff3cd;
  color: #6e5015;
  text-align: center;
  font-size: .9rem;
  font-weight: 700;
}

.site-header,
main {
  width: min(1240px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  padding: 64px 0 34px;
}

.eyebrow,
.product-meta {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(2.25rem, 5vw, 4rem); }
h2 { margin: 0; }
.intro { max-width: 680px; margin-bottom: 0; color: var(--muted); line-height: 1.65; }

.header-actions,
.product-actions,
.cart-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.icon-button,
.remove-button {
  border: 0;
  border-radius: 999px;
  font-weight: 750;
  cursor: pointer;
}

.button { padding: 12px 19px; }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { background: var(--soft); color: var(--accent-dark); }
.button:disabled { cursor: not-allowed; opacity: .55; }

.count-badge {
  display: inline-grid;
  min-width: 1.5rem;
  min-height: 1.5rem;
  margin-left: 5px;
  place-items: center;
  border-radius: 999px;
  background: white;
  color: var(--accent-dark);
  font-size: .78rem;
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(190px, 280px);
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgb(255 255 255 / 82%);
}

.filters label,
.field-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
}

input[type="search"],
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  background: white;
  color: #24211f;
}

.catalog-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 70px;
}

.status,
.product-count { color: var(--muted); }
.status.error,
.cart-message.error { color: var(--danger); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr));
  gap: 24px;
  padding-bottom: 80px;
}

.product-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 12px 36px rgb(62 46 37 / 8%);
}

.image-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #eee9e4;
}

.product-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #918981; }
.sku-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgb(255 255 255 / 90%);
  font-size: .72rem;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.product-content { padding: 22px; }
.product-name { margin-bottom: 18px; font-size: 1.35rem; }
.field-label { margin: 14px 0 10px; }
.field-title { color: #403b37; font-size: .84rem; font-weight: 800; }
.availability { display: inline-block; margin: 5px 0 12px; font-size: .85rem; font-weight: 800; }
.availability.available { color: var(--success); }
.availability.unavailable { color: var(--danger); }

.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tag { padding: 5px 8px; border-radius: 999px; background: #f1eeeb; color: #635b55; font-size: .72rem; }
.product-note { color: var(--muted); font-size: .88rem; line-height: 1.55; }

.tiers {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 0;
  border: 0;
}

.tiers legend { margin-bottom: 8px; }
.tier-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.tier-option:has(input:checked) { border-color: var(--accent); background: #faf6f3; }
.tier-option input { accent-color: var(--accent); }
.tier-detail { display: grid; gap: 3px; }
.tier-name { font-size: .9rem; }
.tier-price { color: var(--muted); font-size: .78rem; }
.product-actions .button { flex: 1 1 140px; }

.cart-dialog {
  width: min(720px, calc(100% - 24px));
  max-height: calc(100vh - 36px);
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: 0 24px 80px rgb(35 25 20 / 28%);
}
.cart-dialog::backdrop { background: rgb(36 29 25 / 45%); backdrop-filter: blur(3px); }
.cart-dialog > * { margin-inline: 24px; }
.dialog-header { display: flex; justify-content: space-between; align-items: start; padding-top: 24px; }
.dialog-header h2 { font-size: 1.7rem; }
.icon-button { width: 42px; height: 42px; background: var(--soft); color: var(--accent-dark); font-size: 1.6rem; }
.cart-note { color: var(--muted); font-size: .85rem; line-height: 1.55; }
.cart-message { min-height: 24px; font-size: .88rem; }
.cart-items { display: grid; gap: 10px; }
.empty-cart { padding: 28px; border-radius: 16px; background: #f7f4ef; color: var(--muted); text-align: center; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.cart-item-description { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.cart-item-description strong { color: #24211f; font-size: .95rem; }
.cart-item-amount { white-space: nowrap; }
.remove-button { padding: 7px 10px; background: #f5e8e8; color: var(--danger); font-size: .78rem; }
.cart-totals { display: grid; gap: 8px; margin-block: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.cart-totals div { display: flex; justify-content: space-between; gap: 18px; }
.cart-totals dt { color: var(--muted); }
.cart-totals dd { margin: 0; font-weight: 800; }
.cart-totals .grand-total { padding-top: 10px; color: var(--accent-dark); font-size: 1.12rem; }
.cart-actions { position: sticky; bottom: 0; margin: 0; padding: 18px 24px 24px; background: white; border-top: 1px solid var(--line); }
.cart-actions .button { flex: 1 1 220px; }

@media (max-width: 700px) {
  .site-header { align-items: start; flex-direction: column; padding-top: 42px; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; }
  .filters { grid-template-columns: 1fr; }
  .catalog-heading { align-items: start; flex-direction: column; padding: 18px 0; }
  .catalog-heading p { margin: 0; }
  .cart-item { grid-template-columns: 1fr auto; }
  .remove-button { grid-column: 2; }
}
