@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@200;400;600;800&family=Crimson+Pro:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --bg: #0D0D0F;
  --bg-raised: #16161A;
  --bg-card: rgba(26, 26, 32, 0.85);
  --surface: #1E1E24;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(236, 72, 153, 0.3);
  --text: #E8E6F0;
  --text-muted: #8B8A96;
  --text-dim: #5A596A;
  --accent: #EC4899;
  --accent-soft: rgba(236, 72, 153, 0.15);
  --accent-glow: rgba(236, 72, 153, 0.4);
  --accent2: #A855F7;
  --accent2-soft: rgba(168, 85, 247, 0.15);
  --bubble-user: rgba(168, 85, 247, 0.2);
  --bubble-ai: rgba(236, 72, 153, 0.12);
  --input-bg: #1A1A20;
  --danger: #EF4444;
  --success: #22C55E;
}

.light-mode {
  --bg: #FAF9FC;
  --bg-raised: #FFFFFF;
  --bg-card: rgba(255, 255, 255, 0.9);
  --surface: #F0EEF4;
  --border: rgba(0, 0, 0, 0.08);
  --border-accent: rgba(236, 72, 153, 0.25);
  --text: #1A1A2E;
  --text-muted: #6B6A7A;
  --text-dim: #9B9AAA;
  --accent: #DB2777;
  --accent-soft: rgba(219, 39, 119, 0.1);
  --accent-glow: rgba(219, 39, 119, 0.25);
  --accent2: #9333EA;
  --accent2-soft: rgba(147, 51, 234, 0.1);
  --bubble-user: rgba(147, 51, 234, 0.1);
  --bubble-ai: rgba(219, 39, 119, 0.08);
  --input-bg: #F0EEF4;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Bricolage Grotesque', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Glass card */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
}

/* Avatar image */
.avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-accent);
  flex-shrink: 0;
}

.avatar-img.large {
  width: 80px;
  height: 80px;
}

.avatar-img.xlarge {
  width: 100px;
  height: 100px;
}

.avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
  border: 2px solid var(--border-accent);
}

.avatar-placeholder.large {
  width: 80px;
  height: 80px;
  font-size: 28px;
}

/* Chat bubbles */
@keyframes bubbleIn {
  0% { transform: translateY(8px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.chat-bubble {
  animation: bubbleIn 0.25s ease-out;
}

/* Typing indicator */
@keyframes typeDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 2px;
  animation: typeDot 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

/* Pulse glow */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 20px 4px var(--accent-glow); }
}

.pulse-glow {
  animation: pulseGlow 2.5s infinite;
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Subtle background pattern */
.bg-pattern {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle at 20% 80%, var(--accent-soft) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, var(--accent2-soft) 0%, transparent 50%);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-weight: 600;
  font-family: 'Bricolage Grotesque', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 20px;
  font-weight: 600;
  font-family: 'Bricolage Grotesque', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--border-accent); }

/* Input */
.input-field {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-field::placeholder { color: var(--text-dim); }

/* Toggle switch */
.toggle-track {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: all 0.25s;
  flex-shrink: 0;
}
.toggle-track.active {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-track.active .toggle-thumb {
  transform: translateX(20px);
}

/* Quick pills */
.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: 'Bricolage Grotesque', sans-serif;
}
.pill:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-accent);
}

/* Modal */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}
.modal-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

/* Character card */
.char-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.char-card:hover {
  border-color: var(--border-accent);
  background: var(--accent-soft);
}
.char-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* Scrollable pills */
.pills-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pills-scroll::-webkit-scrollbar { display: none; }

/* Heart rain */
@keyframes heartFall {
  0% { transform: translateY(-30px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
.heart-rain-item {
  position: fixed;
  pointer-events: none;
  z-index: 100;
  animation: heartFall 2.5s ease-in forwards;
}

/* Online indicator */
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  margin-right: 6px;
  animation: pulseGlow 2s infinite;
  box-shadow: 0 0 6px var(--success);
}

/* Tabs */
.tab-btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: 'Bricolage Grotesque', sans-serif;
  transition: all 0.2s;
}
.tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.tab-btn:hover:not(.active) {
  color: var(--text-muted);
}

/* Age gate */
.age-gate-blur {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

/* Textarea */
.textarea-field {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 14px;
  width: 100%;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.textarea-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea-field::placeholder { color: var(--text-dim); }

@media (max-width: 640px) {
  .modal-box { border-radius: 16px; padding: 20px; }
}