/* Pulpi — noche de alebrije: fondo berenjena profundo, acentos de colores vivos tipo artesanía oaxaqueña */
:root {
  --bg: #170b26;
  --bg-2: #22113a;
  --card: #2a1747;
  --card-2: #341d57;
  --line: rgba(255, 255, 255, .09);
  --ink: #fbf3ff;
  --ink-2: #c9b6e4;
  --ink-3: #8d78ad;
  --magenta: #ee3d8f;
  --turq: #19c9b6;
  --oro: #ffbf2f;
  --naranja: #ff6a2b;
  --rojo: #ff4d5e;
  --verde: #4fd27a;
  --radius: 20px;
  --nav-h: 76px;
  --font-display: 'Gluten', 'Baloo 2', cursive;
  --font-body: 'Figtree', 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.35;
  overscroll-behavior-y: contain;
}
/* puntos y espirales de alebrije muy tenues en el fondo */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(238, 61, 143, .22), transparent 42%),
    radial-gradient(circle at 95% 30%, rgba(25, 201, 182, .14), transparent 40%),
    radial-gradient(circle at 30% 100%, rgba(255, 191, 47, .10), transparent 45%),
    radial-gradient(rgba(255, 255, 255, .05) 1.2px, transparent 1.4px) 0 0 / 18px 18px,
    var(--bg);
}
[x-cloak] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }

/* ---------- Estructura ---------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100%; padding: 0 16px calc(var(--nav-h) + 28px); }
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 0 10px; position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.top .pulpi-mini { width: 46px; height: 46px; flex: none; }
.top h1 { font-family: var(--font-display); font-weight: 700; font-size: 30px; margin: 0; line-height: 1; letter-spacing: .5px; }
.top .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.top .sub::first-letter { text-transform: uppercase; }
.top .grow { flex: 1; min-width: 0; }
.chip-btn {
  padding: 8px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}

/* ---------- Barra inferior ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(23, 11, 38, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr 96px 1fr 1fr; align-items: center;
}
.nav a, .nav button.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--ink-3); text-decoration: none; padding: 8px 0;
}
.nav .ico { font-size: 22px; line-height: 1; filter: grayscale(.6); transition: transform .2s, filter .2s; }
.nav .on { color: var(--ink); }
.nav .on .ico { filter: none; transform: translateY(-2px) scale(1.1); }
.mic {
  justify-self: center; width: 76px; height: 76px; margin-top: -34px; border-radius: 50%;
  background: conic-gradient(from 200deg, var(--magenta), var(--naranja), var(--oro), var(--turq), var(--magenta));
  padding: 4px; box-shadow: 0 10px 28px rgba(238, 61, 143, .45), 0 0 0 6px var(--bg);
  transition: transform .15s;
}
.mic:active { transform: scale(.93); }
.mic span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  background: var(--bg-2); font-size: 30px;
}
.mic.listening { animation: pulse 1.1s infinite; }
.mic.listening span { background: var(--magenta); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 6px var(--bg), 0 0 0 6px rgba(238, 61, 143, .6); }
  100% { box-shadow: 0 0 0 6px var(--bg), 0 0 0 26px rgba(238, 61, 143, 0); }
}

/* ---------- Captura rápida por texto ---------- */
.quick {
  display: flex; gap: 8px; margin: 6px 0 18px; padding: 6px 6px 6px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
}
.quick input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 15px; }
.quick input::placeholder { color: var(--ink-3); }
.quick button { width: 40px; height: 40px; border-radius: 50%; background: var(--turq); color: #072b27; font-weight: 800; font-size: 18px; }
.quick button:disabled { opacity: .4; }

/* ---------- Secciones y tarjetas ---------- */
.sec-title {
  display: flex; align-items: center; gap: 8px; margin: 22px 2px 10px;
  font-family: var(--font-display); font-size: 19px; font-weight: 600;
}
.sec-title .count { font-family: var(--font-body); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--card-2); color: var(--ink-2); }
.sec-title.late { color: var(--rojo); }
.sec-title.late .count { background: rgba(255, 77, 94, .18); color: var(--rojo); }

.card {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 14px 12px; margin-bottom: 10px; overflow: hidden;
  animation: rise .35s both;
}
.card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--turq); }
.card.late::before { background: var(--rojo); }
.card.late { background: linear-gradient(100deg, rgba(255, 77, 94, .13), var(--card) 55%); border-color: rgba(255, 77, 94, .3); }
.card.urgent::before { background: repeating-linear-gradient(180deg, var(--oro) 0 8px, var(--naranja) 8px 16px); }
.card.done { opacity: .55; }
.card.done .t-title { text-decoration: line-through; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.check {
  flex: none; width: 34px; height: 34px; margin-top: 1px; border-radius: 50%;
  border: 2.5px solid var(--ink-3); display: grid; place-items: center; font-size: 17px; color: transparent;
  transition: all .2s;
}
.check:active { transform: scale(.85); }
.card.late .check { border-color: var(--rojo); }
.card.done .check, .check.on { background: var(--verde); border-color: var(--verde); color: #0b2b16; }
.t-body { flex: 1; min-width: 0; }
.t-title { font-weight: 700; font-size: 16px; word-wrap: break-word; }
.t-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.tag { padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .06); white-space: nowrap; }
.tag.red { background: rgba(255, 77, 94, .18); color: #ff9aa4; }
.tag.gold { background: rgba(255, 191, 47, .16); color: var(--oro); }
.tag.turq { background: rgba(25, 201, 182, .15); color: var(--turq); }
.t-actions { display: flex; flex-direction: column; gap: 6px; }
.snz {
  width: 38px; height: 38px; border-radius: 12px; background: var(--card-2); font-size: 17px;
  display: grid; place-items: center;
}

/* ---------- Estado vacío ---------- */
.empty { text-align: center; padding: 36px 20px 10px; color: var(--ink-2); }
.empty .pulpi-big { width: 190px; height: 190px; margin: 0 auto 8px; display: block; animation: bob 3s ease-in-out infinite; }
.empty h3 { font-family: var(--font-display); color: var(--ink); font-size: 24px; margin: 6px 0 4px; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }

/* ---------- Listas ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lcard {
  position: relative; text-align: left; min-height: 112px; padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); overflow: hidden; animation: rise .35s both;
}
.lcard::after {
  content: ''; position: absolute; right: -24px; bottom: -24px; width: 84px; height: 84px; border-radius: 50%;
  background: var(--c, var(--magenta)); opacity: .22;
}
.lcard .emo { font-size: 30px; }
.lcard .nm { font-weight: 800; margin-top: 8px; font-size: 15px; }
.lcard .ct { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.lcard.new { border-style: dashed; display: grid; place-items: center; text-align: center; color: var(--ink-2); font-weight: 700; }

.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 6px 12px 12px; border-bottom: 1px solid var(--line);
}
.item .txt { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; }
.item .qty { color: var(--oro); font-size: 13px; font-weight: 700; margin-left: 6px; }
.item.off .txt { text-decoration: line-through; color: var(--ink-3); font-weight: 500; }
.item .del { color: var(--ink-3); font-size: 18px; padding: 6px 8px; }
.item .check { width: 28px; height: 28px; font-size: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.muted-h { display: flex; justify-content: space-between; align-items: center; margin: 22px 4px 8px; color: var(--ink-3); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; }
.link { color: var(--turq); font-weight: 700; font-size: 13px; text-transform: none; letter-spacing: 0; }

/* ---------- Ajustes ---------- */
.setting { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.setting h4 { margin: 0 0 4px; font-size: 16px; }
.setting p { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; }
.setting ol { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 14px; }
.setting li { margin-bottom: 4px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.status.ok { background: rgba(79, 210, 122, .15); color: var(--verde); }
.status.no { background: rgba(255, 77, 94, .15); color: #ff9aa4; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 16px; font-weight: 800; font-size: 15px;
  background: var(--card-2); border: 1px solid var(--line); text-decoration: none;
}
.btn.primary { background: linear-gradient(135deg, var(--magenta), var(--naranja)); border: 0; color: #fff; box-shadow: 0 8px 20px rgba(238, 61, 143, .3); }
.btn.turq { background: var(--turq); color: #062a26; border: 0; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }

/* ---------- Hoja inferior ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(8, 3, 15, .65); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto;
  max-height: 92vh; overflow-y: auto;
  background: var(--bg-2); border-radius: 26px 26px 0 0; border-top: 1px solid var(--line);
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  animation: up .28s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes up { from { transform: translateY(100%); } }
.grab { width: 44px; height: 5px; border-radius: 9px; background: var(--ink-3); margin: 0 auto 12px; opacity: .5; }
.bubble {
  display: flex; gap: 10px; align-items: center; margin-bottom: 14px;
}
.bubble .pulpi-mini { width: 54px; height: 54px; flex: none; }
.bubble .say {
  position: relative; flex: 1; background: var(--card); border-radius: 18px; padding: 10px 14px; font-size: 14.5px; color: var(--ink-2);
}
.bubble .say b { color: var(--ink); }
.bubble .say::before { content: ''; position: absolute; left: -7px; top: 50%; margin-top: -7px; border: 7px solid transparent; border-right-color: var(--card); border-left: 0; }
.heard { font-size: 13px; color: var(--ink-3); font-style: italic; margin: -6px 0 12px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin: 0 0 6px 4px; text-transform: uppercase; letter-spacing: .5px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; background: var(--card);
  border: 1.5px solid var(--line); outline: none; font-size: 16px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--turq); }
.field input[type=datetime-local] { color-scheme: dark; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--card); border-radius: 16px; }
.seg button { min-height: 44px; border-radius: 12px; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.seg button.on { background: var(--card-2); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--turq); }
.seg-help { font-size: 12.5px; color: var(--ink-3); margin: 6px 4px 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--card); border-radius: 14px; font-weight: 700; }
.toggle input { width: 22px; height: 22px; accent-color: var(--oro); }
.field label.toggle { display: flex; min-height: 50px; margin: 0; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .c { padding: 10px 14px; border-radius: 12px; background: var(--card); font-weight: 700; font-size: 14px; }
.sheet .actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 16px; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick button { width: 44px; height: 44px; font-size: 22px; border-radius: 12px; background: var(--card); }
.emoji-pick button.on { box-shadow: inset 0 0 0 2px var(--turq); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 22px); z-index: 60;
  width: fit-content; max-width: 528px; margin: 0 auto; padding: 12px 18px; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: rise .25s;
}

/* ---------- Mascota ---------- */
.pulpi-img { display: block; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(238, 61, 143, .35)); }
.top .pulpi-img { width: 52px; height: 52px; margin: -4px -2px -4px -6px; }
.bubble .pulpi-img { width: 60px; height: 60px; }
.celebra {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: auto;
  background: radial-gradient(circle, rgba(255, 191, 47, .18), rgba(23, 11, 38, .55) 60%);
  animation: fade .2s;
}
.celebra img { width: min(70vw, 300px); height: auto; animation: brinca 1.7s cubic-bezier(.2, 1.4, .4, 1) both; filter: drop-shadow(0 12px 30px rgba(255, 191, 47, .45)); }
@keyframes brinca {
  0% { transform: scale(.2) rotate(-20deg); opacity: 0; }
  25% { transform: scale(1.08) rotate(4deg); opacity: 1; }
  40% { transform: scale(1) rotate(0); }
  80% { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(.85) translateY(-40px); opacity: 0; }
}

/* ---------- Login ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 380px; text-align: center; }
.auth-box .pulpi-big { width: 190px; height: 190px; margin: 0 auto; animation: bob 3s ease-in-out infinite; }
.auth-box h1 { font-family: var(--font-display); font-size: 46px; margin: 4px 0 0; }
.auth-box .lead { color: var(--ink-2); margin: 4px 0 24px; }
.auth-box form { text-align: left; }
.err { background: rgba(255, 77, 94, .15); color: #ff9aa4; padding: 10px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
