:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #efedf7;
  --text: #17142b;
  --muted: #6b6785;
  --border: #e2dfee;
  --accent: #6d4aff;
  --accent-text: #ffffff;
  --accent-soft: #ece7ff;
  --gold: #e6a817;
  --gold-soft: #fff4d6;
  --danger: #e5484d;
  --me: #6d4aff;
  --me-text: #ffffff;
  --them: #efedf7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 20, 43, .04), 0 8px 24px rgba(23, 20, 43, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0d1a;
    --surface: #18152a;
    --surface-2: #221e38;
    --text: #f1effa;
    --muted: #9c97b8;
    --border: #2c2846;
    --accent: #8b6dff;
    --accent-soft: #2a2350;
    --gold: #f2bb3a;
    --gold-soft: #3a2f12;
    --danger: #ff6369;
    --me: #7b5cff;
    --them: #262140;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.logo { font-weight: 800; font-size: 22px; letter-spacing: -.5px; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
.online { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #2fbf71; box-shadow: 0 0 0 3px rgba(47, 191, 113, .2); }
.nav { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.badge {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.badge.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }

/* ---------- buttons ---------- */
.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.gold { background: var(--gold); color: #1b1400; }
.btn.big { width: 100%; padding: 13px; font-size: 16px; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* ---------- layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.hero { text-align: center; margin-bottom: 28px; }
.hero h1 { font-size: clamp(32px, 6vw, 48px); letter-spacing: -1.5px; line-height: 1.1; margin: 0 0 10px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); margin: 0 auto; max-width: 460px; }

/* ---------- setup ---------- */
.setup { display: flex; flex-direction: column; gap: 22px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.hint.center { text-align: center; }

.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.gold-pill { background: var(--gold-soft); color: var(--gold); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  flex: 1 1 0;
  min-width: 90px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.seg button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.seg button:disabled { cursor: default; }
.seg button:disabled:not(.active) { opacity: .45; }
.seg.locked button:not([data-value="any"])::after { content: " 🔒"; font-size: 12px; }

.big-label { font-size: 18px; }

.gender-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gender-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 8px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, transform .05s;
}
.gender-grid button:hover { border-color: var(--accent); }
.gender-grid button:active { transform: translateY(1px); }
.gender-grid button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.gender-grid .emoji { font-size: 32px; line-height: 1; }

.you {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
}

.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- plans ---------- */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 28px; }
.plan h3 { margin: 0 0 4px; }
.plan ul { padding-left: 18px; color: var(--muted); margin: 12px 0 18px; }
.plan li { margin: 4px 0; }
.plan.featured { border-color: var(--gold); }
.plans > .plan:first-child { grid-column: 1 / -1; }
.price { font-size: 28px; font-weight: 800; margin: 0; }
.price span { font-size: 14px; font-weight: 500; color: var(--muted); }

/* ---------- chat ---------- */
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 0;
  height: calc(100vh - 140px);
}
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.chat-actions { display: flex; gap: 8px; }
.status { margin-left: 8px; color: var(--muted); font-size: 13px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-x: hidden;
}
.msg {
  position: relative;
  max-width: 75%;
  touch-action: pan-y;
  padding: 9px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.me { align-self: flex-end; background: var(--me); color: var(--me-text); border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: var(--them); border-bottom-left-radius: 4px; }
.msg.system {
  align-self: center;
  max-width: 90%;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}


/* ---------- replies ---------- */
.msg[data-id] { transition: transform .2s ease; user-select: text; }
.msg.swiping { transition: none; user-select: none; }
/* Reply arrow revealed to the left of the bubble while swiping. */
.msg[data-id]::before {
  content: '↩';
  position: absolute;
  left: -30px;
  top: 50%;
  transform: translateY(-50%) scale(calc(.6 + .4 * var(--swipe, 0)));
  opacity: var(--swipe, 0);
  color: var(--muted);
  font-size: 18px;
  pointer-events: none;
}
.reply-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  opacity: 0;
  pointer-events: none;
}
.msg.me .reply-btn { right: calc(100% + 4px); }
.msg.them .reply-btn { left: calc(100% + 4px); }
@media (hover: hover) {
  .msg[data-id]:hover .reply-btn, .reply-btn:focus-visible { opacity: 1; pointer-events: auto; }
}
.quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 6px 10px;
  margin-bottom: 4px;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(0, 0, 0, .08);
  font-size: 13px;
  cursor: pointer;
}
.msg.me .quote { border-left-color: currentColor; background: rgba(255, 255, 255, .18); }
.quote strong { font-size: 12px; color: var(--accent); }
.msg.me .quote strong { color: inherit; }
.quote span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: .85;
}
.msg.flash { animation: flash 1s ease; }
@keyframes flash { 30% { box-shadow: 0 0 0 3px var(--accent); } }
.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 0;
}
.reply-bar[hidden] { display: none; }
.reply-bar .quote { flex: 1; margin: 0; background: var(--surface-2); cursor: default; }
.reply-bar .close { position: static; }

.typing { padding: 0 18px 6px; color: var(--muted); font-size: 13px; font-style: italic; }

.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.composer input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
}
.composer input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- modals ---------- */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 28px;
  width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(10, 8, 20, .55); }
.modal h2 { margin: 0 0 16px; }
.modal form, .modal > div { display: flex; flex-direction: column; gap: 12px; position: relative; }
.modal input {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  width: 100%;
}
.close {
  position: absolute;
  top: -12px;
  right: -12px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
}
.perks { padding-left: 18px; color: var(--muted); margin: 0; }
.error { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- legal pages, feedback, footer ---------- */
/* Content pages scroll normally instead of fitting the viewport like the chat. */
body.page { height: auto; min-height: 100%; }
body.page main { flex: 1 0 auto; }
.legal h1, .feedback h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.5px; }
.legal h2 { font-size: 18px; margin: 28px 0 8px; }
.legal p, .legal li { color: var(--text); }
.legal ul { padding-left: 20px; margin: 8px 0; }
.legal li { margin: 4px 0; }
.legal .lead { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin: 18px 0 0; }
.legal table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.legal th { color: var(--muted); font-weight: 600; font-size: 13px; }
.legal mark { background: var(--gold-soft); color: var(--gold); border-radius: 4px; padding: 0 4px; }
.feedback textarea, .feedback input[type="email"] {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  resize: vertical;
}
.feedback textarea:focus, .feedback input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.footer, .legal-links { text-align: center; color: var(--muted); font-size: 13px; }
.footer { padding: 0 16px 24px; }
.legal-links { margin: 20px 0 0; }
.footer a, .legal-links a { color: var(--muted); }

/* ---------- mobile ---------- */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .online { display: none; }
  main { padding: 20px 16px; }
  .plans { grid-template-columns: 1fr; }
  .chat { height: calc(100dvh - 110px); }
  .msg { max-width: 85%; }
  .card.legal { padding: 20px 16px; }
  /* Stack the privacy table into labelled blocks on phones. */
  .legal table, .legal tbody, .legal tr, .legal td { display: block; }
  .legal thead { display: none; }
  .legal tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .legal td { border: 0; padding: 2px 0; }
  .legal td:nth-child(2)::before { content: "Why: "; font-weight: 600; color: var(--muted); }
  .legal td:nth-child(3)::before { content: "Kept: "; font-weight: 600; color: var(--muted); }
}
