:root {
  --bg: #f3efe8;
  --card: #fbf9f5;
  --ink: #2a2622;
  --muted: #7a7068;
  --line: #e2dbd0;
  --accent: #7d5338;
  --ok: #4f6b4a;
  --sold: #9a8f86;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent); }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + var(--safe-top)) 18px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-size: 26px; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.langs { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.langs button { padding: 6px 9px; font-size: 12px; color: var(--muted); }
.langs button.on { background: var(--ink); color: var(--bg); }
.install { padding: 7px 12px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; }

.filters { padding: 12px 0 4px; }
.chips { display: flex; gap: 8px; padding: 0 18px 8px; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); font-size: 14px; white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips.sub .chip { font-size: 13px; padding: 6px 12px; }

main { padding: 4px 14px calc(30px + var(--safe-bottom)); max-width: 1100px; margin: 0 auto; }
.count { font-size: 13px; color: var(--muted); margin: 4px 4px 12px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card { text-align: left; display: flex; flex-direction: column; background: var(--card); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.card .ph { position: relative; aspect-ratio: 3 / 4; background: #e9e3d9; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .meta { padding: 10px 12px 12px; }
.card h3 { font-family: var(--serif); font-weight: normal; font-size: 17px; margin: 0 0 4px; }
.card .price { font-size: 14px; color: var(--muted); }
.badge { position: absolute; left: 8px; top: 8px; font-size: 11px; padding: 4px 8px; border-radius: 999px; background: rgba(251,249,245,.92); }
.badge.available { color: var(--ok); }
.badge.sold { color: var(--sold); }
.badge.madeToOrder { color: var(--accent); }
.card.is-sold img { filter: grayscale(.5) opacity(.75); }

.empty, .offline { text-align: center; color: var(--muted); padding: 30px 10px; }
.offline { padding: 14px; font-size: 13px; }
.skeleton { aspect-ratio: 3/4.6; border-radius: 14px; background: linear-gradient(90deg, #ebe5db, #f4efe7, #ebe5db); background-size: 200% 100%; animation: sh 1.4s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

.foot { text-align: center; padding: 10px 0 calc(28px + var(--safe-bottom)); font-size: 14px; }

/* Fitxa */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(30,26,22,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-inner {
  position: relative; width: 100%; max-width: 640px; max-height: 94vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding-bottom: calc(24px + var(--safe-bottom));
  animation: up .25s ease-out;
}
.sheet-inner.small { padding: 22px 22px calc(26px + var(--safe-bottom)); }
.sheet-inner.small h2 { font-family: var(--serif); font-weight: normal; margin: 0 0 12px; }
.sheet-inner.small li { margin-bottom: 10px; line-height: 1.45; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-inner { border-radius: 20px; } }
.close { position: absolute; right: 12px; top: 10px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; background: rgba(251,249,245,.92); font-size: 24px; line-height: 1; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; background: #e9e3d9; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: 0 0 100%; width: 100%; aspect-ratio: 3/4; max-height: 62vh; object-fit: cover; scroll-snap-align: center; }
.dots { display: flex; justify-content: center; gap: 6px; padding: 10px 0 0; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--ink); }
.detail { padding: 8px 22px 0; }
.detail h2 { font-family: var(--serif); font-weight: normal; font-size: 28px; margin: 6px 0 4px; }
.detail .row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.detail .price { font-size: 18px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid currentColor; }
.pill.available { color: var(--ok); } .pill.sold { color: var(--sold); } .pill.madeToOrder { color: var(--accent); }
.detail p.desc { line-height: 1.6; margin: 0 0 16px; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 0 0 20px; }
.specs dt { color: var(--muted); } .specs dd { margin: 0; }
.ctas { display: flex; flex-direction: column; gap: 10px; }
.btn { display: block; text-align: center; padding: 14px; border-radius: 12px; text-decoration: none; font-size: 15px; }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.ghost { border: 1px solid var(--ink); color: var(--ink); }
.btn.wa { display: flex; align-items: center; justify-content: center; gap: 8px; background: #25d366; color: #fff; font-weight: 600; }

.wa-fab {
  position: fixed; right: 18px; bottom: calc(20px + var(--safe-bottom)); z-index: 10;
  width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: #25d366; color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
body:has(.sheet:not([hidden])) .wa-fab { display: none; }
