:root {
    /* Light mode — accessible clinical palette */
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-subtle: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --healing-blue: #2563eb;
    --healing-blue-bright: #3b82f6;
    --healing-blue-soft: rgba(37, 99, 235, 0.1);
    --healing-blue-ring: rgba(37, 99, 235, 0.35);
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
    --shadow-tile: 0 1px 3px rgba(15, 23, 42, 0.07), 0 2px 8px rgba(15, 23, 42, 0.05);
    --overlay-scrim: rgba(248, 250, 252, 0.92);
    --neon-teal: #0d9488;
    --glow-white: #ffffff;
    --purpose-blue: var(--healing-blue);
    --warning-red: #dc2626;
    --alert: var(--warning-red);
    --emergency-footer-height: 80px;
    --emergency-footer-gap: 12px;
    --emergency-footer-reserve: calc(var(--emergency-footer-height) + var(--emergency-footer-gap));
    /* Legacy aliases */
    --bg-black: var(--bg-page);
    --teal: var(--neon-teal);
    --blue: var(--healing-blue);
    /* dᶻix̌ʷ (OBD) — clinical OKN background velocity clamps */
    --obd-gradient-cycle: 24s;
    --obd-ripple-cycle-primary: 24s;
    --obd-ripple-cycle-secondary: 24s;
    /* Low-stimulation dark onboarding / disclaimer palette */
    --onboarding-bg: #0d1117;
    --onboarding-bg-deep: #000000;
    --onboarding-surface: #161b22;
    --onboarding-text: #e2e8f0;
    --onboarding-text-muted: #94a3b8;
    --onboarding-border: rgba(148, 163, 184, 0.28);
    --onboarding-accent-border: rgba(96, 165, 250, 0.35);
}

html,
body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body {
    background-color: var(--bg-page);
    display: flex;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    overflow-x: hidden;
}

body:has(.onboarding-overlay),
body:has(.master-init-overlay) {
    background-color: var(--onboarding-bg);
    color: var(--onboarding-text);
}

body:has(#dashboard:not(.hidden)) {
    background-color: #0d1117;
    color: #e6edf3;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Protocol viewport — true edge-to-edge black canvas shell */
html.protocol-viewport-active,
html.protocol-viewport-active body {
    background-color: #000000 !important;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#dashboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 12px 16px calc(var(--emergency-footer-reserve) + 0.5rem);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    background: #0d1117;
    color: #e6edf3;
    box-sizing: border-box;
}

.app-brand {
    width: 100%;
    max-width: 22rem;
    margin: 0 auto 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    justify-content: center;
}

.app-brand-title {
    margin: 0;
    font-size: clamp(1.05rem, 4.2vw, 1.35rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    text-indent: 0;
    text-transform: none;
    text-align: center;
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    line-height: 1.35;
}

.app-brand-logo {
    width: 100%;
    max-width: 150px;
    height: auto;
    display: block;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
}

#dashboard .app-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 0;
    background: transparent !important;
    border: none;
    box-shadow: none;
    gap: 0.35rem;
    flex-shrink: 0;
}

#dashboard .app-brand-logo {
    display: block;
    margin: 0 auto;
    width: auto;
    max-width: 120px;
    height: auto;
    filter: invert(1);
    mix-blend-mode: screen;
    background: transparent;
}

.protocol-card {
    background: var(--bg-surface);
    border: 1.5px solid var(--border-strong);
    padding: 35px 20px;
    width: 85%;
    max-width: 400px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.protocol-card:hover {
    border-color: var(--healing-blue-bright);
    box-shadow:
        var(--shadow-md),
        0 0 0 1px var(--healing-blue-soft);
}

.protocol-card--warning {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(220, 38, 38, 0.08);
}

.protocol-warning-note {
    font-size: 0.58rem;
    line-height: 1.4;
    letter-spacing: 0.04em;
    color: var(--warning-red);
    margin: 14px 0 0;
    padding-top: 10px;
    border-top: 1px solid rgba(220, 38, 38, 0.2);
    text-transform: none;
}

.callsign {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 8px;
    margin: 0;
    color: var(--text-primary);
    text-shadow: none;
}

.term {
    font-size: 0.6rem;
    letter-spacing: 3px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 10px;
}

.purpose {
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.7rem;
    margin-top: 15px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 10px;
}

#viewport {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    background: var(--bg-page);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 32px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--emergency-footer-reserve));
}

#viewport:not(.hidden) {
    background-color: #000000 !important;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    justify-content: stretch;
    align-items: stretch;
}

.instruction-bar {
    position: fixed;
    top: calc(env(safe-area-inset-top, 32px) + 52px);
    left: max(16px, env(safe-area-inset-left, 0px));
    right: calc(max(20px, env(safe-area-inset-right, 0px)) + 5.75rem);
    margin: 0;
    color: var(--healing-blue);
    font-family: monospace;
    font-size: clamp(0.74rem, 2.8vw, 0.88rem);
    line-height: 1.35;
    letter-spacing: 1px;
    font-weight: 800;
    text-align: center;
    pointer-events: none;
    z-index: 12001;
}

#viewport:not(.hidden) .instruction-bar {
    position: absolute;
    top: 20px;
    left: max(16px, env(safe-area-inset-left, 0px));
    right: calc(max(20px, env(safe-area-inset-right, 0px)) + 5.75rem);
    z-index: 1000;
    background: transparent !important;
    color: rgba(255, 255, 255, 0.88);
}

/* Universal top-center protocol title — Lushootseed word + phonetic helper */
.protocol-header {
    position: fixed;
    top: calc(env(safe-area-inset-top, 32px) + 12px);
    left: max(16px, env(safe-area-inset-left, 0px));
    right: calc(max(20px, env(safe-area-inset-right, 0px)) + 5.75rem);
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: 0.02em;
    text-align: center;
    color: #cbd5e1;
    pointer-events: none;
    z-index: 12001;
}

#viewport:not(.hidden) .protocol-header {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    left: max(16px, env(safe-area-inset-left, 0px));
    right: calc(max(20px, env(safe-area-inset-right, 0px)) + 5.75rem);
    z-index: 1000;
    background: transparent !important;
}

.exit-btn {
    position: fixed;
    top: calc(env(safe-area-inset-top, 32px) + 12px);
    right: max(12px, env(safe-area-inset-right, 12px));
    z-index: 12000;
    border: 1.5px solid var(--healing-blue);
    background: var(--bg-surface);
    color: var(--healing-blue);
    padding: 11px 14px;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    box-shadow: var(--shadow-sm);
    border-radius: 4px;
}

#viewport:not(.hidden) .exit-btn {
    position: absolute;
    top: 20px;
    right: max(12px, env(safe-area-inset-right, 12px));
    z-index: 1000;
    background: transparent !important;
    border-color: rgba(255, 255, 255, 0.55);
    color: rgba(255, 255, 255, 0.92);
    box-shadow: none;
}

.exit-btn:hover {
    background: var(--healing-blue-soft);
    border-color: var(--healing-blue-bright);
    color: var(--healing-blue);
}

#viewport:not(.hidden) .exit-btn:hover {
    background: transparent !important;
    border-color: rgba(255, 255, 255, 0.85);
    color: #ffffff;
}

/* Mid-session theta wave toggle — fixed in gameplay viewport, low-impact sensory layout */
.gameplay-theta-toggle {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 3.65rem);
    right: max(10px, env(safe-area-inset-right, 10px));
    z-index: 1001;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0.42rem 0.55rem;
    min-height: 2rem;
    min-width: 2.75rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.28);
    color: rgba(148, 163, 184, 0.78);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0.72;
    transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.gameplay-theta-toggle:hover,
.gameplay-theta-toggle:focus-visible {
    opacity: 1;
    border-color: rgba(148, 163, 184, 0.5);
    color: rgba(226, 232, 240, 0.95);
    background: rgba(0, 0, 0, 0.42);
    outline: none;
}

.gameplay-theta-toggle:focus-visible {
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.45);
}

.gameplay-theta-toggle--on {
    border-color: rgba(45, 212, 191, 0.38);
    color: rgba(153, 246, 228, 0.88);
}

.gameplay-theta-toggle--on .gameplay-theta-toggle-prefix {
    color: rgba(45, 212, 191, 0.95);
}

.gameplay-theta-toggle-prefix {
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    opacity: 0.9;
}

.gameplay-theta-toggle-label {
    display: none;
}

@media (min-width: 380px) {
    .gameplay-theta-toggle-label {
        display: inline;
    }
}

.gameplay-theta-toggle-state {
    font-weight: 800;
}

.hidden {
    display: none !important;
    pointer-events: none;
}

.master-init-overlay {
    position: relative;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    z-index: 11000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    background: var(--onboarding-bg);
    box-sizing: border-box;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-x: none;
}

.onboarding-overlay {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    position: relative;
    background: var(--onboarding-bg);
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    touch-action: pan-y;
    overscroll-behavior-x: none;
}

html:has(#master-init-overlay:not(.hidden)),
html:has(body > main.onboarding-overlay),
body:has(#master-init-overlay:not(.hidden)),
body:has(> main.onboarding-overlay) {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    position: relative;
}

.master-init-card {
    width: 100%;
    max-width: 32rem;
    padding: 1.5rem 1.25rem 1.35rem;
    border: 1px solid var(--onboarding-border);
    border-radius: 12px;
    background: var(--onboarding-surface);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-sizing: border-box;
    margin: auto 0;
}

.onboarding-card {
    color: var(--onboarding-text);
}

.onboarding-header {
    margin: 0;
}

.onboarding-title {
    margin: 0;
    color: var(--onboarding-text);
    font-size: clamp(1rem, 4.2vw, 1.2rem);
    font-weight: 800;
    line-height: 1.4;
    text-align: center;
    letter-spacing: 0.01em;
}

.onboarding-legal {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.onboarding-section {
    padding: 4px 0;
}

.onboarding-section--privacy {
    padding: 12px 14px;
    border: 1px solid var(--onboarding-accent-border);
    border-radius: 10px;
    background: rgba(22, 27, 34, 0.85);
}

.onboarding-section-heading {
    margin: 0 0 0.55rem;
    color: var(--onboarding-text);
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.35;
}

.onboarding-body {
    margin: 0 0 0.65rem;
    color: var(--onboarding-text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.55;
}

.onboarding-body a {
    color: var(--onboarding-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.onboarding-body--emphasis {
    font-weight: 800;
}

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

.onboarding-audio-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 14px 12px;
    border: 1px solid var(--onboarding-border);
    border-radius: 10px;
    background: rgba(22, 27, 34, 0.65);
}

.onboarding-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.onboarding-toggle-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.onboarding-toggle-switch {
    flex-shrink: 0;
    position: relative;
    width: 2.65rem;
    height: 1.45rem;
    margin-top: 0.1rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
    transition: background 0.18s ease;
}

.onboarding-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s ease;
}

.onboarding-toggle-input:checked + .onboarding-toggle-switch {
    background: rgba(96, 165, 250, 0.45);
}

.onboarding-toggle-input:checked + .onboarding-toggle-switch::after {
    transform: translateX(1.2rem);
}

.onboarding-toggle-input:focus-visible + .onboarding-toggle-switch {
    outline: 2px solid rgba(96, 165, 250, 0.55);
    outline-offset: 2px;
}

.onboarding-toggle-label {
    color: var(--onboarding-text);
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.4;
}

.onboarding-frequency-label {
    margin: 2px 0 0;
    color: var(--onboarding-text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.onboarding-frequency-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--onboarding-border);
    border-radius: 8px;
    background: var(--onboarding-bg);
    color: var(--onboarding-text);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.35;
    font-family: inherit;
    cursor: pointer;
    box-sizing: border-box;
}

.onboarding-frequency-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: var(--onboarding-border);
}

.onboarding-frequency-hint {
    margin: 0;
    color: var(--onboarding-text-muted);
    font-size: 0.68rem;
    line-height: 1.4;
}

.onboarding-enter-btn {
    margin-top: 2px;
}

a.onboarding-enter-btn,
button.onboarding-enter-btn {
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
}

.master-init-kicker {
    margin: 0;
    color: var(--onboarding-text-muted);
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.24em;
    text-align: center;
    text-transform: uppercase;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.headphone-required-notice {
    padding: 14px 15px;
    border: 1px solid var(--onboarding-border);
    border-radius: 10px;
    background: rgba(22, 27, 34, 0.65);
    color: var(--onboarding-text);
    box-shadow: none;
}

.headphone-required-title {
    margin: 0;
    color: var(--onboarding-text);
    font-size: clamp(0.82rem, 3.4vw, 0.96rem);
    font-weight: 900;
    line-height: 1.35;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.headphone-required-sub {
    margin: 8px 0 0;
    color: var(--onboarding-text-muted);
    font-size: 0.72rem;
    line-height: 1.45;
    text-align: center;
}

.master-init-btn {
    width: 100%;
    min-height: 3rem;
    padding: 13px 16px;
    border: 1px solid var(--onboarding-accent-border);
    border-radius: 8px;
    background: transparent;
    color: var(--onboarding-text);
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    box-shadow: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.master-init-btn:hover {
    border-color: rgba(148, 163, 184, 0.55);
    background: rgba(22, 27, 34, 0.85);
    color: var(--onboarding-text);
}

.master-init-btn:active {
    transform: scale(0.99);
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(248, 250, 252, 0) 50%, rgba(15, 23, 42, 0.015) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.35;
}

.master-start-overlay {
    position: fixed;
    inset: 0;
    z-index: 13000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top, rgba(37, 99, 235, 0.08), transparent 34rem),
        var(--bg-page);
    color: var(--text-primary);
    opacity: 1;
    pointer-events: all;
    transition:
        opacity 0.55s ease,
        visibility 0.55s ease;
}

.master-start-overlay--exiting {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.master-start-card {
    width: min(100%, 28rem);
    padding: clamp(1.35rem, 5vw, 2rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.master-start-kicker {
    margin: 0;
    color: var(--healing-blue);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

.master-start-button {
    width: 100%;
    padding: 1rem 1.15rem;
    border: 1.5px solid var(--healing-blue);
    border-radius: 10px;
    background: var(--healing-blue);
    color: #ffffff;
    cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: clamp(0.72rem, 2.9vw, 0.94rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    line-height: 1.35;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.18);
    touch-action: manipulation;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.08s ease,
        box-shadow 0.15s ease;
}

.master-start-button:hover {
    background: var(--healing-blue-bright);
    border-color: var(--healing-blue-bright);
    box-shadow: 0 16px 34px rgba(37, 99, 235, 0.22);
}

.master-start-button:active {
    transform: scale(0.985);
}

.master-start-button:disabled {
    cursor: wait;
    opacity: 0.75;
}

.master-start-subtext {
    max-width: 22rem;
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.5;
}

#protocol-stage {
    flex: 1;
    align-self: stretch;
    width: 100%;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-sizing: border-box;
    padding-top: 4.75rem;
    padding-bottom: var(--emergency-footer-reserve);
}

#viewport:not(.hidden) #protocol-stage {
    background-color: #000000 !important;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    flex: 1 1 auto;
    align-self: stretch;
}

#viewport:not(.hidden) #protocol-stage canvas,
#viewport:not(.hidden) .obd-stage,
#viewport:not(.hidden) .obd-canvas,
#viewport:not(.hidden) .obd-bg-canvas,
#viewport:not(.hidden) .prcb-rivalry-canvas,
#viewport:not(.hidden) .cas-canvas,
#viewport:not(.hidden) .sam-canvas {
    background-color: transparent;
}

#viewport:not(.hidden) .prcb-root,
#viewport:not(.hidden) .kcb-root,
#viewport:not(.hidden) .cas-root,
#viewport:not(.hidden) .mif-root,
#viewport:not(.hidden) .aed-root,
#viewport:not(.hidden) .obd-root {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Pre-flight / standardized onboarding overlay — all primary protocols */
.protocol-preflight-overlay,
.protocol-onboarding-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(env(safe-area-inset-top, 32px) + 3.5rem) 1.25rem calc(1.5rem + var(--emergency-footer-reserve));
    box-sizing: border-box;
    background: #000000;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.protocol-preflight-card,
.protocol-onboarding-card {
    width: 100%;
    max-width: 24rem;
    padding: 1.5rem 1.35rem 1.6rem;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    background: #0a0c10;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
    text-align: left;
    cursor: pointer;
}

.protocol-preflight-title,
.protocol-onboarding-title {
    margin: 0 0 1.15rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: clamp(1.05rem, 4.6vw, 1.22rem);
    font-weight: 800;
    letter-spacing: 0.1em;
    line-height: 1.35;
    text-transform: uppercase;
    color: #ffffff;
    text-align: center;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.85);
}

.protocol-preflight-steps,
.protocol-onboarding-steps {
    margin: 0 0 1.1rem;
    padding-left: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    list-style: disc;
}

.protocol-preflight-steps li,
.protocol-onboarding-steps li,
.protocol-preflight-step {
    font-size: clamp(0.98rem, 4.2vw, 1.1rem);
    line-height: 1.5;
    font-weight: 600;
    color: #f8fafc;
}

.protocol-preflight-step-label {
    display: inline;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #ffffff;
}

.protocol-preflight-step-text {
    color: #f1f5f9;
    font-weight: 600;
}

.protocol-onboarding-note {
    margin: 0 0 1.25rem;
    font-size: clamp(0.82rem, 3.5vw, 0.92rem);
    line-height: 1.45;
    font-weight: 500;
    color: #cbd5e1;
    text-align: center;
}

.protocol-preflight-start,
.protocol-onboarding-start {
    display: block;
    width: 100%;
    padding: 1.1rem 1.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: clamp(0.92rem, 4vw, 1.05rem);
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #ffffff;
    background: #1e293b;
    border: 2px solid #ffffff;
    border-radius: 6px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.protocol-preflight-start:hover,
.protocol-onboarding-start:hover,
.protocol-preflight-start:focus-visible,
.protocol-onboarding-start:focus-visible {
    background: #334155;
    border-color: #ffffff;
    outline: none;
}

.protocol-preflight-start:active,
.protocol-onboarding-start:active {
    transform: scale(0.98);
}

/* Home dashboard — high-readability crisis accessibility */
#dashboard .symptom-primary {
    width: 100%;
    max-width: 26rem;
    margin: 0 auto;
    padding: 0 8px;
    box-sizing: border-box;
    flex-shrink: 1;
    min-height: 0;
}

#dashboard .dzixw-triage-section {
    padding: 0.75rem 10px 0.5rem;
    border-radius: 12px;
    background: rgba(22, 27, 34, 0.92);
    border: 1.5px solid rgba(56, 139, 253, 0.45);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

#dashboard .diagnostic-hero {
    margin: 0 0 0.75rem;
    font-size: 1.15rem !important;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    color: #f0f6fc;
}

#dashboard .symptom-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

#dashboard .symptom-grid > button {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.05rem !important;
    line-height: 1.35 !important;
    padding: 12px 16px !important;
    text-align: left;
    border: 2px solid rgba(56, 139, 253, 0.55);
    border-radius: 8px;
    background: rgba(13, 17, 23, 0.88);
    color: #e6edf3;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#dashboard .symptom-grid > button:hover,
#dashboard .symptom-grid > button:focus-visible {
    border-color: #58a6ff;
    background: rgba(56, 139, 253, 0.12);
    outline: none;
}

#dashboard .symptom-grid > button:active {
    transform: scale(0.985);
}

#dashboard #protocol-prcb {
    border-color: rgba(248, 113, 113, 0.55);
    background: rgba(69, 10, 10, 0.45);
    color: #fecaca;
}

#dashboard #protocol-prcb:hover,
#dashboard #protocol-prcb:focus-visible {
    border-color: #f87171;
    background: rgba(127, 29, 29, 0.55);
}

.app-studio-brand,
#studio-brand-header {
    letter-spacing: 0.04em;
}

#dashboard .app-studio-brand,
#dashboard #studio-brand-header {
    width: 100%;
    max-width: 26rem;
    margin: 0;
    padding: 0;
    font-size: clamp(1.15rem, 4.5vw, 1.45rem) !important;
    font-weight: 800;
    line-height: 1.3;
    text-align: center;
    color: #f0f6fc;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    box-sizing: border-box;
}

.protocol-indicator {
    margin: 12px 0 0;
    padding-top: 10px;
    border-top: 1px dashed var(--border-subtle);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--healing-blue);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.protocol-best {
    margin: 6px 0 0;
    font-size: 0.6rem;
    line-height: 1.45;
    color: var(--text-secondary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    letter-spacing: 0.02em;
    text-transform: none;
}

.protocol-card--warning .protocol-best {
    color: var(--text-secondary);
}

.protocol-intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.92);
    pointer-events: all;
}

.protocol-intro-overlay.hidden {
    display: none !important;
}

.protocol-intro-card {
    max-width: 24rem;
    padding: 1.5rem 1.35rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    background: #1a202c;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.protocol-intro-body {
    margin: 0 0 1rem;
    font-size: clamp(0.88rem, 3vw, 1.05rem);
    line-height: 1.5;
    font-weight: 800;
    color: #e2e8f0;
    text-align: center;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.protocol-intro-foot {
    margin: 0;
    font-size: 0.58rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #94a3b8;
    text-align: center;
    font-family: monospace;
    font-weight: 600;
}


.protocol-pending-root {
    width: min(90vw, 28rem);
    padding: 1.5rem 1.25rem;
    border: 1px solid var(--onboarding-border);
    border-radius: 12px;
    background: var(--onboarding-surface);
    color: var(--onboarding-text);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    text-align: center;
}

.protocol-pending-kicker {
    margin: 0 0 0.75rem;
    color: var(--healing-blue);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

.protocol-pending-line {
    margin: 0;
    color: var(--onboarding-text);
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.45;
}

.protocol-pending-line span {
    color: var(--healing-blue);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.protocol-pending-sub {
    margin: 0.75rem 0 1rem;
    color: var(--onboarding-text-muted);
    font-size: 0.78rem;
    line-height: 1.45;
}

.protocol-pending-done {
    border: 1px solid var(--onboarding-accent-border);
    border-radius: 8px;
    background: transparent;
    color: var(--onboarding-text);
    cursor: pointer;
    padding: 0.8rem 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.protocol-pending-done:hover {
    border-color: rgba(148, 163, 184, 0.55);
    background: rgba(22, 27, 34, 0.85);
}

/* Emergency lifeline — muted protocol anchor (global across app + standalone protocol pages) */
.emergency-exit-bar,
.emergency-exit-bar--global,
.emergency-exit-bar--viewport,
#emergency-bypass-footer,
.aed-emergency-bar,
.mif-emergency-bar {
    position: fixed !important;
    bottom: 15px !important;
    left: 0;
    right: 0;
    width: 100% !important;
    z-index: 9999;
    max-width: none;
    margin: 0;
    padding: 0 16px calc(env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    display: flex !important;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.emergency-exit-link,
.aed-emergency-link,
.mif-emergency-link,
.emergency-exit-link[data-emergency-bypass] {
    width: 100%;
    max-width: 26rem;
    margin: 0 auto;
    padding: 0;
    border: none !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    color: #64748b !important;
    font-size: 0.85rem !important;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto !important;
}

.emergency-exit-link:hover,
.emergency-exit-link:focus-visible,
.aed-emergency-link:hover,
.aed-emergency-link:focus-visible,
.mif-emergency-link:hover,
.mif-emergency-link:focus-visible {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #94a3b8 !important;
    outline: none;
}

.emergency-exit-link:focus-visible,
.aed-emergency-link:focus-visible,
.mif-emergency-link:focus-visible {
    outline: 1px dotted #94a3b8;
    outline-offset: 3px;
}

/* Dashboard home screen — slightly higher visibility without alert styling */
#emergency-bypass-footer.home-footer .emergency-exit-link {
    padding: 10px 14px;
    border: 1px solid rgba(48, 54, 61, 0.95) !important;
    border-radius: 6px;
    background: rgba(22, 27, 34, 0.92) !important;
    color: rgba(230, 237, 243, 0.72) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    text-decoration: none;
}

#emergency-bypass-footer.home-footer .emergency-exit-link:hover,
#emergency-bypass-footer.home-footer .emergency-exit-link:focus-visible {
    background: rgba(33, 38, 45, 0.95) !important;
    border-color: rgba(56, 139, 253, 0.55) !important;
    color: #f0f6fc !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

body:has(#dashboard:not(.hidden)) .scanlines {
    background: linear-gradient(rgba(13, 17, 23, 0) 50%, rgba(255, 255, 255, 0.02) 50%);
    opacity: 0.22;
}

.legal-portal-link {
    position: fixed;
    bottom: 12px;
    right: 16px;
    z-index: 9999;
    font-size: 9px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 700;
    color: #57534e;
    text-decoration: none;
    font-family: sans-serif;
    transition: color 0.2s ease;
    pointer-events: auto;
}

.legal-portal-link:hover,
.legal-portal-link:focus-visible {
    color: #d97706;
}

