:root {
  --brown: #572F10;
  --brown-2: #7A4A22;
  --gold: #E89F39;
  --gold-dark: #B9741A;
  --ink: #1F1A16;
  --muted: #6E6259;
  --cream: #F4F1EC;
  --paper: #FFFDF9;
  --line: #E4DCD0;
  --ok: #3F6B3A;
  --serif: "Cormorant Garamond", Cambria, Georgia, serif;
  --sans: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  --top: calc(56px + env(safe-area-inset-top));
  --bottom: calc(64px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

/* Barra superior */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: var(--top); padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 253, 249, .94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { flex: 0 0 auto; margin: 0 auto; }
.brand img { height: 34px; width: auto; }
.back, .spacer { width: 40px; height: 40px; flex: 0 0 40px; }
.back { border: 0; background: none; color: var(--brown); border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.back[hidden] { display: grid; visibility: hidden; }

.offline {
  position: fixed; top: var(--top); left: 0; right: 0; z-index: 19;
  background: var(--brown); color: #fff; font-size: 13px; text-align: center; padding: 6px;
}

main {
  padding: calc(var(--top) + 8px) 16px calc(var(--bottom) + 24px);
  max-width: 1100px; margin: 0 auto; outline: none;
  min-height: 100vh;
}

/* Barra de pestañas */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  height: var(--bottom); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper); border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; text-decoration: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--brown); }
.tabbar a.on svg { stroke-width: 2.2; }
.tabbar a[data-tab="deseos"].on svg { fill: var(--gold); stroke: var(--brown); }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--gold); color: var(--ink); font-size: 11px; line-height: 18px; text-align: center;
}

/* Tipografía */
h1, h2, h3 { font-family: var(--serif); color: var(--brown); margin: 0; font-weight: 600; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-dark); font-weight: 600; }
.muted { color: var(--muted); }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head a { font-size: 14px; color: var(--brown); font-weight: 500; text-decoration: none; white-space: nowrap; }

/* Portada */
.hero {
  margin-top: 8px; padding: 22px 20px; border-radius: 16px;
  background: linear-gradient(135deg, #5E3413 0%, #3A1F0A 100%); color: #F7EBDD;
}
.hero h1 { color: #fff; font-size: 32px; margin-top: 6px; }
.hero p { margin: 8px 0 0; color: #E9D9C5; font-size: 15px; }
.hero .eyebrow { color: var(--gold); }
.news-pill {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
  background: var(--gold); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600;
}

.install {
  margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line);
  display: flex; gap: 12px; align-items: center;
}
.install img { width: 44px; height: 44px; border-radius: 10px; }
.install p { margin: 0; font-size: 14px; }
.install .x { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; padding: 4px 8px; }

/* Rejilla de monedas */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  text-decoration: none;
}
.card .ph { aspect-ratio: 1; background: #fff; display: grid; place-items: center; overflow: hidden; }
.card .ph img { width: 100%; height: 100%; object-fit: contain; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .t { font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .p { margin-top: auto; font-weight: 600; color: var(--brown); }
.card.sold .ph img { opacity: .45; }
.tag {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; background: var(--gold); color: var(--ink);
}
.tag.sold { background: var(--ink); color: #fff; }
.heart {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.92); display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.heart svg { width: 20px; height: 20px; fill: none; stroke: var(--brown); stroke-width: 1.8; }
.heart.on svg { fill: var(--gold); }

/* Listas de colecciones */
.filter {
  width: 100%; margin: 14px 0; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); font: inherit;
}
.filter:focus, .searchbox input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.colls { display: grid; gap: 10px; }
@media (min-width: 760px) { .colls { grid-template-columns: 1fr 1fr; } }
.coll {
  display: flex; align-items: center; gap: 12px; padding: 10px; text-decoration: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
}
.coll .ph { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 10px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.coll .ph img { width: 100%; height: 100%; object-fit: contain; }
.coll .ph .ini { font-family: var(--serif); font-size: 28px; color: var(--gold-dark); }
.coll .n { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--brown); line-height: 1.2; }
.coll .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.coll .follow-dot { margin-left: auto; color: var(--gold-dark); font-size: 12px; font-weight: 600; white-space: nowrap; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; cursor: pointer; text-decoration: none;
}
.chip.on { background: var(--brown); color: #fff; border-color: var(--brown); }

/* Página de colección */
.coll-head { margin-top: 6px; }
.coll-head p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--brown); background: var(--paper); color: var(--brown);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--brown); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.btn.on svg { fill: currentColor; }
.more { display: flex; justify-content: center; margin-top: 20px; }

/* Ficha de producto */
.product { display: grid; gap: 20px; margin-top: 6px; }
@media (min-width: 860px) { .product { grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; } }
.gallery { background: #fff; border-radius: 16px; border: 1px solid var(--line); overflow: hidden; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slides img { flex: 0 0 100%; width: 100%; aspect-ratio: 1; object-fit: contain; scroll-snap-align: center; background: #fff; }
.dots { display: flex; justify-content: center; gap: 6px; padding: 10px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--brown); }
.thumbs { display: flex; gap: 8px; padding: 0 10px 10px; }
.thumbs button { width: 56px; height: 56px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; cursor: pointer; }
.thumbs button.on { border-color: var(--brown); }
.thumbs img { width: 100%; height: 100%; object-fit: contain; }
.p-title { font-size: 26px; }
.p-price { font-size: 24px; font-weight: 600; color: var(--brown); margin-top: 8px; }
.p-state { font-size: 14px; margin-top: 4px; }
.p-state.ok { color: var(--ok); }
.p-state.no { color: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.actions .btn.primary { grid-column: 1 / -1; padding: 14px; font-size: 16px; }
.p-colls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.desc { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 15.5px; }
.desc p { margin: 0 0 12px; }
.desc h1, .desc h2, .desc h3 { margin: 18px 0 8px; }
.desc img { height: auto; border-radius: 10px; margin: 10px 0; }
.desc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.desc td, .desc th { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.trust { display: flex; gap: 10px; align-items: center; margin-top: 18px; font-size: 14px; color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 17px; }
.trust img { width: 40px; height: 40px; }

/* Buscar */
.searchbox { position: relative; margin-top: 6px; }
.searchbox input {
  width: 100%; padding: 14px 16px 14px 44px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--paper); font: inherit; font-size: 16px;
}
.searchbox svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; }

/* Blog */
.articles { display: grid; gap: 14px; }
@media (min-width: 760px) { .articles { grid-template-columns: 1fr 1fr; } }
.article-card { display: block; text-decoration: none; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.article-card .ph { aspect-ratio: 16/9; background: var(--line); }
.article-card .ph img { width: 100%; height: 100%; object-fit: cover; }
.article-card .body { padding: 14px 16px 16px; }
.article-card h3 { font-size: 21px; }
.article-card p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.article-card .meta { font-size: 12px; color: var(--gold-dark); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }
.article { max-width: 720px; margin: 0 auto; }
.article .cover { border-radius: 14px; margin: 14px 0; aspect-ratio: 16/9; object-fit: cover; width: 100%; }
.article .content { font-size: 17px; line-height: 1.7; }
.article .content img { height: auto; border-radius: 10px; }

/* Vacíos, errores, carga */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { margin-bottom: 8px; }
.empty .btn { margin-top: 16px; }
.skel { background: linear-gradient(90deg, #ece5da 25%, #f5f0e8 50%, #ece5da 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 14px; }
@keyframes sk { to { background-position: -200% 0; } }
.skel.card { aspect-ratio: .72; border: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom) + 14px); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw;
  box-shadow: 0 4px 18px rgba(0,0,0,.2);
}

/* Hoja de instrucciones (iPhone) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: flex; align-items: flex-end; }
.sheet { background: var(--paper); width: 100%; border-radius: 18px 18px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet ol { padding-left: 20px; }
.sheet li { margin: 6px 0; }

@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
