/**
 * CSS Custom Properties (Variables)
 * ================================
 * Design tokens for colors, spacing, shadows, and typography.
 * These variables ensure consistency throughout the application.
 */

:root {
    /* Primary Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    
    /* Secondary & Accent Colors */
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --teal: #14b8a6;
    
    /* Gray Scale */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Layout */
    --navbar-height: 64px;
    --sidebar-width: 380px;
    --border-radius: 8px;
    
    /* Responsive Breakpoints (for reference in media queries) */
    /* --breakpoint-sm: 640px;   Small tablets */
    /* --breakpoint-md: 768px;   Medium tablets */
    /* --breakpoint-lg: 1024px;  Large tablets / small laptops */
    /* --breakpoint-xl: 1280px;  Desktops */
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/**
 * Base Reset & Typography
 * =======================
 * Foundational styles for the application.
 */

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    overflow: hidden;
    background: var(--gray-100);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-muted {
    font-size: 11px;
    color: var(--gray-400);
}

/**
 * Navbar Styles
 * =============
 * Main navigation bar at the top of the application.
 */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
    max-width: 100%;
}

/* Navbar Left Section */
.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.brand-subtitle {
    font-size: 10px;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.navbar-divider {
    width: 1px;
    height: 32px;
    background: var(--gray-700);
}

/* File Section */
.file-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--gray-700);
    color: var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--gray-600);
}

.file-btn:hover {
    background: var(--gray-600);
    border-color: var(--gray-500);
}

.file-btn-export {
    background: var(--primary);
    border-color: var(--primary-dark);
    color: white;
}

.file-btn-export:hover {
    background: var(--primary-dark);
    border-color: var(--primary);
}

.file-name-display {
    font-size: 12px;
    color: var(--gray-400);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hidden-file-input {
    display: none;
}

/* Connect Button */
.connect-btn {
    position: relative;
}

.connect-btn.connected {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
    color: var(--success);
}

.connect-btn.connected:hover {
    background: rgba(16, 185, 129, 0.25);
    border-color: var(--success);
}

.navbar-connection-status {
    display: flex;
    align-items: center;
    margin-right: 2px;
}

.navbar-connection-status .status-dot {
    font-size: 8px;
}

.navbar-connection-status .status-dot.connected {
    color: var(--success);
}

.navbar-connection-status .status-dot.disconnected {
    color: var(--danger);
}

/* Navbar Center - Navigation */
.navbar-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
}

.nav-group-label {
    font-size: 9px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.nav-group-buttons {
    display: flex;
    gap: 4px;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    background: transparent;
    color: var(--gray-400);
    border: none;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 64px;
}

.nav-btn i {
    font-size: 16px;
}

.nav-btn:hover {
    background: var(--gray-700);
    color: var(--gray-200);
}

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

.nav-btn-ai {
    color: var(--purple);
}

.nav-btn-ai:hover {
    background: rgba(139, 92, 246, 0.2);
    color: var(--primary-light);
}

.nav-btn-ai.active {
    background: var(--purple);
    color: white;
}

/* Navbar Right */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

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

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

.action-btn-help {
    background: transparent;
    color: var(--gray-400);
    padding: 8px 10px;
}

.action-btn-help:hover {
    background: var(--gray-700);
    color: white;
}

/* ==========================================================================
   Hamburger Menu Button (Mobile/Tablet)
   ========================================================================== */

.navbar-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: var(--gray-700);
    border: 1px solid var(--gray-600);
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.15s;
    margin-left: 8px;
}

.navbar-hamburger:hover {
    background: var(--gray-600);
    border-color: var(--gray-500);
}

.navbar-hamburger.active {
    background: var(--primary);
    border-color: var(--primary-dark);
}

.navbar-hamburger span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--gray-200);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.navbar-hamburger.active span {
    background: white;
}

.navbar-hamburger span:nth-child(1) {
    margin-bottom: 5px;
}

.navbar-hamburger span:nth-child(3) {
    margin-top: 5px;
}

/* Hamburger animation when menu is open */
.navbar-hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.navbar-hamburger.active span:nth-child(2) {
    opacity: 0;
}

.navbar-hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ==========================================================================
   Mobile Navigation Menu (Dropdown)
   ========================================================================== */

.navbar-mobile-menu {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: linear-gradient(180deg, var(--gray-800) 0%, var(--gray-900) 100%);
    border-bottom: 1px solid var(--gray-700);
    box-shadow: var(--shadow-lg);
    z-index: 99;
    max-height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    padding: 8px 0;
}

.navbar-mobile-menu.open {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.navbar-mobile-menu .nav-group {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-700);
}

.navbar-mobile-menu .nav-group:last-child {
    border-bottom: none;
}

.navbar-mobile-menu .nav-group-label {
    margin-bottom: 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
}

.navbar-mobile-menu .nav-group-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.navbar-mobile-menu .nav-btn {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    min-width: calc(50% - 5px);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    background: var(--gray-700);
    border: 1px solid var(--gray-600);
}

.navbar-mobile-menu .nav-btn:hover {
    background: var(--gray-600);
    border-color: var(--gray-500);
}

.navbar-mobile-menu .nav-btn.active {
    background: var(--primary);
    border-color: var(--primary-dark);
}

.navbar-mobile-menu .nav-btn i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.navbar-mobile-menu .nav-btn span {
    flex: 1;
}

/* ==========================================================================
   Sidebar Toggle Button - Always visible to allow hiding sidebar
   ========================================================================== */

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--gray-700);
    border: 1px solid var(--gray-600);
    border-radius: 6px;
    color: var(--gray-300);
    cursor: pointer;
    transition: all 0.15s;
    margin-left: 8px;
}

.sidebar-toggle:hover {
    background: var(--gray-600);
    color: white;
}

.sidebar-toggle.sidebar-hidden i {
    transform: rotate(180deg);
}

/* ==========================================================================
   Responsive Styles - Tablet (< 1024px)
   ========================================================================== */

@media (max-width: 1024px) {
    .navbar-hamburger {
        display: flex;
    }
    
    .navbar-center {
        display: none;
    }
    
    .navbar-left {
        flex: 1;
    }
    
    /* Hide text in file buttons on tablet, keep icons larger */
    .file-btn span {
        display: none;
    }
    
    .file-btn {
        padding: 10px 12px;
        font-size: 16px;
    }
    
    .file-btn i {
        font-size: 16px;
    }
    
    /* Hide brand subtitle */
    .brand-subtitle {
        display: none;
    }
    
    .file-name-display {
        max-width: 100px;
        font-size: 11px;
    }
    
    /* Larger sidebar toggle for touch */
    .sidebar-toggle {
        width: 40px;
        height: 40px;
    }
    
    .sidebar-toggle i {
        font-size: 16px;
    }
    
    /* Larger help button for touch */
    .action-btn-help {
        padding: 10px 12px;
        font-size: 16px;
    }
}

/* ==========================================================================
   Responsive Styles - Small Tablet / Large Phone (< 768px)
   ========================================================================== */

@media (max-width: 768px) {
    .navbar-container {
        padding: 0 12px;
    }
    
    .navbar-left {
        gap: 8px;
    }
    
    .navbar-divider {
        display: none;
    }
    
    .file-section {
        gap: 8px;
    }
    
    /* Larger touch targets for file buttons */
    .file-btn {
        padding: 12px 14px;
        font-size: 18px;
        border-radius: 8px;
    }
    
    /* Hide file name on small screens */
    .file-name-display {
        display: none;
    }
    
    .brand-text {
        display: none;
    }
    
    .brand-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        border-radius: 8px;
    }
    
    /* Larger navbar right buttons */
    .sidebar-toggle,
    .navbar-hamburger {
        width: 44px;
        height: 44px;
    }
    
    .action-btn-help {
        padding: 12px 14px;
        font-size: 18px;
    }
}

/**
 * Sidebar (Side Menu) Styles
 * ==========================
 * Right-side panel container and resize handle.
 */

.side-menu {
    position: fixed;
    top: var(--navbar-height);
    right: 0;
    width: var(--sidebar-width);
    min-width: 320px;
    max-width: 500px;
    height: calc(100vh - var(--navbar-height));
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 50;
    border-left: 1px solid var(--gray-200);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Sidebar hidden state */
.side-menu.sidebar-collapsed {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

.side-menu-resize-handle {
    position: absolute;
    left: -3px;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    z-index: 51;
}

.side-menu-resize-handle::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    background: var(--gray-300);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.side-menu-resize-handle:hover::before,
.side-menu-resize-handle.dragging::before {
    opacity: 1;
    background: var(--primary);
}

/* ==========================================================================
   Floating Sidebar Toggle Button (visible when sidebar is hidden)
   ========================================================================== */

.sidebar-show-btn {
    position: fixed;
    top: calc(var(--navbar-height) + 16px);
    right: 16px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    color: var(--gray-600);
    cursor: pointer;
    z-index: 49;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.sidebar-show-btn:hover {
    background: white;
    color: var(--primary);
    transform: scale(1.05);
}

/* Show the floating button when sidebar is collapsed */
.sidebar-show-btn.visible {
    display: flex;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media (max-width: 1024px) {
    .side-menu {
        width: 340px;
        min-width: 300px;
    }
}

@media (max-width: 768px) {
    .side-menu {
        width: 100%;
        max-width: 100%;
        min-width: 100%;
    }
    
    /* Hide resize handle on mobile - full width sidebar */
    .side-menu-resize-handle {
        display: none;
    }
}

/**
 * Canvas Container Styles
 * =======================
 * Main 3D viewport area and cursor states.
 * 
 * By default, canvas reserves space for sidebar so the 3D object
 * is centered in the available area. When sidebar is collapsed,
 * canvas expands to fill the entire viewport.
 */

.canvas-container {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: var(--sidebar-width);
    bottom: 0;
    z-index: 1;
    transition: right 0.3s ease;
}

/* Full-screen canvas when sidebar is collapsed */
.canvas-container.canvas-fullscreen {
    right: 0;
}

.canvas-container canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Cursor States */
.view-cursor {
    cursor: default;
}

.draw-cursor {
    cursor: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48Y2lyY2xlIGN4PSIxMCIgY3k9IjEwIiByPSI1IiBzdHJva2U9Im9yYW5nZSIgc3Ryb2tlLXdpZHRoPSI1Ii8+PC9zdmc+), auto;
}

.erase-cursor {
    cursor: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48Y2lyY2xlIGN4PSIxMCIgY3k9IjEwIiByPSI1IiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjUiLz48L3N2Zz4=), auto;
}

/* Mode Indicator */
.mode-indicator {
    --mode-color: #6366f1;
    position: fixed;
    bottom: 24px;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--mode-color);
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--mode-color);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    z-index: 50;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.mode-indicator:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
}

.mode-indicator:active {
    transform: scale(0.98);
}

.mode-indicator i {
    font-size: 14px;
}

/* Transform Mode Indicator (Rotate/Move) */
.transform-mode-indicator {
    --transform-color: #0ea5e9;
    position: fixed;
    bottom: 24px;
    left: 140px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--transform-color);
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--transform-color);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    z-index: 50;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
}

.transform-mode-indicator.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.transform-mode-indicator:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
}

.transform-mode-indicator.visible:hover {
    transform: scale(1.05);
}

.transform-mode-indicator:active {
    transform: scale(0.98);
}

.transform-mode-indicator i {
    font-size: 14px;
}

.transform-mode-indicator.move-mode {
    --transform-color: #f59e0b;
}

/* Erase Toggle Indicator (Draw/Erase toggle in drawing modes) */
.erase-toggle-indicator {
    --erase-color: #ef4444;
    position: fixed;
    bottom: 24px;
    left: 140px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--erase-color);
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--erase-color);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    z-index: 50;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
}

.erase-toggle-indicator.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.erase-toggle-indicator:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
}

.erase-toggle-indicator.visible:hover {
    transform: scale(1.05);
}

.erase-toggle-indicator:active {
    transform: scale(0.98);
}

.erase-toggle-indicator i {
    font-size: 14px;
}

.erase-toggle-indicator .switch-arrow {
    font-size: 10px;
    opacity: 0.6;
    margin-right: 4px;
}

/* Draw mode variants for the erase toggle */
.erase-toggle-indicator.draw-mode {
    --erase-color: #f59e0b;
}

.erase-toggle-indicator.ridge-mode {
    --erase-color: #14b8a6;
}

.erase-toggle-indicator.lines-mode {
    --erase-color: #8b5cf6;
}

/* Floating Controls - centered in the canvas area */
.floating-controls {
    position: fixed;
    bottom: 24px;
    left: calc((100vw - var(--sidebar-width)) / 2);
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 50;
    transition: left 0.3s ease;
}

/* Center floating controls when sidebar is collapsed */
body.sidebar-collapsed .floating-controls {
    left: 50%;
}

.floating-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-600);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
}

.floating-btn:hover:not(:disabled) {
    background: white;
    color: var(--primary);
    transform: scale(1.1);
}

.floating-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.floating-action-btn {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-action-btn:not(:disabled):hover {
    transform: scale(1.1);
}

.floating-action-btn:not(:disabled):active {
    transform: scale(0.95);
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media (max-width: 1024px) {
    .canvas-container {
        right: 340px;
    }
    
    .canvas-container.canvas-fullscreen {
        right: 0;
    }
    
    .floating-controls {
        left: calc((100vw - 340px) / 2);
    }
    
    body.sidebar-collapsed .floating-controls {
        left: 50%;
    }
}

@media (max-width: 768px) {
    /* On mobile, canvas is always full width (sidebar overlays it) */
    .canvas-container {
        right: 0;
    }
    
    .floating-controls {
        left: 50%;
    }
    
    /* Adjust mode indicators for mobile */
    .mode-indicator {
        left: 16px;
        bottom: 16px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .transform-mode-indicator {
        left: 120px;
        bottom: 16px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .erase-toggle-indicator {
        left: 120px;
        bottom: 16px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .floating-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
}

/* ==========================================================================
   Dual View Mode
   ========================================================================== */

/* Dual view divider - vertical line separating views */
.dual-view-divider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 10%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0.3) 90%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 100;
    transform: translateX(-50%);
}

/* Single-view Annotation Label */
.annotation-label {
    position: absolute;
    top: 16px;
    left: 16px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    border-left: 3px solid #6366f1;
    color: white;
    font-size: 13px;
    font-weight: 600;
    z-index: 100;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.annotation-label:hover {
    transform: scale(1.05);
    background: rgba(0, 0, 0, 0.75);
}

.annotation-label i {
    font-size: 12px;
    opacity: 0.8;
}

.annotation-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hide annotation label when dual view is active */
.canvas-container.dual-view-active .annotation-label {
    display: none;
}

/* View labels */
.dual-view-label {
    position: absolute;
    top: 16px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    z-index: 100;
    pointer-events: none;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dual-view-label-left {
    left: 16px;
    border-left: 3px solid #10b981; /* Green for GT */
}

.dual-view-label-right {
    right: calc(var(--sidebar-width) + 16px);
    border-left: 3px solid #8b5cf6; /* Purple for Pred */
}

/* Adjust right label when sidebar is collapsed */
body.sidebar-collapsed .dual-view-label-right {
    right: 16px;
}

/* Full-screen canvas adjustment for dual view labels */
.canvas-container.canvas-fullscreen .dual-view-label-right {
    right: 16px;
}

/* Hide mode indicator in dual view to avoid clutter */
.canvas-container.dual-view-active .mode-indicator {
    opacity: 0.7;
}

/* Adjust floating controls in dual view */
.canvas-container.dual-view-active ~ .floating-controls {
    left: calc((100vw - var(--sidebar-width)) / 4);
}

body.sidebar-collapsed .canvas-container.dual-view-active ~ .floating-controls {
    left: 25%;
}

/* Dual view color coding for labels */
.dual-view-label[data-view="gt"] {
    border-left-color: #10b981;
}

.dual-view-label[data-view="pred"] {
    border-left-color: #8b5cf6;
}

.dual-view-label[data-view="matched"] {
    border-left-color: #3b82f6;
}

.dual-view-label[data-view="overseg"] {
    border-left-color: #f97316;
}

.dual-view-label[data-view="underseg"] {
    border-left-color: #eab308;
}

.dual-view-label[data-view="missingGt"] {
    border-left-color: #ef4444;
}

.dual-view-label[data-view="missingPred"] {
    border-left-color: #ec4899;
}

.dual-view-label[data-view="all"] {
    border-left-color: #6366f1;
}

/* Clickable view labels for general mode */
.dual-view-label-btn {
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dual-view-label-btn:hover {
    transform: scale(1.05);
    background: rgba(0, 0, 0, 0.75);
}

.dual-view-label-btn i {
    font-size: 12px;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.dual-view-label-btn.active {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.2);
}

.dual-view-label-btn.active i {
    color: #10b981;
    opacity: 1;
}

/* General mode specific styling */
.canvas-container.dual-view-general .dual-view-label-left {
    border-left-color: #6366f1;
}

.canvas-container.dual-view-general .dual-view-label-right {
    border-left-color: #8b5cf6;
}

.canvas-container.dual-view-general .dual-view-label-btn.active {
    border-left-color: #10b981;
}

/* Responsive adjustments for dual view */
@media (max-width: 1024px) {
    .dual-view-label-right {
        right: calc(340px + 16px);
    }
}

@media (max-width: 768px) {
    .dual-view-label {
        font-size: 11px;
        padding: 6px 12px;
    }
    
    .dual-view-label-right {
        right: 16px;
    }
    
    .dual-view-label-btn i {
        font-size: 10px;
    }
}

/**
 * Panel Styles
 * ============
 * Common styles for all sidebar panels.
 */

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
}

.panel.hidden {
    display: none;
}

/* Panel Header */
.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.panel-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.panel-header-icon.annotation-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.panel-header-icon.history-icon {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--gray-600) 100%);
}

.panel-header-icon.ai-icon {
    background: linear-gradient(135deg, var(--purple) 0%, #7c3aed 100%);
}

.panel-header-icon.metadata-icon {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.panel-header-icon.eval-icon {
    background: linear-gradient(135deg, var(--teal) 0%, #0d9488 100%);
}

.panel-header-icon.settings-icon {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.panel-header-icon.cloud-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.panel-header-text h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    border: none;
    padding: 0;
}

.panel-subtitle {
    font-size: 12px;
    color: var(--gray-500);
}

/* Panel Content */
.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Panel Sections */
.panel-section {
    margin-bottom: 16px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.panel-section.flex-grow {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
}

.section-header i {
    color: var(--primary);
    font-size: 12px;
}

.section-header .btn-icon {
    margin-left: auto;
}

.section-content {
    padding: 14px;
}

.section-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 500;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Quick Tips */
.quick-tips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    border: 1px solid var(--gray-200);
}

.tip-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--gray-600);
}

.tip-item i {
    color: var(--primary);
    font-size: 10px;
}

.tip-item kbd {
    padding: 2px 6px;
    background: var(--gray-200);
    border-radius: 4px;
    font-size: 10px;
    font-family: monospace;
}

/* Info List */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--gray-600);
}

.info-item i {
    width: 16px;
    color: var(--primary);
    text-align: center;
}

/* Empty States */
.results-empty,
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.results-empty {
    padding: 20px;
    color: var(--gray-400);
}

.results-empty i,
.empty-state i {
    font-size: 32px;
    color: var(--gray-300);
    margin-bottom: 12px;
}

.results-empty i {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.results-empty p,
.empty-state p {
    margin: 0;
    font-size: 13px;
}

.results-empty p {
    font-size: 12px;
}

/**
 * Button Styles
 * =============
 * All button variants used throughout the application.
 */

/* Base Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
}

/* Primary Button */
.btn-primary {
    background: var(--primary);
    color: white;
}

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

/* Secondary Button */
.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
}

/* Button Group Vertical */
.btn-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Danger Button */
.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Outline Danger */
.btn-outline-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
}

/* Warning Button */
.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

/* AI Button */
.btn-ai {
    background: linear-gradient(135deg, var(--purple) 0%, #7c3aed 100%);
    color: white;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

/* Evaluation Button */
.btn-eval {
    background: linear-gradient(135deg, var(--teal) 0%, #0d9488 100%);
    color: white;
}

.btn-eval:hover:not(:disabled) {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
}

.btn-eval:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Large Button */
.btn-lg {
    padding: 14px 20px;
    font-size: 14px;
}

/* Full Width Button */
.btn-full {
    width: 100%;
}

/* Icon Button */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--gray-500);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.btn-icon-danger:hover {
    background: #fee2e2;
    color: var(--danger);
}

.btn-icon-sm {
    width: 24px;
    height: 24px;
    font-size: 11px;
}

/* Icon Button Standalone */
.icon-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.icon-btn:hover .fa-trash {
    color: var(--danger);
}

.icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Undo/Redo Buttons */
.btn-undo,
.btn-redo {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background: white;
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-undo:hover:not(:disabled),
.btn-redo:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-undo:disabled,
.btn-redo:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Mode Toggle Buttons */
.mode-btn-group {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--gray-100);
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-500);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.mode-btn i {
    font-size: 18px;
}

.mode-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.mode-btn.active {
    background: white;
    box-shadow: var(--shadow-sm);
}

.mode-btn.view-mode.active {
    color: var(--primary);
}

.mode-btn.draw-mode.active {
    color: var(--warning);
}

.mode-btn.erase-mode.active {
    color: var(--danger);
}

.mode-btn.arrow-mode.active {
    color: var(--teal);
}

/* Annotation Action Buttons */
.annotation-actions {
    display: flex;
    gap: 8px;
}

.action-btn-fill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.fill-all-btn {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

.fill-all-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.clear-btn {
    background: var(--gray-100);
    color: var(--gray-700);
}

.clear-btn:hover {
    background: var(--gray-200);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: 0.2s;
    border-radius: 22px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/**
 * Form Styles
 * ===========
 * Input fields, selects, checkboxes, and other form controls.
 */

/* Control Row */
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.control-row label {
    font-size: 12px;
    color: var(--gray-600);
    font-weight: 500;
}

/* Select */
.control-select {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 12px;
    background: white;
    color: var(--gray-700);
    cursor: pointer;
    min-width: 140px;
}

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

/* Color Input */
.color-input {
    width: 36px;
    height: 28px;
    padding: 2px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-input::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.mini-color-picker {
    width: 24px;
    height: 20px;
    padding: 0;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    cursor: pointer;
}

/* Text Input */
.text-input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 12px;
    background: white;
    color: var(--gray-700);
    transition: all 0.15s;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Number Input */
.number-input {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 12px;
    text-align: right;
}

/* Checkbox Control */
.checkbox-control {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-control input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Config Container */
.config-container {
    max-height: 200px;
    overflow-y: auto;
}

#configContainer {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

#configContainer::-webkit-scrollbar {
    width: 6px;
}

#configContainer::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#configContainer::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.input-group input {
    flex: 1;
}

/* Auto-Segmentation Toggle */
.auto-seg-toggle-container {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.auto-seg-toggle-container input {
    opacity: 0;
    width: 0;
    height: 0;
}

.auto-seg-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: 0.2s;
    border-radius: 20px;
}

.auto-seg-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.auto-seg-slider:after {
    display: none;
}

.auto-seg-toggle-container input:checked + .auto-seg-slider {
    background-color: var(--primary);
}

.auto-seg-toggle-container input:checked + .auto-seg-slider:before {
    transform: translateX(16px);
}

.auto-seg-slider.auto-seg-round {
    border-radius: 20px;
}

.auto-seg-slider.auto-seg-round:before {
    border-radius: 50%;
}

.auto-seg-toggle-container.small-toggle {
    width: 36px;
    height: 20px;
}

.auto-seg-toggle-container.small-toggle .auto-seg-slider:before {
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
}

.auto-seg-toggle-container.small-toggle input:checked + .auto-seg-slider:before {
    transform: translateX(16px);
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: 6px;
    font-size: 13px;
    color: var(--gray-600);
}

.status-dot {
    font-size: 8px;
}

.status-dot.disconnected {
    color: var(--danger);
}

.status-dot.connected {
    color: var(--success);
}

.status-dot.connecting {
    color: var(--warning);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Help Text */
.help-text {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 8px;
}

/* Toggle Rows */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.toggle-row span {
    font-size: 12px;
    color: var(--gray-700);
}

/* Toggle Switch - Enhanced */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: 0.2s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* Color Controls */
.color-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.color-control span {
    font-size: 12px;
    color: var(--gray-600);
}

.color-picker {
    width: 36px;
    height: 28px;
    padding: 0;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    background: none;
}

.color-picker:hover {
    border-color: var(--primary);
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

/* Color Presets */
.color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}

.bg-preset {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.bg-preset:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.bg-preset:active {
    transform: scale(0.95);
}

/* Control Input */
.control-input {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 12px;
    background: white;
    color: var(--gray-700);
    min-width: 80px;
}

.control-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* PBR Controls */
.pbr-controls {
    margin-top: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}

.pbr-controls.hidden {
    display: none;
}

/* Config Item */
.config-item {
    margin-bottom: 12px;
}

/* Connection Status Enhanced */
.connection-status.connected {
    color: var(--success);
}

.connection-status.connected .status-dot {
    color: var(--success);
}

/**
 * Slider Styles
 * =============
 * Range sliders and noUiSlider customization.
 */

/* Basic Slider Row */
.slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-row-labeled {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.slider-row-labeled label {
    font-size: 11px;
    color: var(--gray-600);
    min-width: 65px;
}

.slider-label {
    font-size: 11px;
    color: var(--gray-500);
    min-width: 60px;
}

.slider-value {
    min-width: 32px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    text-align: right;
}

/* Styled Slider */
.styled-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--gray-200);
    border-radius: 2px;
    cursor: pointer;
}

.styled-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s;
}

.styled-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.styled-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Light Card Slider Override */
.light-card .styled-slider {
    background: #fde68a;
}

.light-card .styled-slider::-webkit-slider-thumb {
    background: #f59e0b;
}

.light-card .styled-slider::-moz-range-thumb {
    background: #f59e0b;
}

/* Native Range Input */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* noUiSlider Styles */
.noUi-target,
.noUi-target * {
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -ms-touch-action: none;
    touch-action: none;
    -ms-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.noUi-target {
    position: relative;
}

.noUi-base,
.noUi-connects {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.noUi-connects {
    overflow: hidden;
    z-index: 0;
}

.noUi-connect,
.noUi-origin {
    will-change: transform;
    position: absolute;
    z-index: 1;
    top: 0;
    right: 0;
    height: 100%;
    width: 100%;
    -ms-transform-origin: 0 0;
    -webkit-transform-origin: 0 0;
    -webkit-transform-style: preserve-3d;
    transform-origin: 0 0;
    transform-style: flat;
}

.noUi-txt-dir-rtl.noUi-horizontal .noUi-origin {
    left: 0;
    right: auto;
}

.noUi-vertical .noUi-origin {
    top: -100%;
    width: 0;
}

.noUi-horizontal .noUi-origin {
    height: 0;
}

.noUi-handle {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    position: absolute;
}

.noUi-touch-area {
    height: 100%;
    width: 100%;
}

.noUi-state-tap .noUi-connect,
.noUi-state-tap .noUi-origin {
    -webkit-transition: transform .3s;
    transition: transform .3s;
}

.noUi-state-drag * {
    cursor: inherit !important;
}

.noUi-horizontal {
    height: 8px;
}

.noUi-horizontal .noUi-handle {
    width: 18px;
    height: 18px;
    right: -9px;
    top: -5px;
    border-radius: 50%;
}

.noUi-vertical {
    width: 18px;
}

.noUi-vertical .noUi-handle {
    width: 28px;
    height: 34px;
    right: -6px;
    bottom: -17px;
}

.noUi-txt-dir-rtl.noUi-horizontal .noUi-handle {
    left: -17px;
    right: auto;
}

.noUi-target {
    background: var(--gray-200);
    border-radius: 4px;
    border: none;
    box-shadow: none;
}

.noUi-connects {
    border-radius: 4px;
}

.noUi-connect {
    background: var(--primary);
}

.noUi-draggable {
    cursor: ew-resize;
}

.noUi-vertical .noUi-draggable {
    cursor: ns-resize;
}

.noUi-handle {
    border: 2px solid var(--primary);
    border-radius: 50%;
    background: #FFF;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.noUi-active {
    box-shadow: var(--shadow-md);
}

[disabled] .noUi-connect {
    background: var(--gray-300);
}

[disabled] .noUi-handle,
[disabled].noUi-handle,
[disabled].noUi-target {
    cursor: not-allowed;
}

/* Light Slider (for lighting controls) */
.light-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.light-slider {
    flex: 1;
    height: 6px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: #fde68a;
    border-radius: 3px;
}

.light-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #f59e0b;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}

.light-slider::-webkit-slider-thumb:hover {
    background: #d97706;
}

.light-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #f59e0b;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.light-value {
    min-width: 28px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #92400e;
    text-align: right;
}

.light-direction-controls {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

/**
 * Modal Styles
 * ============
 * Dialog boxes and overlay modals.
 */

/* Modal Overlay */
.modal {
    display: none; 
    position: fixed; 
    z-index: 200; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

/* Settings Modal */
.settings-modal {
    max-width: 480px;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    border: none;
    padding: 0;
}

.modal-header h2 i {
    color: var(--primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--gray-400);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-600);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

/* Form Group */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group label i {
    color: var(--gray-400);
    font-size: 11px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    color: var(--gray-700);
    transition: all 0.15s;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-input.readonly {
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: not-allowed;
}

.form-hint {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-help {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions .btn {
    flex: 1;
}

/* Label Badge */
.label-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 6px;
    background: var(--gray-200);
    color: var(--gray-600);
    border-radius: 10px;
    margin-left: auto;
}

/* Input with Action */
.input-with-action {
    display: flex;
    gap: 8px;
}

.input-with-action .form-input {
    flex: 1;
}

.input-action-btn {
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-300);
    background: var(--gray-50);
    border-radius: 6px;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.15s;
}

.input-action-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Settings Result */
.settings-result {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    margin-top: 16px;
}

.settings-result.success {
    background: #dcfce7;
    color: #166534;
}

.settings-result.error {
    background: #fee2e2;
    color: #991b1b;
}

.settings-result.warning {
    background: #fef3c7;
    color: #92400e;
}

.settings-result.hidden {
    display: none;
}

/* Save Annotation Modal */
.save-annotation-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
}

.save-annotation-status .status-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-500);
    font-size: 18px;
}

.save-annotation-status .status-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.save-annotation-status .status-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.save-annotation-status .status-subtitle {
    font-size: 11px;
    color: var(--gray-500);
}

.save-annotation-status.cloud-connected {
    background: #dcfce7;
    border-color: #bbf7d0;
}

.save-annotation-status.cloud-connected .status-icon {
    background: #22c55e;
    color: white;
}

.save-annotation-status.cloud-connected .status-title {
    color: #166534;
}

.save-annotation-status.cloud-connected .status-subtitle {
    color: #15803d;
}

.save-annotation-status.not-connected {
    background: #fef3c7;
    border-color: #fde68a;
}

.save-annotation-status.not-connected .status-icon {
    background: #f59e0b;
    color: white;
}

.save-annotation-status.not-connected .status-title {
    color: #92400e;
}

.save-annotation-status.not-connected .status-subtitle {
    color: #b45309;
}

/* Legacy Modal Content */
.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-content h1,
.modal-content h2,
.modal-content h3,
.modal-content h4,
.modal-content h5,
.modal-content h6 {
    font-weight: bold;
    margin-top: 1em;
    margin-bottom: 0.5em;
}

.modal-content p {
    margin: 0.5em 0;
}

.modal-content ul,
.modal-content ol {
    margin: 1em 0;
    padding-left: 1.5em;
}

.modal-content code {
    background-color: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

/* Connection Modal */
.connection-info-section {
    margin-top: 24px;
}

.section-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--gray-400);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--gray-200);
}

.section-divider span {
    padding: 0 12px;
}

.connection-info-text {
    font-size: 12px;
    color: var(--gray-500);
    line-height: 1.5;
}

/**
 * Card Styles
 * ===========
 * Light cards, info cards, and similar container elements.
 */

/* Light Cards (for lighting controls) */
.light-card {
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
    border: 1px solid #fef08a;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
}

.light-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.light-card-header span {
    font-size: 11px;
    font-weight: 600;
    color: #854d0e;
}

.light-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.light-color-label {
    font-size: 10px;
    color: #92400e;
    min-width: 40px;
}

.light-color-picker {
    width: 28px;
    height: 20px;
    padding: 0;
    border: 1px solid #fde68a;
    border-radius: 4px;
    cursor: pointer;
}

.light-color-picker::-webkit-color-swatch-wrapper {
    padding: 1px;
}

.light-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* Settings Cards */
.settings-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-group {
    background: var(--gray-800);
    border-radius: 8px;
    padding: 10px;
}

.settings-group-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-300);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.settings-group-title i {
    font-size: 10px;
    color: var(--primary-400);
}

.settings-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px solid var(--gray-700);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item-key {
    color: var(--gray-400);
}

.settings-item-value {
    color: var(--gray-200);
    font-family: monospace;
    font-size: 11px;
}

.settings-item-color {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--gray-600);
    vertical-align: middle;
    margin-right: 4px;
}

/* Storage Info */
.storage-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* About Info */
.about-info {
    font-size: 12px;
    color: var(--gray-300);
}

.about-info p {
    margin: 0 0 8px 0;
}

.about-info p:last-child {
    margin-bottom: 0;
}

/* Inference Status Card */
.inference-status {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--gray-50);
    border-radius: 8px;
    font-size: 12px;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.inference-status i {
    color: var(--primary);
    margin-top: 2px;
}

.inference-status.success {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.inference-status.success i {
    color: var(--success);
}

.inference-status.error {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.inference-status.error i {
    color: var(--danger);
}

.inference-status.loading {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.inference-status.loading i {
    color: var(--warning);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/**
 * Rendering Panel Styles
 * ======================
 * Lighting, display, and material controls.
 */

/* Render Section */
.render-section {
    margin-bottom: 0.5rem;
}

.render-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.render-section-title i {
    color: #6366f1;
    font-size: 0.7rem;
}

/* Color Row */
.color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Background Presets */
.bg-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Material Select */
.material-select-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.material-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    background: white;
    cursor: pointer;
}

.material-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Lighting Preset */
.lighting-preset-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.lighting-preset-row label {
    min-width: 45px;
}

.lighting-preset-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    background: white;
    cursor: pointer;
}

.lighting-preset-select:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* Light Control Group */
.light-control-group {
    background: #fefce8;
    border: 1px solid #fef08a;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
}

.light-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.light-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #854d0e;
}

/* Annotation Mode Row */
.annotation-mode-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.annotation-mode-row label {
    min-width: 75px;
}

.annotation-mode-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    background: white;
    cursor: pointer;
}

.annotation-mode-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* PBR Slider Row */
.pbr-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.pbr-slider-row:last-child {
    margin-bottom: 0;
}

.pbr-slider-row label {
    min-width: 70px;
    font-size: 0.7rem;
}

.pbr-slider {
    flex: 1;
    height: 6px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: #e5e7eb;
    border-radius: 3px;
}

.pbr-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}

.pbr-slider::-webkit-slider-thumb:hover {
    background: #4f46e5;
}

.pbr-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #6366f1;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.pbr-value {
    min-width: 32px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #374151;
    text-align: right;
}

/**
 * Annotation Panel Styles
 * =======================
 * Drawing tools, brush settings, and segmentation controls.
 */

/* Annotation Mode Tabs */
.annotation-mode-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--gray-100);
    border-radius: 8px;
    margin-bottom: 16px;
}

.mode-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.15s;
}

.mode-tab i {
    font-size: 16px;
}

.mode-tab:hover {
    background: white;
    color: var(--gray-700);
}

.mode-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.annotation-section {
    display: block;
}

.annotation-section.hidden {
    display: none;
}

/* Tool Grid */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.tool-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.tool-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 10px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s;
}

.tool-btn i {
    font-size: 18px;
}

.tool-btn:hover {
    background: white;
    border-color: var(--primary-light);
    color: var(--primary);
}

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

.tool-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.tool-btn-lg {
    padding: 16px 12px;
}

.tool-btn-lg i {
    font-size: 24px;
}

/* View mode button - distinct styling */
.tool-btn-view {
    border-color: var(--primary-light);
}

.tool-btn-view:hover {
    background: #eef2ff;
    border-color: var(--primary);
}

.tool-btn-view.active {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}

/* Brush Controls */
.brush-controls {
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
}

.brush-slider {
    flex: 1;
}

/* Brush Settings Section */
.brush-settings {
    padding: 12px;
}

.brush-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.brush-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--warning);
    flex-shrink: 0;
    transition: all 0.2s;
}

.brush-info {
    flex: 1;
}

.brush-size-label {
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.brush-size-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
}

/* Segmentation Settings */
.segmentation-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.segment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.segment-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--gray-600);
}

.segment-label i {
    color: var(--primary);
    width: 16px;
}

/* Arrow Mode Settings */
.arrow-settings {
    padding: 12px;
}

.arrow-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    background: var(--gray-50);
    border-radius: 8px;
    margin-bottom: 12px;
}

.arrow-preview svg {
    max-width: 100%;
    max-height: 100%;
}

.arrow-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Edge Color Picker */
.edge-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.edge-color-label {
    font-size: 12px;
    color: var(--gray-600);
    font-weight: 500;
}

.edge-color-picker {
    width: 32px;
    height: 24px;
    padding: 2px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    cursor: pointer;
}

/* Tool Tips */
.tool-tip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--gray-50);
    border-radius: 6px;
    font-size: 11px;
    color: var(--gray-600);
}

.tool-tip-row i {
    color: var(--primary);
}

.tool-tip-row kbd {
    padding: 2px 6px;
    background: var(--gray-200);
    border-radius: 4px;
    font-size: 10px;
    font-family: monospace;
    margin: 0 2px;
}

/* ==========================================================================
   Edge Detection Controls
   ========================================================================== */

.edge-detection-controls {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.edge-detection-actions {
    display: flex;
    gap: 8px;
}

.edge-detection-stats {
    margin-top: 12px;
    padding: 10px;
    background: var(--gray-50);
    border-radius: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.edge-detection-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 80px;
}

.edge-detection-stat .stat-label {
    font-size: 10px;
    color: var(--gray-500);
    text-transform: uppercase;
    font-weight: 500;
}

.edge-detection-stat .stat-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.edge-detection-stat.highlight {
    flex: 1 0 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-light);
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 4px;
}

.edge-detection-stat.highlight .stat-label {
    color: var(--primary-dark);
}

.edge-detection-stat.highlight .stat-value {
    color: var(--primary);
    font-size: 14px;
}

/**
 * History Panel Styles
 * ====================
 * Undo/redo history and timeline display.
 */

.section-content.history-timeline {
    flex: 1;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Undo/Redo Buttons Container */
.undo-redo-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.history-controls {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.history-stats {
    text-align: center;
    font-size: 12px;
    color: var(--gray-500);
    padding: 8px;
    background: var(--gray-50);
    border-radius: 6px;
}

.history-stats i {
    margin-right: 4px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

#historyList {
    min-height: 100px;
}

#historyList::-webkit-scrollbar {
    width: 6px;
}

#historyList::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#historyList::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

#historyList::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.history-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--gray-400);
}

.history-empty i {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.history-empty p {
    margin: 4px 0;
}

/* History Item - Unified with Library Panel styling */
.history-item {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.15s;
    overflow: hidden;
}

.history-item:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.history-item.current {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.02);
}

.history-item.future {
    opacity: 0.5;
}

.history-item-content {
    padding: 10px 12px;
    cursor: pointer;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.history-item-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-name i {
    flex-shrink: 0;
}

.history-item.current .history-item-name {
    color: var(--primary);
}

.history-item-indicator {
    color: var(--primary);
    flex-shrink: 0;
}

.history-item-meta {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--gray-500);
}

/* Source icons in history items */
.history-item .text-purple-500 {
    color: #8b5cf6;
}

.history-item .text-blue-500 {
    color: #3b82f6;
}

.history-item .text-amber-500 {
    color: #f59e0b;
}

.history-item .text-gray-500 {
    color: #6b7280;
}

/* Evaluation Labels on History Items */
.eval-btn {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.6;
}

.eval-btn:hover {
    opacity: 1;
}

.eval-btn.gt-btn {
    border-color: #10b981;
    color: #10b981;
    background: transparent;
}

.eval-btn.gt-btn.active {
    background: #10b981;
    color: white;
    opacity: 1;
}

.eval-btn.pred-btn {
    border-color: #8b5cf6;
    color: #8b5cf6;
    background: transparent;
}

.eval-btn.pred-btn.active {
    background: #8b5cf6;
    color: white;
    opacity: 1;
}

.eval-labels {
    display: flex;
    gap: 4px;
}

.eval-label {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.eval-label.gt-label {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.eval-label.pred-label {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Alternate eval label styles */
.eval-label.gt-label {
    background: #d1fae5;
    color: #065f46;
}

.eval-label.pred-label {
    background: #ede9fe;
    color: #5b21b6;
}

/**
 * Library Panel Styles
 * ====================
 * Saved annotations library display and management.
 */

/* Library Panel Header Icon */
.panel-header-icon.library-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Library Stats */
.library-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--gray-500);
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: 6px;
}

.library-stats i {
    margin-right: 4px;
}

.library-labels {
    display: flex;
    gap: 4px;
}

/* Library List Container */
.library-list-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.library-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.library-list::-webkit-scrollbar {
    width: 6px;
}

.library-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.library-list::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

.library-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Library Empty State */
.library-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--gray-400);
}

.library-empty i {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
    display: block;
}

.library-empty p {
    margin: 4px 0;
}

.library-empty .text-muted {
    font-size: 11px;
    color: var(--gray-400);
}

/* Library Item */
.library-item {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.15s;
    overflow: hidden;
}

.library-item:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.library-item.library-item-labeled {
    border-color: var(--primary-light);
    background: rgba(99, 102, 241, 0.02);
}

.library-item-content {
    padding: 10px 12px;
    cursor: pointer;
}

.library-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.library-item-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-item-name i {
    flex-shrink: 0;
}

.library-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.library-item:hover .library-item-actions {
    opacity: 1;
}

/* Always show buttons on touch devices (tablets) */
@media (pointer: coarse), (max-width: 1024px) {
    .library-item-actions {
        opacity: 1;
    }
}

.library-item-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.15s;
}

.library-item-btn:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.library-item-btn.load-btn:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.library-item-btn.cloud-upload-btn {
    color: #3b82f6;
}

.library-item-btn.cloud-upload-btn:hover {
    color: #2563eb;
    background: rgba(59, 130, 246, 0.1);
}

.library-item-btn.delete-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.library-item-meta {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.library-item-labels {
    display: flex;
    gap: 6px;
}

/* Source icons */
.library-item .text-purple-500 {
    color: #8b5cf6;
}

.library-item .text-blue-500 {
    color: #3b82f6;
}

.library-item .text-gray-500 {
    color: #6b7280;
}

.library-item .text-blue-400 {
    color: #60a5fa;
}

/* Evaluation buttons in library items */
.library-item .eval-btn {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.6;
}

.library-item .eval-btn:hover {
    opacity: 1;
}

.library-item .eval-btn.gt-btn {
    border-color: #10b981;
    color: #10b981;
    background: transparent;
}

.library-item .eval-btn.gt-btn.active {
    background: #10b981;
    color: white;
    opacity: 1;
}

.library-item .eval-btn.pred-btn {
    border-color: #8b5cf6;
    color: #8b5cf6;
    background: transparent;
}

.library-item .eval-btn.pred-btn.active {
    background: #8b5cf6;
    color: white;
    opacity: 1;
}

/**
 * Metadata Panel Styles
 * =====================
 * Metadata display, editing, and management.
 */

/* Metadata List */
.metadata-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.metadata-list::-webkit-scrollbar {
    width: 6px;
}

.metadata-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.metadata-list::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

.metadata-item {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
    transition: background 0.15s;
}

.metadata-item:first-child {
    border-radius: 8px 8px 0 0;
}

.metadata-item:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
}

.metadata-item:only-child {
    border-radius: 8px;
}

.metadata-item:hover {
    background: #f0f9ff;
}

.metadata-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.metadata-key {
    display: flex;
    align-items: center;
    gap: 8px;
}

.key-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.875rem;
}

/* Type Badges */
.type-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
    text-transform: lowercase;
}

.type-badge.type-string {
    background: #dbeafe;
    color: #1e40af;
}

.type-badge.type-number {
    background: #dcfce7;
    color: #166534;
}

.type-badge.type-boolean {
    background: #fef3c7;
    color: #92400e;
}

.type-badge.type-object {
    background: #f3e8ff;
    color: #7e22ce;
}

/* State Badge */
.state-badge {
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: #fef3c7;
    color: #92400e;
    margin-left: 6px;
    font-weight: 500;
}

/* State Metadata List */
.state-metadata-list {
    border-radius: 8px;
}

.state-metadata-item {
    background: #fffbeb;
}

.state-metadata-item:hover {
    background: #fef3c7;
}

.state-metadata-empty i {
    color: #d97706;
}

/* Metadata Value Display */
.metadata-value {
    font-size: 0.8rem;
    color: #4b5563;
    word-break: break-all;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    background: #f3f4f6;
    padding: 6px 10px;
    border-radius: 4px;
}

.metadata-value.long-value {
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

.metadata-value.type-number {
    color: #059669;
}

.metadata-value.type-boolean {
    color: #d97706;
}

.metadata-value.type-object {
    color: #7c3aed;
}

/* Metadata Actions */
.metadata-actions {
    display: flex;
    gap: 4px;
}

.metadata-edit-btn,
.metadata-delete-btn {
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}

.metadata-edit-btn:hover {
    background: #dbeafe;
    color: #3b82f6;
}

.metadata-delete-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* Metadata Add Button Row */
.metadata-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.metadata-btn-row .btn {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metadata-add-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.metadata-add-btn.shared-btn {
    background: #6366f1;
    color: white;
}

.metadata-add-btn.shared-btn:hover {
    background: #4f46e5;
}

.metadata-add-btn.state-btn {
    background: #f59e0b;
    color: white;
}

.metadata-add-btn.state-btn:hover {
    background: #d97706;
}

/* Metadata Add Form */
.metadata-add-form {
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-sizing: border-box;
    overflow: hidden;
}

.metadata-input-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

.metadata-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.metadata-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.metadata-input.key-input {
    flex: 0.4;
}

.metadata-input.value-input {
    flex: 0.6;
}

/* Metadata Edit Container */
.metadata-edit-container {
    background: #f9fafb;
    padding: 8px;
    border-radius: 6px;
    margin-top: 8px;
}

/* Metadata Preview */
.metadata-preview {
    background: var(--gray-100);
    border-radius: 6px;
    font-size: 11px;
}

.metadata-preview .metadata-empty {
    padding: 16px;
    text-align: center;
    color: var(--gray-400);
    font-style: italic;
}

.metadata-preview-item {
    display: flex;
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-200);
}

.metadata-preview-item:last-child {
    border-bottom: none;
}

.metadata-preview-key {
    font-weight: 600;
    color: var(--gray-600);
    min-width: 100px;
    flex-shrink: 0;
}

.metadata-preview-value {
    color: var(--gray-700);
    word-break: break-word;
}

/* Metadata Empty State */
.metadata-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
}

.metadata-empty i {
    font-size: 24px;
    margin-bottom: 8px;
    color: #d1d5db;
}

.metadata-empty p {
    margin: 0;
    font-size: 12px;
}

/* Metadata Edit Mode */
.metadata-edit-container {
    margin-top: 4px;
}

.metadata-edit-input,
.metadata-edit-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #6366f1;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    background: white;
    box-sizing: border-box;
}

.metadata-edit-textarea {
    min-height: 80px;
    resize: vertical;
}

.metadata-edit-input:focus,
.metadata-edit-textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.metadata-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.metadata-edit-actions button {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.metadata-edit-actions .save-btn {
    background: #10b981;
    color: white;
}

.metadata-edit-actions .save-btn:hover {
    background: #059669;
}

.metadata-edit-actions .cancel-btn {
    background: #f3f4f6;
    color: #4b5563;
}

.metadata-edit-actions .cancel-btn:hover {
    background: #e5e7eb;
}

/* Status Message */
.metadata-status {
    font-size: 0.75rem;
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
    min-height: 32px;
}

.metadata-status.success {
    background: #dcfce7;
    color: #166534;
}

.metadata-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.metadata-status.info {
    background: #dbeafe;
    color: #1e40af;
}

/* Comments Section */
.comments-list {
    max-height: 120px;
    overflow-y: auto;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.comment-item {
    padding: 6px 10px;
    font-size: 0.75rem;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

.comment-item:last-child {
    border-bottom: none;
}

/* Metadata Help */
.metadata-help {
    font-size: 0.75rem;
    color: #6b7280;
}

.metadata-help p {
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.metadata-help i {
    width: 16px;
    text-align: center;
}

/**
 * Evaluation Panel Styles
 * =======================
 * Comparison, metrics display, and visualization controls.
 */

/* Visualization Group Label */
.viz-group-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Visualization Options */
.viz-options {
    display: flex;
    gap: 6px;
}

.viz-options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.viz-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.viz-option:hover {
    background: white;
    border-color: var(--primary-light);
}

.viz-option input[type="radio"] {
    margin: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.viz-option input[type="radio"]:checked + .viz-option-label {
    color: var(--primary);
    font-weight: 600;
}

.viz-option-label {
    font-size: 11px;
    color: var(--gray-600);
}

/* Comparison Status */
.comparison-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: 6px;
}

.status-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    min-width: 110px;
}

.status-label.gt-label {
    color: var(--success);
}

.status-label.pred-label {
    color: var(--purple);
}

.status-value {
    flex: 1;
    font-size: 12px;
    color: var(--gray-500);
}

/* Visualization Options */
.viz-group {
    margin-bottom: 12px;
}

.viz-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.viz-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.viz-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: white;
    font-size: 11px;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s;
}

.viz-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

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

.viz-btn i {
    font-size: 10px;
}

/* Metrics Display */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.metric-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
}

.metric-value.success {
    color: var(--success);
}

.metric-value.warning {
    color: var(--warning);
}

.metric-value.danger {
    color: var(--danger);
}

.metric-label {
    font-size: 10px;
    color: var(--gray-500);
    text-transform: uppercase;
    margin-top: 4px;
}

/* Evaluation Metrics Table View */
.eval-table-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.eval-section {
    background: #f9fafb;
    border-radius: 6px;
    padding: 10px;
}

.eval-section-small {
    background: transparent;
    padding: 6px 0;
}

.eval-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.eval-metrics-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.eval-metrics-row:last-child {
    margin-bottom: 0;
}

.eval-metric {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.eval-metric.highlight {
    background: #eff6ff;
    border-color: #3b82f6;
}

.eval-metric-value {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
}

.eval-metric-value.success {
    color: #059669;
}

.eval-metric-value.danger {
    color: #dc2626;
}

.eval-metric-value.warning {
    color: #d97706;
}

.eval-metric-label {
    display: block;
    font-size: 0.65rem;
    color: #6b7280;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Evaluation Errors List */
.eval-errors-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.eval-error-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    padding: 4px 8px;
    background: white;
    border-radius: 4px;
}

.eval-error-label {
    color: #4b5563;
}

.eval-error-value {
    color: #6b7280;
    font-family: monospace;
}

/* Evaluation Info Row */
.eval-info-row {
    display: flex;
    justify-content: space-around;
    font-size: 0.75rem;
    color: #6b7280;
}

.eval-info-row.thresholds {
    font-family: monospace;
    font-size: 0.7rem;
    color: #9ca3af;
}

/* Evaluation View Toggle */
.eval-view-toggle {
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.eval-view-toggle:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Evaluation Raw View */
.eval-raw-view pre {
    margin: 0;
    font-size: 0.7rem;
    max-height: 300px;
    overflow-y: auto;
}

/* Evaluation Computed At */
.eval-computed-at {
    font-size: 0.7rem;
    color: #6b7280;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.eval-computed-at i {
    margin-right: 4px;
}

/* Evaluation Item */
.evaluation-item {
    padding: 12px;
}

/* Evaluation Metrics Grid */
.eval-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.eval-metric-card {
    background: #f3f4f6;
    border-radius: 8px;
    padding: 10px 8px;
    text-align: center;
    cursor: help;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
    position: relative;
}

.eval-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.eval-metric-card.success {
    background: #dcfce7;
    border-color: #86efac;
}

.eval-metric-card.danger {
    background: #fee2e2;
    border-color: #fca5a5;
}

.eval-metric-card.warning {
    background: #fef3c7;
    border-color: #fcd34d;
}

.eval-metric-card .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.2;
}

.eval-metric-card .metric-label {
    font-size: 0.7rem;
    color: #4b5563;
    font-weight: 500;
    margin-top: 2px;
}

/* Evaluation Instance Counts */
.eval-instance-counts {
    display: flex;
    justify-content: space-around;
    padding: 8px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 10px;
}

.eval-count-item {
    font-size: 0.8rem;
    color: #475569;
}

.eval-count-item i {
    margin-right: 4px;
    opacity: 0.7;
}

/* Evaluation Error Items */
.eval-error-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    padding: 8px;
    margin-bottom: 4px;
    background: #f8fafc;
    border-radius: 6px;
    cursor: help;
    transition: background 0.15s;
}

.eval-error-item:hover {
    background: #f1f5f9;
}

.eval-error-item .error-icon {
    font-size: 12px;
    flex-shrink: 0;
}

.eval-error-item.overseg { border-left: 3px solid #f97316; }
.eval-error-item.underseg { border-left: 3px solid #a855f7; }
.eval-error-item.missing-gt { border-left: 3px solid #ef4444; }
.eval-error-item.missing-pred { border-left: 3px solid #eab308; }

.eval-error-item.overseg .error-icon { color: #f97316; }
.eval-error-item.underseg .error-icon { color: #a855f7; }
.eval-error-item.missing-gt .error-icon { color: #ef4444; }
.eval-error-item.missing-pred .error-icon { color: #eab308; }

.eval-error-item .error-label {
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.eval-error-item .error-count {
    color: #1f2937;
    font-weight: 500;
}

.eval-error-item .error-pct {
    color: #6b7280;
    font-size: 0.75rem;
    min-width: 40px;
    text-align: right;
}

/* Color Legend */
.eval-color-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #d1d5db;
}

.legend-label {
    color: #4b5563;
}

/* Evaluation Parameter Row */
.eval-param-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.75rem;
}

.eval-param-row label {
    min-width: 110px;
    color: #4b5563;
}

.eval-slider {
    flex: 1;
    height: 6px;
    cursor: pointer;
}

.eval-param-value {
    min-width: 35px;
    text-align: right;
    font-weight: 600;
    color: #374151;
}

/* Evaluation Status */
.eval-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.eval-status-label {
    font-weight: 600;
    min-width: 90px;
}

.eval-status-value {
    flex: 1;
    font-weight: 500;
}

.eval-clear-btn {
    padding: 2px 6px;
    font-size: 10px;
    background: #fee2e2;
    color: #991b1b;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.eval-clear-btn:hover {
    background: #fecaca;
}

/* Metrics Section */
.eval-metrics-section {
    margin-bottom: 10px;
}

.eval-metrics-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
}

/* Metric Item */
.eval-metric-item {
    flex: 1;
    background: #f8fafc;
    border-radius: 6px;
    padding: 8px;
    cursor: help;
    transition: background 0.15s;
    position: relative;
}

.eval-metric-item:hover {
    background: #f1f5f9;
}

.eval-metric-item.highlight {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.eval-metric-item .metric-name {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 2px;
}

.eval-metric-item .metric-val {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
}

.eval-metric-row-detailed {
    display: flex;
    gap: 8px;
}

/* Hover Hint */
.eval-hover-hint {
    font-size: 0.65rem;
    color: #94a3b8;
    text-align: center;
    margin-top: 8px;
    font-style: italic;
}

/* ==========================================================================
   Dual View Controls
   ========================================================================== */

/* Dual View Toggle Section */
.dual-view-section {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.dual-view-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #86efac;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.dual-view-toggle-row:hover {
    background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
    border-color: #4ade80;
}

.dual-view-toggle-row.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #059669;
}

.dual-view-toggle-row.active .dual-view-toggle-label,
.dual-view-toggle-row.active .dual-view-toggle-hint {
    color: white;
}

.dual-view-toggle-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dual-view-toggle-label {
    font-size: 13px;
    font-weight: 600;
    color: #059669;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dual-view-toggle-label i {
    font-size: 14px;
}

.dual-view-toggle-hint {
    font-size: 11px;
    color: #6b7280;
}

/* Per-View Visualization Controls */
.dual-view-controls {
    margin-top: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    display: none;
}

.dual-view-controls.visible {
    display: block;
}

.dual-view-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.view-control-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.view-control-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.view-control-header.left-view {
    background: #dcfce7;
    color: #059669;
    border-left: 3px solid #10b981;
}

.view-control-header.right-view {
    background: #f3e8ff;
    color: #7c3aed;
    border-left: 3px solid #8b5cf6;
}

.view-control-header i {
    font-size: 10px;
}

/* View Mode Select */
.view-mode-select {
    width: 100%;
    padding: 6px 8px;
    font-size: 11px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: white;
    color: var(--gray-700);
    cursor: pointer;
    transition: border-color 0.2s;
}

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

.view-mode-select option {
    padding: 8px;
}

/* Swap Views Button */
.swap-views-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
}

.swap-views-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-800);
}

.swap-views-btn i {
    transition: transform 0.2s;
}

.swap-views-btn:hover i {
    transform: rotate(180deg);
}

/**
 * Cloud Storage Panel Styles
 * ==========================
 * Cloud connection, mesh list, and state management.
 */

/* Cloud Storage Header */
.cloud-storage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.cloud-storage-status {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
}

.cloud-storage-status.info {
    background: var(--gray-50);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.cloud-storage-status.success {
    background: rgba(34, 197, 94, 0.1);
    color: #15803d;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.cloud-storage-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.cloud-storage-status.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.cloud-storage-actions {
    display: flex;
    gap: 4px;
}

/* Cloud Mesh Search */
.cloud-mesh-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 8px 16px 0 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cloud-mesh-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.cloud-mesh-search i.fa-search {
    color: var(--gray-400);
    font-size: 12px;
}

.cloud-mesh-search input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--gray-800);
    outline: none;
}

.cloud-mesh-search input::placeholder {
    color: var(--gray-400);
}

.cloud-mesh-search .search-clear-btn {
    display: none;
    padding: 4px;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.cloud-mesh-search .search-clear-btn:hover {
    color: var(--gray-600);
    background: var(--gray-200);
}

.cloud-mesh-search.has-value .search-clear-btn {
    display: flex;
}

/* Cloud Mesh List */
.cloud-mesh-list-container {
    max-height: 400px;
    overflow-y: auto;
}

.cloud-mesh-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Cloud Mesh Item */
.cloud-mesh-item {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.cloud-mesh-item:hover {
    border-color: var(--primary-light);
}

.cloud-mesh-item.current {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.cloud-mesh-item.current .mesh-item-name {
    color: var(--primary);
}

/* Mesh Item Header */
.mesh-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
}

.mesh-item-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--gray-200) 0%, var(--gray-300) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
}

.cloud-mesh-item.current .mesh-item-icon {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    color: white;
}

.mesh-item-info {
    flex: 1;
    min-width: 0;
}

.mesh-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mesh-item-meta {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
}

.mesh-item-meta .state-count {
    color: var(--primary);
    font-weight: 500;
}

/* Mesh Item Actions */
.mesh-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mesh-item-actions .icon-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

.cloud-mesh-item:hover .mesh-item-actions .icon-btn {
    opacity: 1;
}

/* Save to Library button - prominent styling */
.mesh-item-actions .save-to-library-btn {
    color: var(--primary);
}

.mesh-item-actions .save-to-library-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

/* Always show buttons on touch devices (tablets) */
@media (pointer: coarse), (max-width: 1024px) {
    .mesh-item-actions .icon-btn {
        opacity: 1;
    }
}

/* Expand Icon */
.expand-icon {
    color: var(--gray-400);
    font-size: 10px;
    margin-left: 4px;
    transition: transform 0.2s;
}

.cloud-mesh-item.expanded .expand-icon {
    transform: rotate(180deg);
}

/* Mesh Item States */
.mesh-item-states {
    display: none;
    border-top: 1px solid var(--gray-200);
    background: white;
    padding: 12px;
}

.cloud-mesh-item.expanded .mesh-item-states {
    display: block;
}

.states-loading,
.states-error,
.states-empty {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--gray-500);
}

.states-error {
    color: var(--danger);
}

/* States List */
.states-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Cloud State Item */
.cloud-state-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    transition: all 0.2s;
}

.cloud-state-item:hover {
    background: white;
    border-color: var(--primary-light);
}

.state-item-icon {
    width: 28px;
    height: 28px;
    background: var(--gray-200);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 12px;
}

.state-item-info {
    flex: 1;
    min-width: 0;
}

.state-item-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.state-item-meta {
    font-size: 10px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* State Item Actions */
.state-item-actions {
    display: flex;
    gap: 4px;
}

.state-item-actions .icon-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

.cloud-state-item:hover .state-item-actions .icon-btn {
    opacity: 1;
}

/* Always show buttons on touch devices (tablets) */
@media (pointer: coarse), (max-width: 1024px) {
    .state-item-actions .icon-btn {
        opacity: 1;
    }
}

/* Cloud Connection Indicator on Save Button */
#saveStateToCloudBtn.cloud-connected {
    border-color: var(--success);
    position: relative;
}

#saveStateToCloudBtn.cloud-connected::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid white;
}

/**
 * NeuroLithic - Main Stylesheet
 * =============================
 * 
 * This is the main entry point for all CSS.
 * Styles are organized into logical modules for maintainability.
 * 
 * Structure:
 * - base/      : Variables, reset, typography
 * - layout/    : Navbar, sidebar, canvas
 * - components/: Reusable UI components
 * - panels/    : Panel-specific styles
 * - utilities/ : Helper classes
 */

/* ==========================================================================
   Base Styles
   ========================================================================== */

/* ==========================================================================
   Layout
   ========================================================================== */

/* ==========================================================================
   Components
   ========================================================================== */

/* ==========================================================================
   Panel-Specific Styles
   ========================================================================== */

