:root {
    /* --- STAR SHINE DARK PRIMITIVES --- */
    --void: #020205;
    --layer-1: #050508;
    --layer-2: #0a0a0f;
    --border-dim: rgba(255, 255, 255, 0.05);
    --border-mid: rgba(255, 255, 255, 0.1);
    --c-brand: #2563eb;
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --header-h: 48px;
    --footer-h: 32px;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
    outline: none;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--void);
    color: var(--text-main);
    font-family: var(--font-sans);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.5;
}

.header-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: var(--font-mono);
    font-size: 10px;
}

#architect-layout {
    display: grid;
    grid-template-columns: 320px 1fr 400px;
    grid-template-rows: var(--header-h) 1fr var(--footer-h);
    height: 100vh;
    width: 100vw;
    gap: 1px;
    background-color: var(--border-dim);
}

/* --- AUTHENTIC FULLSCREEN MICROSCOPE MODE --- */
#architect-layout.micro-fullscreen-active {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
}

#architect-layout.micro-fullscreen-active>header,
#architect-layout.micro-fullscreen-active>aside,
#architect-layout.micro-fullscreen-active .panel:first-child,
#architect-layout.micro-fullscreen-active .panel:last-child,
#architect-layout.micro-fullscreen-active #main-viewport:not(#main-viewport-microscope),
#architect-layout.micro-fullscreen-active #canvas,
#architect-layout.micro-fullscreen-active .hud-panel,
#architect-layout.micro-fullscreen-active .legend-card {
    display: none !important;
}

#architect-layout.micro-fullscreen-active .panel:nth-child(2) {
    grid-row: 1;
    grid-column: 1;
}

#architect-layout.micro-fullscreen-active #viewport-container {
    height: 100vh;
    width: 100vw;
}

/* Floating Analysis Card (Matching Demo) */
.micro-analysis-card {
    position: absolute;
    top: 30px;
    left: 30px;
    width: 300px;
    background: rgba(10, 10, 15, 0.95);
    /* Deeper black-gray balance */
    backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 24px;
    z-index: 100;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    display: none;
    /* Only show when Microscope is active */
}

#main-viewport-microscope:hover .micro-analysis-card,
#architect-layout.micro-fullscreen-active .micro-analysis-card {
    display: block;
}

.micro-card-header {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #34d399;
    text-transform: uppercase;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Space for minimize button */
    gap: 12px;
}


.micro-analysis-card.minimized {
    height: 60px;
    overflow: hidden;
    padding-bottom: 0;
}

.micro-analysis-card.minimized .space-y-6,
.micro-analysis-card.minimized .mt-8 {
    display: none;
}

#btn-micro-maximize {
    position: absolute;
    top: 30px;
    right: 30px;
    background: rgba(255, 255, 255, 0.15);
    /* White Glass as requested */
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 14px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#btn-micro-maximize:hover {
    background: rgba(255, 255, 255, 1);
    color: #000;
    transform: scale(1.15) rotate(180deg);
}

/* --- FULLSCREEN ANALYTICS SIDEBAR (REPLICATING SCREENSHOT) --- */
.micro-analytics-sidebar {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 320px;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 24px;
    z-index: 200;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.9);
    display: none;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: calc(100vh - 60px);
    overflow: hidden;
}

#architect-layout.micro-fullscreen-active .micro-analytics-sidebar {
    display: block;
}

.micro-analytics-sidebar.minimized {
    height: 60px;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
}

.analytics-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 3px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 16px;
    border-radius: 100px;
}

.win-btn-tiny {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s;
}

.win-btn-tiny:hover {
    color: #fff;
    transform: scale(1.2);
}

.chart-label {
    font-size: 8px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.gene-node {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 4px;
    text-align: center;
    font-size: 7px;
    color: #94a3b8;
    transition: all 0.2s;
}

.gene-node:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366f1;
    color: #fff;
}

.thin-scrollbar::-webkit-scrollbar {
    width: 2px;
}

.thin-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.thin-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}



.panel {
    background-color: var(--layer-2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(20px);
}

.panel-header {
    height: 40px;
    min-height: 40px;
    padding: 0 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(0, 0, 0, 0) 100%);
    border-bottom: 1px solid var(--border-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-mid) transparent;
}

.control-group {
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-dim);
    padding-bottom: 8px;
}

.control-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select {
    width: 100%;
    background: var(--layer-1);
    border: 1px solid var(--border-mid);
    color: var(--text-main);
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.btn {
    width: 100%;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-dim);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    margin-bottom: 4px;
}

/* MICROSCOPE VIEWPORT */
#main-viewport-microscope {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background: #000;
    z-index: 5;
}

.view-toggle-container {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 50;
    display: flex;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.view-toggle-btn {
    padding: 6px 12px;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.view-toggle-btn.active {
    background: #2563eb;
    color: white;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

.KAGAWEA-legend {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 40;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 4px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10px;
    /* Increased from 7px */
    color: #fff;
    /* White for max visibility */
    font-weight: 700;
    text-transform: uppercase;
}

.legend-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--border-mid);
    color: var(--text-main);
}

.btn-brand {
    border-left: 3px solid var(--c-brand);
}

.btn-bio {
    border-left: 3px solid #10b981;
}

.btn-warn {
    border-left: 3px solid #f59e0b;
}

.btn-crit {
    border-left: 3px solid #ef4444;
}

.btn-data {
    border-left: 3px solid #8b5cf6;
}

#viewport-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    cursor: crosshair;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hud-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 260px;
    background: rgba(5, 5, 5, 0.85);
    border: 1px solid var(--border-mid);
    border-left: 2px solid var(--c-brand);
    padding: 16px;
    border-radius: 4px;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.hud-row {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    margin-bottom: 6px;
    color: #94a3b8;
}

.gene-matrix {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    padding: 2px;
    background: #000;
    border: 1px solid #334155;
    aspect-ratio: 1;
}

.gene-node {
    background: #050505;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6px;
    font-family: var(--font-mono);
    color: #94a3b8;
    transition: all 0.2s;
    cursor: pointer;
    text-align: center;
    padding: 2px;
    border-radius: 2px;
    font-weight: 600;
    overflow: hidden;
    word-break: break-all;
}

.gene-node:hover {
    border-color: #2563eb;
    background: #111;
}

/* Toast notifications */
#toast-feed {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
}

.toast {
    background: #0f0f0f;
    border: 1px solid var(--border-mid);
    padding: 12px;
    border-radius: 4px;
    pointer-events: auto;
    color: #ccc;
}

.toast-h {
    font-weight: 700;
    color: #fff;
    font-size: 11px;
    margin-bottom: 2px;
}

/* Term/Log */
.log-line {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 10px;
}

/* PH11: CLINICAL DASHBOARD STYLES */
#clinical-dashboard {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #020205;
    z-index: 2000;
    display: none;
    flex-direction: column;
    padding: 40px;
    overflow-y: auto;
    font-family: var(--font-sans);
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    border-bottom: 1px solid #1e293b;
    padding-bottom: 20px;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.dash-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.dash-stat-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.dash-stat-value {
    font-size: 32px;
    font-weight: 800;
    color: #f8fafc;
    font-family: var(--font-mono);
}

.chart-container-large {
    grid-column: span 2;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 24px;
    height: 400px;
}

.close-dash-btn {
    background: #2563eb;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.close-dash-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

/* PRINT STYLES FOR CLINICAL REPORT */
@media print {
    body {
        background: white !important;
        color: black !important;
    }

    #architect-layout,
    #ai-panel,
    #ai-toggle-btn,
    .close-dash-btn,
    #toast-feed {
        display: none !important;
    }

    #clinical-dashboard {
        position: relative !important;
        display: block !important;
        background: white !important;
        color: black !important;
        padding: 20px !important;
        width: 100% !important;
        height: auto !important;
    }

    .dash-card,
    .chart-container-large {
        background: #fff !important;
        border: 1px solid #eee !important;
        box-shadow: none !important;
        color: black !important;
        break-inside: avoid;
    }

    .dash-stat-value,
    .dash-stat-label,
    h1,
    p,
    .text-slate-500,
    .text-slate-400 {
        color: black !important;
    }

    canvas {
        max-width: 100% !important;
    }
}

/* --- MICROSCOPY CORE EFFECTS --- */
.scanline-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.08) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 5;
    opacity: 0.3;
}

.bloom-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, transparent 30%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    z-index: 4;
}

#main-viewport-microscope {
    filter: contrast(1.3) brightness(1.2) saturate(1.4);
    position: absolute;
    inset: 0;
    display: none;
    background: #000;
}

@keyframes microPulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.micro-header-dot {
    width: 6px;
    height: 6px;
    background: #34d399;
    border-radius: 50%;
    box-shadow: 0 0 10px #34d399;
    animation: microPulse 1.5s infinite;
}

.micro-control-card {
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}

.micro-label {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    color: #64748b;
    margin-bottom: 6px;
    font-weight: 700;
    text-transform: uppercase;
}

.micro-range {
    width: 100%;
    height: 2px;
    background: #1e293b;
    border-radius: 2px;
    appearance: none;
    outline: none;
    margin-bottom: 12px;
}

.micro-range::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    background: #34d399;
    border: 1px solid #000;
    border-radius: 50%;
    cursor: pointer;
}

#meta-data-overlay {
    position: absolute;
    bottom: 30px;
    right: 30px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: #475569;
    text-align: right;
    line-height: 1.6;
    z-index: 200;
    pointer-events: none;
}

/* --- Kilo-Genome Explorer Matrix --- */
.gene-matrix {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
}

.gene-node {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 6px 2px;
    border-radius: 4px;
    text-align: center;
    font-size: 8px;
    color: #94a3b8;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'JetBrains Mono', monospace;
    cursor: default;
}

.gene-node:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366f1;
    color: #fff;
    transform: scale(1.05);
    z-index: 10;
}

/* --- Synergy Meter --- */
#synergy-container {
    padding: 8px;
    background: rgba(168, 85, 247, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 6px;
    margin-top: 10px;
}

.synergy-label-row {
    display: flex;
    justify-content: space-between;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 7px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.synergy-bar-bg {
    width: 100%;
    height: 4px;
    background: #1e1b4b;
    border-radius: 2px;
    overflow: hidden;
}

.synergy-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
    transition: width 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}