:root {
  --eclips: #462377;
  --lavendel: #B39DDB;
  --lavendel-text: #6b5a8d;
  --amethyste: #936DA4;
  --shore: #1F1FC9;
  --leaf: #B8DD7B;
  --coral: #E1231C;
  --bg: #faf9fc;
  --card-bg: #fff;
  --text: #372D43;
  --radius: 16px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  background: var(--card-bg);
}

/* Header */
.app-header {
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, #6b4a9e 0%, #7d5cb0 100%);
  color: white;
  flex-shrink: 0;
}
.app-header.show {
  display: flex; /* Show when authenticated */
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 36px;
  height: 36px;
}
.logo-text {
  font-family: 'Ovo', serif;
  font-size: 1.4rem;
  font-weight: 400;
}
.tagline {
  font-size: 0.7rem;
  opacity: 0.85;
  margin-top: 2px;
}

/* Nav Menu Button */
.nav-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 8px 12px;
  color: white;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
}
.nav-btn:hover { background: rgba(255,255,255,0.25); }

/* Dropdown Menu */
.nav-menu {
  position: fixed;
  top: 60px;
  right: 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(70,35,119,0.2);
  min-width: 220px;
  z-index: 1000;
  display: none;
  overflow: hidden;
}
.nav-menu.open { display: block; }
.nav-menu-item {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #f0ecf5;
}
.nav-menu-item:last-child { border-bottom: none; }
.nav-menu-item:hover { background: #f7f4fb; }
.nav-menu-item .item-icon { margin-right: 10px; }

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.screen.active { display: flex; }

/* Chat Screen */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message Bubbles */
.message { display: flex; max-width: 85%; }
.message.user { margin-left: auto; }
.message.assistant { margin-right: auto; }
.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.message.user .bubble {
  background: linear-gradient(135deg, var(--eclips), var(--amethyste));
  color: white;
  border-bottom-right-radius: 6px;
}
.message.assistant .bubble {
  background: #f3effa;
  color: var(--text);
  border-bottom-left-radius: 6px;
}

/* Typing Indicator */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--lavendel-text);
  font-size: 0.85rem;
}
.typing-indicator.show { display: flex; }
.typing-dots {
  display: flex;
  gap: 4px;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lavendel);
  animation: bounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Input Area */
.input-area {
  padding: 12px 16px 16px;
  background: white;
  border-top: 1px solid #ede7f6;
  flex-shrink: 0;
}
.input-group {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.input-field {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e0d8eb;
  border-radius: 24px;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  max-height: 120px;
}
.input-field:focus { border-color: var(--eclips); }
.send-btn {
  background: var(--eclips);
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s;
  flex-shrink: 0;
}
.send-btn:hover { background: #5a3a8a; }
.send-btn:active { transform: scale(0.95); }

/* Info/About Screen */
.info-screen {
  padding: 20px;
  overflow-y: auto;
}
.info-screen .back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--eclips);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 16px;
  cursor: pointer;
}
.info-screen h2 {
  font-family: 'Ovo', serif;
  color: var(--eclips);
  margin: 0 0 16px;
}
.card {
  background: white;
  border: 1px solid #ede7f6;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h3 {
  margin: 0 0 12px;
  color: var(--eclips);
  font-size: 1.1rem;
}
.card p { margin: 0 0 10px; }
.card ul { margin: 8px 0; padding-left: 20px; }
.card li { margin-bottom: 6px; }

/* Crisis Banner */
.crisis-banner {
  background: linear-gradient(135deg, #fff5f5, #fff0f0);
  border: 1px solid #f5d0d0;
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.crisis-banner h3 {
  color: var(--coral);
  margin: 0 0 8px;
  font-size: 1rem;
}
.crisis-banner p { margin: 4px 0; font-size: 0.9rem; }

/* Welcome message in chat */
.welcome-card {
  background: linear-gradient(135deg, #f7f4fb, #ede7f6);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 8px;
}
.welcome-card h3 {
  font-family: 'Ovo', serif;
  color: var(--eclips);
  margin: 0 0 10px;
}
.welcome-card p { margin: 0; font-size: 0.95rem; color: var(--lavendel-text); }

/* Auth Screen */
#auth-screen,
#paywall-screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  z-index: 2000;
  overflow-y: auto;
}

#auth-screen.active,
#paywall-screen.active {
  display: flex;
  flex-direction: column;
}

.auth-container {
  max-width: 420px;
  margin: auto;
  padding: 40px 20px;
  width: 100%;
}

.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}

.auth-logo .logo-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
}

.auth-logo .logo-text {
  font-family: 'Ovo', serif;
  font-size: 2.5rem;
  color: var(--eclips);
  margin-bottom: 8px;
}

.auth-logo .tagline {
  color: var(--lavendel-text);
  font-size: 1rem;
}

.auth-form {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 4px 20px rgba(70, 35, 119, 0.1);
}

.auth-form h2 {
  font-family: 'Ovo', serif;
  color: var(--eclips);
  margin: 0 0 24px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 500;
  color: var(--eclips);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0d8eb;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--eclips);
}

.consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 20px 0;
}

.consent-checkbox input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.consent-checkbox label {
  font-size: 0.85rem;
  color: var(--lavendel-text);
  cursor: pointer;
}

.error-message {
  color: var(--coral);
  font-size: 0.85rem;
  margin: 12px 0;
  text-align: center;
  min-height: 20px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--eclips), var(--lavendel));
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  margin: 8px 0;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(70, 35, 119, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: var(--eclips);
  border: 2px solid var(--lavendel);
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  margin: 8px 0;
  transition: background 0.2s, color 0.2s;
}

.btn-secondary:hover {
  background: var(--lavendel);
  color: white;
}

/* Paywall Screen */
.paywall-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

.paywall-container h2 {
  font-family: 'Ovo', serif;
  color: var(--eclips);
  text-align: center;
  margin-bottom: 16px;
  font-size: 2rem;
}

.paywall-intro {
  text-align: center;
  color: var(--lavendel-text);
  margin-bottom: 40px;
  font-size: 1.1rem;
}

.pricing-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

.pricing-card {
  background: white;
  border: 2px solid #e0d8eb;
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.pricing-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(70, 35, 119, 0.15);
}

.pricing-card.featured {
  border-color: var(--eclips);
  border-width: 3px;
}

.pricing-card .badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--eclips), var(--lavendel));
  color: white;
  padding: 4px 16px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pricing-card h3 {
  font-family: 'Ovo', serif;
  color: var(--eclips);
  margin: 0 0 16px;
  font-size: 1.5rem;
}

.pricing-card .price {
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--eclips);
  margin-bottom: 24px;
}

.pricing-card .price span {
  font-size: 1rem;
  font-weight: 400;
  color: var(--lavendel-text);
}

.pricing-card .features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  text-align: left;
}

.pricing-card .features li {
  padding: 8px 0;
  color: var(--text);
  font-size: 0.95rem;
}

.paywall-footer {
  text-align: center;
  color: var(--lavendel-text);
  font-size: 0.9rem;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .pricing-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .app-header { padding: 10px 12px; }
  .logo-text { font-size: 1.2rem; }
  .tagline { display: none; }
  .chat-area { padding: 12px; }
  .input-area { padding: 10px 12px 14px; }
  .auth-container { padding: 20px 16px; }
  .auth-form { padding: 24px 20px; }
  .paywall-container { padding: 20px 16px; }
}

/* Markdown styling inside bubbles */
.bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 {
  font-family: 'Ovo', serif;
  color: var(--eclips);
  margin: 0 0 12px 0;
  line-height: 1.3;
}
.bubble h1 { font-size: 1.3rem; }
.bubble h2 { font-size: 1.2rem; }
.bubble h3 { font-size: 1.1rem; }
.bubble h4, .bubble h5, .bubble h6 { font-size: 1rem; }
.message.user .bubble h1,
.message.user .bubble h2,
.message.user .bubble h3,
.message.user .bubble h4,
.message.user .bubble h5,
.message.user .bubble h6 { color: white; }

.bubble p { margin: 0 0 10px 0; }
.bubble p:last-child { margin-bottom: 0; }

.bubble ul, .bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}
.bubble li { margin-bottom: 4px; }
.bubble li:last-child { margin-bottom: 0; }

.bubble strong { font-weight: 600; }
.bubble em { font-style: italic; }

.bubble hr {
  border: none;
  border-top: 1px solid rgba(70, 35, 119, 0.2);
  margin: 12px 0;
}
.message.user .bubble hr {
  border-top-color: rgba(255, 255, 255, 0.3);
}

.bubble code {
  background: rgba(70, 35, 119, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}
.message.user .bubble code {
  background: rgba(255, 255, 255, 0.2);
}

.bubble blockquote {
  border-left: 3px solid var(--lavendel);
  margin: 8px 0;
  padding-left: 12px;
  color: var(--lavendel-text);
}
.message.user .bubble blockquote {
  border-left-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.9);
}

.bubble a {
  color: var(--eclips);
  text-decoration: underline;
}
.message.user .bubble a {
  color: white;
}
