  :root {
    --bg: #0f0a12;
    --bg2: #1a1220;
    --card: #241a2e;
    --pink: #ff4f81;
    --pink2: #ff7aa8;
    --text: #f5e8f0;
    --muted: #9a8aa3;
    --bubble-me: linear-gradient(135deg, #ff4f81, #ff7aa8);
    --bubble-her: #2d2238;
    --err: #ff5c5c;
    --success: #4ade80;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { height: 100%; overflow: hidden; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }

  /* ── Auth Screens (login/signup/verify) ── */
  .auth-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 50% 0%, #3a1f3f 0%, var(--bg) 60%);
  }
  .auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border-radius: 20px;
    padding: 28px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  }
  .auth-card h1 {
    text-align: center;
    font-size: 28px;
    margin-bottom: 6px;
    background: var(--bubble-me);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .auth-card .subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 24px;
  }
  .auth-card input {
    width: 100%;
    padding: 13px 14px;
    margin-bottom: 12px;
    background: var(--bg2);
    border: 1px solid #3a2d47;
    border-radius: 12px;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
  }
  .auth-card input:focus { border-color: var(--pink); }
  .auth-card button.primary {
    width: 100%;
    padding: 13px;
    background: var(--bubble-me);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
  }
  .auth-card button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
  .auth-card .link {
    text-align: center;
    margin-top: 14px;
    font-size: 14px;
    color: var(--muted);
  }
  .auth-card .link a { color: var(--pink); cursor: pointer; text-decoration: none; }
  .auth-card .link a:hover { text-decoration: underline; }
  .msg { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
  .msg.err { background: rgba(255,92,92,0.12); color: var(--err); border: 1px solid rgba(255,92,92,0.3); }
  .msg.ok  { background: rgba(74,222,128,0.12); color: var(--success); border: 1px solid rgba(74,222,128,0.3); }
  .hidden { display: none !important; }

  /* ── Chat Screen ── */
  .chat-wrap { display: flex; flex-direction: column; height: 100dvh; }
  .chat-header {
    background: var(--bg2);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #2a1f36;
  }
  .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bubble-me);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
  }
  .header-info { flex: 1; min-width: 0; }
  .header-info .name { font-weight: 600; font-size: 15px; }
  .header-info .status { font-size: 12px; color: var(--muted); }
  .header-info .status.online::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
  }
  .menu-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 22px;
    cursor: pointer;
    padding: 6px 10px;
  }
  .menu-dropdown {
    position: absolute;
    top: 60px;
    right: 12px;
    background: var(--card);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 10;
  }
  .menu-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
  }
  .menu-dropdown button:hover { background: var(--bg2); }

  .messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .messages::-webkit-scrollbar { width: 0; }

  .bubble {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: pop 0.15s ease-out;
  }
  @keyframes pop { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
  .bubble.me {
    align-self: flex-end;
    background: var(--bubble-me);
    color: white;
    border-bottom-right-radius: 4px;
  }
  .bubble.her {
    align-self: flex-start;
    background: var(--bubble-her);
    color: var(--text);
    border-bottom-left-radius: 4px;
  }
  .typing {
    align-self: flex-start;
    background: var(--bubble-her);
    border-radius: 18px;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
  }
  .typing span {
    width: 6px; height: 6px;
    background: var(--muted);
    border-radius: 50%;
    animation: typing 1.2s infinite;
  }
  .typing span:nth-child(2) { animation-delay: 0.2s; }
  .typing span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
  }

  .composer {
    background: var(--bg2);
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    border-top: 1px solid #2a1f36;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .composer textarea {
    flex: 1;
    background: var(--card);
    border: 1px solid #3a2d47;
    color: var(--text);
    padding: 10px 14px;
    border-radius: 22px;
    resize: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    max-height: 100px;
    line-height: 1.3;
  }
  .composer button {
    background: var(--bubble-me);
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .composer button:disabled { opacity: 0.5; }

  .remaining {
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    padding: 4px;
  }

  .toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    z-index: 100;
    animation: toastIn 0.2s;
  }
  @keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

  /* ── Signup Modal (appears over chat) ── */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn 0.2s;
  }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  .modal-card {
    background: var(--card);
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  }
  .modal-card h2 {
    font-size: 20px;
    margin-bottom: 8px;
    background: var(--bubble-me);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .modal-card p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 18px;
    line-height: 1.4;
  }
  .modal-card input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: var(--bg2);
    border: 1px solid #3a2d47;
    border-radius: 12px;
    color: var(--text);
    font-size: 15px;
    outline: none;
  }
  .modal-card input:focus { border-color: var(--pink); }
  .modal-card button.primary {
    width: 100%;
    padding: 12px;
    background: var(--bubble-me);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-size: 15px;
  }
  .modal-card .subtle {
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
    color: var(--muted);
  }
  .modal-card .subtle a {
    color: var(--pink);
    cursor: pointer;
    text-decoration: none;
  }

  /* ── PAYWALL PACK CARDS ────────────────────────────────────── */
  .paywall-message {
    background: var(--bg2);
    border: 1px solid rgba(255, 79, 129, 0.25);
    color: var(--text);
    padding: 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
    text-align: left;
  }
  .pack-grid { display: flex; flex-direction: column; gap: 10px; }
  .pack-card {
    background: var(--bg2);
    border: 1.5px solid #3a2d47;
    border-radius: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    color: var(--text);
    width: 100%;
  }
  .pack-card:hover, .pack-card:active {
    border-color: var(--pink);
    background: rgba(255, 79, 129, 0.08);
    transform: translateY(-1px);
  }
  .pack-card:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
  .pack-card .pack-row {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
  }
  .pack-card .pack-label { font-weight: 600; font-size: 15px; }
  .pack-card .pack-price {
    background: var(--bubble-me); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; font-weight: 700; font-size: 16px;
  }
  .pack-card .pack-desc {
    color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.4;
  }
  .pack-card .pack-meta {
    display: inline-block; background: rgba(255, 79, 129, 0.15);
    color: var(--pink); padding: 2px 8px; border-radius: 6px;
    font-size: 11px; margin-top: 6px;
  }

  /* Credits/free counter — small badge above composer */
  .credits-badge {
    display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
    padding: 4px 12px; font-size: 11px; color: var(--muted);
  }
  .credits-badge .badge-item {
    background: rgba(255,79,129,0.08);
    border: 1px solid rgba(255,79,129,0.2);
    padding: 2px 8px; border-radius: 8px;
  }
  .credits-badge .badge-item.spicy { color: #ffb47a; border-color: rgba(255,180,122,0.3); background: rgba(255,180,122,0.08); }
  .credits-badge .badge-item.tier-friend { color: #7ab8ff; }
  .credits-badge .badge-item.tier-gf { color: #ff7aa8; font-weight: 600; }

  /* Inline paywall buttons inside chat — appears with soft-yes message */
  .inline-paywall {
    margin: 8px 0 12px;
    display: flex; flex-direction: column; gap: 8px;
    padding: 0 12px;
  }
  .inline-pack-btn {
    background: var(--bubble-me); border: none; color: white;
    padding: 10px 14px; border-radius: 10px; font-weight: 600;
    cursor: pointer; font-size: 14px; text-align: center;
  }
  .inline-pack-btn:active { opacity: 0.85; }

  /* ── Signup hint banner (now positioned above composer) ── */
  .signup-hint {
    background: rgba(255, 79, 129, 0.18);
    border: 1px solid rgba(255, 79, 129, 0.4);
    color: var(--text);
    padding: 10px 14px;
    margin: 0 12px 6px;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
  }
  .signup-hint strong { color: var(--pink); }
  @keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,79,129,0.3); }
    50%      { transform: scale(1.02); box-shadow: 0 0 0 6px rgba(255,79,129,0); }
  }

  /* Email display inside verify modal */
  .email-display {
    background: var(--bg2);
    border: 1px solid rgba(255, 79, 129, 0.3);
    border-radius: 10px;
    padding: 12px 14px;
    margin: 8px 0 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--pink2);
    text-align: center;
    word-break: break-all;
  }
  .wrong-email-section {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
  .wrong-email-section span { display: block; margin-bottom: 4px; }

  /* ── Welcome Screen ── */
  .welcome-card {
    max-width: 400px;
    text-align: center;
  }
  .welcome-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bubble-me);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 36px;
    color: white;
    margin: 0 auto 16px;
    box-shadow: 0 10px 40px rgba(255, 79, 129, 0.4);
  }
  .welcome-tagline {
    color: var(--muted);
    font-size: 15px;
    margin-bottom: 24px;
  }
  .welcome-features {
    text-align: left;
    margin: 20px 0 24px;
  }
  .feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg2);
    border-radius: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text);
  }
  .feature-icon {
    font-size: 20px;
    flex-shrink: 0;
  }
  .welcome-btn {
    margin-top: 4px;
    font-size: 16px !important;
    padding: 14px !important;
  }
  .welcome-footer {
    margin-top: 14px;
    font-size: 11px;
    color: var(--muted);
    opacity: 0.7;
  }
