/* ============ TOKENS ============ */
:root {
  --coral: #ff5f6d;
  --coral-2: #ff8a5b;
  --violet: #8a2be2;
  --violet-2: #b06dff;
  --grad: linear-gradient(135deg, #ff5f6d 0%, #ff8a5b 45%, #b06dff 100%);
  --grad-soft: linear-gradient(135deg, #ffe3e6 0%, #f3e6ff 100%);
  --ink: #2b2634;
  --ink-soft: #6b6577;
  --bg: #f6f4fa;
  --card: #ffffff;
  --shadow: 0 12px 34px rgba(120, 60, 130, .16);
  --shadow-sm: 0 4px 14px rgba(120, 60, 130, .12);
  --radius: 22px;
  --radius-lg: 30px;
  --nav-h: 66px;
  --header-h: 58px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #ece8f4;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* ============ DEMO BANNER ============ */
.demo-banner {
  width: 100%;
  text-align: center;
  font-size: 12px;
  letter-spacing: .04em;
  padding: 5px 10px;
  color: #fff;
  background: rgba(43, 38, 52, .92);
  z-index: 60;
  flex: 0 0 auto;
}

/* ============ PHONE SHELL ============ */
.phone-shell {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 0;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Desktop: centered phone mockup */
@media (min-width: 720px) {
  body { background: radial-gradient(1200px 600px at 50% -10%, #f3e6ff 0%, #ece8f4 60%); justify-content: center; }
  .phone-shell { padding: 22px; }
  .app {
    width: 400px;
    height: min(860px, calc(100dvh - 90px));
    border-radius: 42px;
    box-shadow: 0 30px 80px rgba(90, 40, 120, .28), 0 0 0 11px #14101c, 0 0 0 13px #2b2634;
  }
}

/* ============ HEADER ============ */
.app-header {
  flex: 0 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--card);
  border-bottom: 1px solid rgba(0,0,0,.05);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { font-size: 22px; }
.brand-name {
  font-size: 22px; font-weight: 800; letter-spacing: -.02em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.header-tools { display: flex; gap: 10px; align-items: center; }
.header-tools .h-back {
  border: none; background: var(--grad-soft); color: var(--coral);
  width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; font-weight: 700;
}

/* ============ VIEWS ============ */
.views { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transform: translateX(14px);
  transition: opacity .22s ease, transform .22s ease;
  padding: 14px 16px 0;
}
.view.active { opacity: 1; visibility: visible; transform: none; }
.view-title { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 12px; }
.section-label { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 18px 0 10px; }

/* ============ DISCOVER / DECK ============ */
.view-discover { padding-bottom: 0; }
.deck {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 8px;
}
.card {
  position: absolute; inset: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card);
  display: flex; flex-direction: column;
  will-change: transform;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
}
.card.dragging { cursor: grabbing; transition: none; }
.card-photo {
  flex: 1 1 auto;
  position: relative;
  display: flex; align-items: flex-end;
  color: #fff;
}
.card-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.62) 0%, rgba(0,0,0,0) 45%);
}
.card-initial {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 96px; font-weight: 800; color: rgba(255,255,255,.55);
}
.card-info { position: relative; z-index: 2; padding: 18px 20px 22px; width: 100%; }
.card-info h3 { font-size: 25px; font-weight: 800; display: flex; align-items: baseline; gap: 9px; }
.card-info h3 .age { font-weight: 500; font-size: 22px; }
.card-info .city { font-size: 14px; opacity: .92; margin-top: 3px; }
.card-info .bio { font-size: 14px; line-height: 1.4; margin-top: 8px; opacity: .95; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.card-tags span { font-size: 12px; background: rgba(255,255,255,.22); backdrop-filter: blur(4px); padding: 4px 10px; border-radius: 20px; }

.stamp {
  position: absolute; top: 26px; z-index: 5;
  font-size: 30px; font-weight: 900; letter-spacing: .06em;
  border: 4px solid; border-radius: 12px; padding: 4px 14px;
  opacity: 0; transform: rotate(-12deg);
}
.stamp.like { left: 22px; color: #22c55e; border-color: #22c55e; }
.stamp.nope { right: 22px; color: #ef4444; border-color: #ef4444; transform: rotate(12deg); }

.deck-actions {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 8px 0 12px;
}
.round-btn {
  border: none; cursor: pointer; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease;
}
.round-btn:active { transform: scale(.9); }
.round-btn.pass { width: 58px; height: 58px; font-size: 24px; color: #ff5470; }
.round-btn.like { width: 58px; height: 58px; font-size: 24px; color: #22c55e; }
.round-btn.superlike { width: 46px; height: 46px; font-size: 19px; color: #3b9dff; }

.deck-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 30px;
}
.empty-illustration { font-size: 60px; }
.deck-empty h2 { font-size: 20px; }
.deck-empty p { color: var(--ink-soft); }

/* ============ MATCHES ============ */
.view-matches { overflow-y: auto; padding-bottom: 16px; }
.new-matches-row { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 6px; }
.new-match {
  flex: 0 0 auto; width: 68px; text-align: center; cursor: pointer;
}
.nm-avatar {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 5px;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 24px;
  border: 3px solid var(--coral); position: relative;
}
.nm-avatar .dot { position: absolute; top: -1px; right: -1px; width: 15px; height: 15px; background: var(--coral); border: 2px solid #fff; border-radius: 50%; }
.new-match span { font-size: 12px; color: var(--ink-soft); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.match-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.match-item {
  display: flex; align-items: center; gap: 13px; padding: 11px 8px; border-radius: 16px;
  cursor: pointer; transition: background .15s ease;
}
.match-item:active, .match-item:hover { background: rgba(255,255,255,.7); }
.mi-avatar { width: 54px; height: 54px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px; }
.mi-body { flex: 1 1 auto; min-width: 0; }
.mi-top { display: flex; justify-content: space-between; align-items: baseline; }
.mi-name { font-weight: 700; font-size: 15px; }
.mi-time { font-size: 11px; color: var(--ink-soft); }
.mi-msg { font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-unread { font-weight: 700; color: var(--ink); }
.mi-badge { flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--grad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* ============ CHAT ============ */
.view-chat { padding: 0; }
.chat-header {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid rgba(0,0,0,.05); background: var(--card);
}
.chat-header .ch-back { border: none; background: none; font-size: 24px; color: var(--coral); cursor: pointer; line-height: 1; }
.chat-header .ch-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; }
.chat-header .ch-name { font-weight: 700; font-size: 16px; }
.chat-header .ch-status { font-size: 12px; color: #22c55e; }
.chat-scroll { flex: 1 1 auto; overflow-y: auto; padding: 16px 14px 6px; background: var(--grad-soft); }
.messages { display: flex; flex-direction: column; gap: 8px; }
.day-sep { align-self: center; font-size: 11px; color: var(--ink-soft); background: rgba(255,255,255,.7); padding: 3px 12px; border-radius: 12px; margin: 6px 0; }
.bubble {
  max-width: 76%; padding: 10px 14px; border-radius: 20px; font-size: 14.5px; line-height: 1.35;
  box-shadow: 0 2px 6px rgba(120,60,130,.08); word-wrap: break-word; animation: pop .18s ease;
}
.bubble.them { align-self: flex-start; background: #fff; border-bottom-left-radius: 6px; }
.bubble.me { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

.typing-indicator {
  flex: 0 0 auto; display: flex; gap: 4px; align-items: center;
  padding: 4px 22px 6px; background: var(--grad-soft);
}
.typing-indicator span { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); opacity: .5; animation: blink 1.2s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.chat-input {
  flex: 0 0 auto; display: flex; gap: 9px; padding: 10px 12px; background: var(--card);
  border-top: 1px solid rgba(0,0,0,.05);
}
.chat-input input {
  flex: 1 1 auto; border: none; background: var(--bg); border-radius: 22px;
  padding: 11px 16px; font-size: 15px; outline: none;
}
.send-btn {
  flex: 0 0 auto; width: 44px; height: 44px; border: none; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: 17px; cursor: pointer;
  display: grid; place-items: center; transition: transform .12s ease;
}
.send-btn:active { transform: scale(.9); }

/* ============ PROFILE ============ */
.view-profile { padding: 0; overflow-y: auto; }
.profile-hero {
  position: relative; height: 200px; background: var(--grad);
  display: grid; place-items: center; flex: 0 0 auto;
}
.profile-avatar {
  width: 116px; height: 116px; border-radius: 50%; background: rgba(255,255,255,.25);
  border: 4px solid #fff; display: grid; place-items: center; font-size: 46px; font-weight: 800; color: #fff;
}
.avatar-edit {
  position: absolute; bottom: 18px; right: calc(50% - 66px);
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid #fff;
  background: #fff; color: var(--coral); cursor: pointer; font-size: 15px; box-shadow: var(--shadow-sm);
}
.profile-body { padding: 18px 20px 24px; }
.profile-name { font-size: 24px; font-weight: 800; }
.profile-city { color: var(--ink-soft); margin: 2px 0 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 14px 0 7px; }
.bio-input {
  width: 100%; border: 1.5px solid #e7e1f0; border-radius: 16px; padding: 12px 14px;
  font-family: inherit; font-size: 14px; resize: none; outline: none; background: var(--card);
}
.bio-input:focus { border-color: var(--coral); }
.char-count { text-align: right; font-size: 11px; color: var(--ink-soft); margin-top: 4px; }
.pref-block { margin-top: 18px; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; background: #e7e1f0; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--grad); box-shadow: var(--shadow-sm); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border: none; border-radius: 50%; background: var(--coral); cursor: pointer; }

.dual-range { position: relative; height: 24px; }
.dual-track { position: absolute; top: 9px; left: 0; right: 0; height: 6px; border-radius: 6px; background: #e7e1f0; }
.dual-fill { position: absolute; top: 0; bottom: 0; border-radius: 6px; background: var(--grad); }
.dual-range input[type=range] { position: absolute; top: 0; left: 0; width: 100%; background: none; pointer-events: none; }
.dual-range input[type=range]::-webkit-slider-thumb { pointer-events: auto; }
.dual-range input[type=range]::-moz-range-thumb { pointer-events: auto; }

.pref-toggles { margin-top: 22px; display: flex; flex-direction: column; gap: 4px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 14.5px; cursor: pointer; }
.toggle-row input { display: none; }
.toggle-row .switch { position: relative; width: 46px; height: 27px; border-radius: 20px; background: #d9d2e6; transition: background .2s; flex: 0 0 auto; }
.toggle-row .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-row input:checked ~ .switch { background: var(--coral); }
.toggle-row input:checked ~ .switch::after { transform: translateX(19px); }

/* ============ BUTTONS ============ */
.btn-primary { width: 100%; margin-top: 24px; border: none; border-radius: 16px; padding: 15px; font-size: 16px; font-weight: 700; color: #fff; background: var(--grad); cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .12s ease; }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { margin-top: 12px; border: 2px solid var(--coral); color: var(--coral); background: none; border-radius: 16px; padding: 11px 20px; font-weight: 700; cursor: pointer; }
.btn-ghost { width: 100%; margin-top: 8px; border: none; background: none; color: var(--ink-soft); font-size: 14px; cursor: pointer; padding: 8px; }

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  flex: 0 0 auto; height: var(--nav-h);
  display: flex; background: var(--card); border-top: 1px solid rgba(0,0,0,.06);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1 1 0; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-soft); position: relative; transition: color .15s;
}
.nav-item .nav-icon { font-size: 21px; filter: grayscale(1) opacity(.55); transition: filter .15s; }
.nav-item .nav-text { font-size: 11px; font-weight: 600; }
.nav-item.active { color: var(--coral); }
.nav-item.active .nav-icon { filter: none; }
.nav-badge { position: absolute; top: 8px; left: 54%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--coral); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

/* ============ MATCH OVERLAY ============ */
.match-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 30px;
  background: rgba(43,38,52,.55); backdrop-filter: blur(6px);
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.match-card {
  background: #fff; border-radius: 28px; padding: 34px 26px; text-align: center;
  max-width: 340px; width: 100%; box-shadow: var(--shadow); animation: pop .3s ease;
}
.match-spark { font-size: 60px; animation: beat 1s infinite; }
@keyframes beat { 0%,100% { transform: scale(1); } 20% { transform: scale(1.2); } 40% { transform: scale(1); } }
.match-card h2 { font-size: 30px; font-weight: 800; margin: 6px 0; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.match-card p { color: var(--ink-soft); margin-bottom: 18px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 22px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 30px; font-size: 14px;
  opacity: 0; transition: all .3s ease; z-index: 120; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
