:root {
    /* Color Palette - Light Theme (Default) */
    --primary-color: #008080;
    /* Teal */
    --primary-hover: #006666;
    --secondary-color: #f0f4f8;
    /* Light Gray/Blue */
    --accent-color: #ff6b6b;
    /* Coral for delete/cancel */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --bg-body: #ffffff;
    --bg-panel: #f7fafc;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Layout Dimensions */
    --sidebar-width: 280px;
    --header-height: 60px;
    /* Mobile only */
    --bottom-bar-height: 60px;
    /* Mobile only */
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    margin: 0;
    background-color: var(--bg-body);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1,
h2,
h3 {
    margin: 0;
    font-weight: 600;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
}

/* Layout Container */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    flex-direction: column;
    /* Mobile default */
}

/* Mobile Header */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    height: var(--header-height);
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sidebar / Navigation */
.sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    z-index: 20;
}

/* Desktop Sidebar Styles */
@media (min-width: 768px) {
    .app-container {
        flex-direction: row;
    }


    .mobile-header {
        display: none;
    }

    .sidebar {
        width: var(--sidebar-width);
        height: 100%;
    }
}

/* Mobile Bottom Bar Styles */
@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: var(--bottom-bar-height);
        flex-direction: row;
        justify-content: space-around;
        padding: 0.5rem;
        border-right: none;
        border-top: 1px solid var(--border-color);
        background: var(--bg-body);
    }

    /* Hide non-essential tools on mobile bottom bar if needed, or use a 'More' menu */
    .sidebar .nav-group {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
    }

    .sidebar {
        transition: height 0.3s ease, border-radius 0.3s ease;
        z-index: 100;
        /* Ensure it's above other elements */
    }

    .sidebar.mobile-expanded {
        height: auto;
        min-height: 300px;
        flex-direction: column;
        justify-content: flex-start;
        bottom: 0;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.1);
        padding: 1.5rem;
        gap: 1.5rem;
    }

    .sidebar.mobile-expanded .nav-group {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .sidebar.mobile-expanded .nav-btn {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        padding: 1rem;
        font-size: 1rem;
        background: var(--secondary-color);
    }
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    text-align: left;
}

.nav-btn:hover,
.nav-btn.active {
    background: var(--secondary-color);
    color: var(--primary-color);
}

.nav-btn i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

@media (max-width: 767px) {
    .nav-btn {
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.25rem;
        font-size: 0.7rem;
        width: 60px;
        justify-content: center;
    }

    .nav-btn span {
        display: block;
    }
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #e2e8f0;
    /* Darker bg for canvas contrast */
    overflow: hidden;
}

/* Canvas Container */
.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: crosshair;
}

#annotationCanvas,
#cameraFeed {
    box-shadow: var(--shadow-md);
    background: white;
    max-width: 100%;
    max-height: 100%;
}

/* Floating Controls / Right Panel */
.controls-panel {
    background: var(--bg-body);
    border-left: 1px solid var(--border-color);
    width: 300px;
    display: flex;
    flex-direction: column;
    z-index: 15;
}

/* Mobile Drawer for Controls */
@media (max-width: 767px) {
    .controls-panel {
        position: fixed;
        right: 0;
        top: var(--header-height);
        bottom: var(--bottom-bar-height);
        width: 80%;
        max-width: 300px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .controls-panel.open {
        transform: translateX(0);
    }

    .controls-toggle {
        display: block;
    }
}

@media (min-width: 768px) {
    .controls-toggle {
        display: none;
    }
}

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

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

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

.btn-secondary {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
}

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

/* Label Chips */
.label-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.label-chip {
    display: flex;
    align-items: center;
    background: var(--secondary-color);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.label-chip:hover {
    border-color: var(--primary-color);
    background: white;
}

.label-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

/* Thumbnail Bar */
.thumbnail-bar-container {
    height: 80px;
    background: var(--bg-body);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.5rem;
}

.thumbnail-list {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    flex: 1;
    padding-bottom: 5px;
    /* Scrollbar space */
    scrollbar-width: thin;
}

.thumbnail {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.7;
    transition: all 0.2s;
}

.thumbnail:hover {
    opacity: 1;
}

.thumbnail.active {
    border-color: var(--primary-color);
    opacity: 1;
    transform: scale(1.05);
}

/* Dialog */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.dialog-box {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 320px;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.dialog-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 1rem 0;
    font-size: 1rem;
}

.dialog-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

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

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.mb-2 {
    margin-bottom: 0.5rem;
}

.label-color-box {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    margin-right: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Quick Label Picker - Compact & Transparent */
.label-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}

.label-picker {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 10px;
    width: 220px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.15s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.label-search {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    background: rgba(255, 255, 255, 0.8);
}

.label-search:focus {
    border-color: var(--primary-color);
}

.label-options {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0;
    max-height: 100px;
    overflow-y: auto;
}


.label-option {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.1s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.label-option:hover {
    background: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.label-option .color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.create-new-option {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    background: linear-gradient(135deg, var(--primary-color), #00a0a0);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 4px;
    transition: transform 0.1s;
}

.create-new-option:hover {
    transform: scale(1.02);
}

.create-new-option i {
    font-size: 9px;
}

.label-picker-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 4px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.color-picker-inline input[type="color"] {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

.btn-cancel {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.1s;
}

.btn-cancel:hover {
    background: var(--accent-color);
    color: white;
}

/* Dark Horizontal Label Toolbar */
.label-toolbar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 200;
    pointer-events: auto;
}

.label-toolbar {
    position: fixed;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(45, 35, 25, 0.9);
    backdrop-filter: blur(8px);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 200, 100, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.toolbar-label-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-right: 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.toolbar-label-indicator .label-number {
    font-size: 18px;
    font-weight: 700;
    color: #ffd700;
}

.toolbar-label-indicator .label-type {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.toolbar-input-wrapper {
    position: relative;
}

.toolbar-input {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    width: 140px;
    color: #333;
}

.toolbar-input:focus {
    outline: none;
    border-color: #ffd700;
}

.toolbar-input::placeholder {
    color: #999;
}

.label-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    margin-top: 4px;
    max-height: 150px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
}

.label-dropdown.show {
    display: block;
}

.label-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 12px;
    color: #333;
}

.label-dropdown-item:hover {
    background: rgba(255, 215, 0, 0.2);
}

.label-dropdown-item .color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.toolbar-color {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.toolbar-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

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

/* Full-width main content (no left sidebar) */
.main-content.full-width {
    margin-left: 0;
}

/* Action buttons in right panel */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--secondary-color);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 60px;
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

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

.divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

/* Minimized panel icons */
.minimized-icons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--secondary-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    position: relative;
}

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

.icon-btn:hover::after {
    content: attr(title);
    position: absolute;
    right: 100%;
    margin-right: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
}

.icon-btn.expand-btn {
    margin-top: auto;
    background: var(--primary-color);
    color: white;
}

/* Panel minimized state */
.controls-panel.minimized {
    width: 60px;
}

.controls-panel.minimized .panel-header,
.controls-panel.minimized .panel-content {
    display: none;
}

.controls-panel.minimized .minimized-icons {
    display: flex;
}

/* Custom Confirm Dialog */
.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
}

.custom-dialog {
    background: white;
    border-radius: 16px;
    padding: 24px 32px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: dialogSlideIn 0.2s ease-out;
}

@keyframes dialogSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.custom-dialog .dialog-icon {
    font-size: 48px;
    color: var(--accent-color);
    margin-bottom: 16px;
}

.custom-dialog h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.custom-dialog p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.dialog-buttons button {
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}

.btn-danger {
    background: var(--accent-color);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #e55555;
}

/* Hide left sidebar on desktop */
@media (min-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        flex: 1;
    }

    .controls-panel {
        width: 280px;
    }
}

/* Top Thumbnail Bar */
.thumbnail-bar-container.top-bar {
    border-top: none;
    border-bottom: 1px solid var(--border-color);
}

/* Bottom Action Toolbar */
.action-toolbar-container {
    height: 60px;
    background: var(--bg-body);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center !important;
    padding: 0 1rem;
    gap: 8px;
    /* width: 100%; Removed to allow padding without overflow in content-box */
    box-sizing: content-box;
    /* Explicitly requested */
}

/* Toolbar sections for centering */
/* Toolbar sections - Desktop (Flex containers for effective centering) */
.toolbar-fixed,
.toolbar-scrollable {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Consistent gap between buttons */
    /* Ensure groups don't stretch */
    flex: 0 0 auto;
    width: auto;
    /* Reset visibility/overflow from any previous rules */
    overflow: visible;
}

/* Vertical Divider styling */
/* Vertical Divider styling */
.toolbar-divider {
    height: 30px;
    width: 1px;
    background: var(--border-color);
    margin: 0;
    /* Use container gap for spacing */
}

/* Force container centering with dynamic padding */
.action-toolbar-container {
    justify-content: center !important;
}

/* Desktop: Dynamic padding to center/constrain content */
@media (min-width: 768px) {
    .action-toolbar-container {
        /* Use viewport units for dynamic padding (Left only) */
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        padding-left: 10vw !important;
        padding-right: 0 !important;
    }
}

@media (min-width: 1440px) {
    .action-toolbar-container {
        /* Approximate 28rem at 1440px (30vw) but left only */
        padding-left: 30vw !important;
        padding-right: 0 !important;
    }
}

/* Toolbar buttons base style */

.toolbar-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--secondary-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    position: relative;
}

.toolbar-action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 128, 128, 0.3);
}

.toolbar-action-btn:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 11px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 100;
}

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

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

.toolbar-divider {
    width: 1px;
    height: 30px;
    background: var(--border-color);
    margin: 0 4px;
}

/* Simplify right panel to labels only */
.controls-panel {
    width: 240px;
}

/* Button with label */
.toolbar-action-btn.with-label {
    width: auto;
    padding: 8px 14px;
    gap: 6px;
}

.toolbar-action-btn .btn-label {
    font-size: 12px;
    font-weight: 500;
}

/* Hide labels on mobile */
@media (max-width: 767px) {
    .toolbar-action-btn.with-label {
        width: 44px;
        padding: 8px;
    }

    .toolbar-action-btn .btn-label {
        display: none;
    }
}

/* Help Dialog Styles */
.help-dialog {
    max-width: 500px;
    padding: 0;
    text-align: left;
    max-height: 80vh;
    overflow: hidden;
}

.help-dialog .dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--secondary-color);
}

.help-dialog .dialog-header h3 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-dialog .close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.help-dialog .close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.help-content {
    padding: 16px 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

.help-section {
    margin-bottom: 20px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h4 {
    font-size: 13px;
    color: var(--primary-color);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section li {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section li:last-child {
    border-bottom: none;
}

.help-section li i {
    width: 16px;
    text-align: center;
    color: var(--primary-color);
}

kbd {
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-family: monospace;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Mobile Toolbar Fix - Fixed + Scrollable Layout */
.toolbar-fixed {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.toolbar-scrollable {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.toolbar-scrollable::-webkit-scrollbar {
    display: none;
}

/* Mobile specific toolbar adjustments */
@media (max-width: 767px) {
    .action-toolbar-container {
        padding: 8px;
        gap: 6px;
    }

    .toolbar-fixed {
        display: flex;
        align-items: center;
        gap: 6px;
        flex: 0 0 auto;
    }

    .toolbar-scrollable {
        display: flex;
        align-items: center;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        max-width: 100%;
        flex: 1;
        /* Take remaining space */
    }

    .toolbar-scrollable::-webkit-scrollbar {
        display: none;
    }

    .toolbar-action-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        padding: 0;
        font-size: 14px;
    }

    .toolbar-action-btn .btn-label {
        display: none;
    }

    .toolbar-divider {
        height: 24px;
        min-width: 1px;
    }

    /* Burger Menu toggles the controls panel */
    .controls-panel {
        position: fixed;
        top: 50px;
        right: -280px;
        width: 260px;
        height: calc(100vh - 50px);
        z-index: 1000;
        transition: right 0.3s ease;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    }

    .controls-panel.mobile-expanded {
        right: 0;
    }

    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001;
    }

    .main-content {
        padding-top: 50px;
    }
}

/* Desktop - show labels on buttons */
@media (min-width: 768px) {
    .toolbar-action-btn {
        width: auto;
        min-width: 44px;
        padding: 8px 12px;
        gap: 6px;
    }

    .toolbar-action-btn .btn-label {
        display: inline;
        font-size: 12px;
        font-weight: 500;
    }
}

/* Fix mobile panel content visibility */
@media (max-width: 767px) {
    .controls-panel.mobile-expanded {
        display: flex;
        flex-direction: column;
    }

    .controls-panel .panel-header,
    .controls-panel .panel-content {
        display: block !important;
    }

    .controls-panel .panel-content {
        overflow-y: auto;
        flex: 1;
        padding: 1rem;
    }

    .labels-section,
    .debug-section {
        display: block !important;
    }
}

/* Fix Auto button - ensure full visibility */
.toolbar-action-btn.primary {
    min-width: 52px;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .toolbar-action-btn.primary {
        min-width: 44px;
        width: 44px;
    }

    /* Ensure .btn-label is hidden consistently */
    .toolbar-action-btn.primary .btn-label {
        display: none !important;
    }
}

/* Make sure the scrollable area works */
.toolbar-scrollable {
    min-width: 0;
}

.toolbar-scrollable .toolbar-action-btn {
    flex-shrink: 0;
}

/* Header Auto-Annotate Button */
.header-auto-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.header-auto-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Desktop only elements */
@media (min-width: 768px) {
    .header-auto-btn {
        display: none;
    }

    .bottom-expand-btn {
        display: none !important;
    }

    .mobile-only {
        display: none !important;
    }
}

/* Mobile only elements */
@media (max-width: 767px) {
    .desktop-only {
        display: none !important;
    }
}

/* Bottom Expand Button */
.bottom-expand-btn {
    position: fixed;
    bottom: 58px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 28px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

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

.bottom-expand-btn i {
    transition: transform 0.3s ease;
}

.bottom-expand-btn.expanded i {
    transform: rotate(180deg);
}

/* Mobile Bottom Slide Panel */
@media (max-width: 767px) {
    .controls-panel {
        position: fixed;
        bottom: -300px;
        left: 0;
        right: 0;
        width: 100%;
        height: 300px;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
        z-index: 1000;
        transition: bottom 0.3s ease;
    }

    .controls-panel.mobile-expanded {
        bottom: 60px;
    }

    .controls-panel .panel-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-color);
        background: var(--secondary-color);
        border-radius: 16px 16px 0 0;
    }

    .controls-panel .panel-content {
        padding: 12px 16px;
        overflow-y: auto;
        max-height: calc(300px - 50px);
    }

    .controls-panel .close-btn {
        background: transparent;
        border: none;
        padding: 8px;
        cursor: pointer;
        color: var(--text-secondary);
    }

    .action-toolbar-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 99;
    }
}

/* CRITICAL FIX: Override desktop panel styles for mobile */
@media (max-width: 767px) {
    .controls-panel {
        position: fixed !important;
        top: auto !important;
        right: auto !important;
        bottom: -350px !important;
        left: 0 !important;
        width: 100% !important;
        height: 300px !important;
        border-radius: 20px 20px 0 0 !important;
        background: white !important;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25) !important;
        z-index: 1000 !important;
        transition: bottom 0.35s ease !important;
        display: block !important;
    }

    .controls-panel.mobile-expanded {
        bottom: 58px !important;
    }

    .controls-panel .panel-header {
        padding: 14px 20px !important;
        border-bottom: 1px solid #eee !important;
        background: #f8f9fa !important;
        border-radius: 20px 20px 0 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .controls-panel .panel-title {
        font-size: 16px !important;
        font-weight: 600 !important;
        color: #333 !important;
    }

    .controls-panel .panel-content {
        padding: 16px 20px !important;
        overflow-y: auto !important;
        max-height: 230px !important;
    }

    /* Bottom expand button styling - transparent, no gap */
    .bottom-expand-btn {
        display: flex !important;
        position: fixed !important;
        bottom: 58px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 1001 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        transition: bottom 0.35s ease !important;
    }

    /* Move button up when panel is expanded */
    .bottom-expand-btn.expanded {
        bottom: 338px !important;
        /* 58px toolbar + 280px panel */
    }

    /* Hide the panel close button arrow indicator */
    .controls-panel .close-btn {
        background: #e9ecef !important;
        border: none !important;
        border-radius: 8px !important;
        width: 32px !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
    }
}

/* FINAL FIX: Force panel to slide from bottom on mobile */
@media (max-width: 767px) {

    .controls-panel,
    aside.controls-panel,
    #controlsPanel {
        position: fixed !important;
        top: auto !important;
        right: 0 !important;
        left: 0 !important;
        bottom: -320px !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 280px !important;
        transform: none !important;
        transition: bottom 0.35s ease !important;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3) !important;
        border-radius: 0 !important;
        /* Rectangular */
        border-left: none !important;
        z-index: 1100 !important;
        background: white !important;
    }

    /* Hide header on mobile */
    .controls-panel .panel-header {
        display: none !important;
    }

    /* Add padding to content since header is gone */
    .controls-panel .panel-content {
        padding-top: 20px !important;
    }

    .controls-panel.mobile-expanded,
    aside.controls-panel.mobile-expanded,
    #controlsPanel.mobile-expanded {
        bottom: 0 !important;
    }

    .controls-panel.open {
        bottom: 0 !important;
        transform: none !important;
    }

    /* Animate toolbar lifting up */
    .action-toolbar-container {
        transition: transform 0.35s ease, bottom 0.35s ease;
        z-index: 1200 !important;
        /* Ensure toolbar is above panel */
    }

    .action-toolbar-container.mobile-expanded {
        transform: translateY(-280px);
        /* Lift by panel height */
    }

    /* Move expand button with toolbar */
    .bottom-expand-btn {
        transition: transform 0.35s ease, bottom 0.35s ease;
        z-index: 1201 !important;
    }

    .bottom-expand-btn.expanded {
        transform: translateY(-280px) rotate(180deg);
    }
}

/* Fix Label Dialog/Dropdown positioning on mobile */
@media (max-width: 767px) {

    .label-toolbar-overlay,
    #labelDialog {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        background: rgba(0, 0, 0, 0.4) !important;
        z-index: 1200 !important;
    }

    .label-toolbar,
    #labelToolbar {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        bottom: auto !important;
        width: 90% !important;
        max-width: 320px !important;
        padding: 16px !important;
        border-radius: 12px !important;
    }

    .label-dropdown {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1300 !important;
    }
}

/* Fix: Don't override display:none for label dialog */
@media (max-width: 767px) {

    .label-toolbar-overlay[style*="display: none"],
    #labelDialog[style*="display: none"] {
        display: none !important;
    }

    .label-toolbar-overlay[style*="display: block"],
    #labelDialog[style*="display: block"] {
        display: flex !important;
        justify-content: center !important;
        align-items: flex-start !important;
        padding-top: 60px !important;
    }
}

/* CRITICAL: Hide label dialog by default, don't override inline display:none */
#labelDialog[style*="none"] {
    display: none !important;
}

#labelDialog:not([style*="none"]) {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

/* Match panel background color to toolbar */
@media (max-width: 767px) {

    .controls-panel,
    #controlsPanel {
        background: var(--bg-body) !important;
    }

    .controls-panel .panel-header {
        background: var(--bg-body) !important;
        border-bottom: 1px solid var(--border-color) !important;
    }
}

/* Progress Overlay */
.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.progress-dialog {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    text-align: center;
    min-width: 280px;
    max-width: 90%;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.2s ease-out;
}

.progress-spinner {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.progress-dialog h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--secondary-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #00b3b3);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-dialog p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== Canvas Context Menu ===== */
.canvas-context-menu {
    position: absolute;
    min-width: 220px;
    max-width: 280px;
    background: var(--bg-panel);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.context-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--primary-color);
    color: white;
    cursor: move;
    user-select: none;
}

.context-menu-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.context-menu-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.context-menu-close:hover {
    opacity: 1;
}

.context-menu-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.context-menu-search input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    background: var(--bg-body);
    color: var(--text-primary);
}

.context-menu-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.context-menu-list {
    max-height: 180px;
    overflow-y: auto;
    padding: 4px 0;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.context-menu-item:hover {
    background: var(--secondary-color);
}

.context-menu-item.selected {
    background: rgba(0, 128, 128, 0.1);
    font-weight: 500;
}

.context-menu-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.context-menu-actions {
    padding: 8px 10px;
    border-top: 1px solid var(--border-color);
}

.context-create-btn {
    width: 100%;
    padding: 8px 12px;
    background: var(--secondary-color);
    border: 1px dashed var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.context-create-btn:hover {
    background: var(--primary-color);
    color: white;
    border-style: solid;
    border-color: var(--primary-color);
}

/* Upload Source Dialog */
.upload-source-dialog {
    text-align: center;
    max-width: 320px;
    position: relative;
}

/* Dialog close button positioning */
.dialog-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--secondary-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.dialog-close-btn:hover {
    background: var(--accent-color);
    color: white;
}

.upload-source-dialog h3 {
    margin: 12px 0 4px;
    font-size: 18px;
}

.upload-source-dialog p {
    margin: 0 0 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-source-options {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding-bottom: 8px;
}

.upload-source-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 30px;
    background: var(--secondary-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.upload-source-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 128, 128, 0.3);
}

.upload-source-btn i {
    font-size: 28px;
    color: var(--primary-color);
}

.upload-source-btn:hover i {
    color: white;
}

.upload-source-btn span {
    font-size: 14px;
    font-weight: 600;
}

/* ── Header Auth Button (mobile only — in header bar) ────── */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-auth-btn {
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    white-space: nowrap;
}

.header-auth-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.03);
}

.header-auth-btn.signed-in {
    background: #059669;
    border-color: #059669;
}

.header-auth-btn i {
    font-size: 13px;
}

/* Desktop: hide mobile auth btn (auth is in right panel) */
@media (min-width: 768px) {
    .header-auth-btn {
        display: none;
    }
}

/* ── Panel Auth Section ──────────────────────────── */
.panel-auth-section {
    padding: 12px 14px 8px;
}

/* Mobile: hide auth section from bottom panel (auth is in header) */
@media (max-width: 767px) {

    .panel-auth-section,
    .panel-divider {
        display: none;
    }
}

.panel-auth-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--primary-color);
    font-size: 18px;
}

.panel-auth-brand {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 17px;
    color: var(--text-primary);
}

.panel-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 4px 14px 0;
}

/* Panel trigger button */
.panel-auth-trigger-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.panel-auth-trigger-btn:hover {
    background: var(--primary-hover);
}

.panel-auth-trigger-btn i {
    font-size: 15px;
}

/* ── Auth Modal (popup) ──────────────────────────── */
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.auth-modal {
    background: var(--bg-body, #fff);
    border-radius: 16px;
    padding: 28px 24px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.auth-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.auth-modal-close:hover {
    color: var(--text-primary);
}

.auth-modal-header {
    text-align: center;
    margin-bottom: 16px;
}

.auth-logo-icon {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 4px;
    display: block;
}

.auth-modal-header h2 {
    font-family: var(--font-family);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* ── Auth Tabs ───────────────────────────────────── */
.auth-tabs {
    display: flex;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 12px;
}

.auth-tab {
    flex: 1;
    padding: 7px 0;
    border: none;
    background: transparent;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.auth-tab.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ── Auth Form Elements ──────────────────────────── */
.auth-forms {
    /* container */
}

.auth-form-content {
    animation: fadeIn 0.2s ease;
}

.auth-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-panel, #f7fafc);
    margin-bottom: 8px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.auth-input:focus {
    border-color: var(--primary-color);
}

.auth-submit-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
    margin-top: 4px;
}

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

.auth-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-link {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    margin-bottom: 0;
}

.auth-link a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.auth-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
}

.auth-status {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: var(--font-family);
    display: none;
}

.auth-status.success {
    background: #e6fffa;
    color: #047857;
    border: 1px solid #a7f3d0;
    display: block;
}

.auth-status.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    display: block;
}

/* ── Panel User Name Button (signed in) ──────────── */
.panel-user-btn {
    width: 100%;
    padding: 10px;
    background: #059669;
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.panel-user-btn:hover {
    background: #047857;
}

.panel-user-btn i {
    font-size: 15px;
}

/* ── Admin Dashboard Button (Admin Only) ─────────── */
.admin-dash-btn {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    background: #4f46e5;
    /* Indigo */
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.admin-dash-btn:hover {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 6px 10px -1px rgba(79, 70, 229, 0.3);
}

.admin-dash-btn i {
    font-size: 15px;
}

/* ── Profile Popup ───────────────────────────────── */
.profile-modal {
    max-width: 400px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.profile-avatar-lg {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #059669);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 22px;
    font-family: var(--font-family);
    flex-shrink: 0;
    background-position: center;
    background-size: cover;
    position: relative;
    overflow: hidden;
}

/* Edit mode avatar overlay */
.profile-modal.edit-mode .profile-avatar-lg {
    cursor: pointer;
}

.profile-modal.edit-mode .profile-avatar-lg::after {
    content: '\f030';
    /* camera icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    opacity: 0;
    transition: opacity 0.2s;
}

.profile-modal.edit-mode .profile-avatar-lg:hover::after {
    opacity: 1;
}

.profile-header-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.profile-header-name {
    font-weight: 700;
    font-size: 17px;
    color: var(--text-primary);
    font-family: var(--font-family);
}

.profile-header-email {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: var(--font-family);
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-edit-toggle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.profile-edit-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0fdf4;
}

.profile-edit-toggle.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.profile-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 14px 0;
}

/* Profile Fields */
.profile-fields {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.profile-field {
    margin-bottom: 10px;
}

.profile-field label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    font-family: var(--font-family);
}

.profile-input {
    width: 100%;
    padding: 9px 11px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--text-primary);
    background: #f8fafc;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

.profile-input:read-only {
    background: #f1f5f9;
    color: var(--text-secondary);
    cursor: default;
}

.profile-input:not(:read-only) {
    background: white;
    border-color: var(--primary-color);
}

.profile-input:not(:read-only):focus {
    box-shadow: 0 0 0 3px rgba(0, 128, 128, 0.1);
}

/* Affiliations */
.affiliations-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.affiliation-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.affiliation-item input {
    flex: 1;
    padding: 8px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--text-primary);
    background: #f1f5f9;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s;
}

.affiliation-item input:not(:read-only) {
    background: white;
    border-color: var(--primary-color);
}

.affiliation-delete-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: #fef2f2;
    color: #dc2626;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.affiliation-delete-btn:hover {
    background: #fecaca;
}

.profile-add-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s;
    margin-left: auto;
}

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

.profile-empty-hint {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    padding: 6px 0;
    font-family: var(--font-family);
}

/* Save All Button */
.profile-save-all-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
    margin-top: 4px;
}

.profile-save-all-btn:hover {
    background: var(--primary-hover);
}

/* Stats row */
.profile-stats {
    display: flex;
    gap: 12px;
}

.profile-stat {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.profile-stat-value {
    display: block;
    font-weight: 700;
    font-size: 18px;
    color: var(--primary-color);
    font-family: var(--font-family);
}

.profile-stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: var(--font-family);
}

/* Action buttons */
.profile-action-btn {
    width: 100%;
    padding: 10px;
    background: #f8fafc;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.profile-action-btn:hover {
    background: #edf2f7;
}

.profile-action-btn i {
    font-size: 13px;
    color: var(--text-secondary);
    width: 18px;
    text-align: center;
}

.profile-logout-btn:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.profile-logout-btn:hover i {
    color: #dc2626;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}