:root {
    --bg-base: #030712;
    --bg-elevated: rgba(15, 23, 42, 0.72);
    --bg-card: rgba(15, 23, 42, 0.58);
    --border-subtle: rgba(148, 163, 184, 0.14);
    --border-glow: rgba(56, 189, 248, 0.35);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --cyan: #22d3ee;
    --cyan-glow: rgba(34, 211, 238, 0.35);
    --emerald: #10b981;
    --emerald-glow: rgba(16, 185, 129, 0.4);
    --rose: #f43f5e;
    --rose-glow: rgba(244, 63, 94, 0.4);
    --violet: #8b5cf6;
    --violet-glow: rgba(139, 92, 246, 0.45);
    --amber: #f59e0b;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: var(--bg-base);
    background-image:
        radial-gradient(circle at 15% 20%, rgba(139, 92, 246, 0.14) 0%, transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(34, 211, 238, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 50% 90%, rgba(244, 63, 94, 0.08) 0%, transparent 50%);
    color: var(--text-main);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow-x: hidden;
}

/* Subtle medical grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
    background-size: 36px 36px;
    pointer-events: none;
    z-index: 0;
}

.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1680px;
    margin: 0 auto;
    padding: 14px 18px 18px;
    gap: 14px;
}

/* TOP HUD */
.top-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    flex-wrap: wrap;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-pulse {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.2), rgba(139, 92, 246, 0.25));
    border: 1px solid rgba(244, 63, 94, 0.35);
    display: grid;
    place-items: center;
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.2);
}

.brand-pulse svg {
    width: 20px;
    height: 20px;
    color: #fb7185;
    animation: heartIconBeat 1.3s ease-in-out infinite;
}

@keyframes heartIconBeat {
    0%, 100% { transform: scale(1); }
    18% { transform: scale(1.18); }
    32% { transform: scale(1); }
    48% { transform: scale(1.12); }
    65% { transform: scale(1); }
}

.brand-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    background: linear-gradient(to right, #f8fafc, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.4px;
}

.hud-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-selector {
    display: inline-flex;
    padding: 4px;
    background: rgba(2, 6, 23, 0.65);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    gap: 4px;
}

.mode-btn {
    padding: 9px 22px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mode-btn:hover {
    color: #fff;
}

.mode-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--violet), #ec4899);
    box-shadow: 0 6px 20px var(--violet-glow);
}

.hud-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.conn-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid var(--border-subtle);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

.conn-pill.ok {
    color: #a7f3d0;
    border-color: rgba(16, 185, 129, 0.3);
}
.conn-pill.ok .conn-dot {
    background: var(--emerald);
    box-shadow: 0 0 12px var(--emerald-glow);
    animation: pulseDot 1.8s infinite;
}

.conn-pill.err {
    color: #fda4af;
    border-color: rgba(244, 63, 94, 0.3);
}
.conn-pill.err .conn-dot {
    background: var(--rose);
    box-shadow: 0 0 12px var(--rose-glow);
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.7; }
}

.audio-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid var(--emerald-glow);
    background: rgba(16, 185, 129, 0.14);
    color: #6ee7b7;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.2);
}

.audio-btn:hover {
    background: rgba(16, 185, 129, 0.28);
    color: #fff;
    transform: translateY(-1px);
}

.audio-btn.enabled {
    border-color: rgba(34, 211, 238, 0.35);
    background: rgba(34, 211, 238, 0.12);
    color: #67e8f9;
    box-shadow: none;
    cursor: default;
}

.logout-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.logout-link:hover {
    color: #fda4af;
    border-color: rgba(244, 63, 94, 0.35);
    background: rgba(244, 63, 94, 0.08);
}

/* MAIN WORKSPACE GRID */
.workspace-grid {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(340px, 430px);
    gap: 14px;
    align-items: stretch;
}

/* 3D STAGE CARD */
.stage-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    min-height: 620px;
}

.canvas-wrapper {
    position: relative;
    flex: 1;
    min-height: 440px;
    background:
        radial-gradient(circle at 50% 45%, rgba(30, 41, 59, 0.45) 0%, rgba(2, 6, 23, 0.92) 72%);
    overflow: hidden;
    cursor: grab;
}

.canvas-wrapper:active {
    cursor: grabbing;
}

#heart-3d-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* 3D Overlay Controls */
.stage-toolbar {
    position: absolute;
    top: 14px;
    left: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    z-index: 5;
}

.tool-chip {
    padding: 7px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(10px);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-chip:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

.tool-chip.active {
    color: #67e8f9;
    border-color: rgba(34, 211, 238, 0.45);
    background: rgba(34, 211, 238, 0.14);
}

/* Stereo Channels Floating Indicator */
.stereo-hud {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.72);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
    z-index: 5;
    min-width: 170px;
}

.stereo-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.stereo-tag {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 10px;
}

.stereo-tag.left { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.stereo-tag.right { background: rgba(139, 92, 246, 0.25); color: #c084fc; }

.stereo-meter {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    overflow: hidden;
}

.stereo-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 0.06s linear;
}
.stereo-fill.left { background: linear-gradient(90deg, #10b981, #22d3ee); }
.stereo-fill.right { background: linear-gradient(90deg, #8b5cf6, #ec4899); }

/* 3D Projected Hotspot Labels */
.hotspot-labels-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.hs-badge {
    position: absolute;
    transform: translate(-50%, -135%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    backdrop-filter: blur(6px);
    transition: border-color 0.25s, color 0.25s, box-shadow 0.25s, transform 0.2s, opacity 0.2s;
    pointer-events: auto;
    cursor: pointer;
}

.hs-badge .hs-num {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    display: grid;
    place-items: center;
    font-size: 10px;
}

.hs-badge.active-closed {
    border-color: var(--emerald);
    color: #fff;
    background: rgba(6, 78, 59, 0.88);
    box-shadow: 0 0 18px var(--emerald-glow);
    transform: translate(-50%, -145%) scale(1.08);
}
.hs-badge.active-closed .hs-num {
    background: var(--emerald);
    color: #022c22;
}

.hs-badge.active-opened {
    border-color: var(--rose);
    color: #fecdd3;
    background: rgba(76, 5, 25, 0.85);
    box-shadow: 0 0 14px var(--rose-glow);
}
.hs-badge.active-opened .hs-num {
    background: var(--rose);
    color: #fff;
}

.hs-badge.exam-target {
    border-color: var(--violet);
    box-shadow: 0 0 16px var(--violet-glow);
}

.hs-badge.exam-wrong {
    border-color: var(--rose);
    background: rgba(159, 18, 57, 0.92);
    color: #fff;
    animation: badgeShake 0.45s ease;
}

@keyframes badgeShake {
    0%, 100% { transform: translate(-50%, -135%); }
    25% { transform: translate(calc(-50% - 6px), -135%); }
    50% { transform: translate(calc(-50% + 6px), -135%); }
    75% { transform: translate(calc(-50% - 4px), -135%); }
}

/* Active Contact Floating HUD inside bottom of 3D stage */
.stage-status-overlay {
    position: absolute;
    bottom: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
    z-index: 5;
    flex-wrap: wrap;
}

.live-point-pill {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.82);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    pointer-events: auto;
    transition: all 0.35s ease;
}

.live-point-pill.closed {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 28px rgba(16, 185, 129, 0.2);
}

.live-point-pill.opened {
    border-color: rgba(244, 63, 94, 0.45);
    box-shadow: 0 0 24px rgba(244, 63, 94, 0.16);
}

.state-orb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}

.live-point-pill.closed .state-orb {
    background: var(--emerald);
    box-shadow: 0 0 16px var(--emerald-glow);
    animation: pulseDot 1.4s infinite;
}

.live-point-pill.opened .state-orb {
    background: var(--rose);
    box-shadow: 0 0 16px var(--rose-glow);
}

.live-point-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
}

.live-point-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    line-height: 1.15;
}

.live-point-pill.closed .live-point-title { color: #6ee7b7; }
.live-point-pill.opened .live-point-title { color: #fda4af; }

.phase-badge {
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.82);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
}

.phase-label {
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--cyan);
}

.bpm-val {
    font-weight: 700;
    color: #fb7185;
    font-variant-numeric: tabular-nums;
}

/* TELEMETRY WAVEFORM BAR (PCG + ECG) */
.telemetry-strip {
    border-top: 1px solid var(--border-subtle);
    background: rgba(2, 6, 23, 0.88);
    padding: 10px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.telemetry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.telemetry-legend {
    display: flex;
    align-items: center;
    gap: 14px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.legend-dot.pcg { background: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }
.legend-dot.ecg { background: var(--emerald); box-shadow: 0 0 8px var(--emerald-glow); }

#pcg-canvas {
    width: 100%;
    height: 110px;
    display: block;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.09);
}

/* RIGHT SIDEBAR */
.sidebar-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding: 16px 18px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.panel-title {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Anatomical Info Card */
.anatomy-point-name {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px;
    color: #fff;
}

.anatomy-desc {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.5;
    color: #cbd5e1;
}

.anatomy-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.meta-box {
    padding: 9px 11px;
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid var(--border-subtle);
}

.meta-box span {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    margin-bottom: 3px;
}

.meta-box strong {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
}

/* 5-Point Practice Checklist */
.points-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.point-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 11px;
    background: rgba(2, 6, 23, 0.45);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.point-item:hover {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(30, 41, 59, 0.55);
}

.point-item.active {
    border-color: rgba(16, 185, 129, 0.55);
    background: rgba(16, 185, 129, 0.12);
}

.point-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.point-num {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: rgba(148, 163, 184, 0.14);
    color: #cbd5e1;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
}

.point-item.active .point-num {
    background: var(--emerald);
    color: #022c22;
}

.point-status {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 600;
}
.point-item.visited .point-status {
    color: #34d399;
}

/* Speed Controls */
.practice-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
    gap: 8px;
}

.speed-pills {
    display: inline-flex;
    gap: 4px;
}

.speed-btn {
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: rgba(2, 6, 23, 0.6);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.speed-btn.active {
    color: #67e8f9;
    border-color: rgba(34, 211, 238, 0.45);
    background: rgba(34, 211, 238, 0.15);
}

/* Valves Live Matrix */
.valves-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.valve-card {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.18s ease;
}

.valve-card.is-open {
    border-color: rgba(34, 211, 238, 0.4);
    background: rgba(34, 211, 238, 0.08);
}

.valve-card.is-focused {
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.55);
}

.valve-name {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
}

.valve-state-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 999px;
    letter-spacing: 0.6px;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
}

.valve-card.is-open .valve-state-tag {
    background: rgba(34, 211, 238, 0.2);
    color: #67e8f9;
}

/* EXAM PANEL */
.exam-stepper {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 14px;
}

.step-pill {
    padding: 8px 4px;
    border-radius: 10px;
    text-align: center;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid var(--border-subtle);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    transition: all 0.25s ease;
}

.step-pill.current {
    color: #fff;
    border-color: var(--violet);
    background: rgba(139, 92, 246, 0.25);
    box-shadow: 0 0 15px var(--violet-glow);
}

.step-pill.done-clean {
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.15);
}

.step-pill.done-mistake {
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.15);
}

.exam-status-box {
    padding: 16px;
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid var(--border-subtle);
    text-align: center;
    margin-bottom: 12px;
}

#exam-task-counter {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(to right, #c084fc, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

#exam-status-text {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    color: #e2e8f0;
}

.exam-feedback {
    margin-top: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    display: none;
}

.exam-feedback.ok {
    display: block;
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #6ee7b7;
}

.exam-feedback.err {
    display: block;
    background: rgba(244, 63, 94, 0.14);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: #fda4af;
}

.exam-options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.exam-btn-primary {
    width: 100%;
    padding: 11px 16px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--violet), #ec4899);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 22px var(--violet-glow);
    transition: transform 0.2s ease;
}

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

#exam-final-result {
    text-align: center;
    padding: 14px;
    border-radius: 14px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    margin-bottom: 12px;
}

.score-title {
    font-size: 56px;
    font-weight: 900;
    color: #34d399;
    line-height: 1;
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(16, 185, 129, 0.35);
}

.score-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.score-stats strong {
    display: block;
    font-size: 24px;
    margin-top: 4px;
}
.stat-correct { color: #34d399; }
.stat-wrong { color: #f43f5e; }

/* HISTORY TABLE */
.hm-history {
    max-height: 230px;
    overflow-y: auto;
    padding-right: 4px;
}

.hm-history::-webkit-scrollbar {
    width: 5px;
}
.hm-history::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 999px;
}

.hm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.hm-table thead th {
    text-align: left;
    padding: 6px 8px;
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    background: rgba(11, 17, 32, 0.95);
}

.hm-table tbody td {
    padding: 8px 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    color: #cbd5e1;
}

.hm-table tbody tr:last-child td {
    border-bottom: none;
}

.ev-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    margin-left: 8px;
}
.ev-badge.closed {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
}
.ev-badge.opened {
    background: rgba(244, 63, 94, 0.18);
    color: #fb7185;
}

/* PATHOLOGY SCENARIO SELECTOR */
.scenario-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 10px;
}

.scenario-btn {
    min-width: 0;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: rgba(2, 6, 23, 0.52);
    color: #cbd5e1;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.scenario-btn:hover {
    border-color: rgba(245, 158, 11, 0.45);
    color: #fff;
}

.scenario-btn:focus-visible {
    outline: 2px solid rgba(245, 158, 11, 0.7);
    outline-offset: 1px;
}

.scenario-btn.active {
    border-color: rgba(245, 158, 11, 0.65);
    background: rgba(245, 158, 11, 0.14);
    color: #fcd34d;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.18);
}

.scenario-btn[data-scenario="normal"].active {
    border-color: rgba(16, 185, 129, 0.6);
    background: rgba(16, 185, 129, 0.14);
    color: #6ee7b7;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.18);
}

.scenario-clinical-note {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 12px;
    line-height: 1.45;
    color: #cbd5e1;
}

.scenario-clinical-note strong {
    color: #fcd34d;
    display: block;
    margin-bottom: 3px;
}

.pathology-hud-tag {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.16);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fcd34d;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    backdrop-filter: blur(8px);
}

.pathology-hud-tag.normal {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.35);
    color: #6ee7b7;
}

/* EXAM TYPE SWITCHER & DIAGNOSTIC EXAM */
.exam-type-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 12px;
    padding: 4px;
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid var(--border-subtle);
}

.exam-type-btn {
    padding: 8px 10px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.exam-type-btn.active {
    background: rgba(139, 92, 246, 0.28);
    color: #fff;
}

.diag-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    margin: 12px 0;
}

.diag-option-btn {
    padding: 10px 12px;
    border-radius: 11px;
    border: 1px solid var(--border-subtle);
    background: rgba(2, 6, 23, 0.55);
    color: #e2e8f0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.diag-option-btn:hover:not(:disabled) {
    border-color: rgba(139, 92, 246, 0.55);
    background: rgba(139, 92, 246, 0.14);
}

.diag-option-btn.correct {
    border-color: var(--emerald);
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.diag-option-btn.wrong {
    border-color: var(--rose);
    background: rgba(244, 63, 94, 0.2);
    color: #fda4af;
}

.diag-option-btn:disabled {
    cursor: default;
    opacity: 0.85;
}

/* TOAST NOTIFICATIONS */
.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid var(--border-glow);
    color: #f8fafc;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    animation: toastIn 0.3s ease forwards;
    max-width: 360px;
}

.toast.warn {
    border-color: rgba(244, 63, 94, 0.5);
    color: #fecdd3;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* RESPONSIVE */
@media (max-width: 1120px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
    .stage-card {
        min-height: 540px;
    }
}

@media (max-width: 640px) {
    .app-shell {
        padding: 8px 10px 14px;
        gap: 10px;
    }
    .top-hud {
        padding: 10px 12px;
        gap: 10px;
        border-radius: 14px;
    }
    .brand-group {
        width: 100%;
        gap: 10px;
    }
    .brand-pulse {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }
    .brand-title {
        font-size: 14px;
        letter-spacing: 1px;
    }
    .brand-sub {
        font-size: 11px;
    }
    .hud-center {
        width: 100%;
    }
    .mode-selector {
        width: 100%;
    }
    .mode-btn {
        flex: 1;
        padding: 9px 10px;
        font-size: 13px;
        text-align: center;
    }
    .hud-actions {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }
    .conn-pill {
        flex: 1;
        justify-content: center;
        padding: 8px 10px;
        font-size: 11px;
    }
    .audio-btn {
        flex: 1;
        justify-content: center;
        padding: 8px 12px;
        font-size: 12px;
    }
    .logout-link {
        padding: 8px 12px;
        font-size: 12px;
    }
    .stereo-hud {
        display: none;
    }
    .stage-card {
        min-height: auto;
        border-radius: 16px;
    }
    .canvas-wrapper {
        min-height: 360px;
        height: 50vh;
        max-height: 440px;
    }
    .stage-toolbar {
        top: 8px;
        left: 8px;
        right: 8px;
        gap: 5px;
    }
    .tool-chip {
        padding: 5px 9px;
        font-size: 11px;
        border-radius: 8px;
    }
    .hs-badge {
        padding: 3px 7px;
        font-size: 10px;
        gap: 4px;
    }
    .hs-badge .hs-num {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }
    .stage-status-overlay {
        bottom: 8px;
        left: 8px;
        right: 8px;
        gap: 6px;
    }
    .live-point-pill {
        padding: 7px 10px;
        gap: 9px;
        border-radius: 10px;
    }
    .live-point-label {
        font-size: 9px;
    }
    .live-point-title {
        font-size: 15px;
    }
    .phase-badge {
        padding: 6px 10px;
        gap: 6px;
        font-size: 11px;
        border-radius: 10px;
    }
    .pathology-hud-tag {
        padding: 3px 8px;
        font-size: 10px;
    }
    .telemetry-strip {
        padding: 8px 12px 10px;
    }
    .telemetry-header {
        font-size: 10px;
    }
    #pcg-canvas {
        height: 84px;
    }
    .panel-card {
        padding: 13px 14px;
        border-radius: 15px;
    }
    .toast-stack {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
    .toast {
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 420px) {
    .anatomy-meta {
        grid-template-columns: 1fr;
    }
    .scenario-grid {
        gap: 6px;
    }
    .scenario-btn {
        padding: 8px;
        font-size: 11px;
    }
    .step-pill {
        font-size: 10px;
        padding: 7px 2px;
    }
    .practice-controls {
        flex-wrap: wrap;
    }
    .score-title {
        font-size: 46px;
    }
}
