/**
 * ============================================================================
 * STROKE 2D BRAIN ATLAS VIEWER - Complete UI Stylesheet
 * ============================================================================
 *
 * Professional Medical Dashboard Design
 * 6-Column Grid Layout:
 * [MRI Nav] [In vivo MRI] [MRI Registered] [Histology] [Icon Bar] [Histology Nav]
 *
 * ============================================================================
 */

/* ============================================================================
   CSS RESET & BASE
   ============================================================================ */

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    font-size: 13px;
    line-height: 1.4;
    background-color: #f5f5f5;
    color: #333;
}

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */

:root {
    /* Layout Dimensions */
    --header-height: 60px;
    --footer-height: 32px;
    /* Sidebar dimensions - increased for better readability */
    --sidebar-width: 200px;
    --tools-width: 155px;
    --mri-column-width: 240px;
    --icon-bar-width: 70px;

    /* Colors - Light Theme */
    --bg-color: #f5f5f5;
    --surface-color: #ffffff;
    --border-color: #ddd;
    --text-color: #333;
    --text-muted: #666;

    /* Additional variables for thumbnail popup (from old UI) */
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-dark: rgba(0, 0, 0, 0.15);
    --light-surface: #f0f0f0;

    /* Header Colors */
    --mri-nav-header: #fce4d6;      /* Peach/salmon */
    --mri-blue-header: #d6eaf8;     /* Light blue */
    --histology-nav-header: #fce4d6; /* Peach/salmon */

    /* Accent Colors */
    --primary-color: #2196F3;
    --crosshair-yellow: #f5c400;
    --crosshair-black: #000000;
    --crosshair-blue-dashed: rgba(100, 149, 237, 0.6);

    /* MRI Panel */
    --mri-bg: #000000;
    --mri-text: #ffffff;

    /* Slider */
    --slider-track: #ccc;
    --slider-thumb: #888;
    --slider-bar-bg: #555;
}

/* ============================================================================
   DARK MODE
   ============================================================================ */

body.dark-mode {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --border-color: #334155;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;

    /* Shadow variables - Dark Mode */
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-dark: rgba(0, 0, 0, 0.4);
    --light-surface: #334155;

    /* Header Colors - Dark Mode */
    --mri-nav-header: #4a3728;
    --mri-blue-header: #1e3a5f;
    --histology-nav-header: #4a3728;

    /* Slider - Dark Mode */
    --slider-track: #475569;
    --slider-thumb: #64748b;
    --slider-bar-bg: #334155;

    background-color: var(--bg-color);
    color: var(--text-color);
}

body.dark-mode .header {
    background: linear-gradient(135deg, var(--surface-color) 0%, #1a2744 100%);
    border-color: var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .sidebar {
    background: linear-gradient(180deg, var(--surface-color) 0%, #151d2e 100%);
    border-color: var(--border-color);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
}

body.dark-mode .sidebar-header.mri-header,
body.dark-mode .sidebar-header.histology-header {
    background: var(--mri-nav-header);
    color: var(--text-color);
}

body.dark-mode .column-header.mri-blue-header {
    background: var(--mri-blue-header);
    color: var(--text-color);
}

body.dark-mode .mri-column {
    background: linear-gradient(180deg, #1a2744 0%, var(--surface-color) 100%);
    border-color: var(--border-color);
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
}

body.dark-mode .histology-column {
    background: linear-gradient(180deg, #151d2e 0%, var(--surface-color) 100%);
    border-color: var(--border-color);
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
}

body.dark-mode .histology-panel {
    background: var(--surface-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .mri-view-card {
    background: #0f1420;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.2);
}

body.dark-mode .mri-view-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.25);
}

body.dark-mode .histology-panel-header,
body.dark-mode .histology-panel-footer {
    background: var(--surface-color);
    border-color: var(--border-color);
}

body.dark-mode .control-select {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border-color: var(--border-color);
    color: var(--text-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.dark-mode .control-select:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .control-select:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

body.dark-mode .action-btn {
    background: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

body.dark-mode .action-btn:hover {
    background: var(--surface-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Dark mode - Annotations */
body.dark-mode .action-btn-annotations.active {
    background: rgba(236, 72, 153, 0.2);
    border-color: #ec4899;
    color: #f9a8d4;
}

/* Dark mode - Heatmap */
body.dark-mode .action-btn-heatmap.active {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
    color: #fcd34d;
}

/* Dark mode - Measure */
body.dark-mode .action-btn-measure.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #93c5fd;
}

/* Dark mode - 3D */
body.dark-mode .action-btn-3d {
    background: linear-gradient(135deg, #1e293b 0%, #2e1065 100%);
}

body.dark-mode .action-btn-3d:hover {
    background: linear-gradient(135deg, #2e1065 0%, #4c1d95 100%);
}

body.dark-mode .nav-btn {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border-color: var(--border-color);
    color: var(--text-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.dark-mode .nav-btn:hover {
    background: linear-gradient(145deg, #2d3a4f 0%, #1e293b 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

body.dark-mode .footer-nav-controls .nav-separator {
    color: var(--text-muted);
}

body.dark-mode .footer-bar {
    background: linear-gradient(180deg, #1a2744 0%, var(--surface-color) 100%);
    border-color: var(--border-color);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
}

body.dark-mode .coord-value {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .coordinates-box {
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
    border-color: var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Dark mode thumbnail styles are defined in the THUMBNAIL POPUP section below */

body.dark-mode .histology-ref-panel .ref-panel-expanded {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border-color: var(--border-color);
}

body.dark-mode .ref-panel-header {
    border-color: var(--border-color);
    background: linear-gradient(135deg, #1e293b 0%, #1a1f2e 100%);
}

body.dark-mode .ref-panel-title::before {
    color: #475569;
}

body.dark-mode .mri-placeholder-message {
    color: var(--text-secondary);
}

body.dark-mode .loading-overlay {
    background: rgba(15, 23, 42, 0.9);
}

body.dark-mode .theme-toggle {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border-color: var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

body.dark-mode .theme-toggle:hover {
    background: linear-gradient(145deg, #2d3a4f 0%, #1e293b 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Dark mode - Map elements */
body.dark-mode .histology-map-wrapper {
    background: #0f172a;
}

body.dark-mode .histology-map-container {
    background: #1e293b;
}

body.dark-mode .stain-badge {
    background: #dc2626;
}

body.dark-mode .brain-id-badge {
    background: #2980b9;
}

body.dark-mode .section-id-badge {
    background: #1e8449;
}

body.dark-mode .cursor-coords {
    background: rgba(0, 0, 0, 0.5);
}

body.dark-mode .icon-bar-select {
    background: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

/* ============================================================================
   SELECT/DROPDOWN OPTION STYLING - BOTH MODES
   ============================================================================ */

/* Base select styling - Light mode */
select,
.control-select,
.icon-bar-select,
.stain-select {
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

/* Light mode - all select options */
select option,
.control-select option,
.icon-bar-select option,
.stain-select option {
    background: #ffffff;
    color: #333;
    padding: 8px 12px;
}

/* Dark mode - all select elements */
body.dark-mode select,
body.dark-mode .control-select,
body.dark-mode .icon-bar-select,
body.dark-mode .stain-select {
    background-color: #1e293b;
    color: #f1f5f9;
    border-color: #475569;
}

/* Dark mode - all select options */
body.dark-mode select option,
body.dark-mode .control-select option,
body.dark-mode .icon-bar-select option,
body.dark-mode .stain-select option {
    background: #1e293b;
    color: #f1f5f9;
}

/* Dark mode - select on focus */
body.dark-mode select:focus,
body.dark-mode .control-select:focus,
body.dark-mode .icon-bar-select:focus,
body.dark-mode .stain-select:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

/* Dark mode - select hover */
body.dark-mode select:hover,
body.dark-mode .control-select:hover,
body.dark-mode .icon-bar-select:hover {
    border-color: #64748b;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--surface-color) 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: invert(1); /* Invert white logo to black for light mode */
    transition: filter 0.3s ease;
}

/* In dark mode, keep original white logo */
body.dark-mode .header-logo {
    filter: none;
}

.header-titles {
    display: flex;
    flex-direction: column;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.header-subtitle {
    font-size: 12px;
    color: #28a745;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.theme-toggle:hover {
    background: linear-gradient(145deg, #f0f0f0 0%, #e5e5e5 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   MAIN LAYOUT - 5 COLUMN GRID
   ============================================================================ */

.main-layout {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: var(--footer-height);
    display: grid;
    /* 6 columns: MRI Nav | In vivo MRI | MRI Registered | Histology | Histology Nav | Tools */
    /* Tools panel at extreme right (narrower), giving more space to histology area */
    grid-template-columns: var(--sidebar-width) var(--mri-column-width) var(--mri-column-width) 1fr var(--sidebar-width) var(--tools-width);
    background: var(--bg-color);
    overflow: hidden;
}

/* ============================================================================
   SIDEBARS (MRI Nav & Histology Nav Panes)
   ============================================================================ */

.sidebar {
    background: linear-gradient(180deg, var(--surface-color) 0%, #f8f9fa 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.04);
}

.sidebar.histology-nav-pane {
    border-right: none;
    border-left: 1px solid var(--border-color);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.04);
    background: linear-gradient(180deg, var(--surface-color) 0%, #f8f9fa 100%);
}

.sidebar.tools-pane {
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.04), 2px 0 12px rgba(0, 0, 0, 0.04);
}

/* ============================================================================
   TOOLS PANE - Slightly scaled styling for narrower width (155px vs 170px)
   ============================================================================ */

.sidebar.tools-pane .sidebar-content {
    padding: 10px 10px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Tools pane - Section labels */
.sidebar.tools-pane .nav-section-label {
    font-size: 10px;
    padding: 6px 8px;
    margin-bottom: 8px;
}

/* Tools pane - Control groups */
.sidebar.tools-pane .control-group {
    margin-bottom: 10px;
}

/* Tools pane - Control labels */
.sidebar.tools-pane .control-label {
    font-size: 10px;
    margin-bottom: 4px;
}

/* Tools pane - Dropdowns/Selects */
.sidebar.tools-pane .control-select {
    padding: 6px 8px;
    font-size: 10px;
}

/* Tools pane - Slider container */
.sidebar.tools-pane .slider-container {
    gap: 5px;
}

.sidebar.tools-pane .slider {
    height: 5px;
}

.sidebar.tools-pane .slider::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
}

.sidebar.tools-pane .slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
}

.sidebar.tools-pane .slider-value {
    font-size: 10px;
    min-width: 28px;
}

/* Tools pane - Dividers */
.sidebar.tools-pane .sidebar-divider {
    margin: 10px 0;
}

/* Tools pane - Toggle buttons group */
.sidebar.tools-pane .toggle-buttons-group {
    gap: 5px;
}

/* Tools pane - Toggle buttons */
.sidebar.tools-pane .toggle-btn {
    padding: 7px 10px;
    font-size: 10px;
    gap: 7px;
    border-radius: 5px;
}

.sidebar.tools-pane .toggle-btn svg {
    width: 15px;
    height: 15px;
}

.sidebar-header.tools-header {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0369a1;
}

.sidebar-header {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-header.mri-header,
.sidebar-header.histology-header {
    background: linear-gradient(135deg, var(--mri-nav-header) 0%, #f9d5c5 100%);
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 10px;
    letter-spacing: 0.8px;
}

.sidebar-content {
    flex: 1;
    padding: 10px 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Both sidebars - ensure no scrollbar with proper sizing */
.mri-nav-pane .sidebar-content,
.histology-nav-pane .sidebar-content {
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 10px 10px;
}

/* Hide scrollbar but keep functionality */
.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

.sidebar-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--border-color) 20%, var(--border-color) 80%, transparent 100%);
    margin: 12px 0;
}

/* Main center divider between top and bottom image controls */
.sidebar-divider.center-divider {
    height: 2px;
    margin: 14px 0;
    background: linear-gradient(90deg, #3b82f6 0%, #a855f7 100%);
    border-radius: 1px;
}

.nav-section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.08) 0%, rgba(33, 150, 243, 0.02) 100%);
    border-left: 3px solid var(--primary-color);
    border-radius: 0 4px 4px 0;
}

/* Top image section label - blue accent */
.nav-section-label.top-panel {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0.03) 100%);
    border-left-color: #3b82f6;
    color: #1e40af;
}

/* Bottom image section label - purple accent */
.nav-section-label.bottom-panel {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.12) 0%, rgba(168, 85, 247, 0.03) 100%);
    border-left-color: #a855f7;
    color: #6b21a8;
}

/* ============================================================================
   FORM CONTROLS
   ============================================================================ */

.control-group {
    margin-bottom: 12px;
}

.control-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 5px;
}

.control-label-inline {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-color);
    margin-right: 8px;
}

.control-select {
    width: 100%;
    padding: 8px 10px;
    font-size: 11px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.control-select:hover {
    border-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.control-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.control-select-inline,
.control-select-small {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--surface-color);
}

/* Slider Styles */
.slider-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.slider {
    flex: 1;
    min-width: 0; /* Allow slider to shrink */
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--slider-track);
    border-radius: 3px;
    cursor: pointer;
}

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

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

.slider-value {
    font-size: 10px;
    color: var(--text-muted);
    min-width: 28px;
    flex-shrink: 0;
    text-align: right;
}

/* Toggle Buttons Group */
.toggle-buttons-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-color);
    background: linear-gradient(145deg, #ffffff 0%, #f5f5f5 100%);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.toggle-btn svg {
    flex-shrink: 0;
}

.toggle-btn span {
    flex: 1;
    text-align: left;
}

/* Annotations button - Pink */
.toggle-btn.annotations {
    border-color: rgba(236, 72, 153, 0.3);
}
.toggle-btn.annotations:hover {
    background: #fdf2f8;
    border-color: #ec4899;
}
.toggle-btn.annotations.active {
    background: linear-gradient(145deg, #fce7f3 0%, #fbcfe8 100%);
    border-color: #ec4899;
    color: #be185d;
}

/* Heatmap button - Orange */
.toggle-btn.heatmap {
    border-color: rgba(245, 158, 11, 0.3);
}
.toggle-btn.heatmap:hover {
    background: #fffbeb;
    border-color: #f59e0b;
}
.toggle-btn.heatmap.active {
    background: linear-gradient(145deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
    color: #b45309;
}

/* Mask button - Red */
.toggle-btn.mask {
    border-color: rgba(239, 68, 68, 0.3);
}
.toggle-btn.mask:hover {
    background: #fef2f2;
    border-color: #ef4444;
}
.toggle-btn.mask.active {
    background: linear-gradient(145deg, #fee2e2 0%, #fecaca 100%);
    border-color: #ef4444;
    color: #b91c1c;
}

/* Measure button - Blue */
.toggle-btn.measure {
    border-color: rgba(59, 130, 246, 0.3);
}
.toggle-btn.measure:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}
.toggle-btn.measure.active {
    background: linear-gradient(145deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #3b82f6;
    color: #1d4ed8;
}

/* Clear button - Red */
.toggle-btn.clear {
    border-color: rgba(239, 68, 68, 0.3);
}
.toggle-btn.clear:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Thumbnails button - Gray */
.toggle-btn.thumbnails {
    border-color: rgba(107, 114, 128, 0.3);
}
.toggle-btn.thumbnails:hover {
    background: #f9fafb;
    border-color: #6b7280;
}

/* 3D Viewer button - Purple */
.toggle-btn.viewer3d {
    border-color: rgba(139, 92, 246, 0.3);
}
.toggle-btn.viewer3d:hover {
    background: #f5f3ff;
    border-color: #8b5cf6;
}

.slider-small {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--slider-track);
    border-radius: 2px;
}

.slider-small::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
}

/* Coordinates Box */
.coordinates-box {
    background: linear-gradient(145deg, #f8f9fa 0%, #eef1f5 100%);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

.coord-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 3px 0;
}

.coord-row span:first-child {
    font-weight: 600;
}

/* Axis Legend Box */
.axis-legend-box {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
}

.axis-legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.axis-color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.axis-label {
    font-size: 11px;
    color: #ccc;
}

.axis-label.axis-slice {
    color: #EF4444;
    font-weight: 600;
}

.axis-legend-note {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 10px;
    color: #888;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-color);
    background: var(--surface-color);
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn svg {
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.action-btn span {
    flex: 1;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Annotations Button - Pink (#ec4899) */
.action-btn-annotations {
    border-left: 3px solid #ec4899;
}

.action-btn-annotations svg {
    stroke: #ec4899;
}

.action-btn-annotations:hover {
    background: #fdf2f8;
    border-color: #ec4899;
}

.action-btn-annotations.active {
    background: #fce7f3;
    border-color: #ec4899;
    color: #be185d;
}

.action-btn-annotations.active svg {
    stroke: #be185d;
}

/* Heatmap Button - Amber (#f59e0b) */
.action-btn-heatmap {
    border-left: 3px solid #f59e0b;
}

.action-btn-heatmap svg {
    stroke: #f59e0b;
}

.action-btn-heatmap:hover {
    background: #fffbeb;
    border-color: #f59e0b;
}

.action-btn-heatmap.active {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #b45309;
}

.action-btn-heatmap.active svg {
    stroke: #b45309;
}

/* Measure Button - Blue (#3b82f6) */
.action-btn-measure {
    border-left: 3px solid #3b82f6;
}

.action-btn-measure svg {
    stroke: #3b82f6;
}

.action-btn-measure:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}

.action-btn-measure.active {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.action-btn-measure.active svg {
    stroke: #1d4ed8;
}

/* Clear Button - Red (#ef4444) */
.action-btn-clear {
    border-left: 3px solid #ef4444;
}

.action-btn-clear svg {
    stroke: #ef4444;
}

.action-btn-clear:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

.action-btn-clear:active {
    background: #fee2e2;
    transform: scale(0.98);
}

/* Thumbnails Button - Gray (#6b7280) */
.action-btn-thumbnails {
    border-left: 3px solid #6b7280;
}

.action-btn-thumbnails svg {
    stroke: #6b7280;
}

.action-btn-thumbnails:hover {
    background: #f9fafb;
    border-color: #6b7280;
}

/* 3D Viewer Button - Special gradient styling */
.action-btn-3d {
    border-left: 3px solid #8b5cf6;
    background: linear-gradient(135deg, #fafafa 0%, #f5f3ff 100%);
}

.action-btn-3d svg {
    stroke: #8b5cf6;
}

.action-btn-3d:hover {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border-color: #8b5cf6;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.action-btn-3d:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 16px;
}

/* ============================================================================
   MRI COLUMNS (In vivo MRI & MRI Registered to Histology)
   ============================================================================ */

.mri-column {
    background: linear-gradient(180deg, #f0f7ff 0%, var(--surface-color) 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.05);
}

.column-header {
    padding: 10px 15px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 0.3px;
}

.column-header.mri-blue-header {
    background: linear-gradient(135deg, var(--mri-blue-header) 0%, #c5ddf5 100%);
    color: #1e3a5f;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.8px;
}

.header-italic {
    font-style: italic;
}

.mri-views-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    overflow-y: auto;
}

/* MRI View Card */
.mri-view-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #1a1a2e;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mri-view-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 4px 10px rgba(0, 0, 0, 0.12);
}

.mri-view-image {
    flex: 1;
    position: relative;
    background: var(--mri-bg);
    /* Add visible border to show image bounds clearly (like 3D viewer) */
    border: 2px solid rgba(100, 100, 100, 0.5);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    /* Make MRI images approximately square */
    aspect-ratio: 1 / 1;
    max-width: 100%;
    /* Ensure minimum dimensions for VTK.js WebGL context initialization */
    min-height: 50px;
    min-width: 50px;
    /* Inner shadow to show depth and image boundary */
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(60, 60, 80, 0.3);
}

.mri-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mri-bg);
}

.mri-error-text {
    font-size: 10px;
    color: #888;
    text-align: center;
    padding: 10px;
}

/* MRI Loading Spinner */
.mri-loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: mri-spin 0.8s linear infinite;
    margin-bottom: 8px;
}

@keyframes mri-spin {
    to { transform: rotate(360deg); }
}

.mri-loading-text {
    font-size: 10px;
    color: #aaa;
    text-align: center;
}

/* VTK.js Canvas Styling */
.mri-view-image canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* VTK.js Render Window Container */
.mri-view-image .vtk-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* MRI Slider Bar */
.mri-slider-bar {
    background: var(--slider-bar-bg);
    padding: 8px 15px;
    border-radius: 0 0 4px 4px;
    display: flex;
    align-items: center;
}

.mri-slider {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #888;
    border-radius: 4px;
}

.mri-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #ccc;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* ================================================================
   Histology Crosshair (OpenLayers overlay, positioned at map coordinate)
   Uses ::before/::after pseudo-elements for full-spanning crossing lines.
   Plane-based colors: horizontal=BLUE (Axial/Z), vertical=GREEN (Coronal/Y)
   ================================================================ */
.crosshair {
    position: relative;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 10;
}

.crosshair::before {
    /* Horizontal line - BLUE (Axial plane intersection, Z position) */
    content: '';
    position: absolute;
    top: 0;
    left: -5000px;
    width: 10000px;
    height: 2px;
    background-color: #3B82F6;
    opacity: 0.85;
    transform: translateY(-1px);
}

.crosshair::after {
    /* Vertical line - GREEN (Coronal plane intersection, Y position) */
    content: '';
    position: absolute;
    left: 0;
    top: -5000px;
    width: 2px;
    height: 10000px;
    background-color: #22C55E;
    opacity: 0.85;
    transform: translateX(-1px);
}

/* MRI Crosshair Overlay - Synchronized across views like QuadView */
.crosshair-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/*
 * PLANE-BASED CROSSHAIR COLORS
 * ============================
 * Colors represent SLICING PLANES, not just axes:
 *   RED   = Sagittal Plane (YZ plane, normal along X) - CONTROLS SECTIONS
 *   GREEN = Coronal Plane (XZ plane, normal along Y)
 *   BLUE  = Axial Plane (XY plane, normal along Z)
 *
 * Crosshair lines show INTERSECTIONS of planes with the current view:
 * The horizontal line = plane that intersects horizontally
 * The vertical line = plane that intersects vertically
 */

/* DEFAULT: Axial view (XY plane, BLUE plane produces this)
   - Horizontal crosshair = Coronal plane intersection = GREEN
   - Vertical crosshair = Sagittal plane intersection = RED */
.crosshair-h {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background-color: #22C55E; /* GREEN - Coronal plane intersection */
    transform: translateY(-50%);
    transition: top 0.05s ease-out;
    opacity: 0.85;
}

.crosshair-v {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background-color: #EF4444; /* RED - Sagittal plane intersection (CONTROLS SECTIONS) */
    transform: translateX(-50%);
    transition: left 0.05s ease-out;
    opacity: 0.85;
}

/* CORONAL view (XZ plane, GREEN plane produces this)
   - Horizontal crosshair = Axial plane intersection = BLUE
   - Vertical crosshair = Sagittal plane intersection = RED */
#mriInVivoCoronal .crosshair-h,
#mriRegCoronal .crosshair-h,
#mriRawCoronal .crosshair-h {
    background-color: #3B82F6; /* BLUE - Axial plane intersection */
}
/* Vertical stays RED (sagittal) - default is already correct */

/* SAGITTAL view (YZ plane, RED plane produces this)
   - Horizontal crosshair = Axial plane intersection = BLUE
   - Vertical crosshair = Coronal plane intersection = GREEN */
#mriInVivoSagittal .crosshair-h,
#mriRegSagittal .crosshair-h,
#mriRawSagittal .crosshair-h {
    background-color: #3B82F6; /* BLUE - Axial plane intersection */
}

#mriInVivoSagittal .crosshair-v,
#mriRegSagittal .crosshair-v,
#mriRawSagittal .crosshair-v {
    background-color: #22C55E; /* GREEN - Coronal plane intersection */
}

/* Crosshair Center - The draggable intersection point
   =====================================================
   This is the point where the two crosshair lines intersect.
   It can be clicked and dragged to reposition the cursor in real-time.
   Minimalist design: small circle that expands on hover.
*/
.crosshair-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    transition: top 0.05s ease-out, left 0.05s ease-out, transform 0.15s ease, background 0.15s ease;
    border-radius: 50%;
    /* Semi-transparent with subtle border */
    background: rgba(255, 255, 255, 0.5);
    border: 1.5px solid rgba(255, 215, 0, 0.8);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
    /* Enable pointer events on center for drag detection */
    pointer-events: auto;
    /* Use 'move' cursor (four-way arrow) like QuadView */
    cursor: move;
}

/* Inner dot - smaller and subtler */
.crosshair-center::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 4px;
    background: rgba(255, 215, 0, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.15s ease, height 0.15s ease;
}

/* Remove the after pseudo-element */
.crosshair-center::after {
    display: none;
}

/* Direct hover on crosshair center - expand and highlight */
.crosshair-center:hover {
    transform: translate(-50%, -50%) scale(1.25);
    background: rgba(255, 215, 0, 0.85);
    border-color: rgba(255, 215, 0, 1);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6), 0 0 3px rgba(0, 0, 0, 0.4);
    cursor: move;
}

.crosshair-center:hover::before {
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.9);
}

/* Enhanced visual feedback when hovering near crosshair center
   This state is set by JavaScript when cursor is within grab distance */
.mri-view-image.crosshair-hover .crosshair-center {
    transform: translate(-50%, -50%) scale(1.25);
    background: rgba(255, 215, 0, 0.85);
    border-color: rgba(255, 215, 0, 1);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6), 0 0 3px rgba(0, 0, 0, 0.4);
}

/* Cursor style for hovering near crosshair - use 'move' cursor */
.mri-view-image.crosshair-hover {
    cursor: move !important;
}

/* When actively dragging - use 'move' cursor (four-way arrow) */
.mri-view-image.dragging .crosshair-center {
    background: rgba(255, 215, 0, 0.95);
    transform: translate(-50%, -50%) scale(1.3);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.8), 0 0 4px rgba(0, 0, 0, 0.5);
    cursor: move;
}

/* CRITICAL: Disable transitions during dragging for instant response
   ===================================================================
   Transitions create visual lag between mouse movement and crosshair update.
   During active dragging, we need immediate/synchronous position updates. */
.mri-view-image.dragging .crosshair-h,
.mri-view-image.dragging .crosshair-v,
.mri-view-image.dragging .crosshair-center {
    transition: none !important;
}

/* GPU acceleration for crosshair elements to prevent visual artifacts
   ====================================================================
   Using will-change and transform3d triggers GPU compositing layer,
   which prevents white/black flashing during rapid updates. */
.crosshair-overlay {
    will-change: contents;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.crosshair-h,
.crosshair-v,
.crosshair-center {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-style: preserve-3d;
}

/* Ensure VTK canvas doesn't cause z-index conflicts during drag */
.mri-view-image.dragging canvas {
    pointer-events: none;
}

/* Prevent any selection or highlighting during drag which can cause visual glitches */
.mri-view-image.dragging {
    user-select: none;
    -webkit-user-select: none;
    cursor: move !important;
}

/* Default cursor for MRI views - default cursor, grab only on crosshair center */
.mri-view-image {
    cursor: default;
}

/* MRI View Label - Shows view type (Axial, Coronal, Sagittal) */
.mri-view-label {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 500;
    border-radius: 3px;
    z-index: 15;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Coordinate display in MRI views */
.mri-coord-display {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #aaa;
    padding: 2px 6px;
    font-size: 8px;
    font-family: monospace;
    border-radius: 3px;
    z-index: 15;
}

/* ============================================================================
   HISTOLOGY COLUMN
   ============================================================================ */

.histology-column {
    /* NOTE: display: grid is set in the Adaptive Layout section (line ~3473) */
    /* Do NOT set display: flex here - it conflicts with the grid layout system */
    background: linear-gradient(180deg, #f5f5f8 0%, var(--surface-color) 100%);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.05);
}

/* Histology Panel */
.histology-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    margin: 4px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.05);
    background: #1a1a2e;
    overflow: hidden;
}

/* Swap Stains Button — absolutely positioned at gap between panels */
.stain-swap-btn {
    position: absolute;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: rgba(20, 20, 40, 0.75);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    /* Default: vertical layout — centered horizontally, at the gap between top and bottom */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.stain-swap-btn:hover {
    background: rgba(50, 50, 80, 0.95);
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.35);
}

.stain-swap-btn:active {
    transform: translate(-50%, -50%) scale(0.88);
}

/* Show vertical arrows by default, hide horizontal */
.stain-swap-btn .swap-icon-vertical { display: block; }
.stain-swap-btn .swap-icon-horizontal { display: none; }

/* Horizontal layout: show horizontal arrows, position at vertical center gap */
.histology-column.layout-horizontal .stain-swap-btn {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.histology-column.layout-horizontal .stain-swap-btn:active {
    transform: translate(-50%, -50%) scale(0.88);
}
.histology-column.layout-horizontal .stain-swap-btn .swap-icon-vertical { display: none; }
.histology-column.layout-horizontal .stain-swap-btn .swap-icon-horizontal { display: block; }

/* Histology Panel Header - Transparent overlay on top of image */
.histology-panel-header {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.5);
    gap: 4px;
    min-height: 24px;
    z-index: 70;
    pointer-events: none;
    border-radius: 4px;
}

.histology-panel-header > * {
    pointer-events: auto;
}

/* Header left group - stain badge and selector - smaller and subtle */
.header-left-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Info badges - Small, subtle badges */
.info-badge {
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: help;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

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

/* Brain ID badge - Blue */
.brain-id-badge {
    background: rgba(52, 152, 219, 0.8);
}

/* Section ID badge - Green */
.section-id-badge {
    background: rgba(39, 174, 96, 0.8);
}

/* Stain badge - shows current stain (Red) */
.stain-badge {
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    background: rgba(231, 76, 60, 0.8);
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: help;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.stain-badge:hover {
    opacity: 1;
}

/* Stain selector dropdown - small and subtle */
.stain-select {
    padding: 2px 4px;
    font-size: 9px;
    font-weight: 500;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    cursor: pointer;
    min-width: 50px;
    opacity: 0.85;
}

.stain-select:hover {
    opacity: 1;
}

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

/* Dark mode stain select - override for panel headers */
body.dark-mode .stain-select {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
}

body.dark-mode .stain-select:focus {
    border-color: rgba(52, 152, 219, 0.5);
}

/* Header right group - hidden, cursor coords moved to map-info-overlay */
.header-right-group {
    display: none;
}

/* Cursor coordinates display in header (hidden) */
.cursor-coords {
    display: none;
}

/* Dark mode panel header */
body.dark-mode .histology-panel-header {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
}

/* Histology Map Wrapper - Takes full available space */
.histology-map-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    background: #1a1a2e;
}

/* Histology Map Container - Full wrapper space */
.histology-map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
}

.histology-map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    overflow: visible !important;
}

/* Ensure OpenLayers canvas layers are properly visible */
.histology-map canvas {
    z-index: 5;
}

/* OpenLayers overlay for measurements should be on top */
.histology-map .ol-overlay-container {
    z-index: 20;
}

/* Histology Crosshair - lower z-index to not cover measure lines */
/* Histology Crosshair - Hidden (not needed) */
.histology-crosshair {
    display: none;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    z-index: 90;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

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

/* Image Not Available Overlay */
.loading-overlay.image-error {
    background: rgba(30, 30, 30, 0.85);
    color: #ff6b6b;
}

.loading-overlay.image-error .loading-spinner {
    display: none;
}

.loading-overlay.image-error .error-icon {
    font-size: 36px;
    margin-bottom: 8px;
    opacity: 0.8;
}

.loading-overlay.image-error .error-message {
    font-size: 13px;
    font-weight: 600;
    color: #ff6b6b;
}

.loading-overlay.image-error .error-detail {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
    max-width: 250px;
    text-align: center;
}

/* Map Label - Positioned at top-center to avoid zoom controls on left */
.map-label {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 5px 14px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    z-index: 50;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Annotation Legend */
.annotation-legend {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 50;
    font-size: 11px;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

/* Thumbnail Preview (bottom-right of histology panel) */
.thumbnail-preview {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 80px;
    height: 60px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    z-index: 50;
}

.thumbnail-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Map Info Overlay - Top-right with cursor coords + zoom preview */
.map-info-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 140px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 60;
    pointer-events: none;
}

.map-info-overlay > * {
    pointer-events: auto;
}

/* Cursor Coordinates Display - Inside overlay */
.overlay-cursor-coords {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-width: 100%;
    padding: 5px 10px;
    background: var(--surface-color);
    color: var(--text-color);
    font-size: 10px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    border-radius: 4px;
    text-align: center;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    box-shadow: 0 2px 8px var(--shadow);
}

/* Dark mode overlay coords */
body.dark-mode .overlay-cursor-coords {
    background: rgba(30, 41, 59, 0.95);
    color: #f1f5f9;
    border-color: rgba(52, 152, 219, 0.4);
}

/* Cursor Preview / Zoom Preview - Inside overlay */
.cursor-preview {
    position: relative;
    width: 140px;
    height: 140px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface-color);
    box-shadow: 0 4px 15px var(--shadow-dark);
    display: none;
}

/* Light mode cursor preview */
body:not(.dark-mode) .cursor-preview {
    background: #f8f9fa;
    border-color: #ccc;
}

/* Dark mode cursor preview */
body.dark-mode .cursor-preview {
    background: #1e293b;
    border-color: rgba(52, 152, 219, 0.5);
}

/* Let OpenLayers handle canvas sizing via updateSize() */
/* Don't override - the lazy init ensures proper dimensions */

/* Label for cursor preview */
.cursor-preview-label {
    font-size: 8px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: center;
}

/* Footer navigation controls - removed histology panel footer, nav is now in main footer */

.annotation-layer-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-slider {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-muted);
}

.scale-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-color);
}

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

/* Navigation Buttons */
.nav-btn {
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    background: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.nav-btn:hover {
    background: linear-gradient(145deg, #f0f0f0 0%, #e0e0e0 100%);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.15);
    transform: translateY(-1px);
}

.nav-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-separator {
    color: var(--text-muted);
    font-weight: 300;
}

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

/* ============================================================================
   ICON BAR (Quick Actions - Right of Histology)
   ============================================================================ */

.icon-bar {
    background: linear-gradient(180deg, var(--surface-color) 0%, #f8f9fa 100%);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.04), 2px 0 12px rgba(0, 0, 0, 0.04);
}

.icon-bar-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Comparison dropdown in icon bar */
.icon-bar-item.comparison-item {
    padding: 4px;
    gap: 4px;
}

.icon-bar-label {
    font-size: 8px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: center;
    margin-bottom: 2px;
}

.icon-bar-select {
    width: 100%;
    padding: 4px 4px;
    font-size: 9px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--surface-color);
    color: var(--text-color);
    cursor: pointer;
}

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

/* Icon bar section label */
.icon-bar-section-label {
    font-size: 8px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    padding: 2px 0;
}

/* Icon bar slider */
.icon-bar-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--slider-track);
    border-radius: 2px;
    cursor: pointer;
}

.icon-bar-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

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

/* Icon bar divider */
.icon-bar-divider {
    width: 80%;
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.icon-bar-btn {
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: linear-gradient(145deg, #ffffff 0%, #f5f5f5 100%);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.icon-bar-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.15);
}

.icon-bar-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.icon-bar-text {
    font-size: 7px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    line-height: 1;
}

/* Icon bar button states */
.icon-bar-btn.active {
    background: #fce7f3;
    border-color: #ec4899;
}

.icon-bar-btn.active .icon-bar-text {
    color: #be185d;
}

/* Annotations button */
.icon-bar-btn[data-action="annotations"] svg {
    stroke: #ec4899;
}

.icon-bar-btn[data-action="annotations"].active {
    background: #fce7f3;
    border-color: #ec4899;
}

/* Heatmap button */
.icon-bar-btn[data-action="heatmap"] svg {
    stroke: #f59e0b;
}

.icon-bar-btn[data-action="heatmap"].active {
    background: #fef3c7;
    border-color: #f59e0b;
}

.icon-bar-btn[data-action="heatmap"].active .icon-bar-text {
    color: #b45309;
}

/* Measure button */
.icon-bar-btn[data-action="measure"] svg {
    stroke: #3b82f6;
}

.icon-bar-btn[data-action="measure"].active {
    background: #dbeafe;
    border-color: #3b82f6;
}

.icon-bar-btn[data-action="measure"].active .icon-bar-text {
    color: #1d4ed8;
}

/* Clear button */
.icon-bar-btn[data-action="clear"] svg {
    stroke: #ef4444;
}

.icon-bar-btn[data-action="clear"]:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Thumbnails button */
.icon-bar-btn[data-action="thumbnails"] svg {
    stroke: #6b7280;
}

/* 3D button */
.icon-bar-btn[data-action="3d"] {
    background: linear-gradient(135deg, #fafafa 0%, #f5f3ff 100%);
}

.icon-bar-btn[data-action="3d"] svg {
    stroke: #8b5cf6;
}

.icon-bar-btn[data-action="3d"]:hover {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border-color: #8b5cf6;
}

/* Icon bar divider */
.icon-bar-divider {
    width: 70%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--border-color) 30%, var(--border-color) 70%, transparent 100%);
    margin: 6px 0;
    border-radius: 1px;
}

/* Dark mode icon bar */
body.dark-mode .icon-bar {
    background: linear-gradient(180deg, #1a2744 0%, var(--surface-color) 50%, #151d2e 100%);
    border-color: var(--border-color);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.2), 2px 0 12px rgba(0, 0, 0, 0.2);
}

body.dark-mode .icon-bar-btn {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border-color: var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

body.dark-mode .icon-bar-btn:hover {
    background: linear-gradient(145deg, #2d3a4f 0%, #1e293b 100%);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

body.dark-mode .icon-bar-btn[data-action="annotations"].active {
    background: rgba(236, 72, 153, 0.2);
}

body.dark-mode .icon-bar-btn[data-action="heatmap"].active {
    background: rgba(245, 158, 11, 0.2);
}

body.dark-mode .icon-bar-btn[data-action="measure"].active {
    background: rgba(59, 130, 246, 0.2);
}

body.dark-mode .icon-bar-btn[data-action="3d"] {
    background: linear-gradient(135deg, #1e293b 0%, #2e1065 100%);
}

/* ============================================================================
   FOOTER COORDINATE BAR
   ============================================================================ */

.footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background: linear-gradient(180deg, #f8fafc 0%, var(--surface-color) 100%);
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr auto auto auto auto 1fr;
    align-items: center;
    gap: 20px;
    padding: 0 15px;
    z-index: 1000;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
}

.footer-nav-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-self: end;
}

.footer-nav-controls .nav-btn {
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 500;
    border-radius: 4px;
    min-width: auto;
}

.footer-nav-controls .nav-separator {
    color: var(--text-muted);
    font-size: 10px;
    opacity: 0.5;
    margin: 0 2px;
}

.coord-display {
    display: flex;
    align-items: center;
    gap: 5px;
}

.coord-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

.coord-value {
    font-size: 10px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--text-color);
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
}

/* ============================================================================
   THUMBNAIL POPUP - Exact copy from old UI
   ============================================================================ */

.thumbnail-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    overflow: auto;
}

.thumbnail-popup-content {
    background-color: var(--surface-color);
    margin: 1vh auto;
    padding: 1.5vh 2vw;
    width: 90vw;
    max-width: 1400px;
    height: auto;
    max-height: 96vh;
    border-radius: 0.5rem;
    position: relative;
    overflow: auto;
    transition: background-color 0.3s ease;
    box-shadow: 0 4px 20px var(--shadow-dark);
}

.thumbnail-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 3px solid var(--border-color);
    padding-bottom: 1rem;
    transition: border-color 0.3s ease;
}

.thumbnail-popup-header h2 {
    margin: 0;
    color: var(--text-color);
    font-size: 2rem;
    font-weight: normal;
    transition: color 0.3s ease;
}

.thumbnail-close-btn {
    background: none;
    border: none;
    font-size: 2.25rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 1.875rem;
    height: 1.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.thumbnail-close-btn:hover {
    color: var(--text-color);
}

.thumbnail-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: min(2.6rem, 3.3vh);
    padding: 9.5vh 2vw 2vh;
    justify-items: center;
    align-items: center;
    height: fit-content;
    overflow: visible;
    margin-top: 0;
}

.section-thumbnail-group {
    position: relative;
    display: inline-block;
    cursor: pointer;
    transition: transform 0.3s ease;
    margin: min(0.5rem, 1vw);
    perspective: 1000px;
    overflow: visible;
}

.section-thumbnail-group:hover {
    transform: scale(1.05);
    z-index: 100;
}

.thumbnail-images-container {
    position: relative;
    width: min(13rem, 22vh);
    min-height: min(11.5rem, 19vh);
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 0.4s ease;
    overflow: visible;
}

.thumbnail-img {
    position: absolute;
    width: min(6.5rem, 10.5vh);
    height: min(6.5rem, 10.5vh);
    object-fit: cover;
    border-radius: 0.375rem;
    background-color: #fff;
    transition: transform 0.4s ease-out, box-shadow 0.4s ease-out, filter 0.4s ease, opacity 0.4s ease;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

body.dark-mode .thumbnail-img {
    background-color: #fff;
    filter: brightness(0.9);
}

.thumbnail-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 100;
    transition: background-color 0.3s ease;
}

.thumbnail-nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

body.dark-mode .thumbnail-nav-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
}

body.dark-mode .thumbnail-nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.thumbnail-nav-left {
    left: 0.625rem;
}

.thumbnail-nav-right {
    right: 0.625rem;
}

.thumbnail-page-indicator {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 1.125rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.section-thumbnail-label {
    position: absolute;
    bottom: min(5rem, 8vh);
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-size: 1.2rem;
    color: white;
    font-weight: 800;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 0.3rem 0.75rem;
    border-radius: 0.25rem;
    z-index: 50;
    white-space: nowrap;
    transition: background-color 0.3s ease;
}

body.dark-mode .section-thumbnail-label {
    background-color: rgba(255, 255, 255, 0.9);
    color: #1a202c;
}

/* Hide stain label on individual thumbnails */
.thumbnail-stain-label {
    display: none;
}

.thumbnail-error {
    position: absolute;
    width: min(6.5rem, 10.5vh);
    height: min(6.5rem, 10.5vh);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f7fafc;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.4s ease-out, box-shadow 0.4s ease-out, filter 0.4s ease, opacity 0.4s ease, background-color 0.3s ease, color 0.3s ease;
}

.thumbnail-skeleton {
    position: absolute;
    width: min(6.5rem, 10.5vh);
    height: min(6.5rem, 10.5vh);
    background: linear-gradient(90deg, var(--light-surface) 25%, var(--border-color) 50%, var(--light-surface) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 0.375rem;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 3D Thumbnail Effects and Layout */
.thumbnail-img.ihc, .thumbnail-skeleton.ihc, .thumbnail-error.ihc {
    z-index: 30;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 8px 24px rgba(0, 0, 0, 0.25),
        0 2px 8px rgba(0, 0, 0, 0.15);
}

.thumbnail-img.left-1, .thumbnail-skeleton.left-1, .thumbnail-error.left-1 {
    z-index: 20;
    width: min(6rem, 10vh);
    height: min(6rem, 10vh);
    transform: translate(-50%, -50%) translateZ(20px) rotateY(20deg) translateX(min(-42px, -4.2vh));
    transform-origin: center;
    box-shadow:
        -4px 4px 16px rgba(0, 0, 0, 0.2),
        -2px 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0.8;
}

.thumbnail-img.right-1, .thumbnail-skeleton.right-1, .thumbnail-error.right-1 {
    z-index: 20;
    width: min(6rem, 10vh);
    height: min(6rem, 10vh);
    transform: translate(-50%, -50%) translateZ(20px) rotateY(-20deg) translateX(min(42px, 4.2vh));
    transform-origin: center;
    box-shadow:
        4px 4px 16px rgba(0, 0, 0, 0.2),
        2px 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0.8;
}

.thumbnail-img.back, .thumbnail-skeleton.back, .thumbnail-error.back {
    z-index: 10;
    width: min(5.3rem, 9vh);
    height: min(5.3rem, 9vh);
    transform: translate(-50%, -50%) translateZ(0px) translateY(min(-36px, -3.6vh)) scale(0.92);
    opacity: 0.8;
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.15),
        0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Hover Effects for 3D Thumbnails */
.section-thumbnail-group:hover .thumbnail-img.left-1,
.section-thumbnail-group:hover .thumbnail-skeleton.left-1,
.section-thumbnail-group:hover .thumbnail-error.left-1 {
    transform: translate(-50%, -50%) translateZ(20px) rotateY(25deg) translateX(min(-60px, -6vh));
    opacity: 1;
}

.section-thumbnail-group:hover .thumbnail-img.right-1,
.section-thumbnail-group:hover .thumbnail-skeleton.right-1,
.section-thumbnail-group:hover .thumbnail-error.right-1 {
    transform: translate(-50%, -50%) translateZ(20px) rotateY(-25deg) translateX(min(60px, 6vh));
    opacity: 1;
}

.section-thumbnail-group:hover .thumbnail-img.back,
.section-thumbnail-group:hover .thumbnail-skeleton.back,
.section-thumbnail-group:hover .thumbnail-error.back {
    transform: translate(-50%, -50%) translateZ(5px) translateY(min(-48px, -4.8vh)) scale(0.95);
    opacity: 1;
}

.section-thumbnail-group:hover .thumbnail-img.ihc,
.section-thumbnail-group:hover .thumbnail-skeleton.ihc,
.section-thumbnail-group:hover .thumbnail-error.ihc {
    transform: translate(-50%, -50%) translateZ(45px) scale(1.03);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 12px 32px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   OPENLAYERS OVERRIDES
   ============================================================================ */

.ol-viewport {
    border-radius: 0;
    overflow: visible !important;
}

/* OpenLayers Zoom Controls - Compact size to match UI */
.ol-zoom {
    position: absolute !important;
    top: 38px !important;
    left: 10px !important;
    background: transparent !important;
}

.ol-zoom button {
    background: rgba(0, 0, 0, 0.6) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    border: none !important;
    width: 22px !important;
    height: 22px !important;
    font-size: 12px !important;
    line-height: 20px !important;
    border-radius: 3px !important;
    margin: 1px !important;
    cursor: pointer !important;
    padding: 0 !important;
}

.ol-zoom button:hover {
    background: rgba(0, 0, 0, 0.8) !important;
    color: #fff !important;
}

/* OpenLayers ScaleLine - Bottom-left, compact size */
.ol-scale-line {
    position: absolute !important;
    bottom: 10px !important;
    left: 10px !important;
    width: 100px !important;
    background: rgba(0, 0, 0, 0.7) !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    text-align: center !important;
    border: 1px solid rgba(52, 152, 219, 0.4) !important;
    z-index: 55 !important;
}

.ol-scale-line-inner {
    color: #fff !important;
    font-size: 9px !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    display: block !important;
    text-align: center !important;
}

/* Overview Map - Left side, above scale bar */
.ol-overviewmap,
.ol-overviewmap.overviewmap-custom {
    position: absolute !important;
    left: 10px !important;
    right: auto !important;
    bottom: 45px !important;
    top: auto !important;
    background: transparent !important;
    border: none !important;
    z-index: 50 !important;
}

/* Overview map inner map container */
.ol-overviewmap-map {
    width: 120px !important;
    height: 120px !important;
    border: 1px solid rgba(52, 152, 219, 0.5) !important;
    border-radius: 4px !important;
    background: #000 !important;
    overflow: hidden !important;
}

/* Let OpenLayers handle canvas sizing */

/* Overview map box indicator (the red dotted box showing current view) */
.ol-overviewmap-box {
    border: 2px dotted red !important;
    background: rgba(255, 0, 0, 0.1) !important;
}

/* Overview map collapse/expand button - positioned at bottom-left of the overview map */
.ol-overviewmap button {
    position: absolute !important;
    bottom: 2px !important;
    left: 2px !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
    width: 18px !important;
    height: 18px !important;
    background: rgba(0, 0, 0, 0.6) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 3px !important;
    font-size: 10px !important;
    line-height: 18px !important;
    cursor: pointer !important;
    z-index: 60 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

.ol-overviewmap button:hover {
    background: rgba(0, 0, 0, 0.85) !important;
}

/* When overview is collapsed - show only the button with same size */
.ol-overviewmap.ol-collapsed {
    width: auto !important;
    height: auto !important;
}

.ol-overviewmap.ol-collapsed .ol-overviewmap-map {
    display: none !important;
}

.ol-overviewmap.ol-collapsed button {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 10px !important;
    line-height: 18px !important;
}

/* ============================================================================
   TOOLTIPS & OVERLAYS
   ============================================================================ */

.measure-tooltip,
.heatmap-tooltip {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
}

.measure-tip {
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.9);
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 10px;
    pointer-events: none;
    z-index: 100;
}

/* Crosshair for OpenLayers */
.crosshair {
    position: relative;
    width: 20px;
    height: 20px;
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background: #ef4444;
}

.crosshair::before {
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
}

.crosshair::after {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 1600px) {
    :root {
        --sidebar-width: 190px;
        --tools-width: 145px;
        --mri-column-width: 200px;
        --icon-bar-width: 65px;
    }

    /* Tools pane scaling for 1600px */
    .sidebar.tools-pane .sidebar-content {
        padding: 8px 8px;
    }
    .sidebar.tools-pane .nav-section-label {
        font-size: 9px;
        padding: 5px 6px;
        margin-bottom: 6px;
    }
    .sidebar.tools-pane .control-label {
        font-size: 9px;
    }
    .sidebar.tools-pane .control-select {
        padding: 5px 6px;
        font-size: 9px;
    }
    .sidebar.tools-pane .toggle-btn {
        padding: 6px 8px;
        font-size: 9px;
        gap: 6px;
    }
    .sidebar.tools-pane .toggle-btn svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 1400px) {
    :root {
        --sidebar-width: 180px;
        --tools-width: 140px;
        --mri-column-width: 180px;
        --icon-bar-width: 60px;
    }

    .map-info-overlay {
        width: 120px;
    }

    .ol-scale-line {
        width: 90px !important;
    }

    .ol-overviewmap-map {
        width: 100px !important;
        height: 100px !important;
    }

    .cursor-preview {
        width: 120px;
        height: 120px;
    }

    .icon-bar-btn {
        width: 45px;
        height: 45px;
    }

    .icon-bar-text {
        font-size: 7px;
    }

    /* Tools pane scaling for 1400px */
    .sidebar.tools-pane .sidebar-content {
        padding: 7px 7px;
    }
    .sidebar.tools-pane .nav-section-label {
        font-size: 9px;
        padding: 5px 5px;
        margin-bottom: 5px;
    }
    .sidebar.tools-pane .control-group {
        margin-bottom: 8px;
    }
    .sidebar.tools-pane .control-label {
        font-size: 9px;
        margin-bottom: 3px;
    }
    .sidebar.tools-pane .control-select {
        padding: 5px 5px;
        font-size: 9px;
    }
    .sidebar.tools-pane .sidebar-divider {
        margin: 8px 0;
    }
    .sidebar.tools-pane .toggle-buttons-group {
        gap: 4px;
    }
    .sidebar.tools-pane .toggle-btn {
        padding: 5px 7px;
        font-size: 9px;
        gap: 5px;
        border-radius: 4px;
    }
    .sidebar.tools-pane .toggle-btn svg {
        width: 13px;
        height: 13px;
    }
    .sidebar.tools-pane .slider-value {
        font-size: 9px;
        min-width: 24px;
    }
}

@media (max-width: 1200px) {
    :root {
        --sidebar-width: 145px;
        --tools-width: 130px;
        --mri-column-width: 160px;
        --icon-bar-width: 55px;
    }

    .control-label {
        font-size: 11px;
    }

    .map-info-overlay {
        width: 100px;
    }

    .overlay-cursor-coords {
        font-size: 9px;
        padding: 3px 6px;
    }

    .ol-scale-line {
        width: 80px !important;
    }

    .ol-overviewmap-map {
        width: 90px !important;
        height: 90px !important;
    }

    .cursor-preview {
        width: 100px;
        height: 100px;
    }

    .control-select {
        padding: 6px 8px;
        font-size: 11px;
    }

    .icon-bar-btn {
        width: 40px;
        height: 40px;
    }

    .icon-bar-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Tools pane scaling for 1200px */
    .sidebar.tools-pane .sidebar-content {
        padding: 6px 6px;
    }
    .sidebar.tools-pane .nav-section-label {
        font-size: 8px;
        padding: 4px 5px;
        margin-bottom: 4px;
    }
    .sidebar.tools-pane .control-group {
        margin-bottom: 6px;
    }
    .sidebar.tools-pane .control-label {
        font-size: 8px;
        margin-bottom: 2px;
    }
    .sidebar.tools-pane .control-select {
        padding: 4px 4px;
        font-size: 8px;
    }
    .sidebar.tools-pane .sidebar-divider {
        margin: 6px 0;
    }
    .sidebar.tools-pane .toggle-buttons-group {
        gap: 3px;
    }
    .sidebar.tools-pane .toggle-btn {
        padding: 4px 6px;
        font-size: 8px;
        gap: 4px;
        border-radius: 4px;
    }
    .sidebar.tools-pane .toggle-btn svg {
        width: 12px;
        height: 12px;
    }
    .sidebar.tools-pane .slider-value {
        font-size: 8px;
        min-width: 22px;
    }
    .sidebar.tools-pane .slider {
        height: 4px;
    }
    .sidebar.tools-pane .slider::-webkit-slider-thumb {
        width: 12px;
        height: 12px;
    }
    .sidebar.tools-pane .slider::-moz-range-thumb {
        width: 12px;
        height: 12px;
    }
}

/* ============================================================================
   MOBILE HAMBURGER MENU BUTTON (Hidden on desktop)
   ============================================================================ */
.mobile-menu-btn {
    display: none; /* Hidden on desktop */
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color, #fff);
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: #f0f0f0;
    border-color: var(--primary-color, #2196F3);
}

.mobile-menu-btn.active {
    background: linear-gradient(145deg, #e3f2fd 0%, #bbdefb 100%);
    border-color: var(--primary-color, #2196F3);
    color: var(--primary-color, #2196F3);
}

body.dark-mode .mobile-menu-btn {
    background: var(--surface-color, #1e293b);
    border-color: var(--border-color);
    color: var(--text-color);
}

body.dark-mode .mobile-menu-btn:hover {
    background: #2d3a4f;
    border-color: #3b82f6;
}

/* ============================================================================
   MOBILE NAVIGATION DRAWER
   ============================================================================ */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-overlay.open {
    display: block;
    opacity: 1;
}

.mobile-nav-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(44vw, 240px);
    height: 100vh;
    background: var(--surface-color, #fff);
    z-index: 2001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.mobile-nav-drawer.open {
    right: 0;
}

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 10px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    flex-shrink: 0;
}

.mobile-nav-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.mobile-nav-close {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.mobile-nav-close:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Tab bar for switching between MRI Nav / Histology Nav / Tools */
.mobile-nav-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
    background: var(--surface-color);
}

.mobile-nav-tab {
    flex: 1;
    padding: 7px 4px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
}

.mobile-nav-tab.active {
    color: var(--primary-color, #2196F3);
    border-bottom-color: var(--primary-color, #2196F3);
}

.mobile-nav-tab:hover {
    color: var(--text-color);
    background: rgba(0, 0, 0, 0.03);
}

/* Content area - scrollable, compact for narrow drawer */
.mobile-nav-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

/* Make sidebar content compact when inside mobile drawer */
.mobile-nav-content .sidebar-content {
    font-size: 11px;
}

.mobile-nav-content .sidebar-content .section-title,
.mobile-nav-content .sidebar-content h4 {
    font-size: 11px;
}

.mobile-nav-content .sidebar-content .slider-container,
.mobile-nav-content .sidebar-content .checkbox-group {
    gap: 4px;
}

.mobile-nav-content .sidebar-content label {
    font-size: 10px;
}

.mobile-nav-content .sidebar-content button,
.mobile-nav-content .sidebar-content .btn {
    font-size: 10px;
    padding: 4px 8px;
}

/* Dark mode for mobile drawer */
body.dark-mode .mobile-nav-drawer {
    background: var(--surface-color);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

body.dark-mode .mobile-nav-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .mobile-nav-tab:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================================================
   MOBILE SCROLL INDICATOR
   A sleek semi-circular pill handle on the right edge (mobile only).
   Drag it vertically to scroll the page without conflicting with map touches.
   ============================================================================ */
.mobile-scroll-indicator {
    display: none; /* Hidden on desktop, shown via media query */
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1500; /* Below drawer (2001) but above content */
    user-select: none;
    -webkit-user-select: none;
    transition: opacity 0.3s ease, top 0.1s linear;
}

.mobile-scroll-indicator .scroll-pill {
    width: 18px;
    height: 48px;
    background: rgba(120, 120, 120, 0.35);
    border-radius: 10px 0 0 10px; /* Semi-circular on left, flat on right (edge) */
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: all 0.2s ease;
    box-shadow: -1px 0 4px rgba(0, 0, 0, 0.1);
    cursor: grab;
}

.mobile-scroll-indicator .scroll-pill:active,
.mobile-scroll-indicator .scroll-pill.dragging {
    width: 24px;
    height: 56px;
    background: rgba(100, 100, 100, 0.55);
    cursor: grabbing;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
}

/* Dark mode */
body.dark-mode .mobile-scroll-indicator .scroll-pill {
    background: rgba(180, 180, 180, 0.25);
    color: rgba(255, 255, 255, 0.6);
}

body.dark-mode .mobile-scroll-indicator .scroll-pill:active,
body.dark-mode .mobile-scroll-indicator .scroll-pill.dragging {
    background: rgba(180, 180, 180, 0.45);
}

/* ============================================================================
   RESPONSIVE: TABLET & MOBILE (max-width: 992px)
   Stack everything vertically, all sections visible via scrolling.
   Sidebars go into hamburger menu drawer.
   ============================================================================ */
@media (max-width: 992px) {
    /* --- BODY: enable scrolling (but allow drawer to lock scroll via class) --- */
    html, body {
        overflow: auto;
        overflow-x: hidden;
        height: auto !important;
        min-height: 100vh;
    }

    /* When mobile drawer is open, prevent background scroll */
    body.mobile-drawer-open {
        overflow: hidden !important;
    }

    /* --- HAMBURGER MENU: show on mobile --- */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* --- MAIN LAYOUT: vertical flow, scrollable --- */
    .main-layout {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        min-height: calc(100vh - var(--header-height));
        margin-top: var(--header-height);
        margin-bottom: 0 !important;
        padding-bottom: 36px; /* Space for fixed footer */
        overflow: visible !important;
        grid-template-columns: none !important;
    }

    /* --- SIDEBARS: hide from flow, available via hamburger drawer --- */
    .sidebar {
        display: none !important;
    }

    /* --- SIDEBAR TOGGLE BUTTONS: hide --- */
    .sidebar-toggle-btn {
        display: none !important;
    }

    /* --- MRI COLUMNS: full width, stacked --- */
    .mri-column {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color);
        overflow: visible !important;
    }

    .mri-views-container {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px;
        padding: 8px;
        overflow: visible !important;
        flex: none !important;
    }

    .mri-view-image {
        aspect-ratio: 1 / 1;
        min-height: 100px;
    }

    /* --- HISTOLOGY: KEEP GRID but force vertical with EXPLICIT row heights --- */
    /* This is critical: 1fr rows collapse to 0 without a definite container height.
       Using explicit heights (45vh) ensures panels always have size. */
    .histology-column,
    .histology-column.layout-vertical,
    .histology-column.layout-horizontal {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: 45vh 45vh !important;
        gap: 4px !important;
        overflow: visible !important;
        height: auto !important;
        min-height: auto !important;
    }

    /* Panels fill their grid cells */
    .histology-panel {
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* Map wrapper fills panel */
    .histology-column .histology-map-wrapper {
        flex: 1;
        min-height: 0;
        position: relative;
    }

    /* Map container fills wrapper - use absolute so it takes full space */
    .histology-column .histology-map-container {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        min-height: 0 !important;
    }

    .histology-column .histology-map {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: auto !important;
        height: auto !important;
    }

    /* --- HEADER: compact --- */
    .header {
        padding: 0 12px;
    }

    .header-title {
        font-size: 14px;
    }

    .header-subtitle {
        font-size: 10px;
    }

    .header-logo {
        width: 32px;
        height: 32px;
    }

    /* Hide tools button on mobile - accessible from hamburger menu */
    .header-btn.tools-btn {
        display: none !important;
    }

    /* --- FOOTER: fixed at bottom on mobile, no dead space --- */
    .footer-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 4px 8px;
        height: auto;
        min-height: 28px;
        z-index: 1000;
    }

    .footer-bar .coord-display:first-child {
        display: none;
    }

    /* --- TOUCH HANDLING: allow page scroll over maps --- */
    /* Single finger scrolls the page. Two-finger pinch/pan works for map interaction. */
    .histology-map,
    .histology-map-container,
    .mri-view-image {
        touch-action: pan-y !important;
    }

    /* --- HISTOLOGY REF PANEL: smaller on tablet --- */
    .histology-ref-panel {
        bottom: 45px;
        right: 10px;
    }
    .ref-expand-icon-btn {
        width: 46px;
        height: 46px;
    }
    .ref-panel-expanded {
        width: 170px;
    }
    .ref-mri-view {
        height: 120px;
    }

    /* --- THUMBNAIL DOCK --- */
    .thumbnail-dock {
        max-width: min(90%, calc(100% - 20px));
    }

    .dock-nav-btn.dock-nav-left {
        margin-right: 16px;
    }

    .dock-nav-btn.dock-nav-right {
        margin-left: 16px;
    }

    .dock-thumbnails {
        overflow: hidden;
        min-width: 0;
    }

    /* --- TOOLS DRAWER: responsive --- */
    .tools-drawer {
        max-width: min(280px, 80vw) !important;
        min-width: 0 !important;
    }

    /* --- MOBILE SCROLL INDICATOR --- */
    .mobile-scroll-indicator {
        display: flex !important;
    }
}

/* ============================================================================
   RESPONSIVE: SMALL TABLET / LARGE PHONE (max-width: 768px)
   ============================================================================ */
@media (max-width: 768px) {
    :root {
        --header-height: 50px;
        --footer-height: auto;
    }

    .header {
        height: 50px;
        padding: 0 10px;
    }

    .header-title {
        font-size: 12px;
    }

    .header-subtitle {
        font-size: 9px;
    }

    .header-logo {
        width: 28px;
        height: 28px;
    }

    .header-left {
        gap: 8px;
    }

    .main-layout {
        margin-top: 50px !important;
    }

    /* MRI views */
    .mri-views-container {
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 4px;
        padding: 4px;
    }

    .mri-view-image {
        min-height: 80px;
    }

    /* Histology panels: smaller on smaller screens */
    .histology-column,
    .histology-column.layout-vertical,
    .histology-column.layout-horizontal {
        grid-template-rows: 40vh 40vh !important;
    }

    /* MRI column header */
    .column-header {
        padding: 6px 8px;
        font-size: 11px;
    }

    /* Footer */
    .footer-bar {
        gap: 6px;
        padding: 4px 8px;
    }

    .coord-display {
        font-size: 9px;
    }

    .footer-nav-controls .nav-btn {
        padding: 3px 6px;
        font-size: 9px;
    }

    /* Histology panel header compact */
    .histology-panel-header {
        padding: 3px 6px;
        gap: 2px;
    }

    .info-badge {
        font-size: 8px;
        padding: 1px 4px;
    }

    .stain-select {
        font-size: 9px;
        min-width: 40px;
    }

    /* Tools drawer full width */
    .tools-drawer {
        max-width: 100% !important;
        min-width: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 50px !important;
        border-radius: 0 !important;
    }

    /* Map info overlay smaller */
    .map-info-overlay {
        width: 80px;
    }

    .cursor-preview {
        width: 80px;
        height: 80px;
    }

    /* Histology ref panel - smaller on small tablet */
    .histology-ref-panel {
        bottom: 40px;
        right: 8px;
    }
    .ref-expand-icon-btn {
        width: 42px;
        height: 42px;
    }
    .ref-expand-icon-btn svg {
        width: 18px;
        height: 18px;
    }
    .ref-panel-expanded {
        width: 150px;
    }
    .ref-mri-view {
        height: 100px;
    }

    /* Thumbnail popup responsive */
    .thumbnail-popup-content {
        width: 95vw;
        max-height: 90vh;
    }

    .thumbnail-container {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Mobile drawer - less than half screen */
    .mobile-nav-drawer {
        width: min(44vw, 220px);
    }

    .mobile-menu-btn {
        width: 36px;
        height: 36px;
        margin-left: 6px;
    }

    .mobile-menu-btn svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================================================
   RESPONSIVE: PHONE (max-width: 480px)
   ============================================================================ */
@media (max-width: 480px) {
    :root {
        --header-height: 44px;
    }

    .header {
        height: 44px;
        padding: 0 8px;
    }

    .header-title {
        font-size: 11px;
    }

    .header-subtitle {
        display: none;
    }

    .header-logo {
        width: 24px;
        height: 24px;
    }

    .header-left {
        gap: 6px;
    }

    /* Tools button already hidden at 992px */

    .theme-toggle {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }

    .mobile-menu-btn {
        width: 34px;
        height: 34px;
        margin-left: 6px;
    }

    .main-layout {
        margin-top: 44px !important;
    }

    /* MRI views: 1 column on phones */
    .mri-views-container {
        grid-template-columns: 1fr !important;
        gap: 4px;
        padding: 4px;
    }

    .mri-view-image {
        min-height: 200px;
        aspect-ratio: 1 / 1;
    }

    /* Histology: shorter panels for phone */
    .histology-column,
    .histology-column.layout-vertical,
    .histology-column.layout-horizontal {
        grid-template-rows: 35vh 35vh !important;
    }

    /* Footer minimal */
    .footer-bar {
        gap: 4px;
        padding: 3px 6px;
    }

    .coord-label {
        font-size: 8px;
    }

    .coord-value {
        font-size: 8px;
        padding: 1px 4px;
    }

    /* Direction indicators */
    .direction-indicator {
        font-size: 9px;
        width: 16px;
        height: 16px;
    }

    /* Thumbnail popup */
    .thumbnail-container {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem;
        padding: 2vh 2vw 2vh;
    }

    .thumbnail-images-container {
        width: min(10rem, 40vw);
        min-height: min(8rem, 35vw);
    }

    /* Annotation legend */
    .annotation-legend {
        font-size: 9px;
        max-height: 100px;
    }

    /* Histology ref panel - smallest on phone */
    .ref-expand-icon-btn {
        width: 40px;
        height: 40px;
    }
    .ref-expand-icon-btn svg {
        width: 16px;
        height: 16px;
    }
    .ref-expand-icon-label {
        font-size: 8px;
    }
    .ref-panel-expanded {
        width: 130px;
    }
    .ref-mri-view {
        height: 80px;
    }
    .ref-view-btn {
        width: 26px;
        height: 20px;
        font-size: 10px;
        line-height: 20px;
    }

    /* Tools drawer */
    .tools-drawer {
        top: 44px !important;
    }

    /* Mobile drawer - compact on phone */
    .mobile-nav-drawer {
        width: min(48vw, 200px);
    }

    .mobile-nav-tab {
        font-size: 10px;
        padding: 8px 4px;
    }
}

/* ============================================================================
   HISTOLOGY 3D REFERENCE PANEL (replaces old coronal indicator)
   ============================================================================ */

/* Reference panel - Fixed position overlay, draggable like tools box */
.histology-ref-panel {
    position: fixed;
    bottom: calc(var(--footer-height, 32px) + 10px);
    right: 15px;
    z-index: 200;
    transition: all 0.3s ease;
}

/* Draggable state */
.histology-ref-panel.dragging {
    cursor: grabbing;
    user-select: none;
    transition: none;
}

/* --- COLLAPSED STATE: Big icon button to expand --- */
.ref-panel-collapsed {
    position: relative;
}

.ref-expand-icon-btn {
    width: 52px;
    height: 52px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0;
    color: #475569;
    transition: all 0.2s ease;
}

.ref-expand-icon-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1);
    color: #1e293b;
    border-color: rgba(0, 0, 0, 0.2);
}

.ref-expand-icon-btn:active {
    transform: scale(1.02);
}

.ref-expand-icon-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.ref-expand-icon-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1;
    user-select: none;
}

body.dark-mode .ref-expand-icon-btn {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border-color: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .ref-expand-icon-btn:hover {
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.4);
}

/* --- EXPANDED STATE: Header + single MRI view + A/C/S toggle --- */
.ref-panel-expanded {
    width: 190px;
    background: linear-gradient(145deg, #ffffff 0%, #f5f5f5 100%);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.ref-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    cursor: grab;
    user-select: none;
}

.ref-panel-header:active {
    cursor: grabbing;
}

.ref-panel-title {
    font-size: 9px;
    font-weight: 600;
    color: #334155;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ref-panel-title::before {
    content: '\22EE\22EE';
    font-size: 8px;
    color: #94a3b8;
    letter-spacing: 1px;
}

body.dark-mode .ref-panel-title {
    color: #cbd5e1;
}

/* Collapse button (shown in expanded state) */
.ref-collapse-btn {
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 4px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}

.ref-collapse-btn:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* Single MRI view container (one visible at a time) */
.ref-panel-views {
    padding: 2px;
}

.ref-mri-view {
    width: 100%;
    height: 140px;
}

.ref-mri-view:not(.active) {
    display: none;
}

.ref-view-image {
    width: 100%;
    height: 100%;
    position: relative;
    background: #0f172a;
    border-radius: 4px;
    overflow: hidden;
}

/* A/C view toggle buttons */
.ref-panel-view-toggle {
    display: flex;
    justify-content: center;
    gap: 3px;
    padding: 2px 3px 4px;
}

.ref-view-btn {
    width: 26px;
    height: 20px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.05);
    color: #64748b;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 20px;
}

.ref-view-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #334155;
}

.ref-view-btn.active {
    background: #EF4444;
    color: white;
    border-color: #EF4444;
    box-shadow: 0 1px 4px rgba(239, 68, 68, 0.4);
}

body.dark-mode .ref-view-btn {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
}

body.dark-mode .ref-view-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

body.dark-mode .ref-view-btn.active {
    background: #EF4444;
    color: white;
    border-color: #EF4444;
}

/* --- MRI PLACEHOLDER COLUMN (future pure in-vivo) --- */
.mri-placeholder-column .mri-placeholder-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.mri-placeholder-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    text-align: center;
    padding: 20px;
}

.mri-placeholder-message p {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
}

.mri-placeholder-message .placeholder-hint {
    font-size: 11px;
    opacity: 0.7;
    font-weight: 400;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ============================================================================
   SCROLLBAR STYLING
   ============================================================================ */

.sidebar-content::-webkit-scrollbar,
.mri-views-container::-webkit-scrollbar,
.thumbnail-container::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track,
.mri-views-container::-webkit-scrollbar-track,
.thumbnail-container::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb,
.mri-views-container::-webkit-scrollbar-thumb,
.thumbnail-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.mri-views-container::-webkit-scrollbar-thumb:hover,
.thumbnail-container::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ============================================================================
   SIDEBAR TOGGLE SYSTEM
   ============================================================================

   This system provides collapsible sidebars with:
   - Smooth sliding animations
   - Toggle buttons that remain visible when sidebar is hidden
   - Responsive layout that adjusts when sidebars collapse

   Left Sidebar (MRI Nav): Slides from left
   Right Sidebar (Histology Nav): Slides from right
   Tools: Opens as a drawer from the right side
   ============================================================================ */

/* ----- HEADER TOOLS BUTTON ----- */
.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface-color, #ffffff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    color: var(--text-color, #333);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.header-btn:hover {
    background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: var(--primary-color, #2196F3);
    color: var(--primary-color, #2196F3);
    box-shadow: 0 2px 6px rgba(33, 150, 243, 0.2);
    transform: translateY(-1px);
}

.header-btn.active {
    background: linear-gradient(145deg, #e3f2fd 0%, #bbdefb 100%);
    border-color: var(--primary-color, #2196F3);
    color: var(--primary-color, #2196F3);
}

.header-btn.tools-btn svg {
    stroke: var(--primary-color, #2196F3);
    width: 18px;
    height: 18px;
}

.header-btn.tools-btn:hover svg {
    stroke: var(--primary-color, #1976D2);
}

/* Dark mode header button */
body.dark-mode .header-btn {
    background: var(--surface-color, #1e293b);
    border-color: var(--border-color, #334155);
    color: var(--text-color, #f1f5f9);
}

body.dark-mode .header-btn:hover {
    background: linear-gradient(145deg, #2d3a4f 0%, #1e293b 100%);
    border-color: #3b82f6;
    color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

body.dark-mode .header-btn.active {
    background: linear-gradient(145deg, #1e3a5f 0%, #1e293b 100%);
    border-color: #3b82f6;
    color: #60a5fa;
}

body.dark-mode .header-btn.tools-btn svg {
    stroke: #60a5fa;
}

/* ----- SIDEBAR TOGGLE BUTTONS ----- */
.sidebar-toggle-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 150; /* Below tools panel (z-index 1100) but above main content */
    width: 24px;
    height: 48px;
    background: var(--panel-bg, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle-btn:hover {
    background: var(--hover-bg, #f3f4f6);
    color: var(--accent-color, #3b82f6);
    border-color: var(--accent-color, #3b82f6);
}

/* Left toggle button positioning - follows MRI nav pane */
.sidebar-toggle-btn.left-toggle {
    left: var(--sidebar-width, 200px);
    border-radius: 0 6px 6px 0;
    border-left: none;
    transition: left 0.3s ease, background 0.2s ease;
}

/* Right toggle button positioning - follows Histology nav pane */
.sidebar-toggle-btn.right-toggle {
    right: var(--sidebar-width, 200px);
    border-radius: 6px 0 0 6px;
    border-right: none;
    transition: right 0.3s ease, background 0.2s ease;
}

/* Toggle icon visibility */
.sidebar-toggle-btn .toggle-icon {
    display: none;
}

.sidebar-toggle-btn .toggle-icon.close-icon {
    display: block;
}

/* When sidebar is collapsed, show open icon */
.sidebar-toggle-btn.collapsed .toggle-icon.close-icon {
    display: none;
}

.sidebar-toggle-btn.collapsed .toggle-icon.open-icon {
    display: block;
}

/* Collapsed state positioning */
.sidebar-toggle-btn.left-toggle.collapsed {
    left: 0;
}

.sidebar-toggle-btn.right-toggle.collapsed {
    right: 0;
}

/* ----- COLLAPSIBLE SIDEBARS ----- */
/* Left sidebar (MRI Nav) collapse */
.sidebar.mri-nav-pane {
    transition: transform 0.3s ease, width 0.3s ease, opacity 0.3s ease;
    transform: translateX(0);
}

.sidebar.mri-nav-pane.collapsed {
    transform: translateX(-100%);
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
}

/* Right sidebar (Histology Nav) collapse */
.sidebar.histology-nav-pane {
    transition: transform 0.3s ease, width 0.3s ease, opacity 0.3s ease;
    transform: translateX(0);
}

.sidebar.histology-nav-pane.collapsed {
    transform: translateX(100%);
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
}

/* ----- MAIN LAYOUT ADJUSTMENTS ----- */
/* Default: 5-column layout (tools moved to drawer) - only on desktop */
@media (min-width: 993px) {
    .main-layout {
        grid-template-columns: var(--sidebar-width, 170px) 240px 240px 1fr var(--sidebar-width, 170px) !important;
        /* Fast, smooth sidebar collapse/expand animation */
        transition: grid-template-columns 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* When left sidebar is collapsed */
    .main-layout.left-collapsed {
        grid-template-columns: 0 240px 240px 1fr var(--sidebar-width, 170px) !important;
    }

    /* When right sidebar is collapsed */
    .main-layout.right-collapsed {
        grid-template-columns: var(--sidebar-width, 170px) 240px 240px 1fr 0 !important;
    }

    /* When both sidebars are collapsed */
    .main-layout.left-collapsed.right-collapsed {
        grid-template-columns: 0 240px 240px 1fr 0 !important;
    }
}

/* ----- TOOLS PANE HIDDEN ----- */
.sidebar.tools-pane.tools-pane-hidden {
    display: none !important;
}

/* ----- TOOLS DRAWER (Slides from Right) ----- */
/* ==========================================================
   TOOLS PANEL - Compact Floating Box Design
   No overlay fade, positioned above histology sidebar
   Draggable, non-intrusive, grid layout for tools
   ========================================================== */

/* Overlay - DISABLED to prevent blocking map interactions */
/* Tools panel floats independently, click-outside closes via document listener */
.tools-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: -1; /* Behind everything */
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* ALWAYS disabled - never block interactions */
}

.tools-drawer-overlay.open {
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Keep disabled even when "open" */
}

/* Tools Panel - Compact Floating Box */
.tools-drawer {
    position: fixed;
    /* Position: right side, above histology nav pane */
    top: 80px;
    right: 20px;
    width: auto;
    max-width: 280px;
    min-width: 200px;
    height: auto;
    max-height: calc(100vh - 120px);
    background: var(--surface-color, #ffffff);
    border-radius: 12px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 1100;
    /* Initially hidden */
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95) translateY(-10px);
    transform-origin: top right;
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease,
        transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tools-drawer.open {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* Draggable state */
.tools-drawer.dragging {
    cursor: grabbing;
    user-select: none;
    transition: none;
}

/* Tools Panel Header - Compact, draggable handle */
.tools-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--border-color);
    cursor: grab;
    user-select: none;
}

.tools-drawer-header:active {
    cursor: grabbing;
}

.tools-drawer-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Drag indicator dots */
.tools-drawer-header h3::before {
    content: '⋮⋮';
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.tools-drawer-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    width: 24px;
    height: 24px;
}

.tools-drawer-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.tools-drawer-close svg {
    width: 14px;
    height: 14px;
}

/* Tools Panel Content - Grid Layout */
.tools-drawer-content {
    padding: 12px;
    overflow-y: auto;
    max-height: 400px;
}

/* Section labels in floating panel */
.tools-drawer-content .nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

.tools-drawer-content .control-group {
    margin-bottom: 12px;
}

.tools-drawer-content .sidebar-divider {
    margin: 10px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* Tool Buttons Grid - 2 columns */
.tools-drawer-content .toggle-buttons-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

/* Compact tool buttons */
.tools-drawer-content .toggle-btn {
    padding: 8px 10px;
    font-size: 10px;
    gap: 6px;
    min-width: unset;
    flex: unset;
}

.tools-drawer-content .toggle-btn svg {
    width: 14px;
    height: 14px;
}

.tools-drawer-content .toggle-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ----- DARK MODE ADJUSTMENTS ----- */
body.dark-mode .sidebar-toggle-btn {
    background: var(--panel-bg);
    border-color: var(--border-color);
}

body.dark-mode .tools-drawer {
    background: var(--surface-color, #1a1f2e);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

body.dark-mode .tools-drawer-header {
    background: linear-gradient(135deg, #1e293b 0%, #1a1f2e 100%);
}

body.dark-mode .tools-drawer-overlay {
    background: transparent; /* NO FADE in dark mode either */
}

/* Dark mode - Toggle buttons in tools */
body.dark-mode .toggle-btn {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    color: #e2e8f0;
    border-color: #334155;
}

body.dark-mode .toggle-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .toggle-btn.annotations {
    border-color: rgba(236, 72, 153, 0.4);
}
body.dark-mode .toggle-btn.annotations:hover {
    background: rgba(236, 72, 153, 0.15);
    border-color: #ec4899;
    color: #f9a8d4;
}
body.dark-mode .toggle-btn.annotations.active {
    background: rgba(236, 72, 153, 0.2);
    border-color: #ec4899;
    color: #f9a8d4;
}

body.dark-mode .toggle-btn.heatmap {
    border-color: rgba(245, 158, 11, 0.4);
}
body.dark-mode .toggle-btn.heatmap:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
    color: #fcd34d;
}
body.dark-mode .toggle-btn.heatmap.active {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
    color: #fcd34d;
}

body.dark-mode .toggle-btn.mask {
    border-color: rgba(239, 68, 68, 0.4);
}
body.dark-mode .toggle-btn.mask:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #fca5a5;
}
body.dark-mode .toggle-btn.mask.active {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fca5a5;
}

body.dark-mode .toggle-btn.measure {
    border-color: rgba(59, 130, 246, 0.4);
}
body.dark-mode .toggle-btn.measure:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #93c5fd;
}
body.dark-mode .toggle-btn.measure.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #93c5fd;
}

body.dark-mode .toggle-btn.clear {
    border-color: rgba(239, 68, 68, 0.4);
}
body.dark-mode .toggle-btn.clear:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #fca5a5;
}

body.dark-mode .toggle-btn.thumbnails {
    border-color: rgba(148, 163, 184, 0.4);
}
body.dark-mode .toggle-btn.thumbnails:hover {
    background: rgba(148, 163, 184, 0.15);
    border-color: #94a3b8;
    color: #cbd5e1;
}

body.dark-mode .toggle-btn.viewer3d {
    border-color: rgba(139, 92, 246, 0.4);
}
body.dark-mode .toggle-btn.viewer3d:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: #8b5cf6;
    color: #c4b5fd;
}

/* ----- RESPONSIVE ADJUSTMENTS ----- */
@media (max-width: 1400px) {
    .tools-drawer {
        max-width: 260px;
        right: 15px;
    }
}

@media (max-width: 1200px) {
    /* Keep toggle buttons visible even when sidebars are hidden by media query */
    .sidebar-toggle-btn.left-toggle {
        left: 0;
    }

    .sidebar-toggle-btn.right-toggle {
        right: 0;
    }
}

/* ============================================================================
   ADAPTIVE HISTOLOGY COMPARISON LAYOUT
   ============================================================================

   This system provides automatic layout switching for histology comparison panels:
   - VERTICAL layout: Panels stacked on top of each other (default)
   - HORIZONTAL layout: Panels side by side

   The layout changes automatically based on:
   1. Available viewport width vs height ratio
   2. Whether sidebars are collapsed or expanded
   3. Which layout provides more usable viewing area

   DECISION LOGIC:
   - Calculate available space for histology column
   - If horizontal layout gives > 20% more area per panel → use horizontal
   - If vertical layout gives > 20% more area per panel → use vertical
   - If similar (within 20%), prefer vertical for consistency

   JavaScript in app.js handles the calculation and applies layout classes.
   ============================================================================ */

/* ----- BASE HISTOLOGY COLUMN ----- */
.histology-column {
    display: grid;
    gap: 4px;
    padding: 4px;
    position: relative;
    overflow: hidden;
    /* Default to vertical layout */
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
}

/* ----- VERTICAL LAYOUT (Default) ----- */
/* Panels stacked on top of each other */
.histology-column.layout-vertical {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
}

/* ----- HORIZONTAL LAYOUT ----- */
/* Panels side by side */
.histology-column.layout-horizontal {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

/* ----- PANEL BASE STYLES ----- */
.histology-panel {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ----- PANEL TRANSITION EFFECTS ----- */
.histology-column {
    transition: grid-template-columns 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                grid-template-rows 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----- LAYOUT CHANGE INDICATOR (for debugging) ----- */
.histology-column::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    padding: 2px 6px;
    font-size: 10px;
    color: transparent;
    pointer-events: none;
    z-index: 100;
}

/* Optional: Show layout indicator in debug mode */
.histology-column.show-layout-debug::after {
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px 0 0 0;
}

.histology-column.show-layout-debug.layout-vertical::after {
    content: 'Vertical';
}

.histology-column.show-layout-debug.layout-horizontal::after {
    content: 'Horizontal';
}

/* ----- MAP CONTAINER ADJUSTMENTS ----- */
/* Ensure map fills available space in both layouts */
.histology-column .histology-map-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
}

.histology-column .histology-map-container {
    flex: 1;
    width: 100%;
    min-height: 0;
    position: relative;
}

.histology-column .histology-map {
    width: 100%;
    height: 100%;
}

/* ----- RESPONSIVE ADJUSTMENTS FOR ADAPTIVE LAYOUT ----- */
/* Force vertical on very narrow screens */
/* Force vertical on very narrow screens */
@media (max-width: 1000px) {
    .histology-column {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr 1fr !important;
    }
}

/* Force horizontal on ultra-wide screens with limited height */
@media (min-width: 2400px) and (max-height: 900px) {
    .histology-column {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: 1fr !important;
    }
}

/* ============================================================================
   NEW COMPONENTS (Per Mentor's Specification)
   ============================================================================ */

/* ============================================================================
   1. MRI NAVIGATION PANE - STROKE SIGNATURES PANEL
   ============================================================================ */

/* Stroke Signatures Panel Container */
.stroke-signatures-panel {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 8px;
    margin: 4px 0;
}

/* Stroke Section Label */
.nav-section-label.stroke-section {
    color: #dc2626;
    border-left-color: #dc2626;
    font-weight: 600;
    margin-bottom: 8px;
}

/* ROI Overlay Group */
.roi-overlay-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Overlay Checkbox Styling */
.overlay-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.overlay-checkbox:hover {
    background: rgba(255, 255, 255, 0.8);
}

body.dark-mode .overlay-checkbox {
    background: rgba(0, 0, 0, 0.2);
}

body.dark-mode .overlay-checkbox:hover {
    background: rgba(0, 0, 0, 0.3);
}

.overlay-name {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ROI Opacity Controls */
.roi-opacity-controls {
    margin-top: 8px;
}

.roi-slider-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

body.dark-mode .roi-slider-row {
    background: rgba(0, 0, 0, 0.15);
}

.roi-slider-label {
    font-size: 9px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Compact Slider Container */
.slider-container.compact {
    gap: 4px;
}

.slider-container.compact .slider {
    height: 4px;
}

.slider-container.compact .slider-value {
    font-size: 9px;
    min-width: 28px;
}

/* ROI Opacity Slider */
.roi-opacity-slider {
    flex: 1;
}

/* ============================================================================
   2. MRI DIRECTION INDICATORS
   ============================================================================ */

/* Direction Indicators Container */
.mri-direction-indicators {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 15;
}

/* Individual Direction Indicator */
.direction-indicator {
    position: absolute;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 16;
}

/* Direction Positions */
.direction-indicator.dir-top {
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
}

.direction-indicator.dir-left {
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.direction-indicator.dir-right {
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.direction-indicator.dir-bottom {
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
}

/* ============================================================================
   3. HISTOLOGY PANEL - POSITION AND STAIN BADGES
   ============================================================================ */

/* Position Badge (Sagittal position in mm) */
.info-badge.position-badge {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    font-weight: 600;
}

/* Antibody Badge (for IHC stains) */
.info-badge.antibody-badge {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: white;
    font-weight: 600;
    font-size: 9px;
}

/* Feature Overlay Container */
.feature-overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 50;
}

/* ============================================================================
   4. BOTTOM THUMBNAIL DOCK (File-packed Layout like thumbnailPopup)
   ============================================================================ */

/*
 * DOCK DESIGN - File-packed like thumbnailPopup:
 * 1. Multiple stain images stacked per section (like card stack)
 * 2. Minimal gaps between section groups
 * 3. Overflow visible for hover zoom (not clipped)
 * 4. ~10 sections visible, compact width
 * 5. Labels showing section number
 */

/* ==========================================================
   DOCK ACTIVATION ZONE - Invisible trigger area at bottom
   This prevents accidental dock triggering when using images
   ========================================================== */
.dock-activation-zone {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    z-index: 95; /* Below scale bar */
    pointer-events: auto;
}

/* ==========================================================
   THUMBNAIL DOCK CONTAINER - Beautiful Mac-style dock
   Premium glassmorphism design with smooth animations
   ========================================================== */
.thumbnail-dock {
    position: absolute;
    bottom: -90px; /* Hidden state */
    left: 50%;
    transform: translateX(-50%);
    transform-origin: bottom center;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 12px 16px;
    min-width: 220px;
    max-width: min(600px, calc(100% - 20px));
    box-sizing: border-box;
    background: linear-gradient(
        180deg,
        rgba(40, 40, 58, 0.95) 0%,
        rgba(25, 25, 40, 0.98) 100%
    );
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-radius: 16px 16px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: none;
    box-shadow:
        0 -6px 30px rgba(0, 0, 0, 0.4),
        0 -2px 10px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    transition:
        bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease,
        transform 0.3s ease;
    opacity: 0;
    z-index: 98;
    overflow: visible;
}

/* Dock visible state */
.thumbnail-dock.visible {
    bottom: 0;
    opacity: 1;
}

/* Subtle inner glow effect */
.thumbnail-dock::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0.2) 80%,
        transparent 100%
    );
    border-radius: 1px;
}

/* Dock Navigation Buttons - Elegant, separated design */
.dock-nav-btn {
    width: 32px;
    height: 48px;
    min-width: 32px;
    max-width: 32px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: linear-gradient(145deg,
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0.04) 100%
    );
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    flex-grow: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.dock-nav-btn:hover {
    background: linear-gradient(145deg,
        rgba(255, 255, 255, 0.22) 0%,
        rgba(255, 255, 255, 0.1) 100%
    );
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-2px);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.dock-nav-btn:active {
    transform: translateY(0) scale(0.95);
    background: rgba(255, 255, 255, 0.08);
}

.dock-nav-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.dock-nav-btn:hover svg {
    transform: scale(1.1);
}

/* Left navigation button - with generous spacing */
.dock-nav-btn.dock-nav-left {
    margin-left: 4px;
    margin-right: 28px;
}

/* Right navigation button - with generous spacing */
.dock-nav-btn.dock-nav-right {
    margin-left: 28px;
    margin-right: 4px;
}

/* Vertical separator lines between buttons and thumbnails */
.dock-nav-btn.dock-nav-left::after,
.dock-nav-btn.dock-nav-right::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 32px;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(255, 255, 255, 0.12) 15%,
        rgba(255, 255, 255, 0.12) 85%,
        transparent 100%
    );
}

.dock-nav-btn.dock-nav-left::after {
    right: -15px;
}

.dock-nav-btn.dock-nav-right::before {
    left: -15px;
}

/* ==========================================================
   DOCK THUMBNAILS CONTAINER - Elegant spacing
   ========================================================== */
.dock-thumbnails {
    display: flex;
    flex: 1 1 auto;
    gap: 10px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 4px 8px;
    min-height: 54px;
    min-width: 0;
    max-width: 450px;
}

/* ==========================================================
   SECTION GROUP - Polished thumbnail cards
   ========================================================== */
.dock-section-group {
    position: relative;
    width: 40px;
    height: 52px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
}

/* Hover effect - smooth bounce up */
.dock-section-group:hover {
    transform: scale(1.18) translateY(-8px);
    z-index: 50;
}

/* Active section styling - glowing indicator */
.dock-section-group.active {
    z-index: 10;
}

.dock-section-group.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    border-radius: 50%;
    box-shadow:
        0 0 8px rgba(59, 130, 246, 0.7),
        0 0 16px rgba(59, 130, 246, 0.4);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow:
            0 0 8px rgba(59, 130, 246, 0.7),
            0 0 16px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow:
            0 0 12px rgba(59, 130, 246, 0.9),
            0 0 24px rgba(59, 130, 246, 0.5);
    }
}

/* Stacked images container */
.dock-images-stack {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Base stacked image style */
.dock-stacked-img {
    position: absolute;
    object-fit: cover;
    border-radius: 4px;
    background: linear-gradient(135deg, #3a3a4a 0%, #2a2a3a 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    left: 50%;
    top: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ==========================================================
   STACKED IMAGES - Larger sizes for visibility
   ========================================================== */

/* BACK IMAGE (1st child) - Peeks behind */
.dock-stacked-img:nth-child(1) {
    z-index: 1;
    width: 26px;
    height: 32px;
    transform: translate(-50%, -50%) translate(-5px, -5px);
    opacity: 0.75;
    box-shadow: -1px 1px 4px rgba(0, 0, 0, 0.4);
}

/* MIDDLE IMAGE (2nd child) - Peeks right */
.dock-stacked-img:nth-child(2) {
    z-index: 2;
    width: 28px;
    height: 35px;
    transform: translate(-50%, -50%) translate(4px, -2px);
    opacity: 0.85;
    box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.35);
}

/* FRONT IMAGE (3rd child) - Main visible */
.dock-stacked-img:nth-child(3) {
    z-index: 3;
    width: 30px;
    height: 38px;
    transform: translate(-50%, -50%) translate(0, 2px);
    opacity: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.18);
}

/* 2 images only */
.dock-stacked-img:first-child:nth-last-child(2) {
    z-index: 1;
    width: 26px;
    height: 32px;
    transform: translate(-50%, -50%) translate(-4px, -4px);
    opacity: 0.75;
    box-shadow: -1px 1px 4px rgba(0, 0, 0, 0.4);
}

.dock-stacked-img:last-child:nth-child(2) {
    z-index: 2;
    width: 30px;
    height: 38px;
    transform: translate(-50%, -50%) translate(1px, 2px);
    opacity: 1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Single image */
.dock-stacked-img:only-child {
    z-index: 1;
    width: 24px;
    height: 38px;
    transform: translate(-50%, -50%);
    opacity: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.18);
}

/* ==========================================================
   HOVER - Subtle fan out (reduced expansion)
   ========================================================== */

.dock-section-group:hover .dock-stacked-img:nth-child(1) {
    transform: translate(-50%, -50%) translate(-6px, -6px) rotate(-4deg);
    opacity: 0.9;
}

.dock-section-group:hover .dock-stacked-img:nth-child(2) {
    transform: translate(-50%, -50%) translate(5px, -3px) rotate(3deg);
    opacity: 0.95;
}

.dock-section-group:hover .dock-stacked-img:nth-child(3) {
    transform: translate(-50%, -50%) translate(0, 3px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
}

/* 2 images hover */
.dock-section-group:hover .dock-stacked-img:first-child:nth-last-child(2) {
    transform: translate(-50%, -50%) translate(-5px, -5px) rotate(-3deg);
    opacity: 0.9;
}

.dock-section-group:hover .dock-stacked-img:last-child:nth-child(2) {
    transform: translate(-50%, -50%) translate(1px, 3px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
}

/* Active section border highlight */
.dock-section-group.active .dock-stacked-img {
    border-color: rgba(59, 130, 246, 0.5);
}

/* ==========================================================
   SECTION LABEL - Elegant pill-shaped labels
   ========================================================== */
.dock-section-label {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.95);
    /* Elegant dark pill background */
    background: linear-gradient(
        180deg,
        rgba(30, 30, 45, 0.92) 0%,
        rgba(15, 15, 25, 0.96) 100%
    );
    padding: 3px 7px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Subtle shadow */
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    min-width: 22px;
    transition: all 0.2s ease;
}

/* Label on hover - slight glow */
.dock-section-group:hover .dock-section-label {
    background: linear-gradient(
        180deg,
        rgba(50, 50, 70, 0.95) 0%,
        rgba(25, 25, 40, 0.98) 100%
    );
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow:
        0 3px 10px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Active section label - blue accent */
.dock-section-group.active .dock-section-label {
    background: linear-gradient(
        180deg,
        rgba(59, 130, 246, 0.25) 0%,
        rgba(30, 64, 175, 0.35) 100%
    );
    border-color: rgba(59, 130, 246, 0.4);
    color: white;
}

/* ==========================================================
   TOOLTIP - Premium floating tooltip
   ========================================================== */
.dock-section-group[data-tooltip]:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 16px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 14px;
    background: linear-gradient(
        145deg,
        rgba(35, 35, 50, 0.98) 0%,
        rgba(20, 20, 32, 0.99) 100%
    );
    color: white;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 200;
    pointer-events: none;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.45),
        0 2px 8px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    animation: tooltipFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.95) translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

/* Dock Range Indicator - hidden by default, minimal */
.dock-range-indicator {
    display: none; /* Keep dock clean */
}

/* ============================================================================
   5. HISTOLOGY NAVIGATION PANE - FEATURE OVERLAY CONTROLS
   ============================================================================ */

/* Scrollable Feature Overlay Group */
.feature-overlay-group.scrollable {
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom Scrollbar for Feature Overlay */
.feature-overlay-group.scrollable::-webkit-scrollbar {
    width: 4px;
}

.feature-overlay-group.scrollable::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.feature-overlay-group.scrollable::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

.feature-overlay-group.scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* Overlay Opacity Section */
.overlay-opacity-section {
    margin-top: 8px;
}

/* Overlay Opacity Sliders Container */
.overlay-opacity-sliders {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

/* Opacity Placeholder */
.opacity-placeholder {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
    font-style: italic;
}

/* Dynamic Opacity Slider Row */
.overlay-opacity-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

body.dark-mode .overlay-opacity-row {
    background: rgba(255, 255, 255, 0.05);
}

.overlay-opacity-row .overlay-label {
    font-size: 9px;
    color: var(--text-secondary);
    min-width: 60px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-opacity-row .slider {
    flex: 1;
    height: 4px;
}

.overlay-opacity-row .opacity-value {
    font-size: 9px;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: right;
}

/* ============================================================================
   6. MRI TRANSPARENCY DRAG INDICATOR
   ============================================================================ */

/* Transparency Drag Indicator */
.mri-transparency-indicator {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 20;
}

.mri-view-image:hover .mri-transparency-indicator,
.mri-view-image.dragging .mri-transparency-indicator {
    opacity: 1;
}

.mri-transparency-indicator svg {
    width: 12px;
    height: 12px;
    color: white;
}

.mri-transparency-value {
    font-size: 9px;
    color: white;
    font-weight: 600;
}

/* Dragging State */
.mri-view-image.dragging {
    cursor: ns-resize;
}

/* ============================================================================
   7. RESPONSIVE ADJUSTMENTS FOR NEW COMPONENTS
   ============================================================================ */

@media (max-width: 1400px) {
    .stroke-signatures-panel {
        padding: 6px;
    }

    .overlay-name {
        font-size: 9px;
    }

    .roi-slider-label {
        font-size: 8px;
    }

    .thumbnail-dock {
        max-width: min(440px, calc(100% - 20px));
        padding: 7px 10px;
    }

    .dock-thumbnails {
        gap: 6px;
        overflow: hidden;
        min-width: 0;
    }

    .dock-section-group {
        width: 34px;
        height: 44px;
    }

    .dock-stacked-img:nth-child(1) {
        width: 24px;
        height: 30px;
    }

    .dock-stacked-img:nth-child(2) {
        width: 26px;
        height: 33px;
    }

    .dock-stacked-img:nth-child(3) {
        width: 28px;
        height: 36px;
    }

    .dock-stacked-img:only-child {
        width: 28px;
        height: 36px;
    }

    .dock-section-label {
        font-size: 8px;
    }
}

@media (max-width: 1200px) {
    .feature-overlay-group.scrollable {
        max-height: 140px;
    }

    .thumbnail-dock {
        max-width: min(400px, calc(100% - 20px));
        padding: 6px 8px;
    }

    .dock-thumbnails {
        gap: 5px;
        overflow: hidden;
        min-width: 0;
    }

    .dock-section-group {
        width: 32px;
        height: 42px;
    }

    .dock-stacked-img:nth-child(1) {
        width: 22px;
        height: 28px;
    }

    .dock-stacked-img:nth-child(2) {
        width: 24px;
        height: 30px;
    }

    .dock-stacked-img:nth-child(3) {
        width: 26px;
        height: 33px;
    }

    .dock-stacked-img:only-child {
        width: 26px;
        height: 33px;
    }

    .dock-section-label {
        font-size: 8px;
    }
}

@media (max-width: 900px) {
    .thumbnail-dock {
        max-width: min(360px, calc(100% - 16px));
        padding: 5px 6px;
    }

    .dock-thumbnails {
        gap: 4px;
        overflow: hidden;
        min-width: 0;
    }

    .dock-section-group {
        width: 28px;
        height: 36px;
    }

    .dock-stacked-img:nth-child(1) {
        width: 18px;
        height: 23px;
    }

    .dock-stacked-img:nth-child(2) {
        width: 20px;
        height: 25px;
    }

    .dock-stacked-img:nth-child(3) {
        width: 22px;
        height: 28px;
    }

    .dock-stacked-img:only-child {
        width: 22px;
        height: 28px;
    }

    .dock-nav-btn {
        width: 26px;
        height: 36px;
        min-width: 26px;
        max-width: 26px;
        border-radius: 6px;
    }

    .dock-nav-btn svg {
        width: 12px;
        height: 12px;
    }

    .dock-nav-btn.dock-nav-left {
        margin-left: 2px;
        margin-right: 6px;
    }

    .dock-nav-btn.dock-nav-right {
        margin-left: 6px;
        margin-right: 2px;
    }

    /* Hide separators on small screens */
    .dock-nav-btn.dock-nav-left::after,
    .dock-nav-btn.dock-nav-right::before {
        display: none;
    }

    .dock-section-label {
        font-size: 7px;
    }

    .dock-section-group:hover {
        transform: scale(1.12) translateY(-4px);
    }
}

/* ============================================================================
   8. DARK MODE ADJUSTMENTS FOR NEW COMPONENTS
   ============================================================================ */

body.dark-mode .stroke-signatures-panel {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

body.dark-mode .nav-section-label.stroke-section {
    color: #f87171;
}

body.dark-mode .direction-indicator {
    background: rgba(0, 0, 0, 0.8);
}

body.dark-mode .thumbnail-dock {
    background: linear-gradient(180deg, rgba(20, 20, 35, 0.98) 0%, rgba(10, 10, 20, 0.99) 100%);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .dock-nav-btn {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.07) 100%);
    color: rgba(255, 255, 255, 0.85);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.dark-mode .dock-nav-btn:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.12) 100%);
    color: white;
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

body.dark-mode .dock-section-group .dock-stacked-img {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .dock-section-group:hover .dock-stacked-img {
    border-color: rgba(255, 255, 255, 0.4);
}

body.dark-mode .overlay-name {
    color: var(--text-secondary);
}

body.dark-mode .roi-slider-label {
    color: var(--text-secondary);
}

body.dark-mode .feature-overlay-group.scrollable::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .feature-overlay-group.scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
}

body.dark-mode .feature-overlay-group.scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
