:root {
  --bg: #fbf3f1;
  --surface: #ffffff;
  --her: #f1e4ea;
  --her-text: #2a1620;
  --me: #7a3552;
  --me-text: #fff6f8;
  --text: #2a1620;
  --muted: #7c6474;
  --line: #e7d6dd;
  --accent: #7a3552;
  --accent-text: #fff6f8;
  --ring: #e59a86;
  --danger: #b3261e;

  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-bubble: 20px;
  --r-ctrl: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1320;
    --surface: #271b2c;
    --her: #33233a;
    --her-text: #f5eaf0;
    --me: #f0b7a4;
    --me-text: #2a1620;
    --text: #f5eaf0;
    --muted: #b39bb0;
    --line: #3b2a42;
    --accent: #f0b7a4;
    --accent-text: #2a1620;
    --ring: #f0b7a4;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ---------- portada ---------- */
.screen { min-height: 100dvh; }
#gate {
  position: relative;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background: #120c15;
}
.hero {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 22%;
}
.hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(18,12,21,0.15) 0%, rgba(18,12,21,0.55) 45%, rgba(18,12,21,0.96) 78%);
}
#gate .gate-inner {
  position: relative;
  width: 100%;
  padding: 0 24px calc(28px + var(--safe-b));
  gap: 10px;
  color: #f7ecf1;
}
#gate .display { margin: 0; text-shadow: 0 2px 24px rgba(0,0,0,0.5); }
.tagline {
  margin: 0 0 4px;
  font-size: 18px;
  color: #f0cfd6;
}
.perks {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: flex; flex-direction: column; gap: 7px;
  font-size: 15px;
}
.perks li { display: flex; align-items: flex-start; gap: 9px; }
.perks li::before {
  content: "";
  flex: none;
  width: 7px; height: 7px; margin-top: 7px;
  border-radius: 50%;
  background: var(--ring);
}
.acks { display: flex; flex-direction: column; gap: 8px; }
#gate .check {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.16);
  padding: 11px 14px;
  font-size: 14px;
  color: #f7ecf1;
  backdrop-filter: blur(6px);
}
#gate .fine { color: rgba(247,236,241,0.62); }
#gate .btn.primary { margin-top: 2px; }
.gate-inner, .auth-inner {
  max-width: 420px;
  margin: 0 auto;
  padding: calc(48px + var(--safe-t)) 24px calc(32px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.gate-avatar {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 42dvh;
  object-fit: cover;
  border-radius: 28px;
  background: var(--her);
}
.auth-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--her);
}
.display {
  font: 400 italic clamp(56px, 16vw, 84px)/0.95 var(--serif);
  letter-spacing: -0.01em;
  margin: 8px 0 0;
}
.display.small { font-size: 40px; line-height: 1.05; }
.lede { margin: 0; color: var(--muted); max-width: 38ch; }
.fine { margin: 0; font-size: 13px; color: var(--muted); }

.check {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-ctrl);
  cursor: pointer;
}
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  padding: 15px 20px;
  border-radius: 999px;
  font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.link {
  appearance: none; background: none; border: 0; padding: 8px 0;
  color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
  align-self: center;
}

form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field input {
  font: 400 16px var(--sans); color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-ctrl);
  padding: 13px 14px;
}
.error { margin: 0; min-height: 1.2em; color: var(--danger); font-size: 14px; }

/* ---------- galería y fotos ---------- */
.cam {
  appearance: none; border: 0; background: none; cursor: pointer;
  width: 42px; height: 46px; flex: none;
  display: grid; place-items: center;
  color: var(--muted);
}
.cam svg { fill: currentColor; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  max-height: 52dvh;
  overflow-y: auto;
  padding-bottom: 4px;
}
.shot {
  position: relative;
  appearance: none; border: 0; padding: 0; cursor: pointer;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: var(--her);
}
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .tag {
  position: absolute; left: 6px; top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(18,12,21,0.66);
  color: #fff;
  backdrop-filter: blur(4px);
}
.shot .price {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 7px 8px;
  font-size: 12px; font-weight: 600;
  color: #fff;
  background: linear-gradient(to top, rgba(18,12,21,0.85), transparent);
}
.shot.owned .price { display: none; }

.msg .photo {
  display: block;
  width: 100%;
  max-width: 260px;
  border-radius: 14px;
  margin-bottom: 6px;
  cursor: zoom-in;
}
.viewer {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10,6,12,0.94);
  display: grid; place-items: center;
  padding: 16px;
}
.viewer img { max-width: 100%; max-height: 92dvh; border-radius: 12px; }

/* ---------- chat ---------- */
.chat {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
}
.topbar {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 12px 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.who { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.presence {
  position: relative;
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  padding: 2px;
  background: var(--ring);
}
.presence img {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg);
  background: var(--her);
  display: block;
}
/* El detalle memorable: el anillo respira mientras ella escribe */
.presence::after {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ring);
  opacity: 0;
}
.chat.typing .presence::after { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { opacity: 0; transform: scale(0.92); }
  50% { opacity: 0.8; transform: scale(1.06); }
}
.name { margin: 0; font: 400 italic 28px/1 var(--serif); }
.status { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.credits {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.credits.low { border-color: var(--ring); }
.icon-btn {
  appearance: none; border: 0; background: none; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
}
.icon-btn svg { fill: currentColor; }
.menu {
  position: absolute; right: 12px; top: calc(100% - 4px);
  z-index: 10;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 32px rgba(28, 19, 32, 0.25);
}
.menu button {
  appearance: none; border: 0; background: none; cursor: pointer;
  text-align: left; padding: 12px 14px; border-radius: 10px;
}
.menu button:hover { background: var(--her); }
.menu .danger { color: var(--danger); }

.lang-toggle {
  position: absolute; top: calc(12px + var(--safe-t)); right: 16px;
  appearance: none; cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}
.crisis {
  margin: 8px 12px; padding: 12px 14px;
  border-radius: var(--r-ctrl);
  background: var(--surface);
  border: 1px solid var(--ring);
  font-size: 14px;
}
.crisis a { color: inherit; }
.crisis .link { display: block; padding-bottom: 0; }

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
  display: flex; flex-direction: column; gap: 4px;
  -webkit-overflow-scrolling: touch;
}
.load-more { margin-bottom: 8px; }
.day {
  align-self: center;
  margin: 14px 0 6px;
  font-size: 12px; color: var(--muted);
}
.msg {
  max-width: min(78%, 480px);
  padding: 9px 14px;
  border-radius: var(--r-bubble);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.her { align-self: flex-start; background: var(--her); color: var(--her-text); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: var(--me); color: var(--me-text); border-bottom-right-radius: 6px; }
.msg.her + .msg.her { border-top-left-radius: 6px; }
.msg.me + .msg.me { border-top-right-radius: 6px; }
.msg.me + .msg.her, .msg.her + .msg.me { margin-top: 8px; }
.msg.failed { opacity: 0.6; }
.msg .time { display: block; margin-top: 2px; font-size: 11px; opacity: 0.6; text-align: right; }

.dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: 0.35;
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 50% { opacity: 1; } }

.notice {
  align-self: center;
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: var(--r-ctrl);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
  text-align: center;
  max-width: 34ch;
}
.notice button { margin-top: 8px; }

.composer {
  flex-direction: row; align-items: flex-end; gap: 8px;
  padding: 8px 12px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  font: 400 16px/1.4 var(--sans);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 11px 16px;
}
.send {
  appearance: none; border: 0; cursor: pointer;
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
}
.send svg { fill: var(--accent-text); }
.send:disabled { opacity: 0.35; cursor: default; }

/* ---------- hoja de créditos ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(28, 19, 32, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 12px;
}
.sheet h2 { margin: 0; font: 400 italic 36px/1 var(--serif); }
.packs { display: flex; flex-direction: column; gap: 10px; }
.pack {
  appearance: none; cursor: pointer;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-ctrl);
  text-align: left;
}
.pack strong { font-size: 18px; font-weight: 600; }
.pack span { color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); z-index: 30;
  transform: translateX(-50%);
  width: min(92vw, 380px);
  padding: 12px 16px;
  border-radius: var(--r-ctrl);
  background: var(--text); color: var(--bg);
  font-size: 14px;
}

@media (min-width: 720px) {
  .chat { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .sheet { border-radius: 24px; margin-bottom: 10vh; }
  .sheet-backdrop { align-items: center; }
}

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