:root {
  --bg: #0a0710;
  --bg-2: #120c1b;
  --surface: rgba(28, 18, 40, 0.82);
  --surface-2: #1c1428;
  --line: rgba(255, 182, 230, 0.14);
  --text: #f7f0f8;
  --muted: #b8a8c4;
  --pink: #ff6b9d;
  --pink-2: #ff8fb7;
  --violet: #b48cff;
  --violet-2: #8b5cf6;
  --good: #6ea8ff;
  --warn: #f0a04b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --radius: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow: hidden;
}
button, input { font-family: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; }

.aurora {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(180, 80, 200, 0.28), transparent 55%),
    radial-gradient(700px 500px at 110% 10%, rgba(255, 80, 140, 0.2), transparent 50%),
    radial-gradient(600px 400px at 50% 110%, rgba(90, 60, 180, 0.22), transparent 55%),
    var(--bg);
}
.view { position: relative; z-index: 1; height: 100%; display: none; }
.view.on { display: flex; flex-direction: column; }

/* ===== Age gate ===== */
#view-gate { align-items: center; justify-content: center; padding: 24px; }
.gate-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px 28px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.logo-mark {
  width: 34px; height: 34px; border-radius: 12px;
  background: linear-gradient(145deg, var(--pink), var(--violet-2));
  display: grid; place-items: center;
  box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.15), 0 8px 20px rgba(255, 107, 157, 0.35);
}
.logo-mark svg { width: 18px; height: 18px; }
.wordmark {
  position: relative;
  letter-spacing: -0.03em;
}
.wordmark .tld {
  font-weight: 500;
  opacity: 0.5;
  letter-spacing: -0.02em;
}
.wordmark .tittle {
  display: inline-block;
  width: 0;
  position: relative;
  vertical-align: top;
}
.wordmark .tittle::before {
  content: "";
  position: absolute;
  left: -0.04em;
  top: 0.16em;
  width: 0.17em;
  height: 0.17em;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--pink-2), var(--violet));
  box-shadow: 0 0 7px rgba(255, 107, 157, 0.5);
  opacity: 0.9;
}
.about-line {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  letter-spacing: 0.005em;
}
.about-line em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 560;
  color: #f3e4ef;
}
.hero .about-line { margin-top: 12px; max-width: 36rem; }
.gate-card .about-line { margin-top: 12px; color: #9a8aa6; }
.gate-card h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 2rem;
  letter-spacing: -0.03em;
  margin: 22px 0 10px;
}
.gate-card p { color: var(--muted); line-height: 1.5; font-size: 0.98rem; }
.gate-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.btn {
  border: 0; cursor: pointer; border-radius: 999px;
  padding: 14px 18px; font-size: 1rem; font-weight: 560;
  transition: transform .15s ease, filter .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active { transform: translateY(0); }
.btn-primary {
  color: #1a0b16;
  background: linear-gradient(180deg, #ffd0e2, var(--pink) 40%, #e85a8c);
  box-shadow: 0 10px 24px rgba(255, 107, 157, 0.28);
}
.btn-ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}
.fineprint { margin-top: 18px; color: #8b7b97; font-size: 0.75rem; line-height: 1.45; }
.warn-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 16px; padding: 6px 12px; border-radius: 999px;
  background: rgba(240, 160, 75, 0.12);
  color: var(--warn); font-size: 0.78rem; font-weight: 560;
  letter-spacing: .04em; text-transform: uppercase;
}

/* ===== Picker ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 16px 20px 8px;
  max-width: 1180px; width: 100%; margin: 0 auto;
}
.topbar .pill { white-space: nowrap; flex: 0 1 auto; }
.pill {
  font-size: 0.78rem; font-weight: 560;
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}
.pill strong { color: var(--good); font-weight: 650; }
.hero {
  max-width: 1180px; width: 100%; margin: 0 auto;
  padding: 10px 20px 18px;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(1.8rem, 3.4vw, 3rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.hero p { color: var(--muted); margin-top: 8px; max-width: 36rem; font-size: 1.02rem; }
.grid {
  max-width: 1180px; width: 100%; margin: 0 auto;
  padding: 4px 20px 28px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  overflow: auto;
  flex: 1;
  align-content: start;
  grid-auto-rows: min-content;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  border-radius: 24px;
  overflow: hidden;
  min-height: min-content;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  color: inherit;
  box-shadow: 0 12px 30px rgba(0,0,0,.25);
  transition: transform .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); border-color: rgba(255, 140, 200, 0.4); }
.card-photo { height: 280px; overflow: hidden; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 18%; }
.card-body { padding: 16px 16px 18px; }
.card-body h2 { font-size: 1.25rem; font-weight: 600; }
.card-body .role { color: var(--pink-2); font-size: 0.82rem; font-weight: 560; margin-top: 2px; }
.traits { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.trait {
  font-size: 0.72rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px;
}
.card .go {
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--line);
}
.card.create {
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 380px;
  background:
    linear-gradient(180deg, rgba(180,140,255,0.16), rgba(20,14,28,0.2) 55%),
    repeating-linear-gradient(-45deg, transparent, transparent 12px, rgba(255,255,255,0.03) 12px, rgba(255,255,255,0.03) 13px),
    var(--surface-2);
  cursor: default;
}
.card.create:hover { transform: none; border-color: var(--line); }
.plus {
  position: absolute; top: 28%; left: 50%; transform: translateX(-50%);
  width: 72px; height: 72px; border-radius: 24px;
  display: grid; place-items: center;
  font-size: 2rem; color: var(--violet);
  border: 1px dashed rgba(180,140,255,0.45);
  background: rgba(180,140,255,0.08);
}
.soon {
  display: inline-block; margin-top: 8px;
  font-size: 0.7rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--violet); font-weight: 650;
}

/* ===== Chat ===== */
#view-chat { background: transparent; }
.chat-shell {
  flex: 1; display: flex; min-height: 0;
  max-width: 1180px; width: 100%; margin: 0 auto;
}
.sidebar {
  display: none;
  width: 300px; flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  overflow: auto;
}
.side-item {
  display: flex; gap: 12px; align-items: center;
  width: 100%; border: 0; background: transparent; color: inherit;
  padding: 10px; border-radius: 16px; cursor: pointer; text-align: left;
}
.side-item:hover, .side-item.on { background: rgba(255,255,255,0.06); }
.side-item img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.side-item .nm { font-weight: 600; font-size: 0.95rem; }
.side-item .sn { color: var(--muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat {
  flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0;
}
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,7,16,0.7);
  backdrop-filter: blur(16px);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.04);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.who img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.who h2 { font-size: 1.02rem; font-weight: 620; }
.who .st { color: #8fd0a8; font-size: 0.72rem; display: flex; align-items: center; gap: 5px; }
.who .st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #57d68a; }
.thread {
  flex: 1; overflow: auto;
  padding: 18px 16px 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { max-width: min(78%, 440px); display: flex; flex-direction: column; gap: 4px; }
.msg.her { align-self: flex-start; }
.msg.me { align-self: flex-end; }
.bubble {
  padding: 11px 14px; border-radius: 18px;
  line-height: 1.45; font-size: 0.95rem;
}
.msg.her .bubble {
  background: #22182f;
  border: 1px solid var(--line);
  border-top-left-radius: 6px;
}
.msg.me .bubble {
  background: linear-gradient(180deg, #c084fc, #a855f7 70%);
  color: #1a1020;
  border-top-right-radius: 6px;
  font-weight: 500;
}
.time { font-size: 0.68rem; color: #8b7b97; padding: 0 4px; }
.msg.me .time { text-align: right; }
.photo-bubble {
  width: min(260px, 72vw);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #1a1324;
}
.photo-bubble img { width: 100%; height: 320px; object-fit: cover; object-position: center 15%; }
.photo-cap { padding: 10px 12px 12px; font-size: 0.88rem; color: var(--text); }
.composer-wrap {
  padding: 8px 12px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: rgba(10,7,16,0.86);
  backdrop-filter: blur(16px);
}
.presets {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 0 2px 10px; scrollbar-width: none;
}
.presets::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--pink); }
.composer {
  display: flex; gap: 8px; align-items: flex-end;
}
.composer input {
  flex: 1; min-width: 0;
  background: #1a1326;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 0.98rem;
  outline: none;
}
.composer input:focus { border-color: rgba(255,107,157,0.5); }
.send {
  width: 46px; height: 46px; border-radius: 16px; border: 0; cursor: pointer;
  color: #1a0b16;
  background: linear-gradient(180deg, #ffd0e2, var(--pink));
  display: grid; place-items: center;
  flex-shrink: 0;
}
.remaining { color: #8b7b97; font-size: 0.7rem; padding: 6px 4px 2px; line-height: 1.3; }

@media (max-width: 759px) {
  .card-photo { height: 220px; }
}
@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .card-photo { height: 320px; }
}
@media (min-width: 1080px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
  .card-photo { height: 300px; }
  .hero h1 { max-width: 16ch; }
  .sidebar { display: block; }
  #view-picker, #view-chat { padding-top: 4px; }
}


/* Light theme */
html[data-theme="light"] {
  --bg: #f6eef3;
  --bg-2: #fffafc;
  --surface: rgba(255, 252, 254, 0.88);
  --surface-2: #ffffff;
  --line: rgba(90, 30, 70, 0.12);
  --text: #2a1220;
  --muted: #7a5a6c;
  --pink: #e85a8c;
  --pink-2: #d4487a;
  --violet: #7c5cbf;
  --violet-2: #6d4ab3;
  --good: #2f6fdb;
  --warn: #c67a22;
  --shadow: 0 16px 40px rgba(80, 20, 50, 0.08);
}
html[data-theme="light"] .aurora {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(255, 160, 200, 0.35), transparent 55%),
    radial-gradient(700px 500px at 110% 10%, rgba(255, 200, 180, 0.28), transparent 50%),
    radial-gradient(600px 400px at 50% 110%, rgba(180, 160, 255, 0.22), transparent 55%),
    var(--bg);
}
html[data-theme="light"] .gate-card,
html[data-theme="light"] .card {
  background: var(--surface-2);
}
html[data-theme="light"] .chat-head,
html[data-theme="light"] .composer-wrap {
  background: rgba(255, 250, 252, 0.9);
}
html[data-theme="light"] .msg.her .bubble { background: #f4eaf0; }
html[data-theme="light"] .composer input { background: #fff; color: var(--text); }
html[data-theme="light"] .fineprint,
html[data-theme="light"] .remaining { color: #8a7380; }
html[data-theme="light"] .who .st { color: #2a8a5a; }
html[data-theme="light"] .who .st::before { background: #2a8a5a; }

.topbar-actions, .head-actions { display: flex; align-items: center; gap: 8px; }
.theme-btn, .forget-btn {
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.04);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
}
html[data-theme="light"] .theme-btn,
html[data-theme="light"] .forget-btn,
html[data-theme="light"] .icon-btn {
  background: rgba(255,255,255,0.7);
}

.crisis {
  margin: 16px;
  padding: 16px 16px 14px;
  border-radius: 18px;
  border: 1px solid rgba(240, 160, 75, 0.35);
  background: rgba(240, 160, 75, 0.1);
}
.crisis h3 { font-size: 1.05rem; font-weight: 620; margin-bottom: 6px; }
.crisis p { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.crisis-links { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.crisis-links a {
  display: block; text-decoration: none;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(240, 160, 75, 0.16);
  color: var(--warn); font-weight: 600; font-size: 0.9rem;
}
.crisis-links a span { display: block; font-weight: 400; color: var(--muted); font-size: 0.75rem; margin-top: 2px; }

.typing { align-self: flex-start; color: var(--muted); font-size: 0.85rem; padding: 4px 8px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.confirm-toast {
  position: absolute; right: 12px; top: 58px; z-index: 5;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px; width: min(240px, 80vw);
  box-shadow: var(--shadow);
}
.confirm-toast p { font-size: 0.85rem; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.confirm-toast .row { display: flex; gap: 8px; }
.confirm-toast .row .btn { flex: 1; padding: 8px 10px; font-size: 0.85rem; }

.thread { position: relative; }
#view-chat { position: relative; }

.send:disabled, .chip:disabled { opacity: .55; cursor: default; }

.chat { position: relative; }

/* Safe area for standalone / notched devices */
:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
.view {
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}
#view-gate { padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b)); }
.topbar { padding: calc(16px + var(--safe-t)) 20px 8px; }
.chat-head { padding: calc(12px + var(--safe-t)) 16px 12px; }
@media (display-mode: standalone) {
  #view-gate { padding-top: calc(28px + var(--safe-t)); }
}

.menu-btn {
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.04);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
}
html[data-theme="light"] .menu-btn { background: rgba(255,255,255,0.7); }

.app-menu {
  position: fixed;
  z-index: 20;
  min-width: 200px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.app-menu[hidden] { display: none; }
.app-menu button {
  appearance: none; border: 0; background: transparent;
  color: var(--text); text-align: left;
  font: inherit; font-size: 0.92rem; font-weight: 560;
  padding: 10px 12px; border-radius: 12px; cursor: pointer;
}
.app-menu button:hover { background: rgba(255,255,255,0.06); }
html[data-theme="light"] .app-menu button:hover { background: rgba(90, 30, 70, 0.06); }
.app-menu button[disabled] { opacity: 0.55; cursor: default; }

.install-hint {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(6, 4, 10, 0.55);
  display: grid; place-items: center;
  padding: 24px;
}
.install-hint[hidden] { display: none; }
.install-card {
  width: min(360px, 100%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.install-card h3 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.35rem;
  margin-bottom: 8px;
}
.install-card p { color: var(--muted); line-height: 1.5; font-size: 0.95rem; }
.install-card .btn { width: 100%; margin-top: 18px; }

.logo, .wordmark { white-space: nowrap; }
.topbar { flex-wrap: nowrap; }
.topbar .logo { flex: 0 1 auto; min-width: 0; }
.who h2, .who .st { white-space: nowrap; }
@media (max-width: 759px) {
  .logo { font-size: 1.15rem; }
  .logo-mark { width: 30px; height: 30px; border-radius: 10px; }
  .logo-mark svg { width: 16px; height: 16px; }
  .topbar .pill { font-size: 0.68rem; padding: 6px 8px; }
  #photo-pill { display: none; }
  .chat-head { gap: 8px; }
}
