:root {
  --bg: #F7F2EA;
  --card: #FFFFFF;
  --tile: rgba(0,0,0,0.035);
  --text: #5C4F43;
  --text-2: #6E6152;
  --muted: #958877;
  --line: rgba(92,79,67,0.12);
  --gold: #C4A882;
  --gold-dark: #A8875E;
  --gold-soft: rgba(196,168,130,0.16);
  --terra: #B5532E;
  --sage: #7C8C6B;
  --shadow: 0 4px 24px rgba(0,0,0,0.07);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --radius: 16px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #221B17; --card: #2E2520; --tile: rgba(255,255,255,0.05); --text: #F1E8DC; --text-2: #D8CBBE;
    --muted: #A99A89; --line: rgba(241,232,220,0.12); --gold-soft: rgba(196,168,130,0.18);
    --shadow: 0 4px 24px rgba(0,0,0,0.35); --shadow-sm: 0 1px 4px rgba(0,0,0,0.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #221B17; --card: #2E2520; --tile: rgba(255,255,255,0.05); --text: #F1E8DC; --text-2: #D8CBBE;
  --muted: #A99A89; --line: rgba(241,232,220,0.12); --gold-soft: rgba(196,168,130,0.18);
  --shadow: 0 4px 24px rgba(0,0,0,0.35); --shadow-sm: 0 1px 4px rgba(0,0,0,0.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); min-height: 100svh; }
body.focus #app { padding-bottom: calc(200px + env(safe-area-inset-bottom)); }
body.focus .tabbar { display: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 900; letter-spacing: -0.02em; margin: 0; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* Encabezado */
.top { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 16px; }
.brand-dot { color: var(--gold); }
.back { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); font-size: 18px; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 14px 20px; border-radius: 999px; font-weight: 700; font-size: 16px; color: #fff; background: linear-gradient(135deg, var(--gold), var(--gold-dark)); box-shadow: 0 8px 24px rgba(168,135,94,0.35); }
.btn.secondary { background: var(--card); color: var(--text); border: 1.5px solid var(--line); box-shadow: none; }
.btn:active { transform: scale(0.98); }

/* Buscador y chips */
.search { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; height: 48px; box-shadow: var(--shadow-sm); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; color: var(--text); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; margin: 10px -16px 4px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; color: var(--text-2); }
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #fff; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }

/* Tarjetas de patrón */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pcard { position: relative; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--line); display: flex; flex-direction: column; }
.pcard .cover { aspect-ratio: 1 / 1; display: grid; place-items: center; font-size: 56px; }
.pcard .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.pcard .name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); align-items: center; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--tile); font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.fav { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 999px; background: rgba(255,255,255,0.92); display: grid; place-items: center; font-size: 16px; box-shadow: var(--shadow-sm); }
.badge-progress { position: absolute; top: 8px; left: 8px; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--gold); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; }

/* Ficha */
.hero { border-radius: 20px; aspect-ratio: 4 / 3; display: grid; place-items: center; font-size: 96px; box-shadow: var(--shadow); }
.card { background: var(--card); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.list { margin: 0; padding-left: 20px; }
.list li { margin: 4px 0; }
.note { background: var(--gold-soft); border-radius: 14px; padding: 12px 14px; font-size: 14px; }

/* Paso a paso */
.progressbar { height: 6px; border-radius: 999px; background: var(--tile); overflow: hidden; }
.progressbar > div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-dark)); border-radius: 999px; transition: width .25s; }
.step-title { text-align: center; }
.vuelta { padding: 12px 14px; border-radius: 14px; background: var(--tile); }
.vuelta .lbl { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-dark); }
.vuelta strong { color: var(--text); }
.vuelta .total { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--text-2); }
.dock { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(0,0,0,0.08); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); z-index: 20; }
.dock-inner { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.counter { display: flex; align-items: center; justify-content: center; gap: 22px; }
.counter .num { font-family: var(--font-display); font-weight: 900; font-size: 40px; min-width: 70px; text-align: center; line-height: 1; }
.counter .lbl { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-align: center; }
.round { width: 52px; height: 52px; border-radius: 999px; display: grid; place-items: center; font-size: 26px; font-weight: 700; background: var(--tile); }
.round.plus { width: 64px; height: 64px; background: var(--gold); color: #fff; box-shadow: 0 6px 18px rgba(168,135,94,0.4); }
.nav-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nav-row .btn { min-height: 46px; padding: 10px; font-size: 15px; }

/* Herramientas y formularios */
.tool { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--card); border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.tool .ico { width: 48px; height: 48px; border-radius: 14px; background: var(--gold-soft); display: grid; place-items: center; font-size: 24px; flex: 0 0 auto; }
.tool .t { font-weight: 700; }
.tool .d { font-size: 13px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field { min-width: 0; }
.field input, .field select { width: 100%; min-width: 0; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 12px; font: inherit; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mat-row { display: grid; grid-template-columns: 1.6fr 1fr 0.7fr 36px; gap: 8px; align-items: end; }
.result { text-align: center; border-radius: 20px; padding: 20px; background: linear-gradient(135deg, rgba(247,216,181,0.35), rgba(230,205,181,0.18)); border: 1.5px solid rgba(196,168,130,0.35); }
.result .big { font-family: var(--font-display); font-weight: 900; font-size: 40px; line-height: 1.1; }
.breakdown { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; margin-top: 12px; text-align: left; }
.punto { display: flex; gap: 14px; padding: 14px; background: var(--card); border-radius: 16px; border: 1px solid var(--line); }
.punto .ab { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 14px; background: var(--gold-soft); display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--gold-dark); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--tile); border-radius: 14px; padding: 4px; }
.seg button { height: 40px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }

/* Barra inferior */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr); background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 6px 0; border-radius: 12px; }
.tabbar a .ti { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabbar a[aria-current="page"] { color: var(--text); background: var(--gold-soft); }
.tabbar a[aria-current="page"] .ti { filter: none; opacity: 1; }

.install { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--gold-soft); font-size: 14px; margin-bottom: 14px; }
.install .btn { width: auto; min-height: 38px; padding: 8px 14px; font-size: 14px; box-shadow: none; }

/* Fotos de los patrones */
.has-photo { position: relative; overflow: hidden; padding: 0; }
.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero.has-photo { aspect-ratio: 1 / 1; }
.ilustrativa { position: absolute; left: 8px; bottom: 8px; font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,0.45); color: #fff; letter-spacing: .02em; }
