/* === DESIGN TOKENS === */
:root {
  --bg: #fafaf9;
  --bg-card: #ffffff;
  --text: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;
  --border: #e7e5e4;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: #f5f3ff;
  --success: #059669;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.08);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100dvh; }
input, textarea, button { font: inherit; }

/* === VIEW SYSTEM === */
.view { display: none; }
.view.active { display: flex; flex-direction: column; min-height: 100dvh; }

/* === LOADING === */
#loading { justify-content: center; align-items: center; gap: 1rem; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading p { color: var(--text-secondary); font-size: .95rem; }

/* === LANDING === */
#landing { background: linear-gradient(180deg, var(--accent-light) 0%, var(--bg) 40%); }
.landing-header { padding: 1.25rem 2rem; display: flex; align-items: center; }
.landing-header .logo { font-size: 1.25rem; font-weight: 700; }
.landing-main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 0 1rem 3rem; max-width: 480px; margin: 0 auto; width: 100%; }

/* Hero */
.hero { text-align: center; margin-bottom: 2rem; }
.hero h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-bottom: .5rem; }
.hero .subtitle { color: var(--text-secondary); font-size: 1.05rem; max-width: 360px; margin: 0 auto; }

/* Pricing Card */
.pricing-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.75rem; text-align: center; width: 100%; box-shadow: var(--shadow-lg); position: relative; margin-bottom: 1.75rem; }
.trial-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: .25rem .875rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pricing-card h2 { font-size: 1.15rem; font-weight: 600; margin-top: .25rem; color: var(--text-secondary); }
.pricing-card .price { font-size: 2.5rem; font-weight: 800; letter-spacing: -.02em; margin: .25rem 0 0; }
.pricing-card .price-note { font-size: .85rem; color: var(--text-muted); margin-bottom: 1rem; }
.features { list-style: none; text-align: left; display: inline-block; }
.features li { padding: .35rem 0; font-size: .9rem; }
.features li::before { content: '✓ '; color: var(--success); font-weight: 700; margin-right: .35rem; }

/* Auth Section */
.auth-section { width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.auth-tabs { display: flex; gap: 0; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.auth-tab { flex: 1; padding: .6rem; background: none; border: none; font-weight: 500; color: var(--text-secondary); cursor: pointer; font-size: .9rem; border-bottom: 2px solid transparent; transition: all .15s; }
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.auth-form { display: none; flex-direction: column; gap: .75rem; }
.auth-form.active { display: flex; }
.auth-form input { padding: .7rem .875rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; outline: none; transition: border-color .15s; }
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,.1); }
.auth-error { color: var(--error); font-size: .8rem; min-height: 1.2em; margin: 0; }
.auth-note { color: var(--text-muted); font-size: .78rem; text-align: center; margin-top: 1rem; }

/* Buttons */
.btn-primary { background: var(--accent); color: #fff; border: none; padding: .75rem 1.5rem; border-radius: var(--radius-sm); font-weight: 600; font-size: .95rem; cursor: pointer; transition: background .15s; width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-large { padding: 1rem 2rem; font-size: 1.05rem; }
.btn-ghost { background: none; border: 1px solid var(--border); padding: .4rem .9rem; border-radius: var(--radius-sm); font-size: .85rem; color: var(--text-secondary); cursor: pointer; transition: all .15s; }
.btn-ghost:hover { background: var(--bg); }

/* === APP HEADER (shared) === */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: .875rem 1.25rem; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.app-header .logo { font-size: 1.15rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: .75rem; }

/* === PAYWALL === */
.paywall-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.paywall-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem 2rem; text-align: center; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.trial-expired { margin-bottom: 1rem; }
.trial-expired .icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.trial-expired h2 { font-size: 1.3rem; font-weight: 700; }
.paywall-desc { color: var(--text-secondary); font-size: .95rem; margin-bottom: 1.5rem; line-height: 1.5; }
.pricing-box { background: var(--accent-light); border-radius: var(--radius-sm); padding: 1.25rem; margin-bottom: 1.25rem; }
.pricing-box .price { font-size: 2rem; font-weight: 800; }
.pricing-box .price-note { color: var(--text-secondary); font-size: .85rem; }
.paywall-note { color: var(--text-muted); font-size: .78rem; margin-top: 1rem; }

/* Trial indicator */
.trial-indicator { font-size: .78rem; padding: .2rem .6rem; border-radius: 999px; font-weight: 600; }
.trial-indicator.active { background: var(--accent-light); color: var(--accent); }
.trial-indicator.expiring { background: #fef3c7; color: #92400e; }
.trial-indicator.paid { background: #ecfdf5; color: var(--success); }

/* === CHAT === */
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.message { display: flex; max-width: 85%; }
.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }
.message-content { padding: .75rem 1rem; border-radius: var(--radius); font-size: .93rem; line-height: 1.55; }
.message.user .message-content { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.message.assistant .message-content { background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.message-content p { margin: 0; }
.message-content p + p { margin-top: .5rem; }
.message-content ul, .message-content ol { margin: .5rem 0 0 1.25rem; }
.message-content li { margin-bottom: .25rem; }

/* Chat input */
.chat-input-bar { display: flex; gap: .5rem; padding: .875rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg-card); }
.chat-input-bar textarea { flex: 1; padding: .65rem .875rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; outline: none; resize: none; max-height: 120px; line-height: 1.4; }
.chat-input-bar textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,.1); }
.btn-send { background: var(--accent); color: #fff; border: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: background .15s; align-self: flex-end; }
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; }

/* Typing indicator */
.typing .message-content { padding: .5rem 1rem; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.typing-dots span:nth-child(1) { animation-delay: -.32s; }
.typing-dots span:nth-child(2) { animation-delay: -.16s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0); } 40% { transform: scale(1); } }

/* === RESPONSIVE === */
@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }
  .pricing-card .price { font-size: 2rem; }
  .paywall-card { padding: 2rem 1.25rem; }
  .message { max-width: 92%; }
}
