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

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --accent: #14b8a6;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Dark theme - Neomorphism Base */
    --neo-bg: #1e293b;
    /* Slate-800 */
    --neo-shadow-flat: 10px 10px 20px #151d29, -10px -10px 20px #27354d;
    --neo-shadow-inset: inset 6px 6px 12px #151d29, inset -6px -6px 12px #27354d;
    --neo-shadow-btn: 5px 5px 10px #151d29, -5px -5px 10px #27354d;
    --neo-shadow-btn-active: inset 3px 3px 6px #151d29, inset -3px -3px 6px #27354d;

    --bg-primary: var(--neo-bg);
    --bg-secondary: var(--neo-bg);
    --bg-tertiary: #1e293b;
    /* Same base to blend */
    --bg-card: var(--neo-bg);
    --bg-hover: linear-gradient(145deg, #202c3f, #1b2535);

    /* Text */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders - Minimal or removed for soft UI */
    --border: transparent;
    --border-hover: rgba(255, 255, 255, 0.05);

    /* Shadows - Mapped to Neo tokens */
    --shadow-sm: var(--neo-shadow-flat);
    --shadow-md: 15px 15px 30px #151d29, -15px -15px 30px #27354d;
    --shadow-lg: 20px 20px 40px #131a25, -20px -20px 40px #293851;
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.3);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border radius - Softer */
    --radius-sm: 0.75rem;
    --radius-md: 1.25rem;
    --radius-lg: 2rem;

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Background Effects Removed for Neomorphism */
.background-gradient {
    display: none;
}

.grid-overlay {
    display: none;
}

/* Controls Bar (Premium Player Look) */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    gap: var(--spacing-md);
    background: var(--neo-bg);
    border: none;
    border-radius: 100px;
    /* Capsule shape */
    padding: 8px 24px;
    margin: 0 auto 20px auto;
    width: fit-content;
    box-shadow: var(--neo-shadow-flat);
    backdrop-filter: none;
}

/* Controls Overlay */
.controls-overlay {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: rgba(15, 23, 42, 0.85);
    /* Semi-transparent dark background */
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    /* Pill shape */
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    /* Subtle border */
    transition: all 0.3s ease;
}

.controls-overlay:hover {
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.control-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.control-btn.primary {
    background: var(--primary);
    color: white;
    width: 48px;
    height: 48px;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    margin: 0 4px;
    /* Slight spacing for big button */
}

.control-btn.primary:hover {
    background: var(--primary-light);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6);
}

/* Speed Slider Removed */

#speedValue {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--primary-light);
    min-width: 2.5rem;
}

/* Visualization Container Tweaks */
.visualization-container {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    height: 100%;
    /* Fill available space */
    min-height: 400px;
    /* Reduced min-height */
    max-height: 70vh;
    /* Reduced max height */
    box-shadow: var(--shadow-sm);
}

.viz-header {
    height: auto;
    /* Allow growth */
    min-height: 60px;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(15, 23, 42, 0.8);
    /* Darker/More opaque */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.step-info {
    display: flex;
    flex-direction: row;
    /* Horizontal layout */
    justify-content: space-between;
    /* Spread content */
    align-items: center;
    gap: 12px;
    height: 100%;
}

.step-counter {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.step-description {
    font-size: 0.95rem;
    /* Reduced from 1.1rem */
    color: var(--text-primary);
    line-height: 1.3;
    font-weight: 500;
    overflow: visible;
    /* Show all text */
    text-overflow: clip;
    max-width: 100%;
    white-space: normal;
    /* Wrap text */
}

.memory-panel {
    position: absolute;
    top: 80px;
    /* Below the header */
    right: 20px;
    width: 280px;
    height: auto;
    max-height: calc(100% - 120px);
    /* Avoid overlapping bottom controls */
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 10px;
    padding: 16px;
    background: var(--neo-bg);
    backdrop-filter: none;
    border: none;
    border-radius: 20px;
    z-index: 20;
    box-shadow: var(--shadow-lg);
    /* Keeps it floating */
    align-items: stretch;
    padding: 24px;
    gap: 16px;
}

.memory-panel::-webkit-scrollbar {
    width: 4px;
    /* Thinner vertical scrollbar */
    height: 4px;
}

.memory-panel::-webkit-scrollbar-thumb {
    background: transparent;
    box-shadow: var(--neo-shadow-inset);
}

.variable-card {
    background: var(--bg-card);
    border: none;
    border-radius: 16px;
    /* High radius */
    padding: 16px 20px;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: auto;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: var(--neo-shadow-flat);
    /* Flat pop */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.variable-card:hover {
    background: var(--bg-card);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.variable-card.result-card {
    background: rgba(16, 185, 129, 0.15);
    /* Success Green Tint */
    border: 1px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
    order: -1;
    /* Show at top? Or bottom? User didn't specify, but distinct is good. width: 100% helps. */
}

/* Ensure result card text is growing */
.variable-card.result-card .variable-value {
    font-size: 1.2rem;
    color: var(--success);
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.variable-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
    letter-spacing: 0.05em;
    width: 100%;
}

.variable-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 600;
    word-break: break-all;
    /* Prevent overflow */
    line-height: 1.4;
}



.canvas {
    flex: 1;
    width: 100%;
    /* Display block to remove scrollbars caused by inline canvas */
    display: block;
    background: radial-gradient(circle at center, rgba(30, 41, 59, 1) 0%, rgba(15, 23, 42, 1) 100%);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--neo-bg);
    backdrop-filter: none;
    border-bottom: none;
    box-shadow: 5px 5px 10px #151d29;
    /* Sided shadow for header */
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    font-size: 2rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

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

/* Container */
.container {
    display: grid;
    grid-template-columns: auto 1fr;
    /* Sidebar auto size, content fills rest */
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    max-width: 1920px;
    margin: 0 auto;
    min-height: 100vh;
}

/* Navigation Sidebar */
/* Navigation Sidebar */
.navigation-sidebar {
    background: var(--bg-card);
    backdrop-filter: none;
    border: none;
    border-radius: var(--radius-lg);
    height: fit-content;
    max-height: calc(100vh - 120px);
    position: sticky;
    top: 2rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: row;
    /* row for panes */
    overflow: hidden;
    padding: 0;
    transition: all 0.3s ease;
}

/* Problem Info Section */
.problem-info {
    background: var(--bg-card);
    backdrop-filter: none;
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    /* Reduced from lg */
    margin-bottom: var(--spacing-sm);
    /* Reduced from md */
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Reduced from spacing-md */
}

.problem-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

#problemTitle {
    font-size: 1.25rem;
    /* Reduced from 1.75rem */
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.metadata-pills {
    display: flex;
    gap: var(--spacing-xs);
    /* Tighter gap */
    flex-wrap: wrap;
}

.pill {
    font-size: 0.75rem;
    /* Reduced from 0.8rem */
    padding: 4px 10px;
    /* Reduced padding */
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
}

.toggle-desc-txt {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    padding: 0;
    margin-top: 4px;
    /* Reduced from 8px */
    display: inline-block;
    transition: color 0.2s;
}

.toggle-desc-txt:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

#problemDescription {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0;
    font-size: 0.95rem;
    /* Slightly smaller text */
    transition: max-height 0.3s ease;
}

#problemDescription.collapsed {
    max-height: 4.5em;
    /* approx 3 lines */
    overflow: hidden;
    position: relative;
    /* optional fade out effect could go here */
}

/* --- PRIMARY PANE NESTING (Expanded Mode) --- */
.nav-sublist {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border-light);
    display: none;
    /* Collapsed accordion by default */
    flex-direction: column;
    margin-top: 4px;
}

.nav-group.expanded .nav-sublist {
    display: flex;
    /* Expand accordion */
}

/* In COLLAPSED (Cascading) mode, force hide nested lists even if 'expanded' class exists */
.navigation-sidebar.collapsed .nav-sublist {
    display: none !important;
}

.nested-item {
    font-size: 0.9rem;
    padding: 8px 12px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    position: relative;
    font-weight: 500;
}

.nested-item:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nested-item.active {
    color: var(--secondary);
    background: rgba(236, 72, 153, 0.1);
    font-weight: 600;
}

/* --- Nested Problem List (Level 3) --- */
.nav-problem-list {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    margin-top: 4px;
    margin-bottom: 8px;
}

.nav-problem-item {
    font-size: 0.85rem;
    padding: 8px 12px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}

.nav-problem-item:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-problem-item.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    font-weight: 600;
    box-shadow: inset 2px 0 0 0 var(--primary);
}

.problem-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    opacity: 0.6;
    min-width: 3ch;
}

/* Primary Sidebar Pane */
.sidebar-primary {
    display: flex;
    flex-direction: column;
    width: 280px;
    /* Default expanded width */
    padding: var(--spacing-sm) var(--spacing-xs);
    overflow-y: auto;
    transition: width 0.3s ease, padding 0.3s ease;
    border-right: 1px solid transparent;
}

/* Secondary Sidebar Pane (Submenu) - ONLY for Collapsed Mode */
.sidebar-secondary {
    display: flex;
    flex-direction: column;
    width: 0;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-left: 1px solid var(--border);
    transition: width 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    padding: 0;
}

/* EXPANDED MODE: Secondary is HIDDEN. Tertiary is HIDDEN (Problems are nested). */
.navigation-sidebar:not(.collapsed) .sidebar-secondary,
.navigation-sidebar:not(.collapsed) .sidebar-tertiary {
    display: none !important;
}

/* Tertiary Sidebar Pane (Problems) */
.sidebar-tertiary {
    display: flex;
    /* Flex by default, width controls vis */
    flex-direction: column;
    width: 0;
    min-width: 0;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.4);
    border-left: 1px solid var(--border);
    transition: width 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

/* COLLAPSED MODE: Secondary is visible if 'dual-pane' or 'tri-pane' */
.navigation-sidebar.dual-pane .sidebar-secondary,
.navigation-sidebar.tri-pane .sidebar-secondary {
    width: 220px;
    opacity: 1;
}

.navigation-sidebar.tri-pane .sidebar-tertiary {
    width: 280px;
    /* Or flex: 1 */
    flex: 1;
    opacity: 1;
}



.panel-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    /* margin-bottom removed from panel styles, kept padding */
}

/* Ensure panel header content fits */
.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    /* Remove default margins if any */
}

.secondary-header {
    padding: var(--spacing-md) var(--spacing-sm) var(--spacing-sm);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--spacing-sm);
}

/* Sidebar Header */
.sidebar-header {
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 1rem;
    padding-right: 1rem;
}

.sidebar-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.nav-tree {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    flex: 1;
}

.nav-group {
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--spacing-xs);
}

/* Remove border from last child in both panes */
.nav-group:last-child {
    border-bottom: none;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-header:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-header.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* Secondary Navigation Items (Patterns) */
.sidebar-secondary .nav-item {
    margin-left: 0;
    /* Align left in secondary pane */
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}

.nav-item {
    padding: 4px 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(236, 72, 153, 0.1);
    color: var(--secondary);
    border-left: 2px solid var(--secondary);
}

.sidebar-footer {
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-xs);
    border-bottom: 1px solid var(--border);
}

/* Compact Search & Filter Row */
.sidebar-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    height: 36px;
}

.search-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 8px;
    height: 100%;
    transition: var(--transition);
}

.search-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.compact-search-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 100%;
    margin-left: 6px;
    outline: none;
    height: 100%;
}

.filter-toggle-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.filter-toggle-btn:hover,
.filter-toggle-btn.active {
    background: var(--bg-tertiary);
    color: var(--primary);
    border-color: var(--primary);
}

.sidebar-filters {
    padding: 0 var(--spacing-sm);
    gap: 8px;
    margin-bottom: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    max-height: 200px;
    /* enough for 2 selects */
    opacity: 1;
}

.sidebar-filters.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding: 0 var(--spacing-sm);
    /* Keep h padding, reduce v to 0 via other means if needed, or margin handles spacing */
}

.sidebar-select {
    width: 100%;
    padding: 6px 10px;
    height: 32px;
    font-size: 0.8rem;
    /* ... existing styles mostly ok */
}

/* --- Accordion / Tree Navigation --- */
.nav-tree {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.nav-tree-item {
    display: flex;
    flex-direction: column;
}

/* Headers (Topic / Pattern) */
.nav-tree-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: all 0.2s ease;
    border-radius: var(--radius-sm);
    user-select: none;
}

.nav-tree-header:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-tree-header.active {
    color: var(--primary-light);
    font-weight: 500;
}

.topic-header {
    font-weight: 600;
    color: var(--text-primary);
    padding-top: 10px;
    padding-bottom: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-card);
    /* Ensure text doesn't overlap transparently */
    box-shadow: 0 1px 0 var(--border);
    /* Subtle separator */
    margin-bottom: 2px;
}

.pattern-header {
    padding-left: 12px;
}

.tree-icon {
    font-size: 0.65rem;
    margin-right: 8px;
    width: 12px;
    text-align: center;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Children Containers */
.nav-tree-children {
    display: none;
    /* Controlled by JS */
    flex-direction: column;
}

.pattern-list {
    padding-left: 8px;
    /* Indent Patterns */
}

.problem-list {
    padding-left: 20px;
    /* Indent Problems */
    border-left: 1px solid var(--border);
    margin-left: 14px;
    margin-top: 2px;
    margin-bottom: 4px;
}

/* Problem Links */
.nav-tree-link {
    padding: 4px 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-tree-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-tree-link.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    font-weight: 500;
}

/* Sidebar Header (Title + Toggle) */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    /* Removed border from here, moving to filters or leaving separate */
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

/* Search Bar */
.search-container {
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
}

.sidebar-search {
    width: 100%;
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.sidebar-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

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

/* Sidebar Filters (Vertical Stack) */
.sidebar-filters {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border);
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

/* --- Collapsed Sidebar State --- */
/* --- Collapsed Sidebar State (Tri-Pane Logic) --- */
/* 
   State 0: Default (Expanded Primary)
   State 1: Collapsed Primary + Secondary (Dual Pane)
   State 2: Collapsed Primary + Secondary + Tertiary (Tri Pane)
   
   We use classes on .navigation-sidebar: 'dual-pane' and 'tri-pane'.
   For backward compatibility, 'collapsed' -> 'dual-pane'.
*/

/* DUAL PANE MODE (Topic Selected) */
.navigation-sidebar.dual-pane .sidebar-primary,
.navigation-sidebar.tri-pane .sidebar-primary {
    width: 60px;
    /* Icon rail */
    padding: var(--spacing-md) 4px;
    border-right: 1px solid var(--border);
}

/* Hide Primary Labels */
.navigation-sidebar.dual-pane .sidebar-primary .sidebar-title,
.navigation-sidebar.dual-pane .sidebar-primary .search-container,
.navigation-sidebar.dual-pane .sidebar-primary .sidebar-filters,
.navigation-sidebar.dual-pane .sidebar-primary .sidebar-footer,
.navigation-sidebar.dual-pane .sidebar-primary .nav-header span.topic-label,
.navigation-sidebar.tri-pane .sidebar-primary .sidebar-title,
.navigation-sidebar.tri-pane .sidebar-primary .search-container,
.navigation-sidebar.tri-pane .sidebar-primary .sidebar-filters,
.navigation-sidebar.tri-pane .sidebar-primary .sidebar-footer,
.navigation-sidebar.tri-pane .sidebar-primary .nav-header span.topic-label {
    display: none;
}

.navigation-sidebar.dual-pane .sidebar-secondary {
    display: flex;
    width: 100%;
    /* Fill remaining */
    opacity: 1;
}

/* TRI PANE MODE (Pattern Selected) */
.navigation-sidebar.tri-pane .sidebar-secondary {
    display: flex;
    width: 220px;
    /* Fixed width for pattern list in tri-pane */
    flex-shrink: 0;
}

.navigation-sidebar.tri-pane .sidebar-tertiary {
    display: flex;
    flex: 1;
    /* Fill remaining logic */
    width: auto;
    min-width: 280px;
    opacity: 1;
}

/* Center icons in collapsed primary */
.navigation-sidebar.dual-pane .sidebar-primary .sidebar-header,
.navigation-sidebar.tri-pane .sidebar-primary .sidebar-header {
    justify-content: center;
    border-bottom: none;
    margin-bottom: var(--spacing-sm);
}

.navigation-sidebar.dual-pane .sidebar-primary .nav-header,
.navigation-sidebar.tri-pane .sidebar-primary .nav-header {
    justify-content: center;
    padding: 8px 4px;
}

.navigation-sidebar.dual-pane .sidebar-toggle-btn,
.navigation-sidebar.tri-pane .sidebar-toggle-btn {
    transform: rotate(180deg);
}



.pattern-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.pattern-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.pattern-item {
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.pattern-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
    transform: scaleY(0);
    transition: var(--transition);
}

.pattern-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.pattern-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.pattern-item-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

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

.pattern-item-content h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.pattern-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* Problem Panel */
.problem-panel {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    height: fit-content;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    position: sticky;
    top: 2rem;
    box-shadow: var(--shadow-md);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.panel-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.problem-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.sort-select {
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary);
}

.sort-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.problem-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.problem-card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--neo-shadow-flat);
}

.problem-card:hover {
    transform: translateY(-2px);
    background: var(--bg-card);
    /* Keep base color */
    box-shadow: 15px 15px 30px #151d29, -15px -15px 30px #27354d;
    /* Dynamic uplift */
}

/* Active State for Problem Card if needed */
.problem-card:active {
    box-shadow: var(--neo-shadow-inset);
    transform: translateY(0);
}

.problem-item {
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.problem-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.problem-item.active {
    background: rgba(20, 184, 166, 0.15);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(20, 184, 166, 0.2);
}

.problem-item h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.problem-difficulty {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    margin-top: 0.25rem;
}

.problem-difficulty.easy {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.problem-difficulty.medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.problem-difficulty.hard {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* Tag Pills */
.tag-pill {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    margin-right: 4px;
    margin-top: 2px;
}

.tag-pill:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

/* Main Content Area Styling - Handled by Glass Styles at Bottom */

/* Problem Info Header Removed (Duplicates handled in previous block) */
/* If any separate styles are needed, keep them minimal */

/* Visualization Container */
.visualization-container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    /* Padding removed to let inner elements handle spacing */
    min-height: 400px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    /* Ensure rounded corners */
}

.canvas {
    flex: 1;
    /* Fill remaining space */
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-lg);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-sm);
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Step Info */
.step-info {
    /* Removed duplicative border/background if integrated into Viz Container header */
    background: rgba(15, 23, 42, 0.6);
    /* Slightly darker/transparent */
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    /* Reduced padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    /* Fixed small height */
}

.step-number {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--primary-light);
    font-size: 0.9rem;
}

.step-description {
    color: var(--text-secondary);
    font-size: 0.8rem;
    /* Smaller text */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

/* Controls */
.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}



/* Pattern Explanation */
.pattern-explanation {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
}

.pattern-explanation h3 {
    font-size: 1rem;
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

#patternInsights {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9rem;
}

#patternInsights ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#patternInsights li {
    padding: 2px 0;
    padding-left: 12px;
    position: relative;
}

#patternInsights li::before {
    content: '▹';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: bold;
}

/* Array Visualization */
.array-container {
    display: flex;
    gap: 6px;
    /* Reduced gap */
    justify-content: center;
    align-items: flex-end;
    margin: var(--spacing-md) 0;
    padding: var(--spacing-sm);
    min-height: 150px;
    /* Reduced min-height */
}

.array-element {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.array-bar {
    min-width: 40px;
    /* Reduced width */
    min-height: 30px;
    background: var(--bg-tertiary);
    /* Default */
    border: 2px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    /* Rounded top for bar chart */
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    transition: var(--transition);
    z-index: 1;
    box-shadow: var(--shadow-sm);
    font-size: 0.9rem;
}

.array-bar.current {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(79, 70, 229, 0.3));
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    animation: pulse-glow 1s ease-in-out infinite;
}

.array-bar.comparing {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.3), rgba(219, 39, 119, 0.3));
    border-color: var(--secondary);
    box-shadow: 0 0 20px rgba(236, 72, 153, 0.4);
}

.array-bar.target {
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.3), rgba(13, 148, 136, 0.3));
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(20, 184, 166, 0.4);
}

.array-bar.highlighted {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(5, 150, 105, 0.3));
    border-color: var(--success);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.array-bar.swapped {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(217, 119, 6, 0.3));
    border-color: var(--warning);
    animation: swap-animation 0.5s ease;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    }

    50% {
        box-shadow: 0 0 30px rgba(99, 102, 241, 0.6);
    }
}

@keyframes swap-animation {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.array-index {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.pointer {
    position: absolute;
    top: -40px;
    font-size: 2rem;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* Responsive */
@media (max-width: 1400px) {
    .container {
        grid-template-columns: 220px 300px 1fr;
    }
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .filter-sidebar,
    .problem-panel {
        position: static;
        max-height: none;
    }

    .filter-sidebar {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .complexity-panel {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-wrap: wrap;
    }

    .speed-control {
        width: 100%;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid var(--border);
        padding-top: var(--spacing-sm);
        margin-top: var(--spacing-sm);
    }

    .array-bar {
        min-width: 40px;
        min-height: 40px;
        font-size: 0.9rem;
    }
}

/* Memory Visualization */
.memory-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border);
    animation: fadeIn 0.5s ease-out;
}

.variable-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: var(--transition);
}

.variable-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
}

.variable-card.highlight {
    border-color: var(--accent);
    background: rgba(20, 184, 166, 0.1);
    transform: scale(1.05);
}

.variable-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
}

.variable-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.125rem;
    color: var(--text-primary);
    font-weight: 700;
}

/* Context Cards (Reason, Action, etc.) - Stable Layout */
.variable-card.is-context {
    grid-column: span 2;
    /* Make them wider */
    min-height: 80px;
    /* Prevent jumping when text length changes */
    justify-content: center;
    background: rgba(30, 41, 59, 0.5);
    /* Slightly different bg */
    border-color: var(--border-light);
}

.variable-card.is-context .variable-value {
    font-family: 'Inter', sans-serif;
    /* Readable text font */
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: normal;
    /* Allow wrapping */
    text-align: center;
}

/* Regular Variable Cards - Stable Size */
.variable-card:not(.is-context) {
    min-height: 80px;
    justify-content: center;
}

@media (max-width: 768px) {
    .variable-card.is-context {
        grid-column: span 1;
        /* Stack on mobile */
    }
}

.variable-value.changed {
    color: var(--accent);
    animation: flash 0.5s ease;
}

@keyframes flash {
    0% {
        opacity: 0.5;
        color: var(--accent);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Enhanced Pointers */
.pointer {
    position: absolute;
    bottom: 100%;
    /* Position above the element */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse;
    /* Arrow at bottom (pointing down), Label at top */
    margin-bottom: 8px;
    /* High enough */
    align-items: center;
    transition: var(--transition);
    z-index: 10;
}

.pointer-arrow {
    font-size: 1.5rem;
    line-height: 1;
    margin-bottom: 2px;
}

.pointer-label {
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}

/* Specific pointer colors */
.pointer-left .pointer-arrow,
.pointer-left .pointer-label {
    color: var(--accent);
}

.pointer-left .pointer-label {
    background: rgba(20, 184, 166, 0.1);
    border: 1px solid rgba(20, 184, 166, 0.3);
}

.pointer-right .pointer-arrow,
.pointer-right .pointer-label {
    color: var(--secondary);
}

.pointer-right .pointer-label {
    background: rgba(236, 72, 153, 0.1);
    border: 1px solid rgba(236, 72, 153, 0.3);
}

.pointer-mid .pointer-arrow,
.pointer-mid .pointer-label {
    color: var(--warning);
}

.pointer-mid .pointer-label {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.pointer-slow .pointer-arrow,
.pointer-slow .pointer-label {
    color: var(--accent);
}

.pointer-slow .pointer-label {
    background: rgba(20, 184, 166, 0.1);
    border: 1px solid rgba(20, 184, 166, 0.3);
}

.pointer-fast .pointer-arrow,
.pointer-fast .pointer-label {
    color: var(--secondary);
}

.pointer-fast .pointer-label {
    background: rgba(236, 72, 153, 0.1);
    border: 1px solid rgba(236, 72, 153, 0.3);
}

.sidebar-select {
    width: 100%;
    margin-top: 4px;
    /* Reduced from spacing-sm */
    padding: 6px 12px;
    /* Reduced padding */
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    /* Reduced from 0.9rem */
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.sidebar-select:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.sidebar-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Hash Map Visualization Styling */
.hash-map-container {
    margin-top: var(--spacing-lg);
    width: 100%;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    animation: fadeIn 0.3s ease-out;
}

.hash-map-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.hash-map-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    min-height: 60px;
    align-items: center;
}

.map-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    width: 100%;
    text-align: center;
    padding: var(--spacing-sm);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

/* Old Sidebar and Main Content Styles Removed - See Bottom of File for Glass Styles */
/* Neomorphism Sidebar */
.sidebar {
    width: 280px;
    background: var(--neo-bg);
    border: none;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    z-index: 10;
    box-shadow: 10px 0 20px rgba(0, 0, 0, 0.1);
    /* Subtle separation */
}

/* Neomorphism Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* overflow: hidden; Removed to prevent shadow clipping */
    position: relative;
    background: var(--neo-bg);
    padding: 20px;
    /* Add padding for shadows to breathe */
    gap: 20px;
}

.map-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    min-width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.map-item:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.map-key {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.map-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary);
    font-family: 'JetBrains Mono', monospace;
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- UI Refinements (Metadata & Visibility) --- */

/* 1. Header & Metadata Pills */
.problem-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.problem-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.problem-header-row h2 {
    margin-bottom: 0;
    /* Override previous margin */
}

.metadata-pills {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.pill {
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    /* Slight glass */
    border: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
    transition: var(--transition);
}

.pill:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}

/* Specific pill colors can use style attribute or classes if needed, 
   but simplistic glass look is often more premium. */

/* Drill-Down Sidebar Styles */
.nav-back-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.nav-back-header:hover {
    color: var(--primary-light);
    background: rgba(255, 255, 255, 0.03);
}

.back-arrow {
    font-size: 1.2rem;
    line-height: 1;
}

.nav-section-title {
    padding: 16px 16px 8px 16px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.drill-item {
    padding: 12px 16px;
    margin: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.drill-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
    transform: translateX(2px);
    color: var(--text-primary);
}

.drill-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: var(--primary-light);
}

/* 2. Collapsible Description */
.problem-description-container {
    position: relative;
}

#problemDescription {
    margin-bottom: 0.5rem;
    transition: max-height 0.3s ease;
}

#problemDescription.collapsed {
    max-height: 3.6em;
    /* Show approx 2 lines */
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

.toggle-desc-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-top: 4px;
}

.toggle-desc-btn:hover {
    text-decoration: underline;
}

/* 3. Improved Visibility for Sidebar Selects */
.sidebar-select {
    background-color: rgba(30, 41, 59, 0.8);
    /* Darker, more opaque background */
    border: 1px solid rgba(148, 163, 184, 0.3);
    /* Higher contrast border */
    color: var(--text-primary);
    /* Brighter text */
    /* Update SVG arrow to be white/lighter: %23fff instead of %23888 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.sidebar-select:hover {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Custom Input Editor */
.input-editor-section {
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(8px);
    display: none;
    /* Toggled via JS */
    animation: fadeIn 0.3s ease;
}

.editor-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.editor-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-fast);
    font-family: inherit;
    font-weight: 500;
}

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

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

.editor-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border-color: var(--border);
}

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

.code-input {
    width: 100%;
    min-height: 2.5rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: #a5b4fc;
    /* Indigo-200 for code */
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    transition: var(--transition-fast);
}

.code-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.input-error-msg {
    margin-top: 0.5rem;
    color: var(--error);
    font-size: 0.85rem;
    display: none;
}