:root {
    --project-footer-height: calc(48px + env(safe-area-inset-bottom, 0px));
}

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

body {
    background: #0a0a0f;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Controls bar (top) ── */
#controls-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(20, 20, 30, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 100;
    flex-shrink: 0;
}

#controls-bar h1 {
    font-size: 16px;
    font-weight: 600;
    color: #4ecdc4;
    margin-right: 8px;
    letter-spacing: -0.5px;
}

.toggle-btn {
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: #aaa;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ddd;
}

.toggle-btn.active {
    background: rgba(78, 205, 196, 0.2);
    border-color: #4ecdc4;
    color: #4ecdc4;
}

.toggle-btn.active::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ecdc4;
    margin-right: 6px;
    vertical-align: middle;
}

#camera-select {
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: #ccc;
    font-size: 12px;
    max-width: 180px;
}

#fps-display {
    margin-left: auto;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: #666;
}

#mode-indicator {
    font-size: 12px;
    color: #666;
}

#error-display {
    font-size: 12px;
    color: #ff6b6b;
    display: none;
}

/* ── Main canvas area ── */
#main-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#video-feed {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scaleX(-1); /* selfie mirror */
    opacity: 0.3;
}

#skeleton-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
}

/* ── Timeline strip (bottom) ── */
#timeline-strip {
    height: 120px;
    background: rgba(20, 20, 30, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    position: relative;
}

#timeline-canvas {
    width: 100%;
    height: 100%;
}

/* ── Project provenance (persistent across every mode) ── */
#project-footer {
    height: var(--project-footer-height);
    padding: 0 16px env(safe-area-inset-bottom, 0px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    z-index: 101;
    background: rgba(20, 20, 30, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.project-provenance {
    color: #c9c9d4;
    font-size: 16px;
}

#github-project-link {
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #e9fffd;
    background: rgba(78, 205, 196, 0.11);
    border: 1px solid rgba(78, 205, 196, 0.62);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

#github-project-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: currentColor;
}

#github-project-link:hover {
    color: #ffffff;
    background: rgba(78, 205, 196, 0.2);
    border-color: #4ecdc4;
}

#github-project-link:focus-visible {
    outline: 3px solid #ffe66d;
    outline-offset: -3px;
}

.external-link-mark {
    color: #72e5dc;
    font-weight: 700;
}

/* ── Benchmark panel (right, collapsible) ── */
#benchmark-panel {
    position: fixed;
    top: 50px;
    right: 0;
    width: 280px;
    max-height: calc(100vh - 180px - var(--project-footer-height));
    background: rgba(15, 15, 25, 0.95);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 0 8px;
    padding: 12px;
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    overflow-y: auto;
    z-index: 90;
    transition: transform 0.2s;
}

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

#benchmark-toggle {
    position: fixed;
    top: 54px;
    right: 8px;
    z-index: 91;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    font-size: 11px;
    cursor: pointer;
}

#gesture-lab-toggle {
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    font-size: 11px;
    cursor: pointer;
}

#gesture-lab-toggle:hover,
#gesture-lab-toggle.active {
    border-color: rgba(167, 139, 250, 0.75);
    background: rgba(124, 92, 246, 0.2);
    color: #ddd6fe;
}

.bench-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.bench-label { color: #888; }
.bench-value { color: #4ecdc4; }
.bench-section {
    color: #666;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
    margin-bottom: 4px;
}

/* ── Face gesture recognizer lab (left, collapsible) ── */
/*
   Palette is contrast-checked against the panel's own worst case: a card
   surface (rgba(255,255,255,0.035)) sitting on the strongest point of the
   purple radial gradient, i.e. #282244. Every readable colour below clears
   8:1 there, so it clears it everywhere else in the panel:
     #f4f1ff 13.46:1   #eeebf6 12.73:1   #e8e6f2 12.14:1   #e5deff 11.57:1
     #dad6e8 10.53:1   #d8d3e3 10.23:1   #ffc2c9  9.85:1   #d2cee2  9.74:1
     #73e1d7  9.61:1
   Tinted surfaces (active card, active chip, source row, rehearse hover) are
   checked separately; the lowest ratio across all of them is 8.26:1
   (#73e1d7 on an active card). The two event-source badges are dark
   text on a light fill: #061413 on #4ecdc4 is 9.71:1, #130d28 on #c0abff
   is 9.42:1 — the old #a78bfa fill capped that letter at 7.72:1 even
   against pure black, so the fill had to lift rather than the glyph.
*/
#gesture-lab-panel {
    position: fixed;
    top: 49px;
    left: 0;
    width: min(390px, 100vw);
    max-height: calc(100vh - 169px - var(--project-footer-height));
    padding: 16px;
    overflow-y: auto;
    z-index: 92;
    color: #e8e6f2;
    background:
        radial-gradient(circle at 0 0, rgba(124, 92, 246, 0.18), transparent 45%),
        rgba(12, 12, 21, 0.96);
    border-right: 1px solid rgba(167, 139, 250, 0.28);
    border-bottom: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 0 0 12px 0;
    box-shadow: 18px 24px 60px rgba(0, 0, 0, 0.42);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#gesture-lab-panel.collapsed {
    pointer-events: none;
    opacity: 0;
    transform: translateX(-101%);
}

.gesture-lab-header,
.gesture-source-row,
.gesture-card-heading,
.gesture-state-row,
.gesture-event-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.gesture-kicker,
.gesture-family,
.gesture-source,
.gesture-calibration,
.gesture-event-heading span {
    color: #d2cee2;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.gesture-lab-header h2 {
    margin-top: 2px;
    color: #f4f1ff;
    font-size: 22px;
    letter-spacing: -0.03em;
}

.gesture-close {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #dad6e8;
    background: rgba(255, 255, 255, 0.04);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.gesture-source-row {
    margin-top: 14px;
    padding: 8px 10px;
    border: 1px solid rgba(78, 205, 196, 0.14);
    border-radius: 7px;
    background: rgba(78, 205, 196, 0.05);
}

.gesture-source {
    color: #73e1d7;
}

.gesture-lab-intro {
    margin: 12px 1px;
    color: #dad6e8;
    font-size: 12px;
    line-height: 1.45;
}

.gesture-focus-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding-bottom: 4px;
}

.gesture-focus,
.gesture-lab-actions button,
.gesture-rehearse {
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: #dad6e8;
    background: rgba(255, 255, 255, 0.035);
    font: inherit;
    cursor: pointer;
}

.gesture-focus {
    padding: 6px 9px;
    font-size: 10px;
}

.gesture-focus.active {
    border-color: rgba(167, 139, 250, 0.7);
    color: #e5deff;
    background: rgba(124, 92, 246, 0.22);
}

.gesture-lab-actions {
    display: flex;
    gap: 6px;
    margin: 9px 0 12px;
}

.gesture-lab-actions button {
    padding: 5px 9px;
    font-size: 10px;
}

.gesture-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.gesture-card {
    min-width: 0;
    padding: 11px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.035);
    transition: border-color 0.12s ease, background 0.12s ease;
}

.gesture-card[hidden] {
    display: none;
}

.gesture-card.active {
    border-color: rgba(78, 205, 196, 0.55);
    background: rgba(78, 205, 196, 0.08);
}

.gesture-card-heading > div {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 6px;
}

.gesture-card-heading strong {
    color: #eeebf6;
    font-size: 13px;
}

.gesture-family {
    font-size: 8px;
}

.gesture-rehearse {
    padding: 4px 7px;
    color: #e5deff;
    font-size: 9px;
}

.gesture-rehearse:hover {
    border-color: rgba(167, 139, 250, 0.7);
    background: rgba(124, 92, 246, 0.18);
}

.gesture-card p {
    min-height: 30px;
    margin: 8px 0 7px;
    color: #dad6e8;
    font-size: 10px;
    line-height: 1.35;
}

.gesture-state-row {
    margin-bottom: 5px;
    color: #d2cee2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
}

.gesture-phase {
    color: #73e1d7;
}

.gesture-meter {
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
}

.gesture-meter i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #4ecdc4, #a78bfa);
    transition: width 80ms linear;
}

.gesture-card code {
    display: block;
    margin-top: 7px;
    overflow: hidden;
    color: #d2cee2;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gesture-event-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.gesture-event-heading strong {
    font-size: 12px;
}

.rehearsal-failed .gesture-event-heading span {
    color: #ffc2c9;
}

.gesture-event-log {
    display: grid;
    gap: 4px;
    margin-top: 8px;
    list-style: none;
}

.gesture-event-log li {
    display: grid;
    grid-template-columns: 18px 62px 58px minmax(40px, 1fr) 30px;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    color: #d2cee2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 9px;
}

.gesture-event-log strong {
    overflow: hidden;
    color: #d8d3e3;
    text-overflow: ellipsis;
}

.gesture-event-source {
    display: grid;
    width: 17px;
    height: 17px;
    place-items: center;
    border-radius: 50%;
    color: #061413;
    background: #4ecdc4;
    font-size: 8px;
    font-style: normal;
    font-weight: 800;
}

.gesture-event-source.synthetic {
    color: #130d28;
    background: #c0abff;
}

.gesture-event-log i {
    height: 3px;
    border-radius: 999px;
    background:
        linear-gradient(90deg, #4ecdc4 calc(var(--strength) * 100%), rgba(255, 255, 255, 0.07) 0);
}

.gesture-event-log small {
    color: #d2cee2;
    text-align: right;
}

.gesture-event-empty {
    display: block !important;
    color: #d2cee2 !important;
}

@media (max-width: 680px) {
    #controls-bar {
        gap: 6px;
        padding-inline: 8px;
    }

    #controls-bar h1,
    #camera-select,
    #mode-indicator {
        display: none;
    }

    #gesture-lab-panel {
        top: 47px;
        max-height: calc(100vh - 167px - var(--project-footer-height));
    }

    #project-footer {
        padding-inline: 8px;
        justify-content: center;
    }

    .project-provenance {
        display: none;
    }

    #github-project-link {
        width: 100%;
    }

    .gesture-cards {
        grid-template-columns: 1fr;
    }
}

/* ─────────────────────────────────────────────────────────────
   Hand gesture lab — the hand-side parallel to the face Gesture Lab

   Palette is contrast-checked against this panel's own worst case: a card
   surface (rgba(255,255,255,0.035)) over the strongest point of the purple
   radial gradient, i.e. #282244. Every readable colour below clears the
   project's 8:1 floor there, so it clears it everywhere else in the panel:
     #e8e6f2 12.14:1   #dad6e8 10.53:1   #d2cee2 9.74:1
     #a5f3ef 11.88:1   #7cf5c4 11.21:1   #ffc2c9  9.85:1   #fcd9a0 11.10:1
   Chip, meter and log surfaces are darkened rather than tinted, which only
   raises those ratios.
   ───────────────────────────────────────────────────────────── */

#hand-lab-toggle {
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: #d2cee2;
    font-size: 11px;
    cursor: pointer;
}

#hand-lab-toggle:hover,
#hand-lab-toggle.active {
    border-color: rgba(124, 246, 196, 0.75);
    background: rgba(60, 180, 140, 0.22);
    color: #7cf5c4;
}

#hand-lab-panel {
    position: fixed;
    top: 49px;
    right: 0;
    width: min(400px, 100vw);
    max-height: calc(100vh - 169px - var(--project-footer-height));
    padding: 16px;
    overflow-y: auto;
    z-index: 92;
    color: #dad6e8;
    background:
        radial-gradient(circle at 100% 0, rgba(124, 92, 246, 0.18), transparent 45%),
        rgba(12, 12, 21, 0.96);
    border-left: 1px solid rgba(167, 139, 250, 0.28);
    border-bottom: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 0 0 0 12px;
    box-shadow: -18px 24px 60px rgba(0, 0, 0, 0.42);
    font-size: 12px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#hand-lab-panel.collapsed {
    pointer-events: none;
    opacity: 0;
    transform: translateX(101%);
}

.hlab-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.hlab-header h2 {
    margin: 2px 0 0;
    color: #e8e6f2;
    font-size: 15px;
    font-weight: 600;
}

.hlab-kicker {
    color: #d2cee2;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hlab-close {
    border: 0;
    background: none;
    color: #d2cee2;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.hlab-intro {
    margin: 10px 0 12px;
    color: #d2cee2;
    font-size: 11px;
    line-height: 1.5;
}

.hlab-intro strong { color: #e8e6f2; }

.hlab-source {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 10px;
    margin: 0 0 10px;
    padding: 9px 10px;
    list-style: none;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.28);
}

.hlab-source li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.hlab-source span {
    color: #d2cee2;
    font-size: 10px;
}

.hlab-source b {
    color: #e8e6f2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    font-weight: 600;
}

.hlab-focus-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.hlab-focus {
    padding: 3px 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.3);
    color: #dad6e8;
    font-size: 11px;
    cursor: pointer;
}

.hlab-focus.active {
    border-color: rgba(124, 246, 196, 0.6);
    color: #7cf5c4;
}

.hlab-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.hlab-actions button,
.hlab-rehearse,
.hlab-tuning button,
.hlab-tuning summary {
    padding: 4px 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.3);
    color: #dad6e8;
    font-size: 11px;
    cursor: pointer;
}

.hlab-actions button:hover,
.hlab-rehearse:hover,
.hlab-tuning button:hover,
.hlab-tuning summary:hover {
    border-color: rgba(124, 246, 196, 0.6);
    color: #7cf5c4;
}

.hlab-cards {
    display: grid;
    gap: 8px;
}

.hlab-card {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.035);
    transition: border-color 0.12s ease;
}

.hlab-card.active {
    border-color: rgba(124, 246, 196, 0.5);
}

.hlab-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.hlab-card-heading strong {
    color: #e8e6f2;
    font-size: 13px;
}

.hlab-family {
    display: block;
    margin-top: 1px;
    color: #d2cee2;
    font-size: 9px;
}

.hlab-cue {
    margin: 7px 0 9px;
    color: #d2cee2;
    font-size: 11px;
    line-height: 1.45;
}

.hlab-detail[hidden] { display: none; }

.hlab-warning {
    margin: 10px 0;
    padding: 7px 9px;
    border: 1px solid rgba(252, 217, 160, 0.4);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    color: #fcd9a0;
    font-size: 11px;
    line-height: 1.45;
}

.hlab-state {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.hlab-phase {
    color: #d2cee2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.hlab-phase[data-state="rising"] { color: #fcd9a0; }
.hlab-phase[data-state="holding"] { color: #7cf5c4; }
.hlab-phase[data-state="falling"] { color: #ffc2c9; }

.hlab-episode {
    color: #d2cee2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
}

.hlab-gauge {
    display: grid;
    grid-template-columns: 42px 1fr 34px;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.hlab-gauge > span {
    color: #d2cee2;
    font-size: 10px;
}

.hlab-gauge > b {
    color: #e8e6f2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    font-weight: 600;
    text-align: right;
}

.hlab-meter {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
}

.hlab-meter i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #4ecdc4, #a78bfa);
    transition: width 80ms linear;
}

.hlab-criteria {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.hlab-criterion {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px 50px 46px;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.22);
}

.hlab-criterion + .hlab-criterion { margin-top: 5px; }

.hlab-criterion-name {
    display: flex;
    flex-direction: column;
    gap: 1px;
    color: #e8e6f2;
    font-size: 11px;
}

.hlab-criterion-name em {
    color: #d2cee2;
    font-size: 9px;
    font-style: normal;
}

.hlab-criterion-value,
.hlab-criterion-bound {
    color: #e8e6f2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    text-align: right;
}

.hlab-criterion-bound { color: #d2cee2; }

.hlab-chip {
    padding: 2px 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.35);
    color: #d2cee2;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
}

.hlab-chip[data-state="pass"] {
    border-color: rgba(124, 245, 196, 0.5);
    color: #7cf5c4;
}

.hlab-chip[data-state="fail"] {
    border-color: rgba(255, 194, 201, 0.5);
    color: #ffc2c9;
}

.hlab-diagnostic {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 0 0;
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
    color: #d2cee2;
    font-size: 10px;
}

.hlab-diagnostic b {
    color: #e8e6f2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
}

.hlab-reasons { margin-top: 10px; }

.hlab-reasons > span {
    color: #d2cee2;
    font-size: 10px;
}

.hlab-reasons ol {
    display: grid;
    gap: 3px;
    margin-top: 5px;
    padding: 0;
    list-style: none;
}

.hlab-reasons li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 8px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.3);
    color: #dad6e8;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
}

.hlab-reasons li b { color: #a5f3ef; }

.hlab-reason-empty { color: #d2cee2; }

.hlab-switch {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: 10px;
    color: #dad6e8;
    font-size: 10px;
    line-height: 1.4;
    cursor: pointer;
}

.hlab-switch input { accent-color: #4ecdc4; }

.hlab-tuning { margin-top: 12px; }

.hlab-tuning summary {
    display: inline-block;
    list-style: none;
}

.hlab-tuning summary::-webkit-details-marker { display: none; }

.hlab-slider {
    display: block;
    margin-top: 9px;
}

.hlab-slider > span {
    display: flex;
    justify-content: space-between;
    color: #dad6e8;
    font-size: 10px;
}

.hlab-slider em {
    color: #a5f3ef;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-style: normal;
}

.hlab-slider input {
    width: 100%;
    margin-top: 3px;
    accent-color: #4ecdc4;
}

.hlab-card code {
    display: block;
    margin-top: 9px;
    overflow: hidden;
    color: #d2cee2;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hlab-events {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hlab-events-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.hlab-events-heading strong {
    color: #e8e6f2;
    font-size: 12px;
}

.hlab-events-heading span {
    color: #d2cee2;
    font-size: 10px;
}

.hlab-rehearsal-failed .hlab-events-heading span { color: #ffc2c9; }

.hlab-event-log {
    display: grid;
    gap: 4px;
    margin-top: 8px;
    padding: 0;
    list-style: none;
}

.hlab-event-log li {
    display: grid;
    grid-template-columns: 40px 56px 42px 36px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    padding: 4px 7px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.3);
    color: #dad6e8;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
}

.hlab-event-log li[data-source="rehearsal"] {
    border-left: 2px solid rgba(167, 139, 250, 0.7);
}

.hlab-event-kind { color: #a5f3ef; }
.hlab-event-phase[data-state="start"] { color: #7cf5c4; }
.hlab-event-phase[data-state="peak"] { color: #a5f3ef; }
.hlab-event-phase[data-state="release"] { color: #ffc2c9; }
.hlab-event-note { color: #d2cee2; }

/* The empty state is one sentence, not a five-column log row. */
.hlab-event-empty {
    grid-template-columns: 1fr !important;
    color: #d2cee2;
    font-family: inherit !important;
}

/* Hand lab HUD — large-type overlay for testing from arm's length.
   The backdrop is opaque enough (0.94) that every colour clears 8:1 even over a
   pure-white video frame: worst-case ground is #15151b, giving #e8e6f2 14.76:1,
   #7cf5c4 13.62:1, #fcd9a0 13.49:1, #ffc2c9 11.97:1. Anchored bottom-LEFT: the
   lab panel owns the right edge, so the HUD would hide behind it. */
#hand-lab-hud {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 40;
    display: grid;
    gap: 7px;
    width: 218px;
    padding: 12px 14px;
    border: 1px solid rgba(167, 139, 250, 0.35);
    border-radius: 10px;
    background: rgba(6, 6, 12, 0.94);
    pointer-events: none;
}

#hand-lab-hud[hidden] { display: none; }

.hlab-hud-phase {
    color: #d2cee2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
}

.hlab-hud-phase[data-state="rising"] { color: #fcd9a0; }
.hlab-hud-phase[data-state="holding"] { color: #7cf5c4; }
.hlab-hud-phase[data-state="falling"] { color: #ffc2c9; }

.hlab-hud-meter {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
}

.hlab-hud-meter i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #4ecdc4, #a78bfa);
    transition: width 80ms linear;
}

.hlab-hud-note {
    color: #e8e6f2;
    font-size: 13px;
    line-height: 1.35;
}

/* Guided run prompt — readable from arm's length with both hands up. */
#hand-guided-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 60;
    display: grid;
    justify-items: center;
    gap: 6px;
    min-width: 320px;
    padding: 18px 28px 14px;
    border: 2px solid rgba(167, 139, 250, 0.5);
    border-radius: 14px;
    background: #0b0a14;
    transform: translate(-50%, -50%);
    text-align: center;
}

#hand-guided-overlay[hidden] { display: none; }

#hand-guided-overlay .hgo-stage {
    color: #d2cee2;
    font-size: 16px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#hand-guided-overlay[data-stage="hold"] .hgo-stage { color: #7cf5c4; }
#hand-guided-overlay[data-stage="hold"] { border-color: #7cf5c4; }

#hand-guided-overlay .hgo-pose {
    color: #f4f2fb;
    font-size: 44px;
    font-weight: 700;
    line-height: 1.1;
}

#hand-guided-overlay .hgo-count {
    color: #e8e6f2;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 30px;
}

#hand-guided-overlay .hgo-stop {
    margin-top: 6px;
    padding: 4px 14px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    background: #1a1726;
    color: #dad6e8;
    cursor: pointer;
}

#hand-guided-overlay .hgo-cue {
    max-width: 420px;
    color: #e8e6f2;
    font-size: 18px;
    line-height: 1.35;
}
