:root {
    --clr-bg: #0F1115;
    --clr-surface: #1C1F26;
    --clr-surface-hover: #262A33;
    --clr-border: #2D323E;
    
    --clr-primary: #7C3AED;      /* Violet */
    --clr-primary-hover: #6D28D9;
    --clr-accent: #10B981;       /* Emerald */
    --clr-text-main: #F3F4F6;
    --clr-text-muted: #9CA3AF;
    
    --clr-info: #3B82F6;
    --clr-success: #10B981;
    --clr-warning: #F59E0B;
    --clr-danger: #EF4444;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--clr-bg);
    color: var(--clr-text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

.sidebar {
    width: 360px;
    height: 100%;
    padding: 2rem;
    overflow-y: auto;
    border-right: 1px solid var(--clr-border);
    flex-shrink: 0;
}

.content-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    height: 100vh;
    overflow: hidden;
}

/* Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 0.5rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.mt-3 { margin-top: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-8 { padding-top: 2rem; }
.pb-8 { padding-bottom: 2rem; }
.p-4 { padding: 1rem; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.flex-1 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--clr-text-muted); }
.mono { font-family: var(--font-mono); font-size: 0.85rem; }
.resize-y { resize: vertical; min-height: 120px; }

/* Components */
.glass-panel {
    background: var(--clr-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--clr-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--clr-primary);
}
.brand h1 { font-size: 1.5rem; font-weight: 700; color: var(--clr-text-main); }
.subtitle { font-size: 0.85rem; }

/* Forms */
.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--clr-text-muted);
}

.input-field, .input-select {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--clr-border);
    color: var(--clr-text-main);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    transition: var(--transition);
}
.input-field:focus, .input-select:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.cb-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.cb-label input { accent-color: var(--clr-primary); }

/* Switch Toggle */
.toggle-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.1);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--clr-border);
}
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--clr-border); transition: .4s;
}
.slider:before {
    position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px;
    background-color: white; transition: .4s;
}
input:checked + .slider { background-color: var(--clr-primary); }
input:focus + .slider { box-shadow: 0 0 1px var(--clr-primary); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }

/* Buttons */
.btn {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: inherit;
}
.btn-primary { background: var(--clr-primary); color: white; }
.btn-primary:hover { background: var(--clr-primary-hover); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--clr-border); color: var(--clr-text-main); }
.btn-outline:hover { background: var(--clr-surface-hover); border-color: var(--clr-text-muted); }
.btn-icon { padding: 0.5rem; background: var(--clr-surface-hover); color: var(--clr-text-muted); border: 1px solid var(--clr-border); }
.btn-icon:hover { color: var(--clr-text-main); border-color: var(--clr-primary); }

/* Main Area Elements */
.stats-pills { display: flex; gap: 0.5rem; }
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}
.badge-info { background: rgba(59, 130, 246, 0.1); color: var(--clr-info); border: 1px solid rgba(59, 130, 246, 0.2); }
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--clr-success); border: 1px solid rgba(16, 185, 129, 0.2); }

.tab-group {
    display: flex;
    background: rgba(0,0,0,0.3);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--clr-border);
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--clr-text-muted);
    padding: 0.35rem 1rem;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}
.tab-btn.active { background: var(--clr-surface); color: var(--clr-text-main); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.tab-btn:hover:not(.active) { color: var(--clr-text-main); }

/* Output Container */
.output-actions { display: flex; align-items: center; gap: 0.5rem; }

.output-container {
    flex-grow: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.view-pane {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#output-md, #output-html {
    border: none;
    background: transparent;
    padding: 1.5rem;
    resize: none;
    line-height: 1.6;
}

/* Rich Preview Layer Styling */
.preview-layer { padding: 2rem; }
.preview-layer h1 { margin-bottom: 0.5rem; font-size: 1.8rem; }
.preview-layer h2 { margin-top: 2rem; margin-bottom: 1rem; color: var(--clr-primary); font-size: 1.25rem; font-weight: 600; border-bottom: 1px solid var(--clr-border); padding-bottom: 0.5rem; }
.preview-layer h3 { margin-top: 1.5rem; font-size: 1.1rem; color: var(--clr-text-muted); }
.preview-layer ul { list-style: none; padding-left: 0; }
.preview-layer li { margin-bottom: 0.5rem; position: relative; padding-left: 1.5rem; }
.preview-layer li::before { content: "•"; position: absolute; left: 0; color: var(--clr-primary); font-size: 1.2rem; line-height: 1; top: 0.1rem; }
.preview-layer code { background: rgba(255,255,255,0.05); padding: 0.15rem 0.35rem; border-radius: 4px; font-family: var(--font-mono); font-size: 0.85em; color: var(--clr-accent); }
.preview-layer a { color: var(--clr-info); text-decoration: none; }
.preview-layer a:hover { text-decoration: underline; }

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--clr-success);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 1000;
}

@media (max-width: 900px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--clr-border); max-height: 40vh; }
    .content-area { height: 60vh; }
}
