:root {
  --bg: #f7f4f2;
  --surface: #fff;
  --ink: #1c1a1f;
  --muted: #6f6a75;
  --line: #e8e2de;
  --brand: #e4201f;
  --brand2: #0b0b0b;
  --grad: linear-gradient(135deg, #ff3b36, #c4121a);
  --ok: #18a874;
  --soft: #ffe8ec;
  --soft-ink: #c2183a;
  --shadow: 0 10px 30px rgba(20, 10, 10, .12);
}

* { box-sizing: border-box; margin: 0; }
html, body { min-height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 3px solid rgba(228, 32, 31, .45); outline-offset: 2px; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- Barra superior y navegación ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; line-height: 1.1; }
.brand svg { width: 34px; height: 34px; }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: 0; }
.spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); position: relative;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

.main { flex: 1; display: flex; flex-direction: column; padding: 8px 18px 100px; }

.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex; z-index: 10;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; font-weight: 600; color: var(--muted); padding: 6px; border-radius: 12px; position: relative;
}
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--brand); }
.badge {
  position: absolute; top: 2px; left: calc(50% + 6px);
  background: var(--brand); color: #fff; font-size: .65rem; font-style: normal;
  min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px;
}

/* ---------- Avatares ---------- */
.avatar {
  --h: 260;
  background: linear-gradient(135deg, hsl(var(--h) 85% 66%), hsl(calc(var(--h) + 50) 80% 56%));
  display: grid; place-items: center; color: #fff; font-weight: 800; overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 48px; height: 48px; border-radius: 50%; font-size: 1rem; }
.avatar.md { width: 84px; height: 84px; border-radius: 50%; font-size: 1.6rem; border: 4px solid #fff; box-shadow: var(--shadow); }
.avatar.hero { height: 50%; min-height: 200px; font-size: 4.5rem; letter-spacing: -.03em; pointer-events: none; }

/* ---------- Tarjetas ---------- */
.deck { position: relative; flex: 1; min-height: 470px; }
.card {
  position: absolute; inset: 0;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
  touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform .25s ease;
}
.card.behind { transform: scale(.95) translateY(14px); opacity: .7; }
.card.top { cursor: grab; }
.card.top:active { cursor: grabbing; }
.card.static { position: relative; inset: auto; touch-action: auto; user-select: auto; }
.card.static .avatar.hero { height: 240px; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.card h2 { font-size: 1.5rem; letter-spacing: -.02em; }
.card h2 span { font-weight: 500; }
.fac { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: #efeaf0; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.tag.cross { background: var(--grad); color: #fff; }
.muted { color: var(--muted); font-size: .9rem; }
.bio { font-size: .95rem; line-height: 1.4; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chip { font-size: .8rem; padding: 5px 10px; border-radius: 999px; background: #f2eef0; border: 1px solid transparent; }
.chip.on { background: var(--soft); color: var(--soft-ink); border-color: #ffc6d1; font-weight: 600; }
.modes { display: flex; gap: 12px; font-size: .8rem; color: var(--muted); margin-top: 4px; }

.stamp {
  position: absolute; top: 28px; padding: 6px 12px; border: 3px solid; border-radius: 10px;
  background: rgba(255, 255, 255, .92); font-weight: 900; font-size: 1.2rem; letter-spacing: .06em; pointer-events: none;
}
.like-stamp { left: 20px; color: var(--ok); transform: rotate(-12deg); opacity: var(--like, 0); }
.pass-stamp { right: 20px; color: var(--brand); transform: rotate(12deg); opacity: var(--pass, 0); }

.actions { display: flex; justify-content: center; align-items: center; gap: 28px; padding: 18px 0 4px; }
.round {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; transition: transform .15s;
}
.round:hover { transform: scale(1.06); }
.round:active { transform: scale(.92); }
.round svg { width: 28px; height: 28px; }
.round.pass { color: var(--muted); }
.round.like { background: var(--grad); color: #fff; width: 74px; height: 74px; }

/* ---------- Estados vacíos y botones ---------- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 40px 20px; }
.empty .big { font-size: 3rem; }
.empty .btn { min-width: 240px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 14px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--line);
}
.btn.primary { background: var(--grad); color: #fff; border: 0; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--soft-ink); border-color: #ffc6d1; background: #fff5f7; }
.btn.block { width: 100%; }
.btn.small { padding: 8px 14px; font-size: .85rem; cursor: pointer; }
.h { font-size: 1.6rem; letter-spacing: -.02em; margin: 6px 0 12px; }
.sub { margin: -6px 0 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.fine { font-size: .78rem; color: var(--muted); text-align: center; margin-top: 16px; line-height: 1.5; }

/* ---------- Lista de cruces ---------- */
.convos { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.convos button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; text-align: left; }
.convos button:hover { background: var(--surface); }
.convos div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.convos .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.new-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); flex: none; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; height: 100dvh; position: relative; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.who .muted { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu {
  position: absolute; right: 14px; top: 64px; z-index: 5;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.menu button { padding: 12px 22px; text-align: left; }
.menu button:hover { background: #f6f2f4; }
.menu button:last-child { color: var(--soft-ink); }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.hint { text-align: center; color: var(--muted); font-size: .88rem; margin: 24px 10px; line-height: 1.5; }
.msg { max-width: 78%; padding: 9px 13px; border-radius: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.msg.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.typing { display: flex; gap: 4px; padding: 13px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #bbb; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.composer { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.composer input { flex: 1; min-width: 0; padding: 12px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); outline: none; }
.composer input:focus { border-color: var(--brand2); }
.composer .btn { border-radius: 50%; width: 46px; height: 46px; padding: 0; flex: none; }
.composer .btn svg { width: 20px; height: 20px; }

/* ---------- Ventanas ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(20, 10, 30, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet {
  background: var(--surface); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; animation: up .25s ease;
}
.sheet .label { font-weight: 600; font-size: .9rem; }
.sheet .chip { padding: 8px 14px; font-size: .88rem; }
.switch { display: flex; flex-direction: row; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand); }
.overlay.center { align-items: center; background: linear-gradient(160deg, rgba(11, 11, 11, .96), rgba(196, 18, 26, .96)); }
.match-pop { text-align: center; color: #fff; display: flex; flex-direction: column; gap: 12px; padding: 30px; width: 100%; max-width: 380px; animation: pop .4s cubic-bezier(.2, 1.4, .4, 1); }
.match-pop .eyebrow { font-size: 2.4rem; font-weight: 900; letter-spacing: -.03em; }
.match-pop h2 { font-size: 1.2rem; }
.pair { display: flex; justify-content: center; margin: 8px 0; }
.pair .avatar { width: 110px; height: 110px; font-size: 2rem; }
.pair .avatar:last-child { margin-left: -20px; }
.match-pop .muted { color: rgba(255, 255, 255, .88); }
.match-pop .btn.primary { background: #fff; color: var(--brand); margin-top: 10px; }
.match-pop .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- Formulario ---------- */
.onboard { padding: 24px 20px 48px; }
.form-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.form-head .h { margin: 0; }
.hero-brand { text-align: center; margin: 12px 0 26px; }
.hero-brand .logo svg { width: 72px; height: 72px; }
.hero-brand h1 { font-size: 2.3rem; letter-spacing: -.03em; margin-top: 6px; }
.hero-brand p { color: var(--muted); margin-top: 4px; }
form { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
label small, legend small { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 400; outline: none; resize: vertical;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand2); box-shadow: 0 0 0 3px rgba(228, 32, 31, .15); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 8px; padding: 0; }
.pick .chip {
  position: relative; flex-direction: row; cursor: pointer; font-weight: 500; font-size: .85rem;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); user-select: none;
}
.pick .chip input { position: absolute; opacity: 0; pointer-events: none; }
.pick .chip:has(input:checked) { background: var(--soft); border-color: var(--brand); color: var(--soft-ink); }
.pick .chip:has(input:focus-visible) { outline: 3px solid rgba(228, 32, 31, .45); }
.check { flex-direction: row; align-items: flex-start; font-weight: 400; font-size: .85rem; color: var(--muted); gap: 10px; }
.check input { margin-top: 1px; accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.photo-pick { display: flex; align-items: center; gap: 16px; }
.error { color: var(--soft-ink); font-size: .88rem; font-weight: 600; min-height: 1.2em; }

.toast {
  position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .9rem;
  max-width: calc(100% - 40px); text-align: center; transition: opacity .3s;
}
.toast.out { opacity: 0; }

/* ---------- Galería de fotos en las tarjetas ---------- */
.hero { position: relative; height: 56%; min-height: 240px; flex: none; background: #ddd; overflow: hidden; }
.card.static .hero { height: auto; aspect-ratio: 4 / 5; max-height: 460px; }
.hero[data-act] { cursor: pointer; }
.card.top .hero[data-act] { cursor: inherit; }
.slide { position: absolute; inset: 0; opacity: 0; transition: opacity .2s; }
.slide.on { opacity: 1; }
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ph {
  --h: 260; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, hsl(var(--h) 85% 66%), hsl(calc(var(--h) + 50) 80% 56%)); color: #fff;
}
.ph span { font-size: 4.5rem; font-weight: 800; letter-spacing: -.03em; }
.ph .emo { font-size: 5rem; }
.ph small { font-weight: 700; font-size: 1rem; opacity: .9; }
.bars { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; z-index: 2; }
.bars i { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .45); }
.bars i.on { background: #fff; }
.tip { text-align: center; font-size: .78rem; color: var(--muted); margin-top: 10px; }
.actions { padding-top: 8px; }

/* ---------- Fotos en el formulario ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ph-tile { position: relative; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.ph-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px dashed #d8cfd4; color: var(--muted); cursor: pointer; font-size: .8rem;
}
.ph-add svg { width: 26px; height: 26px; }
.ph-add:hover { border-color: var(--brand); color: var(--brand); }
.ph-del, .ph-star {
  position: absolute; top: 6px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(20, 10, 30, .6); color: #fff; display: grid; place-items: center;
}
.ph-del { right: 6px; }
.ph-star { left: 6px; }
.ph-del svg, .ph-star svg { width: 14px; height: 14px; }
.ph-main { position: absolute; left: 6px; bottom: 6px; background: var(--grad); color: #fff; font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; }

/* ---------- Acceso ---------- */
.form-title { font-size: 1.25rem; letter-spacing: -.01em; }
.lead { color: var(--muted); line-height: 1.5; margin-bottom: 4px; }
.lead b { color: var(--ink); }
.pw { position: relative; display: block; }
.pw input { padding-right: 76px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: .8rem; font-weight: 700; color: var(--brand2); padding: 6px 10px; border-radius: 8px; }
.link { color: var(--brand2); font-weight: 700; padding: 0; }
.link:hover { text-decoration: underline; }
.link.right { align-self: flex-end; font-size: .88rem; margin-top: -6px; }
.switch-auth { text-align: center; margin-top: 20px; color: var(--muted); }
.notice { background: #e9f8f1; color: #0f6e4b; padding: 10px 14px; border-radius: 12px; font-weight: 600; font-size: .9rem; }
.notice:empty { display: none; }
.inbox { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 14px 0 18px; font-size: .88rem; line-height: 1.6; box-shadow: var(--shadow); }
.inbox-tag { display: flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand2); margin-bottom: 6px; }
.inbox-tag svg { width: 16px; height: 16px; }
.inbox .code { font-size: 2rem; font-weight: 800; letter-spacing: .15em; text-align: center; margin: 8px 0; font-variant-numeric: tabular-nums; }
.inbox small { color: var(--muted); display: block; line-height: 1.4; }
.code-input { font-size: 1.4rem !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.btn:disabled { opacity: .6; cursor: progress; }

/* ---------- Chat: botón de perfil y hoja de perfil ---------- */
.chat-head .who { display: flex; flex-direction: row; align-items: center; gap: 10px; text-align: left; }
.chat-head .who > span { display: flex; flex-direction: column; min-width: 0; }
.sheet.tall { max-height: 92dvh; overflow-y: auto; padding-top: 14px; }
.sheet.tall .card.static { box-shadow: none; }

.check a, .fine a { color: var(--brand2); font-weight: 600; }
.onboard .fine { margin-top: 28px; }

.splash { flex: 1; display: grid; place-items: center; min-height: 100dvh; }
.splash svg { width: 72px; height: 72px; animation: blink 1.2s infinite; }

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

/* ---------- Marca UnapCrush ---------- */
.crush { color: var(--brand); }
.brand svg, .hero-brand .logo svg, .splash svg { border-radius: 22%; }
.match-pop .btn.primary { color: var(--brand2); }

/* ---------- Espacio para el botón "Powered by Netlify" (plan gratis) ----------
   Netlify inserta su botón abajo a la derecha (64 px de alto).
   Subimos el menú, el chat y las ventanas para que nunca quede tapado. */
body.has-badge { --badge: 64px; }
.nav { bottom: var(--badge, 0px); }
body.has-badge::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: var(--badge);
  background: var(--surface); border-top: 1px solid var(--line); z-index: 9;
}
.main { padding-bottom: calc(100px + var(--badge, 0px)); }
.chat { height: calc(100dvh - var(--badge, 0px)); }
.overlay { bottom: var(--badge, 0px); }
