/* ProjectY Segmentation Dashboard — Stylesheet */

:root {
    --bg: #0a0e14;
    --bg-card: #131820;
    --bg-panel: #1a212d;
    --bg-hover: #232b3a;
    --border: #2a3445;
    --border-light: #3d4a60;
    --text: #e6edf3;
    --text-muted: #8b9bb4;
    --text-dim: #5a6a82;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --green: #3fb950;
    --green-dim: rgba(63, 185, 80, 0.15);
    --yellow: #d29922;
    --orange: #f0883e;
    --red: #f85149;
    --pink: #ff6b9d;
    --cyan: #48dbfb;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
}

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

html, body {
    min-height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
}
/* Pages that need a fixed full-viewport layout (canvas annotators) opt-in */
body.fixed-viewport,
body.fixed-viewport html { height: 100%; overflow: hidden; }

/* ─── Top Nav ─── */
.topnav {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 48px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    gap: 2rem;
    flex-shrink: 0;
}
.nav-brand {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.02em;
}
.nav-links { display: flex; gap: 0.5rem; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.chart-canvas { background: var(--bg-panel); border-radius: 6px;
    display: block; width: 100%; height: auto;
    max-width: 900px; }
.chart-canvas-wide { background: var(--bg-panel); border-radius: 6px;
    display: block; width: 100%; height: auto; }
.nav-right > a { color: var(--text-muted); text-decoration: none;
    padding: 0.4rem 0.75rem; border-radius: 6px; font-size: 0.9rem; font-weight: 500; }
.nav-right > a:hover { color: var(--text); background: var(--bg-hover); }
.nav-right > a.active { color: var(--text); background: rgba(88,166,255,0.2); }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--bg-hover); }
.nav-links a.active { color: var(--text); background: rgba(88,166,255,0.2); }

main {
    min-height: calc(100vh - 48px);
    padding: 1.25rem;
}
/* Canvas-based pages (annotate, mobility) keep the fixed-viewport behaviour */
body.fixed-viewport main { height: calc(100vh - 48px); overflow: hidden; padding: 1rem; }

/* ─── Page header ─── */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; }

.annotate-header {
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-right { font-size: 0.75rem; color: var(--text-dim); }
.btn-back { padding: 0.3rem 0.7rem; font-size: 1rem; }

.kbd-help { font-size: 0.78rem; color: var(--text-dim); }
kbd {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text);
    margin: 0 0.1rem;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
}
.btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.btn-primary {
    background: var(--accent); color: #001830;
    border-color: var(--accent); font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-accent {
    background: var(--green); color: #001a06;
    border-color: var(--green); font-weight: 600;
}
.btn-accent:hover:not(:disabled) { background: #56d364; }

/* ─── Subject grid (index page) ─── */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}
.subject-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
}
.subject-card:hover:not(.disabled) {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}
.subject-card.disabled { opacity: 0.4; pointer-events: none; }
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem;
}
.subject-id { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    background: var(--border);
    color: var(--text-muted);
    font-weight: 600;
}
.badge.status-done { background: var(--green-dim); color: var(--green); }
.badge.status-partial { background: rgba(210,153,34,0.15); color: var(--yellow); }
.card-body { display: flex; gap: 1.5rem; }
.stat-value { font-size: 1.3rem; font-weight: 800; display: block; line-height: 1.1; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ─── Annotate Layout ─── */
.annotate-layout {
    display: grid;
    grid-template-columns: 220px 1fr 320px;
    gap: 1rem;
    height: calc(100vh - 130px);
}

/* Tablet: collapse side panel into bottom drawer */
@media (max-width: 1100px) {
    .annotate-layout {
        grid-template-columns: 180px 1fr;
        grid-template-rows: 1fr auto;
    }
    .side-panel {
        grid-column: 1 / -1;
        grid-row: 2;
        flex-direction: row;
        max-height: 220px;
        gap: 0.5rem;
    }
    .side-panel > .panel-section {
        flex: 1;
        min-width: 250px;
    }
}

/* Phone: stack vertically */
@media (max-width: 700px) {
    main { padding: 0.5rem; }
    .annotate-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 100px 1fr auto;
        gap: 0.5rem;
        height: calc(100vh - 130px);
    }
    .image-sidebar {
        grid-row: 1;
        flex-direction: row;
        overflow-x: auto;
    }
    .image-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        gap: 0.4rem;
    }
    .img-item {
        flex-shrink: 0;
        width: 80px;
    }
    .session-group {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0.4rem;
        margin-bottom: 0;
    }
    .session-header {
        flex-shrink: 0;
        flex-direction: column;
        padding: 0.3rem;
        font-size: 0.65rem;
        writing-mode: vertical-rl;
    }
    .canvas-main { grid-row: 2; }
    .side-panel {
        grid-row: 3;
        flex-direction: row;
        max-height: 180px;
        overflow-x: auto;
    }
    .header-right { display: none; }
    .annotate-header h1 { font-size: 1.1rem; }
    .canvas-toolbar { flex-direction: column; gap: 0.4rem; align-items: stretch; }
}

/* Sidebar (left) */
.image-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: hidden;
}
.filter-bar {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}
.chip {
    padding: 0.3rem 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--border-light); }
.chip-active { background: var(--accent); color: #001830; border-color: var(--accent); font-weight: 600; }

.image-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.3rem;
}
.image-list::-webkit-scrollbar { width: 6px; }
.image-list::-webkit-scrollbar-track { background: transparent; }
.image-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.session-group { margin-bottom: 0.8rem; }
.session-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
}
.session-header.is-raw { background: rgba(63,185,80,0.1); }
.session-header.is-annot { background: rgba(88,166,255,0.1); }
.session-badge {
    background: var(--bg-panel);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: var(--mono);
    font-weight: 700;
    font-size: 0.7rem;
}
.session-label { font-weight: 600; flex: 1; }
.session-count {
    background: var(--border);
    color: var(--text-muted);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
}

.img-item {
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.4rem;
    background: var(--bg-card);
    transition: all 0.12s;
}
.img-item:hover { border-color: var(--border-light); transform: translateX(2px); }
.img-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
.img-item.thickness::before {
    content: '';
    position: absolute;
    left: 0; top: 0;
    width: 3px; height: 100%;
    background: var(--accent);
    z-index: 1;
}
.img-item img { width: 100%; display: block; }
.img-meta {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 0.4rem 0.5rem 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
}
.img-type { font-size: 0.85rem; }
.img-loc {
    color: var(--accent);
    font-weight: 700;
    font-family: var(--mono);
    flex: 1;
}
.img-count {
    background: var(--green);
    color: #001a06;
    border-radius: 50%;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; font-weight: 700;
}

/* Canvas main area */
.canvas-main {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: hidden;
}
.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    flex-shrink: 0;
}
.image-info-bar {
    display: flex;
    gap: 1.2rem;
    font-size: 0.82rem;
    flex-wrap: wrap;
}
.info-item { color: var(--text); }
.info-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.3rem;
}
.canvas-actions { display: flex; gap: 0.5rem; }

.canvas-container {
    flex: 1;
    position: relative;
    background: #000;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.canvas-container canvas {
    position: absolute;
    top: 0; left: 0;
}
#overlay-canvas { z-index: 2; }

.canvas-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-dim);
    z-index: 3;
}
.empty-icon { font-size: 3rem; opacity: 0.4; }

.canvas-banner {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(-200%);
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    color: var(--text);
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 5;
    pointer-events: none;
    transition: transform 0.25s;
    border: 1px solid var(--border-light);
}
.canvas-banner.visible { transform: translateX(-50%) translateY(0); }
.banner-action { border-color: var(--yellow); color: var(--yellow); }
.banner-info { border-color: var(--green); color: var(--green); }

/* Side panel (right) */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    overflow-y: auto;
    padding-right: 0.3rem;
}
.side-panel::-webkit-scrollbar { width: 6px; }
.side-panel::-webkit-scrollbar-track { background: transparent; }
.side-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.panel-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem;
}
.panel-section h3 {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.7rem;
    font-weight: 700;
}

/* Measurements */
.measurements-list { display: flex; flex-direction: column; gap: 0.3rem; }
.meas-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    background: var(--bg-panel);
    border-radius: 5px;
    font-family: var(--mono);
    font-size: 0.85rem;
    cursor: default;
}
.meas-row:hover { background: var(--bg-hover); }
.meas-num {
    background: var(--green);
    color: #001a06;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}
.meas-val { font-weight: 700; flex: 1; color: var(--green); }
.meas-px { color: var(--text-dim); font-size: 0.75rem; }
.btn-x {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 0.3rem;
}
.btn-x:hover { color: var(--red); }

.meas-summary {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--accent);
}
.value-only-note {
    font-size: 0.72rem;
    color: var(--text-dim);
    background: rgba(139,155,180,0.1);
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.4rem;
    font-style: italic;
}
.meas-row.meas-value-only {
    background: rgba(139,155,180,0.05);
    opacity: 0.85;
}
.meas-row.meas-value-only .meas-px {
    color: var(--text-dim);
    font-style: italic;
}

/* AI results */
.ai-results { display: flex; flex-direction: column; gap: 0.5rem; }
.ai-manual-ref {
    padding: 0.4rem 0.5rem;
    background: var(--green-dim);
    border-radius: 5px;
    font-size: 0.8rem;
    color: var(--green);
    font-family: var(--mono);
}
.ai-row {
    background: var(--bg-panel);
    border-radius: 6px;
    padding: 0.5rem;
    border-left: 3px solid var(--border);
}
.ai-row-langevin {
    border-left-color: #ffd166;
    background: linear-gradient(90deg, rgba(255,209,102,0.05), var(--bg-panel) 30%);
}
.ai-method-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    margin-top: -0.1rem;
    padding-left: 1.3rem;
    font-style: italic;
}
.ai-row-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    margin-bottom: 0.4rem;
}
.ai-color-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
}
.ai-name { font-weight: 600; flex: 1; }
.ai-time { color: var(--text-dim); font-family: var(--mono); font-size: 0.7rem; }
.ai-row-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.5rem;
    align-items: center;
    font-family: var(--mono);
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
}
.ai-value { color: var(--text); }
.ai-deviation { text-align: right; }
.dev-good { color: var(--green); font-weight: 600; }
.dev-ok { color: var(--yellow); font-weight: 600; }
.dev-bad { color: var(--red); font-weight: 600; }
.dev-neutral { color: var(--text-dim); font-size: 0.7rem; }

.ai-conf {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.conf-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.conf-fill { height: 100%; transition: width 0.3s; }
.conf-label { color: var(--text-dim); font-size: 0.7rem; min-width: 30px; text-align: right; }

.ai-feedback {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.4rem;
}
.fb-btn {
    flex: 1;
    padding: 0.25rem 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.12s;
    font-family: inherit;
}
.fb-btn:hover { color: var(--text); border-color: var(--border-light); }
.fb-correct:hover { color: var(--green); border-color: var(--green); }
.fb-close:hover { color: var(--yellow); border-color: var(--yellow); }
.fb-incorrect:hover { color: var(--red); border-color: var(--red); }
.fb-btn.fb-sent {
    background: var(--accent);
    color: #001830;
    border-color: var(--accent);
}

/* Best match */
.best-algo-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--green);
    margin-bottom: 0.3rem;
}
.best-algo-dev {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Help overlay */
.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 20, 0.85);
    backdrop-filter: blur(6px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.help-overlay.visible { display: flex; }
.help-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 2rem;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    color: var(--text);
}
.help-content h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--accent);
}
.help-content h3 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}
.help-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
}
.help-content table td {
    padding: 0.3rem 0.5rem;
    font-size: 0.9rem;
    vertical-align: middle;
}
.help-content table td:first-child {
    width: 110px;
    text-align: right;
}
.method-info {
    background: var(--bg-panel);
    padding: 0.7rem;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.6;
}
.method-info > div { margin-bottom: 0.2rem; }
.help-close-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Image adjustment sliders ─── */
.image-adjust {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    margin-top: 0.5rem;
    flex-shrink: 0;
}
.image-adjust label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.image-adjust input[type=range] {
    width: 120px;
    accent-color: var(--accent);
}

/* ─── Canvas zoom/pan ─── */
.canvas-zoom-indicator {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(0,0,0,0.75);
    color: var(--text);
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.78rem;
    z-index: 4;
    pointer-events: none;
    border: 1px solid var(--border-light);
}
.btn-icon-only {
    padding: 0.45rem 0.7rem;
    min-width: 38px;
    justify-content: center;
}

/* ─── AI Layer toggles ─── */
.ai-layers {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    margin-top: 0.5rem;
    flex-shrink: 0;
}
.layer-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.5rem;
}
#layer-toggles {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.layer-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.12s;
}
.layer-chip:hover { background: var(--bg-hover); }
.layer-chip input { display: none; }
.layer-chip input:checked ~ .layer-color {
    box-shadow: 0 0 0 2px var(--accent);
}
.layer-color {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--algo-color);
}
.layer-chip input:not(:checked) ~ .layer-name {
    text-decoration: line-through;
    opacity: 0.5;
}
.raw-swap-notice {
    background: rgba(63,185,80,0.1);
    border: 1px solid rgba(63,185,80,0.3);
    color: var(--green);
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    font-size: 0.78rem;
    margin-top: 0.4rem;
    width: 100%;
}

/* ─── Auth / Multi-User ─── */
.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.user-color-dot {
    display: inline-block;
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
}
.user-name { color: var(--text); }

.user-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-right: 1px;
}
.img-users {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 1px;
    z-index: 1;
    background: rgba(0,0,0,0.6);
    padding: 2px 4px;
    border-radius: 8px;
}

.view-only-banner {
    background: rgba(88,166,255,0.1);
    border: 1px solid rgba(88,166,255,0.3);
    color: var(--accent);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    text-align: center;
}
.view-only-banner a {
    color: var(--accent);
    font-weight: 600;
}

.user-meas-block {
    background: var(--bg-panel);
    border-radius: 6px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}
.user-meas-block.compact { padding: 0.4rem 0.5rem; }
.user-meas-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    margin-bottom: 0.3rem;
    color: var(--text-muted);
}
.user-meas-header strong { color: var(--text); }
.other-users-section {
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--border);
}
.other-users-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.show-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    cursor: pointer;
}
.show-toggle input { cursor: pointer; }

.inter-op-stats {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--accent);
    font-family: var(--mono);
}

/* Utilities */
.loading { color: var(--text-muted); font-style: italic; font-size: 0.85rem; }
.muted { color: var(--text-muted); font-size: 0.85rem; }
.error { color: var(--red); }
.empty { color: var(--text-muted); text-align: center; padding: 2rem; }

/* ─── Module Sub-Nav (Ultraschall) ─── */
.subnav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 1.5rem;
    height: 38px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.subnav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.35rem 0.7rem;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}
.subnav a:hover { color: var(--text); background: var(--bg-hover); }
.subnav a.active { color: var(--accent); }
body.fixed-viewport main { height: calc(100vh - 86px); }  /* topnav + subnav */

/* ─── Module Tabs (inside Subject-Data / Proprioception) ─── */
.module-tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 4px;
    margin: 0 0 1.4rem;
}
.mtab {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.45rem 1.1rem;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: color .12s, background .12s;
}
.mtab:hover { color: var(--text); }
.mtab.active { background: var(--accent); color: #fff; }
.mt-pane { display: none; }
.mt-pane.active { display: block; }

/* ─── Pane info / empty state ─── */
.pane-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.1rem 1.3rem;
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text);
}
.pane-info code { background: var(--bg-panel); padding: 1px 6px; border-radius: 3px;
                  font-family: var(--mono); font-size: 0.85em; color: var(--accent); }
.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border-light);
    border-radius: 12px;
    padding: 2.4rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}
.empty-state .es-icon { font-size: 2.4rem; margin-bottom: 0.6rem; line-height: 1; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.92rem; line-height: 1.55; max-width: 520px; margin: 0 auto; }
.empty-state code { background: var(--bg-panel); padding: 1px 6px; border-radius: 3px;
                    font-family: var(--mono); font-size: 0.85em; color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────
 * Hover tooltips — universal pattern.
 *   <span class="hint" data-tip="Explanation">Term</span>
 *   <span class="hint-icon" data-tip="Explanation">i</span>
 * 200ms delay before showing; styled box with shadow; max 320px wide.
 * ─────────────────────────────────────────────────────────────── */
.hint {
    border-bottom: 1px dotted var(--text-muted);
    cursor: help;
    position: relative;
}
.hint::after,
.hint-icon::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 130%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text);
    white-space: normal;
    width: max-content;
    max-width: 320px;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    z-index: 1000;
    box-shadow: 0 6px 18px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease 0.2s;
}
.hint:hover::after,
.hint-icon:hover::after { opacity: 1; }
.hint-icon {
    display: inline-block;
    width: 14px; height: 14px; line-height: 14px;
    text-align: center;
    font-size: 0.7rem;
    border-radius: 50%;
    background: var(--text-muted);
    color: var(--bg-card);
    margin-left: 4px;
    cursor: help;
    position: relative;
    vertical-align: middle;
    font-style: normal; font-weight: 600;
}

/* ── Inter-Operator Boxplot ───────────────────────────── */
.bp-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.7rem 0.5rem;
    margin-bottom: 0.7rem;
}
.bp-title {
    font: 500 0.66rem var(--mono, monospace);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}
.bp-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-end;
}
.bp-panel {
    flex: 0 0 auto;
    text-align: center;
    width: 260px;
}
.bp-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 0.1rem;
    font-weight: 500;
    line-height: 1.15;
}
.bp-unit {
    font-family: var(--mono, monospace);
    font-weight: 400;
    color: var(--text-dim);
    font-size: 0.85em;
}
.bp-svg { display: block; width: 100%; height: auto; }
.bp-sub {
    font: 400 0.62rem var(--mono, monospace);
    color: var(--text-dim);
    margin-top: 0.05rem;
    line-height: 1.1;
}
.bp-cap {
    font-size: 0.62rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
    font-style: italic;
    line-height: 1.2;
}
.bp-empty {
    padding: 0.55rem 0.8rem;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.78rem;
    margin-bottom: 0.7rem;
}

/* ── Inter-Operator Agreement Panel (BA + Dumbbell) ───────── */
.iop-title {
    font: 600 0.95rem var(--font, sans-serif);
    margin: 0 0 0.4rem 0;
    color: var(--text);
}
.iop-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.7rem;
    align-items: baseline;
    font-size: 0.83rem;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    margin-bottom: 0.8rem;
}
.iop-sep {
    color: var(--text-dim);
    opacity: 0.55;
    margin: 0 0.1rem;
}
.iop-empty {
    padding: 0.6rem 0.85rem;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 0.84rem;
    margin-bottom: 0.7rem;
}
.iop-metric {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem 0.8rem 0.55rem;
    margin-bottom: 0.85rem;
}
.iop-metric-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.9rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.5rem;
}
.iop-metric-head h5 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}
.iop-metric-head .iop-unit {
    color: var(--text-muted);
    font-weight: 400;
    font-family: var(--mono, monospace);
    font-size: 0.84em;
    margin-left: 0.25em;
}
.iop-metric-stats {
    font-size: 0.78rem;
    color: var(--text);
    font-family: var(--mono, monospace);
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.55rem;
    align-items: baseline;
}
.iop-metric-stats b { color: var(--accent, #5fd49a); font-weight: 600; }
.iop-plots {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}
.iop-plot {
    background: var(--bg-panel, var(--bg));
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45rem 0.55rem 0.5rem;
    width: 480px;
    flex: 0 0 480px;
}
.iop-plot-title {
    font: 500 0.7rem var(--mono, monospace);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.05rem;
}
.iop-plot-sub {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
    line-height: 1.2;
}
.iop-svg { display: block; width: 100%; height: auto; }
.iop-caption {
    font-size: 0.74rem;
    color: var(--text-dim);
    line-height: 1.45;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent, #5fd49a);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.4rem;
}
.iop-caption b { color: var(--text); }
