@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,500;1,9..144,300&family=DM+Sans:wght@300;400;500&display=swap');

/* ── Variables ── */
:root {
  --bg: #0d0a0f;
  --surface: #17121c;
  --surface2: #221a2a;
  --border: #2e2438;
  --accent: #c96fd8;
  --accent2: #e8a0f5;
  --warm: #f0c87a;
  --text: #f0eaf5;
  --muted: #8a7898;
  --danger: #e05a6a;
  --radius: 20px;
  --radius-sm: 12px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app-shell {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Desktop centering — phone frame on wide screens ── */
@media (min-width: 600px) {
  body {
    background: #07050a;
    display: flex;
    justify-content: center;
  }

  /* Subtle phone outline on desktop */
  .app-shell,
  .chat-page,
  .auth-page {
    max-width: 430px;
    width: 100%;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 32px 80px rgba(0,0,0,0.6);
    border-radius: 0;
    min-height: 100dvh;
    position: relative;
  }

  /* Auth pages need bg contained */
  .auth-page {
    background: radial-gradient(ellipse at 50% 0%, #2a1535 0%, var(--bg) 65%);
  }

  /* Bottom nav stays within the frame */
  .bottom-nav {
    max-width: 430px;
  }

  /* Recorder sheet stays within frame */
  .recorder-sheet {
    max-width: 430px;
  }

  /* Chat input bar stays within frame */
  .chat-input-bar {
    max-width: 430px;
  }
}

/* ── Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: rgba(13,10,15,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 12px;
  transition: color 0.2s;
  text-decoration: none;
}
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.active { color: var(--accent2); }
.nav-btn .notif-dot {
  position: absolute;
  top: 6px;
  right: 14px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg);
}

/* ── Page Header ── */
.page-header {
  padding: 54px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.5px;
  color: var(--text);
}
.page-title em {
  font-style: italic;
  color: var(--accent2);
}

/* ── Auth Pages ── */
.auth-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
  background: radial-gradient(ellipse at 50% 0%, #2a1535 0%, var(--bg) 65%);
}

.auth-logo {
  font-family: 'Fraunces', serif;
  font-size: 42px;
  font-weight: 300;
  font-style: italic;
  color: var(--accent2);
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.auth-tagline {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 40px;
  text-align: center;
}

.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.field-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--muted); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #9b3dba);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.2px;
}
.btn-primary:active { opacity: 0.85; transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.2s;
}
.btn-ghost:hover { border-color: var(--accent); }

.auth-switch {
  text-align: center;
  margin-top: 20px;
  color: var(--muted);
  font-size: 14px;
}
.auth-switch a { color: var(--accent2); text-decoration: none; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  padding: 10px;
  background: rgba(224,90,106,0.1);
  border-radius: 8px;
  display: none;
}
.error-msg.show { display: block; }

/* ── Feed Card ── */
.feed-page {
  padding: 0 0 90px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.feed-header {
  padding: 54px 24px 20px;
  background: linear-gradient(180deg, rgba(42,21,53,0.6) 0%, transparent 100%);
}

.profile-card {
  margin: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  flex: 1;
}

.card-image {
  width: 100%;
  height: 280px;
  object-fit: cover;
  display: block;
}

.card-image-placeholder {
  width: 100%;
  height: 280px;
  background: linear-gradient(135deg, var(--surface2) 0%, #2a1a38 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
}

.card-body {
  padding: 20px;
}

.card-name {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 300;
  letter-spacing: -0.3px;
}
.card-age {
  color: var(--muted);
  font-size: 16px;
  margin-left: 8px;
}

/* ── Audio Player ── */
.voice-player {
  margin-top: 16px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9b3dba);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.play-btn:active { transform: scale(0.93); }

.waveform {
  flex: 1;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.waveform-bar {
  flex: 1;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.2s;
}

.voice-player.playing .waveform-bar {
  animation: wave 1.2s ease-in-out infinite;
  background: var(--accent);
}
.waveform-bar:nth-child(2n) { animation-delay: 0.15s !important; }
.waveform-bar:nth-child(3n) { animation-delay: 0.3s !important; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

.voice-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Feed Actions ── */
.feed-actions {
  display: flex;
  gap: 12px;
  padding: 16px;
  margin: 0 16px;
}

.btn-skip {
  flex: 1;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.btn-skip:active { opacity: 0.7; }

.btn-reply {
  flex: 2;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), #9b3dba);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s;
}
.btn-reply:active { opacity: 0.85; }

/* ── Recorder ── */
.recorder-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  border-top: 1px solid var(--border);
  padding: 24px 24px calc(40px + env(safe-area-inset-bottom));
  z-index: 200;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.recorder-sheet.open { transform: translateX(-50%) translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.recorder-title {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 300;
  text-align: center;
  margin-bottom: 6px;
}
.recorder-for {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.recorder-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: transparent;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  position: relative;
}
.recorder-btn:active { transform: scale(0.95); }
.recorder-btn.recording {
  background: rgba(201,111,216,0.15);
  animation: pulse-ring 1.5s ease-out infinite;
}
.recorder-btn-inner {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  transition: border-radius 0.2s, background 0.2s;
}
.recorder-btn.recording .recorder-btn-inner {
  border-radius: 10px;
  background: var(--danger);
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(201,111,216,0.4); }
  70% { box-shadow: 0 0 0 16px rgba(201,111,216,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,111,216,0); }
}

.recorder-status {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  min-height: 20px;
  margin-bottom: 20px;
}
.recorder-status.active { color: var(--accent2); }

.recorder-preview {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: none;
}
.recorder-preview.show { display: flex; align-items: center; gap: 12px; }

.btn-send-voice {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), #9b3dba);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: none;
}
.btn-send-voice.show { display: block; }

.btn-cancel-rec {
  width: 100%;
  padding: 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  cursor: pointer;
  margin-top: 8px;
}

/* ── Empty State ── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 12px;
}
.empty-icon { font-size: 56px; margin-bottom: 8px; }
.empty-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 300;
}
.empty-text { color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ── Conversations List ── */
.conversations-page {
  padding: 0 0 90px;
}

.section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 24px 8px;
}

.convo-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.convo-item:active { background: var(--surface); }

.convo-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
}
.convo-avatar img { width: 100%; height: 100%; object-fit: cover; }

.convo-info { flex: 1; }
.convo-name { font-weight: 500; font-size: 15px; }
.convo-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.convo-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
}

.pending-badge {
  background: var(--surface2);
  color: var(--muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ── Chat Page ── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  background: var(--bg);
}

.chat-header {
  padding: 54px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}

.chat-partner-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.chat-partner-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-partner-name {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 300;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 100px;
}

.msg-bubble {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 4px;
}
.msg-bubble.mine { align-self: flex-end; align-items: flex-end; }
.msg-bubble.theirs { align-self: flex-start; align-items: flex-start; }

.msg-audio-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px 16px 10px 10px;
  cursor: pointer;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
}
.msg-bubble.mine .msg-audio-btn { background: var(--surface2); }

.msg-time {
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px;
}

.chat-input-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(13,10,15,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 50;
}

.record-bar-btn {
  width: 100%;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.record-bar-btn.recording {
  background: rgba(201,111,216,0.1);
  border-color: var(--accent);
  color: var(--accent2);
  animation: pulse-ring 1.5s ease-out infinite;
}

/* ── Profile Setup Page ── */
.setup-page {
  padding: 54px 20px 100px;
}

.setup-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.setup-section-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 300;
  margin-bottom: 4px;
}
.setup-section-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.profile-img-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: none;
}
.profile-img-preview.show { display: block; }

.upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-upload {
  padding: 12px 20px;
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  cursor: pointer;
  flex: 1;
  text-align: center;
}

.audio-recorded-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(201,111,216,0.08);
  border: 1px solid rgba(201,111,216,0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--accent2);
  margin-top: 12px;
  display: none;
}
.audio-recorded-indicator.show { display: flex; }

/* ── Toast ── */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 20px;
  font-size: 14px;
  color: var(--text);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: rgba(201,111,216,0.5); color: var(--accent2); }
.toast.error { border-color: rgba(224,90,106,0.5); color: var(--danger); }

/* ── Match Overlay ── */
.match-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,10,15,0.95);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.match-overlay.show { opacity: 1; pointer-events: all; }

.match-title {
  font-family: 'Fraunces', serif;
  font-size: 38px;
  font-weight: 300;
  font-style: italic;
  color: var(--accent2);
  text-align: center;
  margin-bottom: 8px;
}
.match-sub {
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  margin-bottom: 40px;
}

/* ── Loading Spinner ── */
.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent2); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
