:root {
    --bg-dark: #0F1219;
    --bg-panel: rgba(25, 30, 40, 0.7);
    --bg-panel-hover: rgba(35, 42, 55, 0.8);

    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;

    --primary: #8B5CF6;
    --primary-hover: #7C3AED;
    --secondary: #A78BFA;
    --accent: #F59E0B;

    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.2);

    --success: #10B981;
    --error: #EF4444;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glass);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: #131722;
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.brand-icon {
    font-size: 1.5rem;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.brand span {
    color: var(--primary);
}

/* Controls */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
}

.color-input-wrapper.sm {
    padding: 4px;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-input-wrapper.sm input[type="color"] {
    width: 28px;
    height: 28px;
}

input[type="text"] {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1rem;
    flex: 1;
    outline: none;
    text-transform: uppercase;
}

.select-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    outline: none;
    cursor: pointer;
}

.select-input option {
    background: var(--bg-dark);
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

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

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

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

/* Saved Palettes */
.saved-palettes-container {
    margin-top: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.saved-palettes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.saved-palette-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.saved-palette-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.palette-swatch-mini {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.palette-hex {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    /* Apply filter dynamically via JS */
}

.section {
    padding: 24px;
}

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

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Toggles */
.mode-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--bg-panel-hover);
    color: var(--text-primary);
}

/* Palette Swatches */
.palette-swatches {
    display: flex;
    height: 120px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    /* Determine background based on mode */
    background: #ffffff;
    transition: background 0.3s;
}

.palette-swatches.dark-mode {
    background: #000000;
}

.swatch {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 12px 8px;
    transition: flex 0.2s;
    cursor: pointer;
}

.swatch:hover {
    flex: 1.5;
}

.swatch-info {
    opacity: 0;
    transition: opacity 0.2s;
    text-align: center;
}

.swatch:hover .swatch-info {
    opacity: 1;
}

.swatch-shade {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.swatch-hex {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.8;
}

/* Grid 2 */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* Contrast Checker */
.contrast-inputs {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 24px;
}

.contrast-result-card {
    border-radius: var(--radius-sm);
    padding: 24px;
    margin-bottom: 24px;
    transition: all 0.3s;
}

.contrast-score {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 16px;
    font-feature-settings: "tnum";
}

.contrast-score::after {
    content: ': 1';
    font-size: 1.5rem;
    font-weight: 600;
    opacity: 0.7;
}

.demo-large {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.demo-normal {
    font-size: 0.9rem;
}

.wcag-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.wcag-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--border);
}

.wcag-badge.pass {
    border-left-color: var(--success);
}

.wcag-badge.fail {
    border-left-color: var(--error);
}

.badge-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-status {
    font-size: 0.8rem;
    font-weight: 700;
}

.pass .badge-status {
    color: var(--success);
}

.fail .badge-status {
    color: var(--error);
}

/* UI Preview */
.ui-preview-container {
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    padding: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    transition: background 0.3s;
}

.preview-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.preview-card h3 {
    margin-bottom: 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #111;
}

.preview-card p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 24px;
}

.preview-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.preview-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    flex: 1;
}

.preview-btn.primary {
    background-color: var(--primary);
    color: white;
}

.preview-btn.secondary {
    background-color: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.preview-stats {
    display: flex;
    gap: 12px;
}

.stat-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.03);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.stat-box .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-box .stat-label {
    font-size: 0.8rem;
    color: #666;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: all;
}

.modal {
    width: 90%;
    max-width: 600px;
    padding: 24px;
}

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

.modal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.modal-body textarea {
    width: 100%;
    height: 200px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: none;
    outline: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--text-primary);
    color: var(--bg-dark);
    padding: 12px 24px;
    border-radius: 100px;
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .main-content {
        height: 65vh;
    }
}