:root {
    --bg-color: #f5f7fa;
    --text-color: #24292f;
    --accent-color: #0969da;
    --card-bg: rgba(255, 255, 255, 0.85);
    --border-color: #d0d7de;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Outfit', sans-serif;
    color: var(--text-color);
}

#app {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
}

/* Global fog overlay for spotlight effect - subtle on hover */
#fog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, transparent 50%, rgba(0, 0, 0, 0.2) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease-out;
    z-index: 5;
}

#fog-overlay.active {
    opacity: 1;
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Floating Filter Status Bar - Always visible at top */
#floating-filter-bar {
    position: fixed;
    top: 70px;
    left: 420px;
    right: 200px;
    max-width: 450px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(99, 102, 241, 0.95));
    color: white;
    padding: 10px 16px;
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 500;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    backdrop-filter: blur(8px);
    font-size: 14px;
}

#floating-filter-bar .filter-status-text {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#floating-filter-bar .filter-details {
    opacity: 0.9;
    font-size: 13px;
}

#floating-filter-bar .clear-filters-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#floating-filter-bar .clear-filters-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile: Position floating filter bar differently */
@media (max-width: 768px) {
    #floating-filter-bar {
        top: 60px;
        left: 50px;
        right: 50px;
        max-width: none;
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* Compact Modal - Top Left */
.summary-card {
    position: absolute;
    bottom: 20px;
    left: 280px;
    /* Right of sidebar */
    right: auto;
    width: 320px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 12px 14px;
    border-radius: 10px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    transform-origin: bottom left;
    overflow: visible;
    /* Allow dropdowns to extend outside */
}

.summary-card h2 {
    margin-top: 0;
    color: var(--accent-color);
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.summary-card p {
    margin: 2px 0;
    line-height: 1.2;
    font-size: 0.8rem;
}

.summary-card button {
    background: #1f883d;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    font-family: inherit;
    transition: background 0.2s;
}

.summary-card button:hover {
    background: #1a7f37;
}

/* Popup Actions - Compact */
.popup-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.email-btn {
    background: #0969da !important;
    flex: 1;
}

.email-btn:hover {
    background: #0756b0 !important;
}

/* Responsive button text - show full on desktop, short on mobile */
.btn-text-short {
    display: none;
}

.btn-text-full {
    display: inline;
}


#close-btn {
    background: #6c757d !important;
    flex: 1;
}

#close-btn:hover {
    background: #5a6268 !important;
}

/* Invite Section Styles */
.invite-section {
    margin-top: 12px;
    padding: 10px;
    background: rgba(9, 105, 218, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(9, 105, 218, 0.15);
}

.invite-input-wrapper {
    display: flex;
    gap: 6px;
}

.invite-email-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.invite-email-input:focus {
    border-color: #0969da;
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.send-invite-btn {
    padding: 8px 14px !important;
    margin-top: 0 !important;
    background: #1f883d !important;
    font-size: 13px !important;
}

.send-invite-btn:hover {
    background: #1a7f37 !important;
}

.invite-feedback {
    margin-top: 8px;
    font-size: 12px;
    min-height: 16px;
}

.invite-feedback.error {
    color: #cf222e;
}

.invite-feedback.success {
    color: #1a7f37;
}

/* Panel collapse toggle (hidden on desktop, visible on mobile via media query) */
.panel-collapse-toggle {
    display: none;
}

.node-label {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #24292f;
    border-radius: 8px;
    padding: 4px 8px;
    font-family: 'Outfit', sans-serif;
    /* Yellow spotlight glow effect */
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 0 15px rgba(255, 215, 0, 0.25),
        0 0 30px rgba(255, 215, 0, 0.15),
        0 0 50px rgba(255, 215, 0, 0.08);
    pointer-events: none;
    user-select: none;
    text-align: center;
}

.node-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    color: #1a1a1a;
}

.node-relation {
    font-size: 9px;
    font-weight: 400;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 1px;
}

.node-age {
    font-size: 9px;
    color: #6b7280;
    margin-bottom: 3px;
}

/* 5-Segment Completeness Bar */
.completeness-segments {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-top: 2px;
}

.completeness-segments .segment {
    width: 8px;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 1px;
}

.completeness-segments .segment.filled {
    background: linear-gradient(180deg, #34d399, #10b981);
}

/* Chips for conditions */
.chip {
    display: inline-block;
    background: #ddf4ff;
    color: #0969da;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.85rem;
    margin-right: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.chip:hover {
    background: #0969da;
    color: white;
}

.chip.active {
    background: #0969da;
    color: white;
    border-color: #0550ae;
}

/* Custom (non-HPO) condition chips */
.chip.custom {
    background: #fef3c7;
    color: #92400e;
    border: 1px dashed #f59e0b;
}

.chip.custom:hover {
    background: #f59e0b;
    color: white;
    border-style: solid;
}

.chip.custom::after {
    content: ' ⚠';
    font-size: 10px;
}

.add-condition-container {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.add-condition-input {
    flex: 1;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 0.9rem;
}

.add-btn {
    padding: 4px 8px !important;
    margin-top: 0 !important;
    font-size: 0.9rem;
    background: #f6f8fa !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
}

.add-btn:hover {
    background: #eaeef2 !important;
}

/* Fixed Generation Labels - Flat on channel planes */
#gen-labels-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    /* Low z-index, above canvas but below most UI */
}

.generation-label-fixed {
    position: absolute;
    font-size: 48px;
    font-weight: 900;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 12px;
    text-transform: uppercase;
    /* Very faint - subtle watermark effect */
    opacity: 0.08 !important;
    background: transparent;
    padding: 0;
    transform: translate(-50%, -50%);
    text-shadow: none;
    z-index: 1;
}

/* Sidebar Items */
.sidebar-item.checkbox-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 6px 10px;
    background: white;
    margin-bottom: 6px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    border: 1px solid transparent;
    font-size: 13px;
    /* Smaller text */
}

.sidebar-item.checkbox-item:hover,
.sidebar-item.checkbox-item.highlight-hover {
    background: #eff6ff;
    border-color: #3b82f6;
    transform: translateX(4px);
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.1);
}

.sidebar-item.checkbox-item.highlight-hover {
    background: #dbeafe;
    /* Slightly darker/more prominent for linkage */
}

.percent-badge {
    margin-left: auto;
    font-size: 9px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
    font-weight: 500;
    color: #6b7280;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 36px;
    text-align: right;
    display: inline-block;
}

.sort-btn {
    background: none;
    border: none;
    font-size: 11px;
    color: #3b82f6;
    cursor: pointer;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.sort-btn:hover {
    background: #eff6ff;
}

/* Age Filter */
.age-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
}

.age-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.age-input-group label {
    font-size: 10px;
    color: #6b7280;
}

.age-input-group input {
    width: 100%;
    padding: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 12px;
}

/* Sidebar Items - Compact */
.sidebar-item.checkbox-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 5px 8px;
    background: white;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    border: 1px solid transparent;
    font-size: 12px;
}

/* ... existing hover styles ... */

.sidebar-item.checkbox-item:hover,
.sidebar-item.checkbox-item.highlight-hover {
    background: #eff6ff;
    border-color: #3b82f6;
    transform: translateX(4px);
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.1);
}

.sidebar-item.checkbox-item.highlight-hover {
    background: #dbeafe;
    /* Slightly darker/more prominent for linkage */
}

.count-badge {
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
    margin-left: 4px;
    white-space: nowrap;
}

/* ... existing percent-badge style removed/deprecated ... */

.checkbox-content {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.checkbox-content input {
    width: 14px;
    height: 14px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-content span {
    font-size: 12px;
    color: #334155;
    font-weight: 500;
    line-height: 1.3;
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

/* Mini Prevalence Bar - Compact with gradient */
.bar-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    margin-top: 2px;
}

.mini-bar-container {
    width: 100%;
    height: 16px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.mini-bar-fill {
    height: 100%;
    /* Gradient set dynamically via JS based on percentage intensity */
    border-radius: 4px;
    transition: width 0.3s ease, background 0.3s ease;
}

/* Stats displayed inside the bar */
.bar-stats-inside {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

/* Left side (inside the bar fill) - for high percentages */
.bar-stats-left {
    left: 6px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Right side (outside/end of bar) - for low percentages */
.bar-stats-right {
    right: 6px;
    color: #475569;
}

.percent-text-outside {
    display: none;
}

/* Bar Stats (percent + count) - now positioned inside */
.bar-stats {
    display: none;
}

.count-small {
    font-size: 9px;
    font-weight: 400;
    opacity: 0.8;
}

/* Condition name in sidebar */
.condition-name {
    font-size: 13px;
    color: #334155;
    font-weight: 500;
    line-height: 1.3;
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

/* Filter Groups */
.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.sex-toggle {
    display: flex;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.sex-toggle button {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px 0;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sex-toggle button:hover {
    color: #1a1a1a;
}

.sex-toggle button.active {
    background: white;
    color: #2563eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* Sidebar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.5);
    padding: 24px;
    padding-top: 40px;
    box-sizing: border-box;
    z-index: 100;
    overflow-y: auto;
    font-family: 'Outfit', sans-serif;
    pointer-events: auto;
}

#sidebar h2 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

.sidebar-item {
    display: block;
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #444;
    transition: all 0.2s ease;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.sidebar-item.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Query Builder Styles */
.query-hint {
    font-size: 12px;
    color: #6b7280;
    margin: -16px 0 12px 0;
    font-style: italic;
}

.query-status {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 12px;
    color: #6b7280;
    min-height: 20px;
}

.query-status.active {
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

.query-status small {
    opacity: 0.8;
    word-break: break-word;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-item span {
    flex: 1;
    line-height: 1.3;
}

.checkbox-item:has(input:checked) {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.3);
}

.reset-btn {
    background: #3b82f6 !important;
    border: none !important;
    color: white !important;
    margin-top: 16px !important;
    text-align: center !important;
    font-weight: 600 !important;
}

.reset-btn:hover {
    background: #2563eb !important;
    transform: translateX(0) !important;
}

.recalc-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    border: none !important;
    color: white !important;
    margin-top: 8px !important;
    text-align: center !important;
    font-weight: 600 !important;
}

.recalc-btn:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important;
    transform: translateX(0) !important;
}

.recalc-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Data Completeness Progress Bar */
.completeness-section {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.completeness-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 6px;
}

.completeness-value {
    font-weight: 600;
    color: #374151;
}

.completeness-bar {
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.completeness-fill {
    height: 100%;
    background: linear-gradient(90deg, #34d399 0%, #10b981 50%, #059669 100%);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Add Member Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #374151;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.gender-options {
    display: flex;
    gap: 12px;
}

.gender-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.gender-option:hover {
    border-color: #9ca3af;
}

.gender-option.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.gender-option input {
    display: none;
}

.gender-option span {
    font-size: 14px;
}

.conditions-input {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    min-height: 44px;
}

.condition-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #e0f2fe;
    color: #0369a1;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.condition-tag button {
    background: none;
    border: none;
    cursor: pointer;
    color: #0369a1;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

.conditions-input input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 100px;
    font-size: 14px;
    padding: 4px;
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.submit-btn:hover {
    background: #2563eb;
}

.add-member-btn {
    background: #10b981 !important;
    color: white !important;
    border: none !important;
    font-weight: 600 !important;
}

.add-member-btn:hover {
    background: #059669 !important;
}

/* HPO Autocomplete Dropdown */
.conditions-input {
    position: relative;
}

.hpo-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hpo-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

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

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

.hpo-item.disabled {
    color: #9ca3af;
    cursor: default;
    font-style: italic;
}

.hpo-item.disabled:hover {
    background: transparent;
}

.hpo-id {
    float: right;
    font-size: 11px;
    color: #3b82f6;
    font-family: monospace;
}

/* HPO Search in Popup */
.hpo-search-wrapper {
    position: relative;
    flex: 1;
}

.hpo-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.hpo-search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.hpo-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 280px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.hpo-dropdown .hpo-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid #f3f4f6;
}

.hpo-dropdown .hpo-item:hover {
    background: #eff6ff;
}

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

.hpo-dropdown .hpo-name {
    font-weight: 500;
    font-size: 13px;
    color: #374151;
}

.hpo-dropdown .hpo-id {
    font-size: 10px;
    color: #3b82f6;
    font-family: monospace;
}

.hpo-dropdown .hpo-item.no-match {
    color: #9ca3af;
    font-style: italic;
    cursor: default;
}

.hpo-dropdown .hpo-item.no-match:hover {
    background: transparent;
}

/* Add Related Member Button */
.add-related-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.add-related-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* Natural Language Modal - Bottom Left */
.nl-modal {
    width: 420px;
    margin-top: auto;
    /* Push to bottom of flex container */
}

.nl-hint {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
    line-height: 1.5;
}

.nl-hint em {
    color: #8b5cf6;
    font-style: italic;
}

.nl-related-info {
    background: rgba(139, 92, 246, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
    color: #6b7280;
}

.nl-related-info strong {
    color: #374151;
}

.nl-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.nl-textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.nl-status {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 12px;
    min-height: 20px;
}

.nl-status.loading {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.nl-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.nl-status.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.nl-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.nl-preview {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.nl-preview h4 {
    margin: 0 0 8px 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
}

.preview-item {
    font-size: 14px;
    padding: 4px 0;
    border-bottom: 1px solid #e5e7eb;
}

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

.preview-item.missing {
    background: rgba(245, 158, 11, 0.1);
    margin: 2px -8px;
    padding: 4px 8px;
    border-radius: 4px;
}

.missing-value {
    color: #f59e0b;
    font-style: italic;
}

.nl-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.nl-parse-btn {
    flex: 1;
    padding: 12px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.nl-parse-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.nl-parse-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.nl-cancel-btn {
    padding: 12px 20px;
    background: #f3f4f6;
    color: #4b5563;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.nl-cancel-btn:hover {
    background: #e5e7eb;
}

/* Editable form for incomplete parsing */
.nl-edit-form {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}

.nl-edit-form h4 {
    margin: 0 0 14px 0;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.nl-edit-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.nl-edit-form .form-row:last-child {
    margin-bottom: 0;
}

.nl-edit-form label {
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
}

.nl-edit-form label .required {
    color: #ef4444;
    font-weight: 700;
}

.nl-edit-form input,
.nl-edit-form select {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.nl-edit-form input:focus,
.nl-edit-form select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.nl-edit-form .gender-toggle-group {
    display: flex;
    gap: 16px;
    padding: 8px 0;
}

.nl-edit-form .gender-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.nl-edit-form .gender-radio input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: #8b5cf6;
    cursor: pointer;
}

/* Missing field highlight for validation */
.missing-field {
    border-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.05);
    animation: pulse-warning 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
    }
}

.gender-toggle-group.missing-field {
    background: rgba(245, 158, 11, 0.1);
    border-radius: 6px;
    padding: 8px 6px;
    margin: -4px -6px;
}

#command-bar {
    position: fixed;
    top: 20px;
    left: 55%;
    transform: translateX(-50%);
    width: 450px;
    max-width: 40%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    pointer-events: auto;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#command-bar:focus-within {
    width: 540px;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    transform: translateX(-50%) translateY(2px);
}

.cmd-icon {
    font-size: 18px;
    color: #3b82f6;
    font-weight: 700;
    font-family: monospace;
    user-select: none;
}

#cmd-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
    font-family: 'Outfit', sans-serif;
    color: #1f2937;
}

#cmd-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

#cmd-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    display: none;
    animation: fadeIn 0.2s ease;
}

#cmd-status.success {
    display: block;
    background: #ecfdf5;
    color: #059669;
}

#cmd-status.error {
    display: block;
    background: #fef2f2;
    color: #dc2626;
}

#cmd-status.loading {
    display: block;
    background: #eff6ff;
    color: #3b82f6;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

/* Legend Panel - Bottom Right */
#legend-panel {
    position: fixed;
    bottom: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    min-width: 120px;
}

#legend-panel h4 {
    margin: 0 0 6px 0;
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    cursor: pointer;
    font-size: 11px;
    color: #374151;
}

.legend-toggle:hover {
    color: #1f2937;
}

.legend-toggle input[type="checkbox"] {
    width: 12px;
    height: 12px;
    accent-color: #3b82f6;
    cursor: pointer;
}

/* Node label hover highlight */
.node-label {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.node-label:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* ===== Unified Add Sections ===== */
.add-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    margin-top: 12px;
}

.add-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.add-section-icon {
    font-size: 16px;
}

.add-section-title {
    font-weight: 600;
    font-size: 13px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.add-section-body {
    display: flex;
    gap: 8px;
    align-items: center;
    /* Vertically center for better alignment */
}

.add-section-body .unified-input-wrapper {
    flex: 1;
}

.add-section-body button {
    flex-shrink: 0;
    height: 40px;
    /* Match input height */
}

.unified-input-wrapper {
    flex: 1;
    position: relative;
}

.unified-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.unified-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.unified-input::placeholder {
    color: #9ca3af;
}

.unified-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}

.unified-dropdown .hpo-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f3f4f6;
}

.unified-dropdown .hpo-item:hover {
    background: #f3f4f6;
}

.unified-dropdown .hpo-item:last-child {
    border-bottom: none;
}

.unified-add-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.unified-add-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.unified-add-btn:active {
    transform: translateY(0);
}

/* Feedback Messages */
.add-feedback {
    display: none;
    margin-top: 8px;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
}

.feedback-success {
    color: #047857;
    background: #d1fae5;
    padding: 4px 8px;
    border-radius: 4px;
}

.feedback-warning {
    color: #92400e;
    background: #fef3c7;
    padding: 4px 8px;
    border-radius: 4px;
}

.feedback-error {
    color: #dc2626;
    background: #fee2e2;
    padding: 4px 8px;
    border-radius: 4px;
}

.feedback-loading {
    color: #2563eb;
    background: #dbeafe;
    padding: 4px 8px;
    border-radius: 4px;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ===== Dual-Thumb Range Slider ===== */
.range-slider-container {
    position: relative;
    height: 40px;
    margin-top: 8px;
}

.range-slider {
    position: absolute;
    width: 100%;
    height: 6px;
    top: 50%;
    transform: translateY(-50%);
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    z-index: 2;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2563eb;
    cursor: pointer;
    pointer-events: auto;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
    transition: transform 0.15s ease;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2563eb;
    cursor: pointer;
    pointer-events: auto;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

.range-track {
    position: absolute;
    width: 100%;
    height: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: #e5e7eb;
    border-radius: 3px;
    z-index: 0;
}

.range-fill {
    position: absolute;
    height: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 3px;
    z-index: 1;
}

#age-range-display {
    font-weight: 600;
    color: #2563eb;
    margin-left: 8px;
}

/* ===== Smaller Condition Fonts ===== */
.sidebar-item .condition-name {
    font-size: 13px;
}

.sidebar-item .condition-count {
    font-size: 11px;
}

/* ===== Collapsible Sidebar ===== */
#sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    z-index: 200;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

#sidebar-toggle:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Filter badge on hamburger menu */
.filter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#sidebar.collapsed {
    transform: translateX(-100%);
}

/* ===== Mobile Compatibility ===== */
@media (max-width: 768px) {

    /* Show hamburger menu */
    #sidebar-toggle {
        display: flex;
    }

    /* Sidebar mobile adjustments */
    #sidebar {
        width: 280px;
        transition: transform 0.3s ease;
        padding-top: 60px;
    }

    #sidebar.collapsed {
        transform: translateX(-100%);
    }

    /* Smaller sidebar items */
    .sidebar-item {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Move buttons to top right on mobile - compact */
    #view-toggle,
    #export-btn {
        top: 12px !important;
        bottom: auto !important;
        padding: 8px 12px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
    }

    #view-toggle {
        right: 12px !important;
    }

    #export-btn {
        right: 90px !important;
    }

    /* Hide legend panel on mobile - too crowded */
    #legend-panel {
        display: none !important;
    }

    #legend-panel h4 {
        font-size: 11px;
        margin-bottom: 8px;
    }

    .legend-toggle {
        font-size: 12px;
        padding: 4px 0;
    }

    /* Popup as bottom sheet drawer on mobile - above command bar */
    .summary-card {
        position: fixed !important;
        top: auto !important;
        right: 0 !important;
        left: 0 !important;
        bottom: 80px !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 40vh !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 12px 16px !important;
        padding-top: 20px !important;
        text-align: center;
        overflow-y: auto !important;
        transform: translateY(0) !important;
        transition: transform 0.3s ease, max-height 0.3s ease !important;
        z-index: 900 !important;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12) !important;
    }

    /* Hide add section on mobile entirely - cleaner popup */
    .summary-card .add-section {
        display: none !important;
    }

    .summary-card.collapsed {
        max-height: 100px !important;
        overflow: hidden !important;
    }

    /* Peek content when collapsed - show name, relation, conditions */
    .summary-card.collapsed .add-section,
    .summary-card.collapsed .popup-actions,
    .summary-card.collapsed .invite-section {
        display: none !important;
    }

    /* Show conditions in collapsed mode, but compact */
    .summary-card.collapsed #conditions-list {
        max-height: 30px;
        overflow: hidden;
        margin-bottom: 0;
    }

    .summary-card h2 {
        font-size: 1.1rem;
        margin-bottom: 4px;
        margin-top: 0;
    }

    .summary-card p {
        font-size: 0.85rem;
        margin: 4px 0;
    }

    /* Collapse toggle as drag handle at top */
    .panel-collapse-toggle {
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 50px;
        height: 20px;
        background: transparent;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        padding: 0;
        font-size: 0;
    }

    /* Smaller, more subtle drag handle bar */
    .panel-collapse-toggle::before {
        content: '';
        width: 36px;
        height: 4px;
        background: #e5e7eb;
        border-radius: 3px;
    }

    .panel-collapse-toggle:active::before {
        background: #d1d5db;
    }

    /* Smaller chips on mobile */
    .chip {
        font-size: 0.75rem;
        padding: 2px 6px;
    }

    /* Compact add section on mobile */
    .add-section {
        padding: 8px 10px;
    }

    .add-section-title {
        font-size: 11px;
    }

    /* Prevent iOS zoom on input focus - must be 16px+ */
    .unified-input,
    #hpo-search-input {
        padding: 8px 10px;
        font-size: 16px !important;
    }

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

    /* Popup actions on mobile - hide Add button, Invite/Close side by side */
    .popup-actions {
        flex-direction: row;
        gap: 8px;
        flex-wrap: wrap;
    }

    .popup-actions .add-member-btn {
        display: none !important;
    }

    .popup-actions button {
        flex: 1;
        min-width: 100px;
        padding: 10px !important;
        font-size: 13px;
    }

    /* Show short button text on mobile */
    .btn-text-short {
        display: inline !important;
    }

    .btn-text-full {
        display: none !important;
    }

    /* Command bar on mobile - positioned at bottom, compact */
    #command-bar {
        display: flex !important;
        top: auto;
        bottom: 20px;
        width: calc(100% - 24px);
        max-width: none;
        left: 12px;
        right: 12px;
        transform: none;
        padding: 8px 12px;
        font-size: 14px;
    }

    #command-bar:focus-within {
        width: calc(100% - 24px);
        transform: none;
    }

    /* Range slider touch-friendly */
    .range-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    .range-slider::-moz-range-thumb {
        width: 26px;
        height: 26px;
    }

    /* Touch target sizes */
    .sex-toggle button {
        min-height: 44px;
        min-width: 60px;
    }

    .sort-btn {
        min-height: 36px;
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    #sidebar {
        width: 100vw;
    }

    .summary-card {
        width: 95vw !important;
    }

    #view-toggle,
    #export-btn {
        padding: 6px 10px !important;
        font-size: 11px !important;
        top: 12px !important;
        bottom: auto !important;
        width: auto !important;
    }

    #export-btn {
        right: 75px !important;
    }
}

/* ===== Glass Plane Obscured Labels ===== */
.node-label.glass-obscured {
    opacity: 0.95;
    backdrop-filter: blur(4px);
    filter: blur(4px);
    /* Added back for broader compatibility */
    transition: filter 0.4s ease, opacity 0.4s ease;
    pointer-events: none;
}

/* Placeholder Labels (Unknown members) */
.node-label.placeholder-label {
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.5);
    border-style: dashed;
}

.placeholder-indicator {
    color: #f59e0b;
    font-weight: 700;
    font-size: 0.9em;
}

/* Exclude the selected node's label from being obscured */
.node-label.glass-obscured.selected-label {
    filter: none;
    opacity: 1;
    pointer-events: auto;
}

/* Dimmed labels for filtered-out nodes (at base Z level) */
.node-label.dimmed-label {
    filter: blur(2px) grayscale(80%);
    opacity: 0.5;
    transition: filter 0.4s ease, opacity 0.4s ease;
    pointer-events: none;
}

/* 2D View: Let CSS2D renderer position labels naturally */
body.view-2d .node-label {
    transform: none;
    /* Override default transform - let projection handle positioning */
}

body.view-2d .node-label:hover {
    transform: scale(1.05);
}

/* ===== Controls Panel (Top, After Sidebar, Collapsible) ===== */
#controls-panel {
    position: fixed;
    top: 20px;
    left: 280px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    min-width: 100px;
    overflow: hidden;
    transition: all 0.3s ease;
    font-size: 11px;
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    color: #4b5563;
    user-select: none;
    transition: background 0.2s;
}

.controls-header:hover {
    background: rgba(0, 0, 0, 0.03);
}

.controls-header .toggle-icon {
    font-size: 8px;
    color: #9ca3af;
    transition: transform 0.3s ease;
}

#controls-panel.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.controls-body {
    padding: 0 14px 12px 14px;
    max-height: 200px;
    opacity: 1;
    transition: all 0.3s ease;
}

#controls-panel.collapsed .controls-body {
    max-height: 0;
    opacity: 0;
    padding: 0 14px;
    overflow: hidden;
}

.control-hint {
    font-size: 11px;
    color: #4b5563;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-hint .key {
    background: linear-gradient(180deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 10px;
    font-weight: 600;
    color: #374151;
    min-width: 50px;
    text-align: center;
}

.control-btn {
    margin-top: 8px;
    width: 100%;
    padding: 6px 10px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.3);
}

/* Mobile: Hide controls panel (gestures work natively) */
@media (max-width: 768px) {
    #controls-panel {
        display: none;
    }
}