:root {
  --bg: #faf7f3;
  --surface: #ffffff;
  --ink: #2b2420;
  --muted: #7a6c63;
  --line: #e8dfd6;
  --accent: #8c5a3c;
  --accent-soft: #f3e8df;
  --sold: #9a8f88;
  --whatsapp: #1c8a4c;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header ---------- */
.masthead { padding: 36px 0 18px; text-align: center; }
.masthead h1 {
  margin: 0; font: 400 clamp(2.1rem, 6vw, 3rem)/1.1 var(--serif);
  letter-spacing: 0.04em;
}
.logo { display: block; width: min(300px, 68vw); height: auto; margin: 0 auto; }
.masthead:has(.logo:not([hidden])) { padding-top: 24px; }
.tagline {
  margin: 8px 0 0; color: var(--muted); font-size: 0.8rem;
  letter-spacing: 0.18em; text-transform: uppercase;
}

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 0 0;
}
.toolbar-inner { display: flex; gap: 10px; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
input, select { font: inherit; color: var(--ink); }
.search input {
  width: 100%; padding: 10px 12px 10px 38px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.sort select {
  height: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); max-width: 44vw;
}
@media (max-width: 480px) { .sort select { max-width: 120px; } }

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; font: inherit; font-size: 0.88rem; cursor: pointer;
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- grid ---------- */
.count { margin: 16px 0 12px; color: var(--muted); font-size: 0.88rem; }
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  display: flex; flex-direction: column; width: 100%; height: 100%;
  padding: 0; border: 0; background: none; text-align: left; font: inherit; color: inherit;
  cursor: pointer;
}
.card-media {
  position: relative; aspect-ratio: 1; overflow: hidden;
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line);
}
.card-media img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  transition: transform 0.35s ease;
}
.card:hover .card-media img { transform: scale(1.04); }
.placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font: 400 2.4rem var(--serif); color: var(--line); background: var(--surface);
}
.badge {
  position: absolute; top: 8px; left: 8px;
  padding: 2px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600;
  background: rgba(43, 36, 32, 0.78); color: #fff;
}
.card-body { padding: 10px 2px 4px; }
.card-name {
  margin: 0; font-size: 0.95rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-price { margin: 4px 0 0; font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; }
.card.sold .card-media img { opacity: 0.55; }
.card.sold .card-price { color: var(--sold); }

.message { text-align: center; color: var(--muted); padding: 48px 16px; }
.message button {
  margin-top: 12px; font: inherit; padding: 8px 18px; border-radius: 999px;
  border: 1px solid var(--ink); background: none; cursor: pointer;
}

.footer {
  margin-top: 48px; padding-top: 20px; padding-bottom: 40px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; text-align: center;
}
.footer p { margin: 4px 0; }

/* ---------- product dialog ---------- */
dialog {
  width: min(880px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  padding: 0; border: 0; border-radius: 14px; color: var(--ink); background: var(--surface);
  box-shadow: 0 20px 60px rgba(43, 36, 32, 0.3);
}
dialog::backdrop { background: rgba(43, 36, 32, 0.5); }
.close {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.9); color: var(--ink);
}
.close svg { width: 20px; height: 20px; }
.product { display: grid; grid-template-columns: 1fr; }
@media (min-width: 720px) { .product { grid-template-columns: 1.15fr 1fr; } }
.product-image {
  background: #fff; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; border-bottom: 1px solid var(--line);
}
@media (min-width: 720px) { .product-image { border-bottom: 0; border-right: 1px solid var(--line); } }
.product-image img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.product-info { padding: 22px 22px 26px; display: flex; flex-direction: column; }
@media (min-width: 720px) { .product-info { padding: 44px 32px 32px; } }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.16em; text-transform: uppercase; }
.product-info h2 { margin: 0; font: 400 1.7rem/1.2 var(--serif); }
.price { margin: 12px 0 0; font-size: 1.35rem; font-weight: 650; color: var(--accent); }
.status { margin: 6px 0 0; font-size: 0.9rem; }
.status.ok { color: var(--whatsapp); }
.status.sold { color: var(--sold); }
.unique {
  display: inline-block; margin-left: 10px; padding: 2px 10px; border-radius: 999px; vertical-align: 1px;
  background: var(--accent-soft); color: var(--accent); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em;
}
.sku { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }
.order {
  margin-top: 24px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; text-decoration: none; font-weight: 600;
  background: var(--whatsapp); color: #fff;
}
.order:hover { filter: brightness(1.08); }
.order svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }

/* ---------- order (cart) ---------- */
.add {
  margin-top: 24px; padding: 13px 20px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 600; background: var(--ink); color: #fff;
}
.add:hover { background: #3d342f; }
.add + .in-cart { margin: 10px 0 0; font-size: 0.9rem; color: var(--muted); text-align: center; }
.order.secondary {
  margin-top: 12px; background: none; color: var(--whatsapp);
  border: 1px solid currentColor; padding: 10px 18px; font-size: 0.92rem;
}
.order.secondary:hover { background: #eef7f1; filter: none; }
.text-btn {
  border: 0; background: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
}

.cart-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 10;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 600; background: var(--ink); color: #fff;
  box-shadow: 0 8px 24px rgba(43, 36, 32, 0.28);
}
.cart-fab svg { width: 20px; height: 20px; }
.cart-count {
  min-width: 24px; padding: 1px 7px; border-radius: 999px; text-align: center;
  background: var(--accent-soft); color: var(--ink); font-size: 0.85rem;
}
body:has(.cart-fab:not([hidden])) .footer { padding-bottom: 96px; }

dialog.cart-dialog { width: min(560px, calc(100vw - 24px)); }
.cart-body { padding: 22px 20px 20px; }
.cart-body h2 { margin: 0 44px 14px 0; font: 400 1.6rem/1.2 var(--serif); }
.cart-items { list-style: none; margin: 0; padding: 0; max-height: 52vh; overflow-y: auto; }
.cart-item {
  display: grid; grid-template-columns: 56px 1fr auto; grid-template-rows: auto auto;
  gap: 2px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line);
}
.cart-item:first-child { border-top: 0; }
.cart-thumb { grid-row: 1 / span 2; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.cart-thumb img, .cart-thumb .placeholder { width: 100%; height: 100%; object-fit: contain; font-size: 1.2rem; }
.cart-info { min-width: 0; }
.cart-name { margin: 0; font-size: 0.95rem; line-height: 1.3; }
.cart-meta { margin: 2px 0 0; color: var(--muted); font-size: 0.8rem; }
.cart-item.sold .cart-meta { color: #a4443b; }
.cart-item.sold .cart-thumb, .cart-item.sold .cart-name { opacity: 0.55; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.stepper button {
  width: 32px; height: 32px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 1.1rem; color: var(--ink); border-radius: 999px;
}
.stepper button:disabled { color: var(--line); cursor: default; }
.stepper span { min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.cart-sub { grid-column: 3; margin: 0; text-align: right; font-weight: 600; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.cart-empty { color: var(--muted); margin: 8px 0 4px; }
.cart-footer { display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 14px; }
.cart-total { display: flex; justify-content: space-between; margin: 0; font-size: 1.15rem; }
.cart-total b { color: var(--accent); font-variant-numeric: tabular-nums; }
.cart-note { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }
.cart-footer .order { margin-top: 16px; }
.cart-footer .text-btn { align-self: center; margin-top: 12px; font-size: 0.88rem; color: var(--muted); }

.toast {
  position: fixed; inset: auto auto 84px 50%; margin: 0; border: 0; overflow: visible;
  z-index: 20; transform: translate(-50%, 12px);
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff;
  font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
  .card-media img { transition: none; }
  .card:hover .card-media img { transform: none; }
}
