:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* Navbar */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-inner { display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.25rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user { color: var(--text-muted); font-size: 0.875rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-size: 0.9375rem; font-weight: 500; text-decoration: none;
    border: none; cursor: pointer; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 0.9375rem; }
.form-group small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 0.8125rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], textarea, select {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.9375rem;
    background: var(--surface); color: var(--text);
    transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
textarea { resize: vertical; font-family: inherit; }

/* Cards */
.form-card, .info-card, .analyze-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 32px; box-shadow: var(--shadow); margin-bottom: 24px;
}
.info-card h3 { margin-bottom: 12px; font-size: 1rem; }

/* Alerts */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 20px; font-size: 0.9375rem;
}
.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Auth pages */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 80vh; padding: 20px;
}
.auth-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 40px; box-shadow: var(--shadow-lg); width: 100%; max-width: 420px;
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 24px; text-align: center; }
.auth-link { text-align: center; margin-top: 20px; font-size: 0.875rem; color: var(--text-muted); }
.auth-link a { color: var(--primary); text-decoration: none; }

/* Page header */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin: 32px 0 24px;
}
.page-header h1 { font-size: 1.75rem; }
.back-link { color: var(--text-muted); text-decoration: none; font-size: 0.875rem; }
.back-link:hover { color: var(--primary); }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 24px; }

/* Projects grid */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.project-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 24px; box-shadow: var(--shadow); text-decoration: none; color: var(--text);
    border: 1px solid var(--border); transition: all 0.15s;
}
.project-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.project-card h3 { margin-bottom: 4px; }
.project-url { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 12px; word-break: break-all; }
.project-status { margin-bottom: 8px; }
.project-date { font-size: 0.75rem; color: var(--text-muted); }

/* Badges */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 100px;
    font-size: 0.75rem; font-weight: 500;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Radio cards */
.radio-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.radio-card {
    display: block; padding: 14px 16px; border: 2px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
}
.radio-card:has(input:checked) { border-color: var(--primary); background: #eef2ff; }
.radio-card input { display: none; }
.radio-label { display: block; font-weight: 600; font-size: 0.9375rem; }
.radio-desc { display: block; font-size: 0.8125rem; color: var(--text-muted); margin-top: 2px; }

/* Analyze */
.analyze-status { text-align: center; padding: 40px; }
.spinner {
    width: 40px; height: 40px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.summary-text { background: var(--bg); padding: 16px; border-radius: var(--radius-sm); margin-bottom: 20px; }

/* Settings grid */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

/* Project actions */
.project-actions { display: flex; gap: 12px; margin-bottom: 24px; }

/* Generations */
.section { margin-top: 32px; }
.section h2 { margin-bottom: 16px; }
.generations-list { display: flex; flex-direction: column; gap: 12px; }
.generation-card {
    background: var(--surface); border-radius: var(--radius-sm);
    padding: 20px; border: 1px solid var(--border);
}
.gen-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.gen-header h3 { font-size: 1rem; }
.gen-date { font-size: 0.75rem; color: var(--text-muted); }
.gen-preheader { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 12px; }
.gen-json {
    background: #1e293b; color: #e2e8f0; padding: 16px;
    border-radius: var(--radius-sm); overflow-x: auto;
    font-size: 0.8125rem; margin-top: 12px; white-space: pre-wrap;
}

/* Chat page */
.chat-page {
    display: grid; grid-template-columns: 280px 1fr;
    height: calc(100vh - 57px); max-width: 100%;
    margin: 0 -20px; padding: 0;
}
.chat-sidebar {
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 20px; overflow-y: auto;
}
.chat-sidebar h2 { font-size: 1.125rem; margin: 12px 0; }
.sidebar-info {
    background: var(--bg); border-radius: var(--radius-sm);
    padding: 12px; margin-bottom: 12px; font-size: 0.8125rem;
}
.sidebar-info small { color: var(--text-muted); display: block; margin-bottom: 4px; }

.chat-main { display: flex; flex-direction: column; height: 100%; }

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

.message { max-width: 80%; }
.message-user { align-self: flex-end; }
.message-assistant { align-self: flex-start; }

.message-content {
    padding: 12px 16px; border-radius: var(--radius);
    font-size: 0.9375rem; line-height: 1.6;
}
.message-user .message-content {
    background: var(--primary); color: white;
    border-bottom-right-radius: 4px;
}
.message-assistant .message-content {
    background: var(--surface); border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Email card in chat */
.email-card {
    background: var(--surface); border: 2px solid var(--primary);
    border-radius: var(--radius); padding: 20px; max-width: 80%;
}
.email-card-header { margin-bottom: 12px; }
.email-card-badge {
    background: #eef2ff; color: var(--primary);
    padding: 4px 12px; border-radius: 100px;
    font-size: 0.8125rem; font-weight: 600;
}
.email-field { margin-bottom: 10px; font-size: 0.9375rem; }
.email-blocks { margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.email-block {
    display: flex; gap: 12px; padding: 12px;
    background: var(--bg); border-radius: var(--radius-sm);
}
.block-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.block-content { flex: 1; }
.block-type {
    display: inline-block; background: #e2e8f0; padding: 1px 8px;
    border-radius: 4px; font-size: 0.6875rem; text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 4px;
}
.block-content p { font-size: 0.875rem; color: var(--text-muted); margin-top: 4px; }
.block-cta { font-size: 0.8125rem; color: var(--primary); font-weight: 500; }

/* Chat input */
.chat-input-area {
    display: flex; gap: 12px; padding: 16px 24px;
    border-top: 1px solid var(--border); background: var(--surface);
}
.chat-input-area textarea {
    flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 14px; font-size: 0.9375rem; resize: none;
    max-height: 120px; font-family: inherit;
}

/* Channel select in sidebar (checkboxes) */
.sidebar-section { margin-bottom: 16px; }
.sidebar-label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.channel-select { display: flex; flex-direction: column; gap: 4px; }
.channel-option {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.875rem; transition: all 0.15s;
    border: 1px solid transparent;
}
.channel-option:hover { background: var(--bg); }
.channel-option:has(input:checked) { background: #eef2ff; border-color: var(--primary); color: var(--primary); font-weight: 500; }
.channel-option input { display: none; }
.channel-check {
    width: 18px; height: 18px; border: 2px solid var(--border); border-radius: 4px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: all 0.15s;
}
.channel-option:has(input:checked) .channel-check {
    background: var(--primary); border-color: var(--primary);
}
.channel-option:has(input:checked) .channel-check::after {
    content: '✓'; color: white; font-size: 0.75rem; font-weight: 700;
}
.channel-icon { font-size: 1.1rem; }

/* Typing indicator */
.typing-bubble {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    border-bottom-left-radius: 4px;
}
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary); opacity: 0.4;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}
.typing-text { color: var(--text-muted); font-size: 0.8125rem; }

/* Save button */
.message-actions {
    display: flex; align-items: center; gap: 10px;
    margin-top: 8px; padding-left: 2px;
}
.btn-save {
    padding: 5px 14px; border-radius: 6px;
    background: var(--surface); border: 1px solid var(--primary);
    color: var(--primary); font-size: 0.8125rem; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
}
.btn-save:hover { background: var(--primary); color: white; }
.btn-save.saved { background: var(--success); border-color: var(--success); color: white; cursor: default; }
.btn-save:disabled { opacity: 0.7; }
.save-hint { font-size: 0.6875rem; color: var(--text-muted); font-style: italic; }

/* Saved list in sidebar */
.saved-list { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.saved-empty { font-size: 0.8125rem; color: var(--text-muted); padding: 8px 0; }
.saved-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; background: var(--bg); border-radius: var(--radius-sm);
    gap: 8px;
}
.saved-item-info { flex: 1; min-width: 0; }
.saved-item-title {
    font-size: 0.8125rem; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.saved-item-meta {
    display: flex; gap: 8px; font-size: 0.6875rem; color: var(--text-muted); margin-top: 2px;
}
.saved-delete {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.125rem; cursor: pointer; padding: 0 4px; line-height: 1;
    flex-shrink: 0;
}
.saved-delete:hover { color: var(--error); }

/* Banner */
.banner {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: var(--radius); padding: 20px 28px;
    margin-bottom: 24px; margin-top: 24px;
}
.banner-content {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.banner-text { color: white; }
.banner-text strong { display: block; font-size: 1.0625rem; margin-bottom: 4px; }
.banner-text span { font-size: 0.875rem; opacity: 0.9; }
.banner .btn { white-space: nowrap; background: white; color: var(--primary); border: none; }
.banner .btn:hover { background: #f0f0ff; }

/* Page with sidebar */
.page-with-sidebar {
    display: grid; grid-template-columns: 1fr 280px; gap: 24px;
    align-items: flex-start;
}
.page-main { min-width: 0; }
.page-sidebar { position: sticky; top: 80px; }
.page-sidebar p { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 12px; }

/* Sidebar cards */
.sidebar-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.sidebar-card h4 { font-size: 0.9375rem; margin-bottom: 12px; }
.sidebar-features, .sidebar-services {
    list-style: none; padding: 0; font-size: 0.875rem;
}
.sidebar-features li, .sidebar-services li {
    padding: 4px 0; color: var(--text);
}
.sidebar-services li { padding-left: 12px; position: relative; color: var(--text-muted); }
.sidebar-services li::before { content: '→'; position: absolute; left: 0; color: var(--primary); }

/* Promo card */
.promo-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd; border-radius: var(--radius);
    padding: 20px; margin-bottom: 16px; text-align: center;
}
.promo-icon { font-size: 1.5rem; margin-bottom: 8px; }
.promo-text strong { display: block; font-size: 0.9375rem; margin-bottom: 6px; }
.promo-text p { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 12px; }
.sidebar-card-accent {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border: 1px solid #c7d2fe;
}
.sidebar-promo-mini { margin-top: auto; padding-top: 16px; }

/* Onboarding card */
.onboarding-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 48px 40px; box-shadow: var(--shadow); text-align: center;
    max-width: 560px; margin: 0 auto;
}
.onboarding-icon { font-size: 3rem; margin-bottom: 16px; }
.onboarding-card h2 { margin-bottom: 16px; }
.onboarding-list {
    list-style: none; padding: 0; text-align: left;
    display: inline-block; margin: 16px 0;
}
.onboarding-list li {
    padding: 6px 0 6px 24px; position: relative;
    font-size: 0.9375rem; color: var(--text-muted);
}
.onboarding-list li::before {
    content: '✓'; position: absolute; left: 0;
    color: var(--success); font-weight: 700;
}
.onboarding-card p { color: var(--text-muted); font-size: 0.9375rem; margin-bottom: 12px; }
.onboarding-note { display: block; margin-top: 12px; color: var(--text-muted); font-size: 0.75rem; }

/* Profile fields */
.profile-field { padding: 6px 0; font-size: 0.9375rem; line-height: 1.5; }
.profile-field strong { color: var(--text); }
.profile-form { display: flex; flex-direction: column; gap: 0; margin: 20px 0; }

/* Danger zone */
.danger-zone {
    margin-top: 40px; padding: 24px;
    border: 1px solid #fecaca; border-radius: var(--radius);
    background: #fef2f2;
}
.danger-zone h3 { color: var(--error); font-size: 0.9375rem; margin-bottom: 16px; }
.danger-zone-content {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.danger-zone-content p { font-size: 0.8125rem; color: var(--text-muted); margin-top: 4px; }
.btn-danger { color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error); color: white; }

/* Generation header */
.gen-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.gen-header-left { flex: 1; min-width: 0; }
.gen-header-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Generation content */
.gen-content {
    font-size: 0.9375rem; line-height: 1.7; margin: 12px 0;
    padding: 16px; background: var(--bg); border-radius: var(--radius-sm);
}
.gen-actions { display: flex; gap: 8px; }
.btn-danger { color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error); color: white; }
.gen-meta { display: flex; align-items: center; gap: 8px; }

/* Landing page */
.landing { max-width: 900px; margin: 0 auto; padding: 0 20px; }

.hero {
    text-align: center; padding: 80px 0 60px;
}
.hero-badge {
    display: inline-block; background: #eef2ff; color: var(--primary);
    padding: 6px 16px; border-radius: 100px; font-size: 0.8125rem;
    font-weight: 600; margin-bottom: 20px;
}
.hero h1 { font-size: 2.75rem; line-height: 1.15; margin-bottom: 20px; }
.hero-sub {
    font-size: 1.125rem; color: var(--text-muted); max-width: 600px;
    margin: 0 auto 32px; line-height: 1.6;
}
.hero-actions { display: flex; justify-content: center; gap: 12px; }
.btn-lg { padding: 14px 32px; font-size: 1.0625rem; }

.how-it-works { padding: 60px 0; }
.how-it-works h2, .channels h2, .features h2, .cta-section h2 {
    text-align: center; font-size: 1.75rem; margin-bottom: 40px;
}

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.step {
    text-align: center; padding: 24px;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.step-num {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.125rem; font-weight: 700;
    margin: 0 auto 16px;
}
.step h3 { margin-bottom: 8px; }
.step p { font-size: 0.9375rem; color: var(--text-muted); }

.channels { padding: 60px 0; }
.channels-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.channel-card {
    text-align: center; padding: 24px 16px;
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); transition: all 0.15s;
}
.channel-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.channel-card-icon { font-size: 2rem; display: block; margin-bottom: 12px; }
.channel-card h3 { margin-bottom: 8px; font-size: 1rem; }
.channel-card p { font-size: 0.8125rem; color: var(--text-muted); }

.features { padding: 60px 0; }
.features-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.feature {
    padding: 24px; background: var(--surface);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.feature strong { display: block; margin-bottom: 6px; }
.feature p { font-size: 0.9375rem; color: var(--text-muted); }

.cta-section {
    text-align: center; padding: 60px 40px;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-radius: var(--radius); margin: 40px 0;
}
.cta-section p { color: var(--text-muted); margin-bottom: 24px; }

.landing-footer {
    text-align: center; padding: 40px 0;
    color: var(--text-muted); font-size: 0.8125rem;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-page { grid-template-columns: 1fr; }
    .chat-sidebar { display: none; }
    .page-with-sidebar { grid-template-columns: 1fr; }
    .page-sidebar { position: static; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .projects-grid { grid-template-columns: 1fr; }
    .radio-group { grid-template-columns: 1fr; }
    .message { max-width: 95%; }
    .banner-content { flex-direction: column; text-align: center; }
    .hero h1 { font-size: 1.75rem; }
    .steps { grid-template-columns: 1fr; }
    .channels-grid { grid-template-columns: repeat(2, 1fr); }
    .features-grid { grid-template-columns: 1fr; }
    .hero-actions { flex-direction: column; align-items: center; }
}
