:root {
    --bg-base: #f8fafc;
    --bg-panel: rgba(255, 255, 255, 0.85);
    --bg-input: #ffffff;
    --bg-hover: rgba(139, 92, 246, 0.08);
    /* Derived from primary */

    --border-light: rgba(15, 23, 42, 0.1);
    --border-highlight: rgba(139, 92, 246, 0.3);

    --text-main: #0f172a;
    --text-muted: #64748b;

    --primary: #8B5CF6;
    /* Purple */
    --primary-hover: #7C3AED;
    --accent: #10B981;
    /* Emerald */
    --accent-hover: #059669;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --radius-lg: 16px;
    --radius-md: 8px;
    --radius-sm: 4px;
}

[data-theme="dark"] {
    --bg-base: #0F172A;
    /* Requested dark bg */
    --bg-panel: rgba(30, 41, 59, 0.7);
    --bg-input: #1e293b;
    --bg-hover: rgba(139, 92, 246, 0.15);

    --border-light: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(139, 92, 246, 0.4);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 25px 30px -5px rgba(0, 0, 0, 0.7);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
    /* App feels native */
}

svg {
    display: block;
}

.w-4 {
    width: 1rem;
}

.h-4 {
    height: 1rem;
}

.w-5 {
    width: 1.25rem;
}

.h-5 {
    height: 1.25rem;
}

.w-6 {
    width: 1.5rem;
}

.h-6 {
    height: 1.5rem;
}

.w-16 {
    width: 4rem;
}

.h-16 {
    height: 4rem;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.w-full {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-auto {
    margin-top: auto;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.text-muted {
    color: var(--text-muted);
}

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

.text-sm {
    font-size: 0.875rem;
}

.text-xl {
    font-size: 1.25rem;
}

.font-bold {
    font-weight: 700;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

.opacity-50 {
    opacity: 0.5;
}

/* Buttons & Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

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

.btn-outline {
    background: transparent;
    border-color: var(--border-light);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--border-highlight);
}

/* Glass Panel */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    border-right: 1px solid var(--border-light);
}

.brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.brand h2 {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sidebar-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-section.scrollable {
    overflow-y: auto;
    flex: 1;
    border-bottom: none;
}

.section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

/* Filter Items */
.filter-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    background: transparent;
}

.filter-item:hover {
    background: var(--bg-hover);
}

.filter-item.active {
    background: var(--bg-input);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.filter-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

.filter-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* View Toggles */
.view-toggles {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.25rem;
}

.btn-toggle {
    flex: 1;
    padding: 0.5rem;
    background: transparent;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-toggle:hover {
    color: var(--text-main);
}

.btn-toggle.active {
    background: var(--bg-panel);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .btn-toggle.active {
    background: var(--border-light);
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-base);
    position: relative;
}

.topbar {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    border-bottom: 1px solid var(--border-light);
}

.canvas-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: repeating-conic-gradient(var(--bg-input) 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}

[data-theme="dark"] .canvas-container {
    background: repeating-conic-gradient(rgba(0, 0, 0, 0.2) 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}

.empty-state {
    text-align: center;
}

.view-single {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-split {
    width: 100%;
    height: 100%;
    display: flex;
    gap: 1rem;
}

.split-pane {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.sim-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: var(--shadow-lg);
    transition: filter 0.3s;
}

.pane-label {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 10;
    backdrop-filter: blur(4px);
}

/* SVG Filter Application */
[data-filter="protanopia"] {
    filter: url(#protanopia);
}

[data-filter="protanomaly"] {
    filter: url(#protanomaly);
}

[data-filter="deuteranopia"] {
    filter: url(#deuteranopia);
}

[data-filter="deuteranomaly"] {
    filter: url(#deuteranomaly);
}

[data-filter="tritanopia"] {
    filter: url(#tritanopia);
}

[data-filter="tritanomaly"] {
    filter: url(#tritanomaly);
}

[data-filter="achromatopsia"] {
    filter: url(#achromatopsia);
}

[data-filter="achromatomaly"] {
    filter: url(#achromatomaly);
}

/* Drag and Drop State */
.drag-over {
    border: 2px dashed var(--primary);
    background: rgba(139, 92, 246, 0.05) !important;
}