:root {
  --bg: #fff7ee;
  --bg2: #ffeede;
  --card: #ffffff;
  --ink: #2b2230;
  --muted: #7a6d80;
  --line: #f0e1d2;
  --rojo: #c8283f;
  --rojo2: #e8456b;
  --pino: #1f6f5c;
  --oro: #f4b942;
  --sombra: 0 6px 22px rgba(120, 50, 60, .12);
  --radio: 20px;
  --fuente: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a1d;
    --bg2: #1d2428;
    --card: #232b30;
    --ink: #f6eee8;
    --muted: #a9a0ae;
    --line: #34404a;
    --sombra: 0 6px 22px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--fuente); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(circle at 20% 0%, var(--bg2), transparent 55%);
  min-height: 100vh; padding-bottom: 110px;
}
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 1; width: 100%; height: 100%; }
button { font: inherit; cursor: pointer; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; opacity: .85; }

/* ---------- cabecera ---------- */
.hero {
  position: relative; color: #fff; text-align: center;
  padding: calc(env(safe-area-inset-top) + 34px) 18px 56px;
  background: linear-gradient(135deg, #b3264f 0%, #d9435f 45%, #e8805a 100%);
  border-radius: 0 0 38px 38px; overflow: hidden; box-shadow: var(--sombra);
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .09);
}
.hero::before { width: 260px; height: 260px; top: -90px; left: -70px; }
.hero::after { width: 200px; height: 200px; bottom: -80px; right: -40px; }
.hero-in { position: relative; z-index: 2; max-width: 760px; margin: auto; }
.kicker {
  display: inline-block; margin: 0 0 10px; padding: 6px 14px; border-radius: 99px; font-size: .9rem;
  background: rgba(255, 255, 255, .22); backdrop-filter: blur(6px); font-weight: 600;
}
h1 { margin: 0; font-size: clamp(1.9rem, 6vw, 3rem); letter-spacing: -.5px; line-height: 1.1; }
.sub { margin: 10px auto 14px; max-width: 520px; opacity: .95; font-size: 1.02rem; }
.who { font-size: .95rem; opacity: .95; }
.who .link { color: #fff; }

/* ---------- barra de filtros ---------- */
main { position: relative; z-index: 2; max-width: 1180px; margin: -26px auto 0; padding: 0 14px; }
.toolbar {
  background: var(--card); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
#secciones { display: flex; gap: 8px; flex: 1 1 100%; }
#chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 260px; }
.chip {
  border: 1.5px solid var(--line); background: transparent; color: var(--ink);
  padding: 7px 14px; border-radius: 99px; font-weight: 600; font-size: .92rem;
}
.chip.on { background: var(--pino); border-color: var(--pino); color: #fff; }
select, input, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 9px 11px; width: 100%;
}
.toolbar select { width: auto; }
#sorpresa {
  border: 0; border-radius: 12px; padding: 9px 14px; font-weight: 700; color: #4a3200;
  background: linear-gradient(135deg, #ffd166, #f4b942);
}
.aviso { margin: 12px 4px 0; font-size: .86rem; color: var(--muted); }

/* ---------- tarjetas ---------- */
.grid {
  display: grid; gap: 18px; margin-top: 18px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.card {
  background: var(--card); border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden;
  display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s;
  animation: sube .45s both;
}
.card:hover { transform: translateY(-4px) rotate(-.4deg); }
.card.resalta { outline: 4px solid var(--oro); animation: salta .7s; }
@keyframes sube { from { opacity: 0; transform: translateY(16px); } }
@keyframes salta { 30% { transform: scale(1.05) rotate(1deg); } 60% { transform: scale(.98); } }
.pic { position: relative; aspect-ratio: 1; background: #fff; display: grid; place-items: center; }
.pic img { width: 100%; height: 100%; object-fit: contain; }
.noimg {
  width: 100%; height: 100%; display: grid; place-items: center; font-size: 4rem;
  background: repeating-linear-gradient(45deg, #ffe9d6, #ffe9d6 14px, #ffdcc2 14px, #ffdcc2 28px);
}
.price {
  position: absolute; left: 10px; top: 10px; background: var(--pino); color: #fff;
  padding: 5px 11px; border-radius: 99px; font-weight: 800; font-size: .9rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .2);
}
.ribbon {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px; text-align: center;
  font-weight: 700; font-size: .9rem; color: #fff; background: linear-gradient(90deg, var(--rojo), var(--rojo2));
}
.ribbon.ok { background: linear-gradient(90deg, #1f6f5c, #2e9a7e); }
.card.bought .pic img { filter: grayscale(.6); opacity: .8; }
.body { padding: 14px 15px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.body h3 { margin: 0; font-size: 1.05rem; line-height: 1.25; }
.meta { margin: 0; font-size: .84rem; color: var(--muted); }
.nota { margin: 2px 0 0; font-size: .9rem; font-style: italic; }
.acts { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.btn {
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px;
  padding: 7px 11px; font-weight: 700; font-size: .88rem; text-decoration: none; display: inline-flex;
  align-items: center; gap: 5px;
}
.btn:active { transform: scale(.95); }
.btn.on { background: #ffe1e6; border-color: var(--rojo2); color: var(--rojo); }
.btn.mia { background: var(--pino); border-color: var(--pino); color: #fff; }
.btn.sorp { opacity: .7; cursor: default; }
.btn.peq { padding: 7px 9px; margin-left: auto; }
.btn.peq + .btn.peq { margin-left: 0; }

.vacio { text-align: center; padding: 50px 20px; color: var(--muted); font-size: 1.1rem; }
.vacio b { display: block; font-size: 3rem; margin-bottom: 8px; }

/* ---------- botón flotante, hoja de nueva idea, avisos ---------- */
.fab {
  position: fixed; z-index: 20; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px); border: 0;
  background: linear-gradient(135deg, var(--rojo), var(--rojo2)); color: #fff; font-weight: 800;
  padding: 15px 22px; border-radius: 99px; font-size: 1.05rem; box-shadow: 0 10px 28px rgba(200, 40, 63, .45);
}
.fab:active { transform: scale(.95); }
dialog {
  border: 0; border-radius: 24px; padding: 0; width: min(520px, 94vw); max-height: 92vh;
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(30, 10, 20, .55); backdrop-filter: blur(3px); }
.hoja { padding: 20px; display: grid; gap: 12px; }
.hoja h2 { margin: 0; }
.hoja label { display: grid; gap: 5px; font-weight: 700; font-size: .9rem; }
.hoja label span { font-weight: 500; color: var(--muted); }
.fila { display: flex; gap: 8px; }
.fila > button { white-space: nowrap; }
.prev { display: flex; gap: 12px; align-items: center; }
.prev img { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 14px; border: 1px solid var(--line); }
.prev:empty { display: none; }
.pie { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.pri {
  border: 0; border-radius: 14px; padding: 11px 20px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--pino), #2e9a7e);
}
.sec { border: 1.5px solid var(--line); background: transparent; color: var(--ink); border-radius: 14px; padding: 11px 16px; font-weight: 700; }
.err { color: var(--rojo); font-weight: 700; min-height: 1.2em; margin: 0; }
#toast {
  position: fixed; z-index: 40; left: 50%; bottom: 96px; transform: translate(-50%, 30px); opacity: 0;
  background: #2b2230; color: #fff; padding: 11px 18px; border-radius: 14px; font-weight: 700;
  transition: .3s; pointer-events: none; max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#confeti { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100%; height: 100%; }

/* ---------- pantalla de entrada ---------- */
.login-body { display: grid; place-items: center; padding: 18px; }
.login {
  position: relative; z-index: 2; background: var(--card); border-radius: 28px; box-shadow: var(--sombra);
  padding: 28px 24px; width: min(420px, 100%); text-align: center; display: grid; gap: 12px;
}
.login .emoji { font-size: 3.4rem; animation: bota 2s infinite; }
@keyframes bota { 50% { transform: translateY(-8px) rotate(-6deg); } }
.login h1 { color: var(--rojo); font-size: 1.8rem; }
.login p { margin: 0; color: var(--muted); }
.login label { text-align: left; font-weight: 700; font-size: .9rem; display: grid; gap: 5px; }
@media (max-width: 600px) {
  .hero { padding: calc(env(safe-area-inset-top) + 20px) 14px 44px; border-radius: 0 0 28px 28px; }
  .sub { font-size: .92rem; margin: 6px auto 10px; }
  .toolbar { padding: 10px; gap: 8px; }
  #chips { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .chip { white-space: nowrap; flex: 0 0 auto; }
  .toolbar select { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 8px; font-size: .9rem; }
  #sorpresa { flex: 1 1 100%; padding: 8px 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
  .body { padding: 10px 11px; }
  .body h3 { font-size: .95rem; }
  .btn { padding: 6px 9px; font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Página del favorito */
.pasos { text-align: left; padding-left: 1.2rem; line-height: 1.6; }
.pasos li { margin-bottom: .8rem; }
.ok { color: #1f7a5a; font-weight: 700; }
#codigo { width: 100%; font-size: .75rem; margin-top: .5rem; }
