:root {
  --bg: #0f0c1d;
  --bg-2: #171329;
  --card: #1e1936;
  --line: #2e2750;
  --text: #f3f0ff;
  --muted: #a39cc4;
  --pink: #ff4d8d;
  --violet: #7c5cff;
  --green: #2ee59d;
  --danger: #ff5c6c;
  --grad: linear-gradient(135deg, var(--pink), var(--violet));
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #2a1f55 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.6rem; margin: .2em 0 .6em; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; margin: 0; letter-spacing: -.01em; }
[hidden] { display: none !important; }

.shell { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 16px; }
main { flex: 1; padding-bottom: 96px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; }
.logo-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--grad); font-size: .85rem; }
.badge { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: #3a2f6b; color: #d9ceff; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--violet); outline-offset: 1px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 99px; padding: 11px 20px;
}
.btn.primary { background: var(--grad); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.big { padding: 15px; font-size: 1.05rem; }
.btn:active { transform: scale(.98); }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; padding: 4px 8px; line-height: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex-direction: row; font-weight: 500; }
.chip input { position: absolute; opacity: 0; pointer-events: none; width: auto; }
.chip span { padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; font-size: .9rem; }
.chip input:checked + span { background: var(--grad); border-color: transparent; }
.chip input:focus-visible + span { outline: 2px solid var(--violet); }
.chip input:disabled + span { opacity: .4; cursor: not-allowed; }
.ranks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ranks:empty { display: none; }

.avatar {
  --hue: 280; width: 48px; height: 48px; border-radius: 50%; flex: none; object-fit: cover;
  display: grid; place-items: center; font-weight: 800; font-size: 1.2rem;
  background: linear-gradient(135deg, hsl(var(--hue) 80% 60%), hsl(calc(var(--hue) + 60) 70% 45%));
}
.avatar.sm { width: 38px; height: 38px; font-size: 1rem; }
.avatar.lg { width: 96px; height: 96px; font-size: 2.4rem; border: 3px solid var(--bg); }
.avatar.xl { width: 110px; height: 110px; font-size: 2.8rem; }
.avatar.fill { width: 100%; height: 100%; border-radius: 0; font-size: 6rem; }
.avatar-edit { display: flex; align-items: center; gap: 18px; }

.hero { padding-top: 6vh; }
.hero h1 { font-size: 2.4rem; line-height: 1.1; }
.lead { color: var(--muted); font-size: 1.1rem; margin-bottom: 28px; }

/* discover */
.deck { position: relative; height: min(68dvh, 620px); margin-top: 4px; }
.swipe-card {
  --like: 0; --nope: 0;
  position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45); touch-action: pan-y; user-select: none; cursor: grab;
}
.swipe-card.under { transform: scale(.95) translateY(12px); opacity: .6; pointer-events: none; }
.swipe-card .photo { position: relative; flex: 0 0 42%; overflow: hidden; }
.swipe-card .info { padding: 16px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.name-row { display: flex; align-items: center; justify-content: space-between; }
.age { font-weight: 400; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9rem; }
.common { margin: 0; font-weight: 600; color: var(--green); font-size: .95rem; }
.bio { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .8rem; padding: 4px 10px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); }
.tag.hot { border-color: var(--green); color: var(--green); }
.tag.mode { background: var(--grad); border: 0; font-weight: 700; }
.tag.soft { color: var(--muted); }
.stamp {
  position: absolute; top: 22px; padding: 6px 12px; border: 3px solid; border-radius: 10px;
  font-weight: 800; font-size: 1.4rem; letter-spacing: .05em; transform: rotate(-12deg);
}
.stamp.like { left: 18px; color: var(--green); opacity: var(--like); }
.stamp.nope { right: 18px; color: var(--danger); opacity: var(--nope); transform: rotate(12deg); }

.actions { display: flex; justify-content: center; gap: 28px; margin-top: 18px; }
.round {
  width: 64px; height: 64px; border-radius: 50%; font-size: 1.6rem; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); color: var(--text);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35); transition: transform .15s;
}
.round:hover { transform: scale(1.08); }
.round.nope { color: var(--danger); border-color: var(--danger); }
.round.like { color: #fff; background: var(--grad); border-color: transparent; }

.empty { text-align: center; padding: 12vh 12px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon { font-size: 3rem; }
.empty p { max-width: 320px; margin: 0 0 8px; }

/* matches */
.match-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.match-list a { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; }
.match-list a:hover { background: var(--card); }

/* chat */
.chat { display: flex; flex-direction: column; height: calc(100dvh - 76px); }
.chat-head { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 16px 2px; }
.bubble { max-width: 78%; padding: 9px 14px; border-radius: 18px 18px 18px 4px; background: var(--card); align-self: flex-start; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--grad); border-radius: 18px 18px 4px 18px; }
.composer { display: flex; gap: 8px; padding: 10px 0 max(14px, env(safe-area-inset-bottom)); }
.composer input { border-radius: 99px; }

/* tabs */
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px;
  display: flex; justify-content: space-around; padding: 8px 8px max(10px, env(safe-area-inset-bottom));
  background: rgba(15, 12, 29, .92); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.tabs a { display: flex; flex-direction: column; align-items: center; font-size: .75rem; color: var(--muted); padding: 4px 16px; gap: 2px; }
.tabs a span { font-size: 1.3rem; }
.tabs a.active { color: var(--text); }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(5, 3, 15, .7); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-box { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.match-pop { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.eyebrow { margin: 0; font-weight: 800; font-size: 1.8rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pair { display: flex; justify-content: center; }
.pair > :last-child { margin-left: -18px; }
.toast {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 20;
  background: #fff; color: #111; font-weight: 600; padding: 10px 18px; border-radius: 99px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); max-width: calc(100% - 32px);
}

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