:root {
    /* Primary Colors */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-hover: #1d4ed8;
    --primary-shadow: rgb(37 99 235 / 25%);
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --accent: #36cfc9;
    
    /* Surface Colors */
    --surface: #ffffff;
    --surface-muted: #f4f6fb;
    --surface-elevated: #ffffff;
    --background: #f8fafc;
    --secondary-bg: #e2e8f0;
    
    /* Border Colors */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-dark: #cbd5e1;
    
    /* Text Colors */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-inverse: #ffffff;
    
    /* Shadow System */
    --shadow-soft: 0 20px 45px rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.08);
    --shadow-md: 0 4px 12px rgb(15 23 42 / 0.08);
    --shadow-lg: 0 12px 24px rgb(15 23 42 / 0.12);
    --shadow-xl: 0 20px 25px rgb(15 23 42 / 0.1);
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --radius-full: 9999px;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Layout */
    --max-width-reading: 720px;
    --max-width-content: 1200px;
    
    /* Editor Specific */
    --editor-height: 600px;
    --editor-min-height: 400px;
}

/* Tool Wrapper */
.tool-wrapper {
    margin-bottom: 40px;
}

/* Editor Card */
.editor-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.editor-card:hover {
    box-shadow: var(--shadow-lg);
}

/* Editor Header */
.editor-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 24px 32px;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
}

.editor-header-left {
    flex: 1;
    min-width: 200px;
}

.editor-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 4px 0;
}

.editor-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.editor-header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Editor Action Buttons */
.btn-editor-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-editor-action:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-editor-action:active {
    transform: translateY(0);
}

.btn-editor-action.btn-primary-action {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.btn-editor-action.btn-primary-action:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--text-inverse);
    box-shadow: 0 4px 12px var(--primary-shadow);
}

.btn-editor-action i {
    font-size: 14px;
}

/* Editor Container - Split Layout */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 600px;
    height: 600px;
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.editor-wrapper {
    flex: 1;
    position: relative;
    min-height: var(--editor-min-height);
}

.editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.preview-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
}

.preview-header-left {
    flex: 1;
    min-width: 150px;
}

.preview-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 4px 0;
}

.preview-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.preview-controls {
    display: flex;
    align-items: center;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border-dark);
    border-radius: var(--radius-full);
    transition: background 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--surface);
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

/* Preview Wrapper */
.preview-wrapper {
    flex: 1;
    position: relative;
    min-height: var(--editor-min-height);
    padding: 16px;
    background: var(--background);
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* ACE Editor Customization */
.ace_editor {
    
    font-size: 14px;
    line-height: 1.6;
}

.ace_gutter {
    background: var(--surface-muted);
    border-right: 1px solid var(--border);
}

.ace_gutter-active-line {
    background: var(--primary-light);
}

.ace_cursor {
    color: var(--primary);
}

.ace_selection {
    background: var(--primary-light);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .editor-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
    
    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .preview-header {
        padding: 16px 20px;
    }
}

@media (max-width: 767px) {
    .editor-header {
        padding: 20px;
        flex-direction: column;
        align-items: stretch;
    }

    .editor-header-left {
        min-width: 100%;
    }

    .editor-header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .btn-editor-action {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }

    .btn-editor-action span {
        display: none;
    }

    .btn-editor-action {
        padding: 10px;
        justify-content: center;
    }

    .editor-container {
        min-height: auto;
    }

    .editor-wrapper,
    .preview-wrapper {
        min-height: 300px;
    }

    .preview-header {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
    }

    .preview-header-left {
        min-width: 100%;
    }

    .preview-controls {
        width: 100%;
        justify-content: space-between;
    }

    .preview-wrapper {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    :root {
        --editor-height: auto;
        --editor-min-height: 250px;
    }

    .editor-header {
        padding: 16px;
    }

    .editor-title {
        font-size: 18px;
    }

    .preview-title {
        font-size: 16px;
    }

    .editor-wrapper,
    .preview-wrapper {
        min-height: 250px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --surface: #1e293b;
        --surface-muted: #334155;
        --background: #0f172a;
        --border: #475569;
        --border-light: #334155;
        --border-dark: #64748b;
        --text-main: #f1f5f9;
        --text-muted: #94a3b8;
        --text-light: #64748b;
    }
}

