/* ==========================================
   BuildFolio — Design System & App Styles
   ========================================== */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #09090b;
    --bg-secondary: #111114;
    --bg-surface: #18181b;
    --bg-surface-hover: #1f1f23;
    --bg-surface-active: #27272a;
    --bg-elevated: #1c1c20;

    --border-primary: #27272a;
    --border-secondary: #333338;
    --border-focus: var(--accent);

    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    --text-muted: #52525b;

    /* Accent - can be changed by user */
    --accent: #6C63FF;
    --accent-rgb: 108, 99, 255;
    --accent-hover: #7f78ff;
    --accent-subtle: rgba(108, 99, 255, 0.1);
    --accent-glow: rgba(108, 99, 255, 0.25);

    /* Semantic Colors */
    --success: #10b981;
    --success-subtle: rgba(16, 185, 129, 0.1);
    --error: #ef4444;
    --error-subtle: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-subtle: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --fs-xs: 0.6875rem;    /* 11px */
    --fs-sm: 0.75rem;      /* 12px */
    --fs-base: 0.875rem;   /* 14px */
    --fs-md: 1rem;          /* 16px */
    --fs-lg: 1.125rem;      /* 18px */
    --fs-xl: 1.25rem;       /* 20px */
    --fs-2xl: 1.5rem;       /* 24px */
    --fs-3xl: 1.875rem;     /* 30px */

    /* Spacing */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;
    --sp-16: 4rem;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Layout */
    --header-height: 60px;
    --sidebar-width: 260px;
    --preview-width: 420px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Loading Screen --- */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loading-content { text-align: center; }
.loading-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-8);
}
.loading-icon { font-size: 2.5rem; }
.loading-text {
    font-size: var(--fs-3xl);
    font-weight: 800;
    letter-spacing: -0.5px;
}
.accent { color: var(--accent); }
.loading-bar {
    width: 200px;
    height: 3px;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    margin: 0 auto var(--sp-4);
    overflow: hidden;
}
.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #b24bf3);
    border-radius: var(--radius-full);
    animation: loadingFill 1.5s ease forwards;
}
.loading-subtitle {
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
}

/* --- Header --- */
.app-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-5);
    position: relative;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.header-left { display: flex; align-items: center; }
.logo {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-lg);
    font-weight: 800;
    letter-spacing: -0.5px;
    user-select: none;
}
.logo-icon { font-size: 1.4rem; }
.logo-text { color: var(--text-primary); }

.header-center {
    display: flex;
    align-items: center;
    gap: var(--sp-6);
}
.header-center label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 2px;
}
.template-selector,
.accent-picker,
.mode-toggle {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Select wrapper */
.select-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.select-wrapper select {
    appearance: none;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: var(--sp-1) var(--sp-8) var(--sp-1) var(--sp-3);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast);
    outline: none;
}
.select-wrapper select:hover { border-color: var(--border-secondary); }
.select-wrapper select:focus { border-color: var(--accent); }
.select-arrow {
    position: absolute;
    right: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Color picker */
.color-input-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.color-input-wrapper input[type="color"] {
    width: 32px;
    height: 26px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    padding: 2px;
}
.color-input-wrapper input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input-wrapper input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

/* Mode toggle */
.toggle-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: var(--sp-1) var(--sp-2);
    cursor: pointer;
    font-size: var(--fs-sm);
    transition: all var(--transition-fast);
    line-height: 1;
}
.toggle-btn:hover { border-color: var(--border-secondary); background: var(--bg-surface-hover); }

.header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

/* Mobile menu */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--sp-2);
}
.mobile-menu-toggle span {
    width: 18px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    font-weight: 500;
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    line-height: 1.4;
}
.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-primary);
}
.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-secondary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--error-subtle);
    color: var(--error);
    border-color: transparent;
}
.btn-danger:hover {
    background: var(--error);
    color: #fff;
}

.btn-sm {
    font-size: var(--fs-xs);
    padding: var(--sp-1) var(--sp-2);
}

/* --- Main Layout --- */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--preview-width);
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* --- Section Navigator --- */
.section-nav {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-4) var(--sp-3);
}
.nav-header h3 {
    font-size: var(--fs-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    font-weight: 600;
}
.section-count {
    background: var(--accent-subtle);
    color: var(--accent);
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 1px 8px;
    border-radius: var(--radius-full);
}
.section-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--sp-2);
}
.section-list-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: 2px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    user-select: none;
}
.section-list-item:hover {
    background: var(--bg-surface-hover);
}
.section-list-item.active {
    background: var(--accent-subtle);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
}
.section-list-item.active .section-item-name { color: var(--accent); }
.section-list-item .section-item-icon {
    font-size: var(--fs-md);
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.section-list-item .section-item-name {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.section-list-item .section-item-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.section-list-item:hover .section-item-actions,
.section-list-item.active .section-item-actions {
    opacity: 1;
}
.section-action-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    line-height: 1;
}
.section-action-btn:hover {
    background: var(--bg-surface-active);
    color: var(--text-primary);
}
.section-action-btn.delete:hover {
    background: var(--error-subtle);
    color: var(--error);
}

/* Drag handle */
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 2px;
    display: flex;
    align-items: center;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { opacity: 0.5; }

/* Nav Footer */
.nav-footer {
    padding: var(--sp-3);
    border-top: 1px solid var(--border-primary);
    position: relative;
}
.btn-add-section {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    background: var(--bg-surface);
    border: 1px dashed var(--border-secondary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-add-section:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}
.btn-add-section svg { flex-shrink: 0; }

/* Add section dropdown */
.add-section-dropdown {
    position: absolute;
    bottom: calc(100% + var(--sp-2));
    left: var(--sp-3);
    right: var(--sp-3);
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    overflow: hidden;
    max-height: 320px;
}
.add-section-dropdown.open { display: block; }
.dropdown-header {
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-primary);
}
.dropdown-list {
    list-style: none;
    max-height: 260px;
    overflow-y: auto;
    padding: var(--sp-1);
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.dropdown-item:hover { background: var(--bg-surface-hover); }
.dropdown-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.dropdown-item-icon { font-size: var(--fs-md); width: 24px; text-align: center; }
.dropdown-item-info { flex: 1; }
.dropdown-item-name {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-primary);
}
.dropdown-item-desc {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
}

/* --- Form Area --- */
.form-area {
    background: var(--bg-primary);
    overflow-y: auto;
    padding: var(--sp-8);
}
.form-container {
    max-width: 680px;
    margin: 0 auto;
}

/* Welcome State */
.welcome-state {
    text-align: center;
    padding: var(--sp-16) var(--sp-8);
}
.welcome-icon { font-size: 4rem; margin-bottom: var(--sp-6); }
.welcome-state h2 {
    font-size: var(--fs-2xl);
    font-weight: 700;
    margin-bottom: var(--sp-3);
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.welcome-state p {
    color: var(--text-secondary);
    max-width: 440px;
    margin: 0 auto var(--sp-2);
    line-height: 1.7;
}
.welcome-hint {
    font-size: var(--fs-sm);
    color: var(--text-muted) !important;
    margin-top: var(--sp-4) !important;
}

/* Form Content */
.form-content { animation: fadeSlideIn 0.3s ease; }
.form-section-header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--border-primary);
}
.form-section-icon { font-size: 1.5rem; }
.form-section-title-group { flex: 1; }
.form-section-title {
    font-size: var(--fs-xl);
    font-weight: 700;
}
.form-section-desc {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Form Groups */
.form-group {
    margin-bottom: var(--sp-5);
}
.form-label {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}
.form-label .required {
    color: var(--error);
    font-size: var(--fs-xs);
}
.form-hint {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: var(--sp-1);
}

/* Input styles */
.form-input,
.form-textarea,
.form-select {
    width: 100%;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--sp-2) var(--sp-3);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    transition: all var(--transition-fast);
    outline: none;
}
.form-input:hover,
.form-textarea:hover,
.form-select:hover {
    border-color: var(--border-secondary);
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}
.form-textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.6;
}

/* Image upload */
.image-upload-area {
    border: 2px dashed var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}
.image-upload-area:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}
.image-upload-area.has-image {
    padding: 0;
    border-style: solid;
    border-color: var(--border-secondary);
}
.image-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    color: var(--text-tertiary);
}
.upload-placeholder svg { opacity: 0.5; }
.upload-placeholder span { font-size: var(--fs-sm); }
.image-preview-container {
    position: relative;
    display: none;
}
.image-upload-area.has-image .upload-placeholder { display: none; }
.image-upload-area.has-image .image-preview-container { display: block; }
.image-preview-img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-md);
}
.image-remove-btn {
    position: absolute;
    top: var(--sp-2);
    right: var(--sp-2);
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: var(--radius-full);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: var(--fs-md);
    transition: background var(--transition-fast);
}
.image-remove-btn:hover { background: var(--error); }

/* Tags Input */
.tags-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    padding: var(--sp-2);
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    min-height: 42px;
    cursor: text;
    transition: border-color var(--transition-fast);
}
.tags-input-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 2px var(--sp-2) 2px var(--sp-3);
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    font-weight: 500;
    animation: tagPop 0.2s ease;
}
.tag-chip-remove {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: var(--fs-md);
    padding: 0 2px;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
    line-height: 1;
}
.tag-chip-remove:hover { opacity: 1; }
.tags-input {
    flex: 1;
    min-width: 80px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    outline: none;
    padding: 2px var(--sp-1);
}
.tags-input::placeholder { color: var(--text-muted); }

/* Repeater (for multi-entry sections) */
.repeater-container {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}
.repeater-entry {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    position: relative;
    transition: border-color var(--transition-fast);
    animation: fadeSlideIn 0.3s ease;
}
.repeater-entry:hover { border-color: var(--border-secondary); }
.repeater-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border-primary);
}
.repeater-entry-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.repeater-entry-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--sp-1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}
.repeater-entry-remove:hover {
    color: var(--error);
    background: var(--error-subtle);
}
.repeater-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3);
    background: transparent;
    border: 1px dashed var(--border-secondary);
    border-radius: var(--radius-lg);
    color: var(--text-tertiary);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
}
.repeater-add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* Two-column form row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}

/* Custom section name input */
.custom-section-name-group {
    margin-bottom: var(--sp-6);
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--border-primary);
}

/* --- Preview Panel --- */
.preview-panel {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-primary);
}
.preview-header h3 {
    font-size: var(--fs-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    font-weight: 600;
}
.preview-controls { display: flex; gap: var(--sp-1); }
.preview-device {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: var(--sp-1) var(--sp-2);
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}
.preview-device:hover {
    color: var(--text-primary);
    border-color: var(--border-secondary);
}
.preview-device.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: rgba(var(--accent-rgb), 0.3);
}

.preview-frame-wrapper {
    flex: 1;
    padding: var(--sp-3);
    overflow: hidden;
    display: flex;
    justify-content: center;
}
.preview-frame-container {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fff;
    transition: width var(--transition-base);
}
.preview-frame-container.mobile {
    width: 375px;
    margin: 0 auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--border-secondary);
}
.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}
.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}
.modal-fullscreen {
    width: 95vw;
    height: 92vh;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-primary);
}
.modal-header h3 {
    font-size: var(--fs-md);
    font-weight: 600;
}
.modal-header-actions { display: flex; align-items: center; gap: var(--sp-2); }
.modal-close {
    padding: var(--sp-1);
}
.modal-body {
    flex: 1;
    overflow: hidden;
    padding: var(--sp-3);
}
.full-preview-container {
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-base);
}
.full-preview-container.mobile {
    width: 375px;
    margin: 0 auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--border-secondary);
}
.full-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* Export Modal */
.export-modal-content {
    width: 720px;
}
.export-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-4);
    padding: var(--sp-6);
}
.export-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--sp-6) var(--sp-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: inherit;
    font-family: var(--font-sans);
    font-size: inherit;
}
.export-option:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.export-icon {
    font-size: 2.5rem;
    margin-bottom: var(--sp-3);
}
.export-option h4 {
    font-size: var(--fs-base);
    font-weight: 600;
    margin-bottom: var(--sp-2);
}
.export-option p {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    line-height: 1.5;
    margin-bottom: var(--sp-4);
    flex: 1;
}
.export-btn-label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--accent);
    padding: var(--sp-1) var(--sp-3);
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    border-radius: var(--radius-md);
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: var(--sp-6);
    right: var(--sp-6);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    z-index: 5000;
}
.toast {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 400px;
    animation: toastSlideIn 0.3s ease;
    font-size: var(--fs-sm);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--info); }
.toast-icon { font-size: var(--fs-md); }
.toast-message { flex: 1; color: var(--text-secondary); }
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    font-size: var(--fs-md);
    line-height: 1;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .app-layout {
        grid-template-columns: var(--sidebar-width) 1fr;
    }
    .preview-panel { display: none; }
}

@media (max-width: 768px) {
    .app-header { padding: 0 var(--sp-3); }
    .header-center { display: none; }
    .header-right .btn span:not(.btn-icon) { display: none; }
    .mobile-menu-toggle { display: flex; }
    
    .app-layout {
        grid-template-columns: 1fr;
    }
    .section-nav {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        bottom: 0;
        width: 280px;
        z-index: 500;
        transition: left var(--transition-base);
        box-shadow: var(--shadow-lg);
    }
    .section-nav.open { left: 0; }
    
    .form-area { padding: var(--sp-4); }
    .form-row { grid-template-columns: 1fr; }
    
    .export-options { grid-template-columns: 1fr; }
    .modal-content { border-radius: var(--radius-lg); }
}
