/* ============================================
   FELT APP DESIGNER - Premium Styling
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-dark: #1e40af;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    --radius-full: 9999px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* WELCOME SCREEN */
#welcomeScreen {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 24px;
}

.welcome-container { max-width: 720px; width: 100%; text-align: center; }

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}

.felt-logo { width: 60px; height: 24px; color: var(--gray-800); }
.logo-text { font-size: 18px; font-weight: 600; color: var(--gray-600); }

.welcome-title {
    font-size: 42px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.welcome-subtitle {
    font-size: 18px;
    color: var(--gray-500);
    margin-bottom: 40px;
}

/* Prompt Hero - Gamma Style */
.prompt-hero {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    margin: 0 auto 24px;
    text-align: left;
}

.prompt-main textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    transition: border-color var(--transition-fast);
    font-family: inherit;
}

.prompt-main textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.prompt-main textarea::placeholder {
    color: var(--gray-400);
}

.map-attach {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
}

.map-attach-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.map-attach-row svg {
    color: var(--gray-400);
    flex-shrink: 0;
}

.map-attach-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.map-attach-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.map-attach-row input::placeholder {
    color: var(--gray-400);
}

.add-map-btn {
    padding: 8px 12px;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.add-map-btn:hover {
    background: var(--gray-200);
}

.remove-map-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    color: var(--gray-500);
    font-size: 18px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.remove-map-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.map-attach-row.second-map {
    margin-top: 10px;
}

.btn-generate-hero {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    margin-top: 16px;
    background: var(--primary);
    color: white;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    transition: all var(--transition-fast);
}

.btn-generate-hero:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-generate-hero:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    transform: none;
}

/* Quick Starts */
.quick-starts {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}

.quick-label {
    font-size: 13px;
    color: var(--gray-500);
}

.quick-chip {
    padding: 6px 14px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    font-size: 13px;
    color: var(--gray-600);
    transition: all var(--transition-fast);
}

.quick-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.help-text {
    font-size: 14px;
    color: var(--gray-400);
}

.help-text a {
    color: var(--primary);
    text-decoration: none;
}

.help-text a:hover {
    text-decoration: underline;
}

/* Legacy styles kept for builder */
.prompt-container {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-xl);
    margin-bottom: 40px;
}

.prompt-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.prompt-input-wrapper textarea {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 16px;
    resize: none;
    transition: border-color var(--transition-fast);
}

.prompt-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.prompt-input-wrapper textarea::placeholder { color: var(--gray-400); }

.btn-generate {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: var(--primary);
    color: white;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-generate:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.prompt-hints {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.map-urls-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.map-url-row {
    margin-bottom: 10px;
}

.map-url-row:last-child {
    margin-bottom: 0;
}

.map-url-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 6px;
}

.map-url-label .optional-hint {
    font-weight: 400;
    color: var(--gray-400);
}

.map-url-row input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 14px;
    color: var(--gray-700);
}

.map-url-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.map-url-row input::placeholder {
    color: var(--gray-400);
}

.second-map {
    padding-top: 10px;
    border-top: 1px dashed var(--gray-200);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.hint-label { font-size: 13px; color: var(--gray-400); }

.hint-chip {
    padding: 4px 12px;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 13px;
    border-radius: 9999px;
    transition: all var(--transition-fast);
}

.hint-chip:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.section-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    color: var(--gray-400);
    font-size: 13px;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.template-card {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: all var(--transition-fast);
}

.template-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.template-preview {
    background: var(--gray-100);
    border-radius: 6px;
    height: 100px;
    margin-bottom: 12px;
    overflow: hidden;
    padding: 8px;
}

.mock-header {
    height: 12px;
    background: var(--gray-300);
    border-radius: 2px;
    margin-bottom: 4px;
}

.mock-map {
    flex: 1;
    background: var(--gray-200);
    border-radius: 2px;
    height: calc(100% - 16px);
}

.mock-split {
    display: flex;
    gap: 4px;
    height: calc(100% - 16px);
}

.mock-sidebar {
    width: 30%;
    background: var(--gray-200);
    border-radius: 2px;
}

.template-name {
    display: block;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.template-desc { font-size: 12px; color: var(--gray-500); }

/* GENERATING SCREEN */
#generatingScreen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.generating-container { text-align: center; max-width: 400px; }

.generating-visual {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 32px;
}

.pulse-ring {
    position: absolute;
    inset: 0;
    border: 2px solid var(--primary);
    border-radius: 50%;
    opacity: 0;
    animation: pulse-ring 2s ease-out infinite;
}

.pulse-ring.delay-1 { animation-delay: 0.5s; }
.pulse-ring.delay-2 { animation-delay: 1s; }

@keyframes pulse-ring {
    0% { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

.generating-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.generating-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 32px;
}

.steps-container { text-align: left; margin-bottom: 24px; }

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    color: var(--gray-400);
    transition: color var(--transition-fast);
}

.step.active { color: var(--primary); }
.step.complete { color: var(--success); }

.step-icon { width: 20px; text-align: center; font-size: 14px; }
.step.active .step-icon::before { content: '→'; }
.step.complete .step-icon::before { content: '✓'; }

.progress-bar {
    height: 4px;
    background: var(--gray-200);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    border-radius: 9999px;
    width: 0%;
    transition: width var(--transition-slow);
}

.generating-detail { font-size: 13px; color: var(--gray-500); }

/* BUILDER SCREEN */
#builderScreen {
    flex-direction: column;
    height: 100vh;
    background: var(--gray-100);
}

.builder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    height: 56px;
    flex-shrink: 0;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-center { display: flex; align-items: center; }

.btn-icon-only {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--gray-600);
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.btn-icon-only:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-icon-only:disabled { opacity: 0.4; cursor: not-allowed; }

.app-name-input {
    border: none;
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    padding: 8px 12px;
    border-radius: 6px;
    width: 200px;
}

.app-name-input:hover { background: var(--gray-50); }
.app-name-input:focus { outline: none; background: var(--gray-100); }

.version-indicator { display: flex; align-items: center; gap: 4px; }

.btn-text-icon {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--gray-600);
    font-size: 13px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.btn-text-icon:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.btn-primary:hover { background: var(--primary-hover); }

.builder-body { display: flex; flex: 1; overflow: hidden; }

.control-panel {
    width: 340px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mode-tabs {
    display: flex;
    padding: 8px;
    gap: 4px;
    border-bottom: 1px solid var(--gray-200);
}

.mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--gray-500);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.mode-tab:hover {
    color: var(--gray-700);
    background: var(--gray-50);
}

.mode-tab.active {
    color: var(--primary);
    background: var(--primary-light);
}

.mode-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.mode-panel.active { display: flex; }

.panel-section { margin-bottom: 20px; }

.section-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.ai-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-input-wrapper textarea {
    padding: 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    resize: none;
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.ai-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-apply {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--gray-900);
    color: white;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.btn-apply:hover { background: var(--gray-800); }
.btn-apply:disabled { opacity: 0.6; cursor: not-allowed; }

.sparkle { animation: sparkle 1.5s ease-in-out infinite; }

@keyframes sparkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.loading-spinner.dark {
    border-color: rgba(0,0,0,0.1);
    border-top-color: var(--primary);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Chapter Suggestion UI */
.suggestion-group {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.suggestion-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: white;
    cursor: pointer;
}

.suggestion-group-header:hover {
    background: var(--gray-50);
}

.suggestion-group-header::before {
    content: '▼';
    font-size: 10px;
    color: var(--gray-400);
    margin-right: 8px;
    transition: transform 0.2s;
}

.suggestion-group.collapsed .suggestion-group-header::before {
    transform: rotate(-90deg);
}

.suggestion-group-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-800);
}

.suggestion-group-meta {
    font-size: 12px;
    color: var(--gray-500);
}

.suggestion-chapters {
    padding: 8px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-group.collapsed .suggestion-chapters {
    display: none;
}

.suggestion-chapter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: white;
    border-radius: 6px;
    font-size: 13px;
}

.suggestion-chapter input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.suggestion-chapter-title {
    flex: 1;
    color: var(--gray-700);
}

.suggestion-chapter-count {
    font-size: 11px;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
}

.suggestion-select-all {
    font-size: 12px;
    color: var(--primary);
    cursor: pointer;
}

.suggestion-select-all:hover {
    text-decoration: underline;
}

.suggestions-section {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
}

.suggestion-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.suggestion-chip {
    padding: 8px 12px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 13px;
    border-radius: 9999px;
    transition: all var(--transition-fast);
}

.suggestion-chip:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.input-with-btn { display: flex; gap: 8px; }

.input-with-btn input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 14px;
}

.input-with-btn input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-small {
    padding: 8px 12px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
}

.btn-small:hover { background: var(--gray-200); }

.btn-small.btn-accent {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
}

.btn-small.btn-accent:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
}

.btn-small.btn-accent:disabled {
    background: var(--gray-200);
    color: var(--gray-500);
    cursor: not-allowed;
}

.btn-text {
    color: var(--primary);
    font-size: 13px;
    margin-top: 8px;
}

.btn-text:hover { text-decoration: underline; }

.color-row { display: flex; align-items: center; gap: 12px; }

.color-input-group { display: flex; align-items: center; gap: 8px; }

.color-input-group input[type="color"] {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}

.color-hex {
    width: 80px;
    padding: 8px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 13px;
}

.color-shades { display: flex; gap: 2px; }

.shade { width: 24px; height: 24px; border-radius: 4px; }
.shade.main { width: 32px; height: 32px; }

.color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.color-preset {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
}

.color-preset:hover { transform: scale(1.1); }

/* Chapter Editor Styles */
.section-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
    line-height: 1.4;
}

.chapter-editors {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.chapter-editor {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 12px;
}

.chapter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.chapter-number {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
}

.chapter-delete {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--gray-400);
    font-size: 16px;
    transition: all var(--transition-fast);
}

.chapter-delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

.chapter-editor input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.chapter-editor input:focus {
    outline: none;
    border-color: var(--primary);
}

.chapter-editor textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.chapter-editor textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.chapter-viewport {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--gray-200);
}

.btn-capture-view {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-capture-view:hover {
    background: var(--primary);
    color: white;
}

.btn-capture-view svg {
    flex-shrink: 0;
}

.viewport-info {
    font-size: 11px;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 4px;
}

.viewport-hint {
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
}

/* Toggle Group */
.toggle-group {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: 8px;
}

.toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.toggle-btn:hover {
    color: var(--gray-800);
}

.toggle-btn.active {
    background: white;
    color: var(--gray-900);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Toggle Row */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.toggle-label {
    font-size: 13px;
    color: var(--gray-700);
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: 0.2s;
    border-radius: 22px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch input:checked + .switch-slider {
    background-color: var(--primary);
}

.switch input:checked + .switch-slider:before {
    transform: translateX(18px);
}

/* Input Row */
.input-row {
    display: flex;
    gap: 8px;
}

.input-row input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
}

.input-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.color-preset.active { border-color: var(--gray-900); }

.select-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: white;
    font-size: 14px;
    cursor: pointer;
}

.select-input:focus {
    outline: none;
    border-color: var(--primary);
}

.checkbox-group { display: flex; flex-direction: column; gap: 8px; }

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
}

.checkbox-item input { display: none; }

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-300);
    border-radius: 4px;
    position: relative;
    transition: all var(--transition-fast);
}

.checkbox-item input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-item input:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.chat-messages { flex: 1; overflow-y: auto; padding-bottom: 16px; }

.chat-message { margin-bottom: 12px; }

.chat-message.assistant .message-content {
    background: var(--gray-100);
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
}

.chat-message.assistant .message-content ul {
    margin: 8px 0 0 16px;
}

.chat-message.user .message-content {
    background: var(--primary);
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-left: 24px;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.chat-input-wrapper textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    resize: none;
    font-size: 14px;
}

.chat-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-send {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.btn-send:hover { background: var(--primary-hover); }

.preview-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
}

.device-toggle {
    display: flex;
    background: white;
    border-radius: 6px;
    padding: 2px;
    box-shadow: var(--shadow-sm);
}

.device-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    color: var(--gray-400);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.device-btn:hover { color: var(--gray-600); }
.device-btn.active { background: var(--primary); color: white; }

.preview-actions { display: flex; gap: 4px; }

.preview-frame-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: auto;
    background: var(--gray-200);
    background-image: radial-gradient(circle, var(--gray-300) 1px, transparent 1px);
    background-size: 20px 20px;
}

.device-frame {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transition: all var(--transition-slow);
}

.device-frame.desktop { width: 100%; max-width: 1000px; height: 600px; }
.device-frame.tablet { width: 768px; height: 600px; }
.device-frame.phone {
    width: 375px;
    height: 667px;
    border-radius: 24px;
    border: 8px solid var(--gray-800);
}

.preview-frame { width: 100%; height: 100%; overflow: hidden; }

.preview-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
}

.placeholder-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.preview-placeholder p { font-size: 16px; margin-bottom: 4px; }
.placeholder-hint { font-size: 14px !important; color: var(--gray-400); }

/* SLIDE PANELS */
.slide-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: white;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right var(--transition-slow);
}

.slide-panel.active { right: 0; }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.panel-header h3 { font-size: 16px; font-weight: 600; }

.history-list { flex: 1; overflow-y: auto; padding: 16px; }

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.history-item:hover { background: var(--gray-50); }
.history-item.active { background: var(--primary-light); }

.history-dot {
    width: 10px;
    height: 10px;
    background: var(--gray-300);
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
}

.history-item.active .history-dot { background: var(--primary); }
.history-info { flex: 1; min-width: 0; }

.history-action {
    font-size: 14px;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-time { font-size: 12px; color: var(--gray-500); }

/* MODALS */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 16px;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.export-options { display: flex; flex-direction: column; gap: 12px; }

.export-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    text-align: left;
    transition: all var(--transition-fast);
}

.export-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.export-icon { font-size: 28px; }
.export-info strong { display: block; color: var(--gray-800); margin-bottom: 2px; }
.export-info span { font-size: 13px; color: var(--gray-500); }

.share-link-container { display: flex; gap: 8px; }

.share-link-container input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 14px;
    background: var(--gray-50);
}

.share-note { font-size: 13px; color: var(--gray-500); margin-top: 12px; }

/* TOASTS */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-900);
    color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    animation: toast-in 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* GENERATED APP STYLES */
.generated-app {
    height: 100%;
    display: flex;
    flex-direction: column;
    font-family: var(--app-font, -apple-system, sans-serif);
}

.generated-app .app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--app-primary, #2563eb);
    color: white;
}

.generated-app .app-title { font-weight: 600; font-size: 16px; }
.generated-app .app-logo { height: 28px; }
.generated-app .header-actions { display: flex; gap: 8px; }

.generated-app .header-btn {
    padding: 6px 12px;
    background: rgba(255,255,255,0.2);
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.generated-app .app-body { flex: 1; position: relative; }
.generated-app .map-container { position: absolute; inset: 0; }
.generated-app .map-container iframe { width: 100%; height: 100%; border: none; }

.generated-app .legend-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 13px;
    max-width: 180px;
}

.generated-app .legend-title { font-weight: 600; margin-bottom: 8px; color: #374151; }
.generated-app .legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.generated-app .legend-color { width: 16px; height: 16px; border-radius: 3px; }
.generated-app .legend-label { color: #6b7280; }

.generated-app .zoom-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.generated-app .zoom-btn {
    width: 32px;
    height: 32px;
    background: white;
    border: none;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    font-size: 18px;
    color: var(--app-primary, #2563eb);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Basemap Switcher */
.generated-app .basemap-switcher {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    overflow: hidden;
}

.generated-app .basemap-btn {
    padding: 6px 12px;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    border-right: 1px solid #e5e7eb;
}

.generated-app .basemap-btn:last-child { border-right: none; }
.generated-app .basemap-btn.active { background: var(--app-primary); color: white; }

/* ========== DASHBOARD TEMPLATE ========== */
.template-dashboard .app-body-split {
    display: flex;
    flex: 1;
}

.template-dashboard .sidebar-panel {
    width: 300px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    padding: 24px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.template-dashboard .sidebar-section { }

.template-dashboard .sidebar-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #9ca3af;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-dashboard .sidebar-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.template-dashboard .stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.template-dashboard .stat-card {
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    text-align: left;
    transition: all 0.2s ease;
}

.template-dashboard .stat-card:hover {
    border-color: var(--app-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.template-dashboard .stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.template-dashboard .stat-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
}

.template-dashboard .layer-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-dashboard .layer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.template-dashboard .layer-item:hover {
    background: #f3f4f6;
}

.template-dashboard .layer-item input {
    width: 16px;
    height: 16px;
    accent-color: var(--app-primary);
}

.template-dashboard .layer-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.template-dashboard .sidebar-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    background: white;
    margin-bottom: 10px;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.template-dashboard .sidebar-select:hover {
    border-color: #d1d5db;
}

.template-dashboard .sidebar-select:focus {
    outline: none;
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(var(--app-primary-rgb, 59, 130, 246), 0.1);
}

.template-dashboard .map-area {
    flex: 1;
    position: relative;
    background: #f9fafb;
}

.template-dashboard .map-area .map-container {
    position: absolute;
    inset: 0;
}

/* ========== COMPARE TEMPLATE ========== */
.template-compare .app-body-compare {
    display: flex;
    flex: 1;
    position: relative;
}

.template-compare .compare-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.template-compare .pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.template-compare .pane-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.template-compare .pane-select {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    color: #374151;
}

.template-compare .compare-pane .map-container {
    flex: 1;
    position: relative;
}

.template-compare .compare-divider {
    width: 12px;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: col-resize;
    position: relative;
    z-index: 10;
}

.template-compare .divider-handle {
    width: 20px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    cursor: col-resize;
}

.template-compare .compare-legend {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

.template-compare .compare-legend .legend-panel {
    position: static;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
}

.template-compare .compare-legend .legend-title {
    margin-bottom: 0;
    margin-right: 8px;
}

.template-compare .compare-legend .legend-item {
    margin-bottom: 0;
}

/* ========== COMPARE SWIPE MODE ========== */
.compare-swipe .swipe-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.compare-swipe .swipe-container {
    position: absolute;
    inset: 0;
}

.compare-swipe .swipe-layer {
    position: absolute;
    inset: 0;
}

.compare-swipe .swipe-before {
    z-index: 1;
}

.compare-swipe .swipe-after {
    z-index: 1; /* Same z-index - clip-path naturally reveals before layer */
    clip-path: inset(0 0 0 50%);
}

.compare-swipe .swipe-layer .map-container {
    position: absolute;
    inset: 0;
}

.compare-swipe .swipe-label {
    position: absolute;
    top: 12px;
    padding: 6px 12px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    z-index: 5;
}

.compare-swipe .before-label {
    left: 12px;
}

.compare-swipe .after-label {
    right: 12px;
}

.compare-swipe .swipe-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(50% - 22px);
    z-index: 100;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ew-resize;
    touch-action: none;
}

.compare-swipe .slider-line {
    width: 4px;
    height: 100%;
    background: var(--slider-color, #2563eb);
    box-shadow: 0 0 8px rgba(0,0,0,0.4);
    border-radius: 2px;
    pointer-events: none;
}

.compare-swipe .slider-handle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--slider-color, #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    position: absolute;
    border: 3px solid white;
    pointer-events: none;
}

.compare-swipe .swipe-legend {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

.compare-swipe .swipe-legend .legend-panel {
    position: static;
}

/* ========== EDITORIAL STYLE (NYT) ========== */
.style-editorial {
    background: #f5f5f5;
}

.style-editorial .editorial-header {
    background: white;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 20px;
    text-align: center;
}

.style-editorial .editorial-nav {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666;
    margin-bottom: 4px;
}

.style-editorial .nav-divider {
    margin: 0 12px;
    color: #ccc;
}

.style-editorial .editorial-masthead {
    font-family: Georgia, serif;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #000;
}

.style-editorial .editorial-date {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

.style-editorial .editorial-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.style-editorial .editorial-headline {
    text-align: center;
    margin-bottom: 16px;
}

.style-editorial .editorial-headline h1 {
    font-family: Georgia, serif;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 4px 0;
}

.style-editorial .editorial-byline {
    font-size: 14px;
    color: #666;
    font-style: italic;
}

.style-editorial .editorial-map-frame {
    flex: 1;
    border: 1px solid #ddd;
    background: white;
    position: relative;
}

.style-editorial .editorial-map-frame .map-container {
    position: absolute;
    inset: 0;
}

.style-editorial .editorial-legend {
    margin-top: 12px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

.style-editorial .legend-label {
    font-weight: 600;
    margin-right: 8px;
}

.style-editorial .legend-item-inline {
    margin-right: 16px;
}

.style-editorial .legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* ========== PLAYFUL STYLE (Airbnb) ========== */
.style-playful {
    background: #f7f7f7;
}

.style-playful .playful-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #ebebeb;
}

.style-playful .playful-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
    color: var(--app-primary);
}

.style-playful .brand-icon {
    font-size: 20px;
}

.style-playful .playful-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 40px;
    font-size: 14px;
    color: #666;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.style-playful .playful-actions {
    display: flex;
    gap: 8px;
}

.style-playful .action-pill {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: white;
    border: 1px solid #ddd;
    color: #222;
}

.style-playful .action-pill.primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: white;
}

.style-playful .playful-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    max-width: 200px;
}

.style-playful .legend-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 12px;
    color: #222;
}

.style-playful .legend-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.style-playful .legend-chip {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: color-mix(in srgb, var(--chip-color) 15%, white);
    color: var(--chip-color);
    font-weight: 500;
}

.style-playful .playful-zoom {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.style-playful .zoom-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 20px;
    color: #222;
    cursor: pointer;
}

/* ========== GRADIENT STYLE (Stripe) ========== */
.style-gradient {
    background: #0a2540;
}

.style-gradient .gradient-header {
    position: relative;
    padding: 16px 20px;
    overflow: hidden;
}

.style-gradient .gradient-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #0a2540 0%, #1a3a5c 50%, #0a2540 100%);
}

.style-gradient .gradient-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.style-gradient .gradient-brand {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.style-gradient .gradient-nav {
    display: flex;
    gap: 12px;
}

.style-gradient .glass-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    backdrop-filter: blur(10px);
}

.style-gradient .glass-btn.primary {
    background: linear-gradient(135deg, var(--app-primary), var(--app-accent));
    border: none;
}

.style-gradient .gradient-body {
    background: #f6f9fc;
}

.style-gradient .glass-legend {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.style-gradient .glass-legend .legend-title {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #0a2540;
    margin-bottom: 12px;
}

.style-gradient .glass-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    color: #425466;
}

.style-gradient .glass-legend .legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.style-gradient .glass-zoom {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.style-gradient .glass-zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 18px;
    color: var(--app-primary);
    cursor: pointer;
}

/* ========== DARK STYLE ========== */
.style-dark {
    background: #111827;
}

.style-dark .dark-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #1f2937;
    border-bottom: 1px solid #374151;
}

.style-dark .dark-brand {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.style-dark .dark-actions {
    display: flex;
    gap: 8px;
}

.style-dark .dark-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background: #374151;
    border: 1px solid #4b5563;
    color: #e5e7eb;
}

.style-dark .dark-btn.primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: white;
}

.style-dark .dark-body {
    background: #111827;
}

.style-dark .dark-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #1f2937;
    border: 1px solid #374151;
    padding: 14px;
    border-radius: 8px;
}

.style-dark .dark-legend .legend-title {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    margin-bottom: 10px;
}

.style-dark .dark-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    color: #e5e7eb;
}

.style-dark .dark-legend .legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.style-dark .dark-zoom {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.style-dark .dark-zoom-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #1f2937;
    border: 1px solid #374151;
    font-size: 16px;
    color: var(--app-primary);
    cursor: pointer;
}

/* ========== MINIMAL STYLE ========== */
.style-minimal {
    background: #fafafa;
}

.style-minimal .minimal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid #eee;
}

.style-minimal .minimal-brand {
    font-size: 14px;
    font-weight: 500;
    color: #000;
    letter-spacing: -0.01em;
}

.style-minimal .minimal-search {
    padding: 6px 10px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    color: #666;
}

.style-minimal .minimal-legend {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    gap: 16px;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e0e0e0;
    font-size: 12px;
}

.style-minimal .minimal-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.style-minimal .minimal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ========== OFFICIAL STYLE (Government) ========== */
.style-official {
    background: #f5f7fa;
}

.style-official .official-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--app-primary);
    color: white;
}

.style-official .official-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.style-official .official-seal {
    font-size: 24px;
}

.style-official .official-title {
    font-size: 18px;
    font-weight: 600;
}

.style-official .official-nav {
    display: flex;
    gap: 8px;
}

.style-official .official-btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
}

.style-official .official-btn.primary {
    background: white;
    border-color: white;
    color: var(--app-primary);
}

.style-official .official-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    background: white;
    border: 1px solid #d1d5db;
    padding: 14px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.style-official .official-legend .legend-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--app-primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--app-primary);
}

.style-official .official-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    color: #374151;
}

.style-official .official-legend .legend-color {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

.style-official .official-footer {
    padding: 8px 16px;
    background: #e5e7eb;
    font-size: 11px;
    color: #6b7280;
    text-align: center;
}

/* ========== MODERN STYLE (Default - Polished) ========== */
.style-modern {
    background: #f8fafc;
}

.style-modern .modern-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.style-modern .modern-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.style-modern .modern-icon {
    font-size: 18px;
}

.style-modern .modern-nav {
    display: flex;
    gap: 8px;
}

.style-modern .modern-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.style-modern .modern-btn.ghost {
    background: transparent;
    color: #64748b;
}

.style-modern .modern-btn.ghost:hover {
    background: #f1f5f9;
}

.style-modern .modern-btn.primary {
    background: var(--app-primary);
    color: white;
}

.style-modern .modern-btn.primary:hover {
    filter: brightness(1.1);
}

.style-modern .modern-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    min-width: 160px;
}

.style-modern .modern-legend .legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.style-modern .modern-legend .legend-title {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.style-modern .modern-legend .legend-toggle {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: white;
    border: 1px solid #e2e8f0;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
}

.style-modern .modern-legend .legend-body {
    padding: 10px 14px;
}

.style-modern .modern-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.style-modern .modern-legend .legend-item:last-child {
    margin-bottom: 0;
}

.style-modern .modern-legend .legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.style-modern .modern-legend .legend-label {
    font-size: 13px;
    color: #475569;
}

.style-modern .modern-zoom {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.style-modern .modern-zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 18px;
    color: var(--app-primary);
    cursor: pointer;
    transition: all 0.15s;
}

.style-modern .modern-zoom-btn:hover {
    background: var(--app-primary);
    color: white;
}

/* ========== SCROLLYTELLING STYLE ========== */
.template-scrollytelling {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: #fafafa;
}

.template-scrollytelling .scrolly-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
    z-index: 10;
}

.template-scrollytelling .scrolly-brand {
    font-family: var(--app-font, -apple-system, sans-serif);
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    letter-spacing: -0.02em;
}

.template-scrollytelling .scrolly-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--app-primary);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.template-scrollytelling .scrolly-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.template-scrollytelling .scrolly-narrative {
    width: 420px;
    min-width: 360px;
    max-width: 480px;
    overflow-y: auto;
    background: white;
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
    border-right: 1px solid #e5e7eb;
}

.template-scrollytelling .scrolly-section {
    min-height: 100%;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0.35;
    transition: opacity 0.4s ease, background 0.3s ease;
    scroll-snap-align: start;
    position: relative;
}

.template-scrollytelling .scrolly-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 40px;
    right: 40px;
    height: 1px;
    background: linear-gradient(90deg, #e5e7eb 0%, transparent 100%);
}

.template-scrollytelling .scrolly-section:last-child::after {
    display: none;
}

.template-scrollytelling .scrolly-section:hover {
    opacity: 0.6;
    background: rgba(0,0,0,0.01);
}

.template-scrollytelling .scrolly-section.active {
    opacity: 1;
    background: transparent;
}

.template-scrollytelling .section-number {
    font-family: var(--app-font);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--app-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-scrollytelling .section-number::before {
    content: '';
    width: 24px;
    height: 2px;
    background: var(--app-primary);
    opacity: 0.5;
}

.template-scrollytelling .section-title {
    font-family: var(--app-font, Georgia, serif);
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    line-height: 1.25;
    margin-bottom: 20px;
    letter-spacing: -0.03em;
}

.template-scrollytelling .section-content {
    font-family: var(--app-font, Georgia, serif);
    font-size: 17px;
    line-height: 1.75;
    color: #4b5563;
}

.template-scrollytelling .scrolly-map-container {
    flex: 1;
    position: relative;
    background: #f3f4f6;
}

.template-scrollytelling .scrolly-map-container iframe,
.template-scrollytelling .scrolly-map-container .felt-map-sdk {
    width: 100%;
    height: 100%;
    border: none;
}

.template-scrollytelling .scrolly-map-container .felt-map-sdk iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.template-scrollytelling .scrolly-map-overlay {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
}

.template-scrollytelling .scrolly-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.template-scrollytelling .scrolly-dot:hover {
    transform: scale(1.3);
    background: #9ca3af;
}

.template-scrollytelling .scrolly-dot.active {
    background: var(--app-primary);
    transform: scale(1.2);
    box-shadow: 0 0 0 3px rgba(var(--app-primary-rgb, 59, 130, 246), 0.2);
}

.template-scrollytelling .scrolly-legend {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    font-size: 13px;
    min-width: 140px;
}

.template-scrollytelling .scrolly-legend .legend-title {
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    margin-bottom: 12px;
}

.template-scrollytelling .scrolly-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    color: #374151;
    font-size: 13px;
}

.template-scrollytelling .scrolly-legend .legend-item:last-child {
    margin-bottom: 0;
}

.template-scrollytelling .scrolly-legend .legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Editorial scrollytelling variant */
/* NYT-style Editorial Scrollytelling */
.template-scrollytelling.style-editorial {
    background: #fff;
}

.template-scrollytelling.style-editorial .scrolly-header {
    background: #fff;
    border-bottom: 2px solid #000;
    padding: 0 32px;
    height: 52px;
}

.template-scrollytelling.style-editorial .scrolly-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.template-scrollytelling.style-editorial .scrolly-brand {
    font-family: 'Cheltenham', 'Times New Roman', Georgia, serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #000;
}

.template-scrollytelling.style-editorial .scrolly-search {
    padding: 6px;
    color: #666;
    cursor: pointer;
    transition: color 0.2s;
}

.template-scrollytelling.style-editorial .scrolly-search:hover {
    color: #000;
}

.template-scrollytelling.style-editorial .scrolly-progress {
    height: 3px;
    background: #326891;
}

.template-scrollytelling.style-editorial .scrolly-narrative {
    background: #fff;
    border-right: 1px solid #e8e8e8;
    width: 440px;
}

.template-scrollytelling.style-editorial .scrolly-section {
    padding: 56px 40px;
    position: relative;
}

.template-scrollytelling.style-editorial .scrolly-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 40px;
    right: 40px;
    height: 1px;
    background: #e8e8e8;
}

.template-scrollytelling.style-editorial .scrolly-section:first-child::after {
    display: none;
}

.template-scrollytelling.style-editorial .section-number {
    font-family: 'Franklin Gothic', 'Helvetica Neue', Arial, sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 16px;
}

.template-scrollytelling.style-editorial .section-number::before {
    display: none;
}

.template-scrollytelling.style-editorial .section-title {
    font-family: 'Cheltenham', 'Times New Roman', Georgia, serif;
    font-size: 32px;
    font-weight: 700;
    line-height: 1.15;
    color: #121212;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.template-scrollytelling.style-editorial .section-content {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 18px;
    line-height: 1.8;
    color: #333;
}

.template-scrollytelling.style-editorial .scrolly-legend {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.template-scrollytelling.style-editorial .scrolly-legend .legend-title {
    font-family: 'Franklin Gothic', Arial, sans-serif;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: #666;
}

.template-scrollytelling.style-editorial .scrolly-legend .legend-color {
    border-radius: 0;
}

.template-scrollytelling.style-editorial .scrolly-map-overlay {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 2px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.template-scrollytelling.style-editorial .scrolly-dot {
    border-radius: 2px;
    width: 8px;
    height: 8px;
}

.template-scrollytelling.style-editorial .scrolly-dot.active {
    background: #326891;
}
    text-transform: uppercase;
    color: #666;
}

/* Dark scrollytelling variant */
.template-scrollytelling.style-dark .scrolly-header {
    background: #1f2937;
    border-bottom-color: #374151;
}

.template-scrollytelling.style-dark .scrolly-brand {
    color: #fff;
}

.template-scrollytelling.style-dark .scrolly-narrative {
    background: #111827;
}

.template-scrollytelling.style-dark .scrolly-section {
    border-bottom-color: #374151;
}

.template-scrollytelling.style-dark .section-title {
    color: #fff;
}

.template-scrollytelling.style-dark .section-content {
    color: #9ca3af;
}

.template-scrollytelling.style-dark .scrolly-legend {
    background: #1f2937;
    border: 1px solid #374151;
}

.template-scrollytelling.style-dark .scrolly-legend .legend-item {
    color: #e5e7eb;
}

@media (max-width: 768px) {
    .welcome-title { font-size: 28px; }
    .template-grid { grid-template-columns: 1fr; }
    .builder-body { flex-direction: column; }
    .control-panel { width: 100%; height: 50%; border-right: none; border-bottom: 1px solid var(--gray-200); }
    .preview-panel { height: 50%; }
}
