/* ==========================================================================
   NEMO PHARMA LAB v6.3 // COMPUTATIONAL PHARMACOLOGY & MOLECULAR DOCKING SUITE
   Theme: High-End Laboratory / Quantum Chemistry / Dark Cyberpunk Scientific
   Architect & Developer: NEMO
   ========================================================================== */

:root {
    --bg-deep: #020704;
    --pharma-green: #00ff77;
    --pharma-green-glow: rgba(0, 255, 119, 0.35);
    --pharma-dim: #043615;
    --pharma-bright: #adffd2;
    
    --cyber-cyan: #00e5ff;
    --cyber-cyan-glow: rgba(0, 229, 255, 0.35);
    
    --affinity-gold: #ffb700;
    --affinity-glow: rgba(255, 183, 0, 0.45);
    
    --danger-red: #ff0044;
    --danger-glow: rgba(255, 0, 68, 0.45);
    
    --panel-bg: rgba(2, 14, 8, 0.92);
    --panel-border: rgba(0, 255, 119, 0.25);
    --panel-border-hover: rgba(0, 255, 119, 0.65);
    
    --font-fa: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-code: 'Fira Code', monospace;
    --font-tech: 'Rajdhani', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body, html {
    width: 100%;
    height: 100%;
    background-color: var(--bg-deep);
    color: #e2ffed;
    font-family: var(--font-fa);
    overflow: hidden;
}

/* 3D WebGL Canvas */
#pharma-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    cursor: grab;
    touch-action: none; /* Allows fluid multi-touch pinch-to-zoom on mobile */
}

#pharma-canvas:active {
    cursor: grabbing;
}

/* Scanlines & Vignette */
.crt-scanlines {
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.18),
        rgba(0, 0, 0, 0.18) 1.5px,
        transparent 1.5px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 2;
}

.pharma-vignette {
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(circle at center, transparent 40%, rgba(1, 5, 2, 0.90) 100%),
        radial-gradient(ellipse at bottom, rgba(0, 255, 119, 0.03) 0%, transparent 65%);
    pointer-events: none;
    z-index: 3;
}

/* Custom Cursor & Coordinate Readout */
#cursor-halo {
    position: fixed;
    width: 24px;
    height: 24px;
    border: 1.5px solid var(--pharma-green);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 0 12px var(--pharma-green-glow);
    transition: width 0.15s, height 0.15s, border-color 0.2s;
}

#cursor-dot {
    position: fixed;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 101;
    box-shadow: 0 0 6px #fff;
}

#cursor-coords {
    position: fixed;
    font-family: var(--font-code);
    font-size: 0.62rem;
    color: var(--pharma-green);
    pointer-events: none;
    z-index: 102;
    transform: translate(16px, 16px);
    background: rgba(0, 10, 4, 0.92);
    padding: 2px 6px;
    border: 1px solid rgba(0, 255, 119, 0.3);
    border-radius: 3px;
    backdrop-filter: blur(4px);
}

/* Interactive Atom Raycast Hover Tooltip */
.atom-tooltip {
    display: none;
    position: fixed;
    z-index: 105;
    background: rgba(2, 16, 8, 0.96);
    border: 1px solid var(--cyber-cyan);
    border-radius: 6px;
    padding: 8px 12px;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.35);
    backdrop-filter: blur(8px);
    pointer-events: none;
    font-size: 0.72rem;
    line-height: 1.5;
}

.atom-tooltip .tip-title {
    font-family: var(--font-tech);
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(0, 229, 255, 0.3);
    padding-bottom: 3px;
    margin-bottom: 4px;
    letter-spacing: 0.05em;
}

.atom-tooltip .tip-body {
    font-family: var(--font-code);
    color: rgba(255, 255, 255, 0.85);
}

/* ==========================================================================
   APP SHELL & TOP BAR
   ========================================================================== */
.app-shell {
    position: relative;
    z-index: 10;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.app-shell > * {
    pointer-events: auto;
}

.top-hud-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    background: rgba(2, 10, 5, 0.96);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--panel-border);
    z-index: 50;
    gap: 8px;
}

.sys-brand {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 190px;
}

.brand-title {
    font-family: var(--font-tech);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #fff;
    text-shadow: 0 0 10px var(--pharma-green);
    display: flex;
    align-items: center;
    gap: 3px;
}

.pulse-bracket {
    color: var(--pharma-green);
}

.brand-label {
    font-family: var(--font-code);
    font-size: 0.54rem;
    color: var(--cyber-cyan);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* Target Protein Receptor Navigation with Scroll Controls */
.target-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
    max-width: 580px;
    overflow: hidden;
}

.nav-arrow-btn {
    background: rgba(0, 255, 119, 0.15);
    border: 1px solid var(--panel-border);
    color: var(--pharma-green);
    font-family: var(--font-code);
    font-size: 0.8rem;
    font-weight: 700;
    width: 22px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.nav-arrow-btn:hover {
    background: var(--pharma-green);
    color: #000;
    box-shadow: 0 0 8px var(--pharma-green-glow);
}

.target-nav {
    display: flex;
    gap: 4px;
    background: rgba(0, 20, 10, 0.5);
    padding: 3px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--pharma-green) transparent;
}

.target-nav::-webkit-scrollbar {
    height: 3px;
}
.target-nav::-webkit-scrollbar-thumb {
    background: var(--pharma-green);
    border-radius: 2px;
}

.target-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 7px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.8);
    font-family: var(--font-fa);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-idx {
    font-family: var(--font-code);
    font-size: 0.58rem;
    color: var(--pharma-green);
    background: rgba(0, 255, 119, 0.12);
    padding: 1px 3px;
    border-radius: 2px;
}

.target-tab:hover, .target-tab.active {
    background: rgba(0, 255, 119, 0.18);
    border-color: var(--pharma-green);
    color: #fff;
    box-shadow: 0 0 10px var(--pharma-green-glow);
}

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

.btn-hud {
    background: rgba(0, 255, 119, 0.08);
    border: 1px solid var(--panel-border);
    color: var(--pharma-bright);
    padding: 4px 8px;
    font-family: var(--font-fa);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.btn-hud:hover {
    background: rgba(0, 255, 119, 0.18);
    border-color: var(--pharma-green);
    color: #fff;
    box-shadow: 0 0 10px var(--pharma-green-glow);
}

.btn-hud.primary {
    background: linear-gradient(135deg, rgba(0, 255, 119, 0.25), rgba(0, 229, 255, 0.25));
    border-color: var(--pharma-green);
    color: #fff;
    font-weight: 700;
}

.btn-hud.alert-btn {
    background: rgba(255, 0, 68, 0.15);
    border-color: var(--danger-red);
    color: #ff6688;
    font-weight: 700;
}

.btn-hud.alert-btn:hover {
    background: var(--danger-red);
    color: #fff;
    box-shadow: 0 0 12px var(--danger-glow);
}

.btn-hud.target-btn {
    background: rgba(255, 183, 0, 0.15);
    border-color: var(--affinity-gold);
    color: var(--affinity-gold);
    font-weight: 700;
}

.btn-hud.target-btn:hover {
    background: var(--affinity-gold);
    color: #000;
    box-shadow: 0 0 12px var(--affinity-glow);
}

.btn-hud.synth-btn {
    background: rgba(0, 229, 255, 0.15);
    border-color: var(--cyber-cyan);
    color: var(--cyber-cyan);
    font-weight: 700;
}

.btn-hud.synth-btn:hover {
    background: var(--cyber-cyan);
    color: #000;
    box-shadow: 0 0 12px var(--cyber-cyan-glow);
}

.btn-audio.active {
    border-color: var(--affinity-gold);
    color: var(--affinity-gold);
}

.audio-wave-anim {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 10px;
}

.audio-wave-anim span {
    width: 2px;
    height: 100%;
    background: currentColor;
    border-radius: 1px;
    animation: waveBounce 0.8s infinite ease-in-out alternate;
}

.audio-wave-anim span:nth-child(2) { animation-delay: 0.2s; }
.audio-wave-anim span:nth-child(3) { animation-delay: 0.4s; }
.audio-wave-anim span:nth-child(4) { animation-delay: 0.6s; }

@keyframes waveBounce {
    0% { height: 2px; }
    100% { height: 10px; }
}

/* ==========================================================================
   MAIN STAGE LAYOUT & SCROLLABLE SIDE PANELS
   ========================================================================== */
.main-stage {
    display: grid;
    grid-template-columns: 310px 1fr 320px;
    gap: 10px;
    padding: 8px 12px;
    flex: 1;
    overflow: hidden;
    pointer-events: none;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 90px);
    pointer-events: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--pharma-green) rgba(0, 20, 10, 0.6);
}

.side-panel::-webkit-scrollbar {
    width: 6px;
}
.side-panel::-webkit-scrollbar-track {
    background: rgba(0, 20, 10, 0.6);
    border-radius: 3px;
}
.side-panel::-webkit-scrollbar-thumb {
    background: var(--pharma-green);
    border-radius: 3px;
    box-shadow: 0 0 6px var(--pharma-green);
}

.panel-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 7px;
    padding: 10px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.2s ease;
}

.panel-card:hover {
    border-color: var(--panel-border-hover);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 255, 119, 0.15);
    padding-bottom: 4px;
}

.panel-title {
    font-size: 0.74rem;
    font-weight: 700;
    color: #fff;
}

.panel-tag {
    font-family: var(--font-code);
    font-size: 0.58rem;
    color: var(--cyber-cyan);
    background: rgba(0, 229, 255, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid rgba(0, 229, 255, 0.2);
}

/* Synthesis & Structural Error Card */
.synthesis-card {
    border-color: rgba(0, 229, 255, 0.35);
}

.synth-errors-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.synth-err-item {
    font-size: 0.62rem;
    line-height: 1.35;
    padding: 3px 5px;
    border-radius: 3px;
    background: rgba(0, 10, 4, 0.7);
}

.synth-err-item.severe {
    border-right: 3px solid var(--danger-red);
    color: #ff99aa;
}

.synth-err-item.warn {
    border-right: 3px solid var(--affinity-gold);
    color: #ffe082;
}

/* Medication Safety Card */
.safety-card {
    border-color: rgba(255, 0, 68, 0.35);
}

.blackbox-banner {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    background: rgba(255, 0, 68, 0.12);
    border: 1px solid rgba(255, 0, 68, 0.35);
    border-radius: 4px;
    padding: 6px;
    font-size: 0.64rem;
    line-height: 1.4;
    color: #ff99aa;
}

.bb-icon {
    font-size: 1rem;
}

.bb-content strong {
    color: #ff6688;
    display: block;
    margin-bottom: 2px;
}

.med-errors-compact-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.med-err-item {
    font-size: 0.62rem;
    background: rgba(0, 10, 4, 0.6);
    padding: 3px 5px;
    border-radius: 3px;
    border: 1px solid rgba(255, 183, 0, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

/* 8-Receptor Matrix Compact Box */
.receptors-matrix-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 10, 4, 0.6);
    padding: 5px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 119, 0.15);
}

.rec-bar-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    transition: background 0.15s ease;
}

.rec-bar-item:hover, .rec-bar-item.active {
    background: rgba(0, 255, 119, 0.1);
}

.rb-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.8);
}

.rb-label strong {
    color: var(--affinity-gold);
    font-family: var(--font-code);
}

/* Metric Rows */
.metric-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.70rem;
}

.m-label {
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 3px;
}

.m-label .eng-sub {
    font-family: var(--font-code);
    font-size: 0.62rem;
    color: var(--cyber-cyan);
    direction: ltr;
    display: inline-block;
}

.m-val {
    font-family: var(--font-code);
    font-weight: 600;
    color: #fff;
    direction: ltr;
    text-align: left;
}

.m-val.highlight {
    color: var(--pharma-green);
    font-weight: 700;
}

.m-val.highlight-bold {
    color: var(--affinity-gold);
    font-size: 0.90rem;
    font-weight: 800;
}

.m-sub {
    font-size: 0.58rem;
    color: rgba(255, 255, 255, 0.45);
}

.progress-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--pharma-green);
    border-radius: 2px;
    transition: width 0.3s ease;
    box-shadow: 0 0 6px var(--pharma-green-glow);
}

.progress-fill.highlight {
    background: linear-gradient(90deg, var(--pharma-green), var(--affinity-gold));
}

.badge-lipinski {
    font-family: var(--font-code);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
}

.badge-lipinski.pass {
    color: var(--pharma-green);
    background: rgba(0, 255, 119, 0.12);
    border: 1px solid rgba(0, 255, 119, 0.4);
}

.badge-lipinski.viol {
    color: var(--danger-red);
    background: rgba(255, 0, 68, 0.12);
    border: 1px solid rgba(255, 0, 68, 0.4);
}

.badge-lipinski.warn {
    color: var(--affinity-gold);
    background: rgba(255, 183, 0, 0.12);
    border: 1px solid rgba(255, 183, 0, 0.4);
}

/* Radar Container */
.radar-container {
    width: 100%;
    height: 120px;
    background: rgba(0, 10, 4, 0.6);
    border: 1px solid rgba(0, 255, 119, 0.15);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

/* Energy Term Breakdown Box */
.energy-breakdown-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: rgba(0, 12, 5, 0.6);
    padding: 5px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 119, 0.15);
}

.eb-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.8);
}

.eb-item strong {
    font-family: var(--font-code);
    color: var(--cyber-cyan);
    direction: ltr;
}

/* Pose Slider Box */
.pose-slider-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: rgba(0, 12, 5, 0.6);
    padding: 5px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 119, 0.15);
}

.ps-header {
    font-size: 0.64rem;
    color: var(--affinity-gold);
    font-weight: 600;
}

.pose-slider {
    width: 100%;
    accent-color: var(--pharma-green);
    cursor: pointer;
}

/* Interactions Table */
.interactions-container {
    max-height: 85px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--pharma-green) transparent;
}

.interactions-container::-webkit-scrollbar {
    width: 4px;
}
.interactions-container::-webkit-scrollbar-thumb {
    background: var(--pharma-green);
    border-radius: 2px;
}

.interaction-row {
    display: grid;
    grid-template-columns: 1fr 40px 40px 1fr;
    gap: 2px;
    font-size: 0.62rem;
    padding: 2px 4px;
    background: rgba(0, 12, 5, 0.7);
    border: 1px solid rgba(0, 255, 119, 0.1);
    border-radius: 3px;
    align-items: center;
}

.int-res {
    color: #fff;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.int-atom, .int-dist {
    font-family: var(--font-code);
    color: var(--pharma-green);
    direction: ltr;
    text-align: center;
}

.int-type {
    color: var(--cyber-cyan);
    font-size: 0.56rem;
    text-align: left;
}

/* Action Buttons */
.action-btn-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 2px;
}

.btn-dock-action {
    width: 100%;
    background: rgba(0, 255, 119, 0.1);
    border: 1px solid var(--pharma-green);
    color: #fff;
    padding: 5px 7px;
    font-family: var(--font-fa);
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-dock-action:hover {
    background: var(--pharma-green);
    color: #000;
    box-shadow: 0 0 14px var(--pharma-green-glow);
}

.btn-dock-action.screening-btn {
    background: linear-gradient(135deg, rgba(255, 183, 0, 0.15), rgba(0, 229, 255, 0.15));
    border-color: var(--affinity-gold);
    color: var(--affinity-gold);
}

.btn-dock-action.screening-btn:hover {
    background: var(--affinity-gold);
    color: #000;
    box-shadow: 0 0 14px var(--affinity-glow);
}

/* Camera Mode Grid */
.camera-btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.btn-cam {
    background: rgba(0, 20, 10, 0.6);
    border: 1px solid rgba(0, 255, 119, 0.2);
    color: rgba(255, 255, 255, 0.8);
    padding: 4px 5px;
    font-family: var(--font-fa);
    font-size: 0.64rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.btn-cam:hover, .btn-cam.active {
    background: rgba(0, 255, 119, 0.2);
    border-color: var(--pharma-green);
    color: #fff;
    box-shadow: 0 0 8px var(--pharma-green-glow);
}

/* ==========================================================================
   CENTER STAGE & VIEWPORT CONTROLS
   ========================================================================== */
.center-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.center-crosshair {
    position: absolute;
    top: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    pointer-events: none;
}

.reticle-tag {
    font-family: var(--font-code);
    font-size: 0.66rem;
    color: var(--pharma-bright);
    background: rgba(2, 14, 7, 0.88);
    padding: 2px 10px;
    border: 1px solid rgba(0, 255, 119, 0.3);
    border-radius: 14px;
    backdrop-filter: blur(8px);
    letter-spacing: 0.04em;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.6);
}

/* Viewport Controls Bar */
.viewport-controls-bar {
    position: absolute;
    top: 36px;
    display: flex;
    gap: 4px;
    pointer-events: auto;
    z-index: 20;
}

.btn-vp {
    background: rgba(2, 14, 7, 0.85);
    border: 1px solid rgba(0, 255, 119, 0.25);
    color: rgba(255, 255, 255, 0.8);
    padding: 3px 7px;
    font-family: var(--font-fa);
    font-size: 0.64rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
}

.btn-vp:hover, .btn-vp.active {
    background: rgba(0, 255, 119, 0.2);
    border-color: var(--pharma-green);
    color: #fff;
    box-shadow: 0 0 8px var(--pharma-green-glow);
}

/* Master Bottom Dock */
.master-bottom-dock {
    width: 100%;
    max-width: 660px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: auto;
    z-index: 30;
    margin-bottom: 2px;
}

/* Presets Bar with Scroll Navigation */
.presets-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(2, 14, 7, 0.92);
    padding: 3px 6px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    backdrop-filter: blur(12px);
}

.drug-presets-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--pharma-green) transparent;
}

.drug-presets-bar::-webkit-scrollbar {
    height: 3px;
}
.drug-presets-bar::-webkit-scrollbar-thumb {
    background: var(--pharma-green);
    border-radius: 2px;
}

.preset-label {
    font-size: 0.64rem;
    font-weight: 700;
    color: var(--cyber-cyan);
    white-space: nowrap;
    margin-left: 2px;
}

.btn-preset {
    background: rgba(0, 20, 10, 0.5);
    border: 1px solid rgba(0, 255, 119, 0.2);
    color: rgba(255, 255, 255, 0.85);
    padding: 2px 6px;
    font-family: var(--font-fa);
    font-size: 0.66rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-preset:hover, .btn-preset.active {
    background: rgba(0, 255, 119, 0.22);
    border-color: var(--pharma-green);
    color: #fff;
    box-shadow: 0 0 8px var(--pharma-green-glow);
}

.btn-preset.highlight-more {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(0, 255, 119, 0.2));
    border-color: var(--cyber-cyan);
    color: var(--cyber-cyan);
    font-weight: 700;
}

/* SMILES Editor Unit */
.smiles-editor-unit {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 7px;
    padding: 6px 9px;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.unit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.unit-title {
    font-size: 0.68rem;
    color: #fff;
}

.atom-stats {
    font-family: var(--font-code);
    font-size: 0.62rem;
    color: var(--pharma-green);
    background: rgba(0, 255, 119, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
}

.smiles-input-row {
    display: flex;
    gap: 5px;
}

.pro-smiles-input {
    flex: 1;
    background: rgba(0, 10, 4, 0.85);
    border: 1px solid rgba(0, 255, 119, 0.3);
    color: #fff;
    font-family: var(--font-code);
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 4px;
    outline: none;
    direction: ltr;
    text-align: left;
    transition: border-color 0.2s ease;
}

.pro-smiles-input:focus {
    border-color: var(--pharma-green);
    box-shadow: 0 0 10px var(--pharma-green-glow);
}

.btn-pro.primary {
    background: var(--pharma-green);
    color: #000;
    border: none;
    padding: 4px 10px;
    font-family: var(--font-fa);
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-pro.primary:hover {
    background: #fff;
    box-shadow: 0 0 14px var(--pharma-green-glow);
}

/* Functional Group Modifiers */
.group-modifiers {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
}

.mod-label {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.6);
}

.btn-mod {
    background: rgba(0, 20, 10, 0.6);
    border: 1px solid rgba(0, 255, 119, 0.2);
    color: rgba(255, 255, 255, 0.85);
    padding: 2px 5px;
    font-family: var(--font-fa);
    font-size: 0.62rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.btn-mod:hover {
    background: rgba(0, 255, 119, 0.2);
    border-color: var(--pharma-green);
    color: #fff;
}

.btn-mod.danger {
    border-color: rgba(255, 0, 68, 0.4);
    color: #ff6688;
}

.btn-mod.danger:hover {
    background: rgba(255, 0, 68, 0.2);
    border-color: var(--danger-red);
    color: #fff;
}

/* ==========================================================================
   RIGHT PANEL: 2D PREVIEW, TERMINAL & STATS
   ========================================================================== */
.structure-2d-box {
    width: 100%;
    height: 70px;
    background: rgba(0, 10, 4, 0.6);
    border: 1px solid rgba(0, 255, 119, 0.15);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#preview-2d-canvas {
    width: 100%;
    height: 100%;
}

.elements-table {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
}

.elem-chip {
    display: flex;
    justify-content: space-between;
    background: rgba(0, 15, 6, 0.7);
    border: 1px solid rgba(0, 255, 119, 0.15);
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.64rem;
}

.elem-chip strong {
    font-family: var(--font-code);
    color: var(--pharma-green);
}

/* CLI Simulation Terminal */
.terminal-card {
    padding: 6px;
}

.terminal-dots {
    display: flex;
    gap: 4px;
}

.tdot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.tdot.r { background: #ff5f56; }
.tdot.y { background: #ffbd2e; }
.tdot.g { background: #27c93f; }

.terminal-screen {
    height: 80px;
    background: rgba(0, 5, 2, 0.95);
    border: 1px solid rgba(0, 255, 119, 0.2);
    border-radius: 4px;
    padding: 4px;
    font-family: var(--font-code);
    font-size: 0.60rem;
    line-height: 1.4;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--pharma-green) transparent;
}

.terminal-screen::-webkit-scrollbar {
    width: 4px;
}
.terminal-screen::-webkit-scrollbar-thumb {
    background: var(--pharma-green);
    border-radius: 2px;
}

.t-line.sys { color: var(--pharma-green); }
.t-line.info { color: var(--cyber-cyan); }
.t-line.warn { color: var(--affinity-gold); }
.t-line.err { color: var(--danger-red); }
.t-line.user { color: #fff; opacity: 0.9; }

.terminal-cmd-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    background: rgba(0, 10, 4, 0.8);
    border: 1px solid rgba(0, 255, 119, 0.2);
    border-radius: 4px;
    padding: 2px 5px;
}

.prompt-sym {
    font-family: var(--font-code);
    font-size: 0.58rem;
    color: var(--pharma-green);
    white-space: nowrap;
}

#term-input-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: var(--font-code);
    font-size: 0.62rem;
}

/* ==========================================================================
   BOTTOM RIBBON
   ========================================================================== */
.bottom-ribbon {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 14px;
    background: rgba(1, 8, 4, 0.94);
    border-top: 1px solid var(--panel-border);
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.7);
    z-index: 50;
}

.r-sep {
    margin: 0 5px;
    color: rgba(0, 255, 119, 0.3);
}

#coords-display {
    font-family: var(--font-code);
    color: var(--pharma-green);
}

/* ==========================================================================
   MODALS: SYNTHESIS, SAFETY, RECEPTORS & 550+ DRUG LIBRARY
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(14px);
    z-index: 200;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-window {
    width: 100%;
    max-width: 1140px;
    max-height: 90vh;
    background: rgba(2, 14, 7, 0.97);
    border: 1px solid var(--pharma-green);
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0, 255, 119, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(0, 25, 12, 0.4);
}

.m-title-wrap h2 {
    font-size: 0.95rem;
    color: #fff;
}

.modal-subtitle {
    font-family: var(--font-code);
    font-size: 0.58rem;
    color: var(--cyber-cyan);
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-close-modal:hover {
    color: #fff;
}

.modal-content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--pharma-green) transparent;
}

.modal-content-scroll::-webkit-scrollbar {
    width: 6px;
}
.modal-content-scroll::-webkit-scrollbar-thumb {
    background: var(--pharma-green);
    border-radius: 3px;
}

/* Synthesis Modal Detailed Cards */
.synth-pass-card {
    background: rgba(0, 255, 119, 0.12);
    border: 1px solid var(--pharma-green);
    border-radius: 6px;
    padding: 14px;
    color: #fff;
    font-size: 0.76rem;
    line-height: 1.5;
}

.synth-card-detail {
    background: rgba(0, 12, 5, 0.75);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.synth-card-detail.error {
    border: 1px solid var(--danger-red);
    border-right: 5px solid var(--danger-red);
}

.synth-card-detail.warning {
    border: 1px solid var(--affinity-gold);
    border-right: 5px solid var(--affinity-gold);
}

.sc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    color: #fff;
}

.sc-badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-code);
    font-size: 0.62rem;
    font-weight: 700;
}

.sc-badge.error {
    background: var(--danger-red);
    color: #fff;
}

.sc-badge.warning {
    background: var(--affinity-gold);
    color: #000;
}

.sc-desc {
    font-size: 0.70rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
}

.sc-fix {
    font-size: 0.70rem;
    color: var(--pharma-bright);
    background: rgba(0, 255, 119, 0.08);
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 119, 0.2);
}

/* Medication Safety Modal Details */
.blackbox-alert-large {
    background: rgba(255, 0, 68, 0.15);
    border: 1px solid var(--danger-red);
    border-radius: 6px;
    padding: 12px;
}

.blackbox-alert-large h3 {
    font-size: 0.82rem;
    color: #ff6688;
    margin-bottom: 4px;
}

.blackbox-alert-large p {
    font-size: 0.76rem;
    color: #fff;
}

.safety-section {
    background: rgba(0, 15, 6, 0.5);
    border: 1px solid rgba(0, 255, 119, 0.2);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.safety-section h3 {
    font-size: 0.80rem;
    color: var(--cyber-cyan);
    border-bottom: 1px solid rgba(0, 229, 255, 0.2);
    padding-bottom: 4px;
}

.med-errors-detailed-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.med-errors-detailed-list li {
    font-size: 0.72rem;
    background: rgba(0, 10, 4, 0.7);
    padding: 6px 10px;
    border-radius: 4px;
    border-right: 3px solid var(--affinity-gold);
    color: rgba(255, 255, 255, 0.9);
}

.ddi-checker-section .ddi-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.74rem;
}

.ddi-controls select {
    background: rgba(0, 10, 4, 0.9);
    border: 1px solid var(--pharma-green);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-fa);
    font-size: 0.72rem;
    outline: none;
}

.ddi-result-box {
    background: rgba(0, 10, 4, 0.85);
    border: 1px solid rgba(0, 255, 119, 0.3);
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ddi-severity-badge {
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 3px;
    font-family: var(--font-code);
    font-size: 0.66rem;
    font-weight: 700;
}

.ddi-severity-badge.severe {
    background: var(--danger-red);
    color: #fff;
}

.ddi-severity-badge.major {
    background: var(--affinity-gold);
    color: #000;
}

.ddi-severity-badge.moderate {
    background: var(--cyber-cyan);
    color: #000;
}

.ddi-desc {
    font-size: 0.72rem;
    line-height: 1.5;
    color: #fff;
}

/* Receptors Chart Canvas Wrap */
.receptors-chart-box {
    background: rgba(0, 10, 4, 0.6);
    border: 1px solid rgba(0, 255, 119, 0.2);
    border-radius: 6px;
    padding: 10px;
}

.receptors-chart-box h3 {
    font-size: 0.78rem;
    color: var(--cyber-cyan);
    margin-bottom: 8px;
}

.receptors-canvas-wrap {
    width: 100%;
    height: 160px;
}

#receptors-bar-canvas {
    width: 100%;
    height: 100%;
}

/* 550+ Drug Table Modal Toolbar */
.modal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0, 15, 6, 0.5);
    border-bottom: 1px solid rgba(0, 255, 119, 0.15);
    gap: 8px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(0, 10, 4, 0.9);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: 4px 8px;
    flex: 1;
    min-width: 220px;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: var(--font-fa);
    font-size: 0.74rem;
    width: 100%;
    margin-right: 5px;
}

.filter-controls {
    display: flex;
    gap: 5px;
    align-items: center;
}

.filter-controls select {
    background: rgba(0, 15, 6, 0.9);
    border: 1px solid var(--panel-border);
    color: #fff;
    font-family: var(--font-fa);
    font-size: 0.70rem;
    padding: 4px 7px;
    border-radius: 4px;
    outline: none;
}

.btn-lib-action {
    background: rgba(0, 255, 119, 0.1);
    border: 1px solid var(--panel-border);
    color: var(--pharma-bright);
    padding: 4px 9px;
    font-family: var(--font-fa);
    font-size: 0.70rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-lib-action:hover {
    background: rgba(0, 255, 119, 0.2);
    border-color: var(--pharma-green);
    color: #fff;
}

.btn-lib-action.primary {
    background: var(--pharma-green);
    color: #000;
    border-color: var(--pharma-green);
}

.btn-lib-action.primary:hover {
    background: #fff;
    box-shadow: 0 0 12px var(--pharma-green-glow);
}

/* Screening Banner */
.screening-banner {
    padding: 7px 16px;
    background: rgba(255, 183, 0, 0.08);
    border-bottom: 1px solid rgba(255, 183, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sb-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.70rem;
    color: var(--affinity-gold);
}

/* Table Container */
.table-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
    max-height: 500px;
    scrollbar-width: thin;
    scrollbar-color: var(--pharma-green) transparent;
}

.table-container::-webkit-scrollbar {
    width: 6px;
}
.table-container::-webkit-scrollbar-thumb {
    background: var(--pharma-green);
    border-radius: 3px;
}

.pharma-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.70rem;
    text-align: right;
}

.pharma-table th {
    position: sticky;
    top: 0;
    background: rgba(2, 18, 9, 0.98);
    color: var(--cyber-cyan);
    padding: 7px 5px;
    border-bottom: 1px solid var(--pharma-green);
    font-weight: 700;
    z-index: 5;
}

.pharma-table td {
    padding: 6px 5px;
    border-bottom: 1px solid rgba(0, 255, 119, 0.1);
    color: rgba(255, 255, 255, 0.85);
}

.pharma-table tr:hover {
    background: rgba(0, 255, 119, 0.08);
}

.btn-select-drug {
    background: rgba(0, 255, 119, 0.15);
    border: 1px solid var(--pharma-green);
    color: #fff;
    padding: 3px 6px;
    font-family: var(--font-fa);
    font-size: 0.64rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.btn-select-drug:hover {
    background: var(--pharma-green);
    color: #000;
}

/* ==========================================================================
   V7.0 ADVANCED MODULES (2D MAP, MD SIMULATION, AI OPTIMIZER, DUAL COMPARISON)
   ========================================================================== */
.btn-hud.ai-btn {
    border-color: #ff00ea;
    color: #ff00ea;
    background: rgba(255, 0, 234, 0.12);
}
.btn-hud.ai-btn:hover {
    background: #ff00ea;
    color: #000;
    box-shadow: 0 0 12px rgba(255, 0, 234, 0.6);
}

.btn-hud.md-btn {
    border-color: #00e5ff;
    color: #00e5ff;
    background: rgba(0, 229, 255, 0.12);
}
.btn-hud.md-btn:hover {
    background: #00e5ff;
    color: #000;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}

.btn-hud.compare-btn {
    border-color: #ffd700;
    color: #ffd700;
    background: rgba(255, 215, 0, 0.12);
}
.btn-hud.compare-btn:hover {
    background: #ffd700;
    color: #000;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

/* 2D Interaction Map Canvas Container */
.interaction-map-wrap {
    width: 100%;
    height: 420px;
    background: #060d17;
    border: 1px solid rgba(0, 255, 119, 0.2);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    margin: 8px 0;
}

#interaction-2d-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* AI Lead Optimizer Card */
.ai-candidate-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.ai-candidate-card {
    background: rgba(10, 20, 32, 0.85);
    border: 1px solid rgba(255, 0, 234, 0.3);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
}

.ai-candidate-card:hover {
    border-color: #ff00ea;
    box-shadow: 0 0 14px rgba(255, 0, 234, 0.3);
    transform: translateY(-2px);
}

.cand-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cand-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: #fff;
}

.cand-delta {
    background: rgba(0, 255, 119, 0.15);
    color: var(--pharma-green);
    border: 1px solid var(--pharma-green);
    font-family: var(--font-code);
    font-size: 0.70rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.cand-desc {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
}

.cand-meta {
    display: flex;
    gap: 10px;
    font-size: 0.64rem;
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-code);
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 5px;
}

.cand-meta span strong {
    color: var(--cyber-cyan);
}

.btn-apply-cand {
    background: linear-gradient(90deg, #ff00ea, #00e5ff);
    color: #000;
    font-family: var(--font-fa);
    font-size: 0.68rem;
    font-weight: 700;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 4px;
    transition: all 0.2s ease;
}

.btn-apply-cand:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

/* Dual Drug Side-by-Side Comparison */
.compare-container-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 10px;
}

.compare-card {
    background: rgba(8, 16, 26, 0.85);
    border: 1px solid rgba(0, 255, 119, 0.25);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.compare-card.left {
    border-color: #00e5ff;
}

.compare-card.right {
    border-color: #ffd700;
}

.compare-title {
    font-size: 0.80rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

/* ==========================================================================
   MOBILE TAB BAR SWITCHER (App-like Mobile UX)
   ========================================================================== */
.mobile-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 54px;
    background: rgba(2, 10, 5, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--panel-border);
    z-index: 99;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
}

.mob-tab-btn {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-fa);
    font-size: 0.62rem;
    font-weight: 600;
    cursor: pointer;
    gap: 2px;
    transition: all 0.2s ease;
}

.mob-tab-btn .mob-icon {
    font-size: 1.05rem;
}

.mob-tab-btn.active {
    color: var(--pharma-green);
    background: rgba(0, 255, 119, 0.12);
    border-top: 2px solid var(--pharma-green);
}

/* ==========================================================================
   RESPONSIVE MASTER SUITE (DESKTOP, LAPTOP, TABLET & MOBILE)
   ========================================================================== */

/* 1. Large Displays & Standard Laptops (1200px - 1440px) */
@media (max-width: 1366px) {
    .main-stage {
        grid-template-columns: 280px 1fr 290px;
        gap: 8px;
        padding: 6px 8px;
    }
    .top-hud-bar {
        padding: 5px 10px;
    }
    .brand-title {
        font-size: 1.05rem;
    }
    .btn-hud {
        padding: 4px 6px;
        font-size: 0.64rem;
    }
}

/* 2. Compact Laptops (993px - 1200px) */
@media (max-width: 1200px) {
    .main-stage {
        grid-template-columns: 260px 1fr 270px;
        gap: 6px;
        padding: 4px 6px;
    }
    .panel-card {
        padding: 6px;
        gap: 4px;
    }
    .top-hud-bar {
        flex-wrap: wrap;
    }
    .target-nav-wrapper {
        max-width: 400px;
    }
    .hud-right {
        overflow-x: auto;
        max-width: 100%;
        padding-bottom: 2px;
    }
}

/* 3. Tablets & Mobile Phones (<= 992px) */
@media (max-width: 992px) {
    .mobile-tab-bar {
        display: flex;
    }

    .app-shell {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        pointer-events: auto;
    }

    .top-hud-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 6px 8px;
    }

    .sys-brand {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        min-width: unset;
    }

    .brand-title {
        font-size: 0.95rem;
    }

    .target-nav-wrapper {
        max-width: 100%;
        width: 100%;
    }

    .hud-right {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
        padding: 2px 0;
    }

    .btn-hud {
        padding: 4px 7px;
        font-size: 0.60rem;
        flex-shrink: 0;
    }

    .main-stage {
        display: block;
        position: relative;
        width: 100%;
        height: calc(100vh - 120px);
        height: calc(100dvh - 120px);
        padding: 6px;
        overflow: hidden;
        pointer-events: auto;
    }

    /* Mobile View Switching System */
    .center-stage, .side-panel.left-panel, .side-panel.right-panel {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 65px;
        pointer-events: auto;
    }

    /* Active View Class */
    .center-stage.mobile-active,
    .side-panel.left-panel.mobile-active,
    .side-panel.right-panel.mobile-active {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .center-stage.mobile-active {
        display: block;
    }

    .master-bottom-dock {
        position: absolute;
        bottom: 60px;
        left: 6px;
        right: 6px;
        width: auto;
        transform: none;
        padding: 8px;
        background: rgba(2, 10, 5, 0.94);
    }

    .viewport-controls-bar {
        top: 6px;
        left: 6px;
        right: 6px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .btn-vp {
        font-size: 0.58rem;
        padding: 3px 6px;
    }

    .center-crosshair {
        display: none;
    }

    .smiles-input-row {
        flex-direction: column;
        gap: 5px;
    }

    .pro-smiles-input {
        width: 100%;
        font-size: 0.68rem;
        padding: 6px 8px;
    }

    .btn-pro.primary {
        width: 100%;
        padding: 7px;
        font-size: 0.68rem;
    }

    .group-modifiers {
        flex-wrap: wrap;
        gap: 3px;
    }

    .btn-mod {
        font-size: 0.58rem;
        padding: 3px 5px;
        flex: 1 1 28%;
    }

    .modal-window {
        width: 96vw !important;
        max-width: 96vw !important;
        max-height: 90vh !important;
        max-height: 90dvh !important;
        padding: 8px !important;
    }

    .modal-header h2 {
        font-size: 0.82rem !important;
    }

    .modal-toolbar {
        flex-direction: column;
        gap: 5px;
    }

    .search-box, .filter-controls {
        width: 100%;
    }

    .filter-controls {
        flex-direction: column;
        gap: 4px;
    }

    .filter-controls select, .filter-controls button {
        width: 100%;
    }

    .interaction-map-wrap {
        height: 280px;
    }

    .ai-candidate-grid, .compare-container-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        max-height: 240px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .bottom-ribbon {
        display: none;
    }
}

/* 4. Extra Small Smartphones (<= 480px) */
@media (max-width: 480px) {
    .brand-title {
        font-size: 0.82rem;
    }

    .target-tab {
        font-size: 0.58rem;
        padding: 3px 4px;
    }

    .panel-title {
        font-size: 0.70rem;
    }

    .m-label, .m-val {
        font-size: 0.62rem;
    }

    .energy-breakdown-box {
        grid-template-columns: 1fr;
    }
}
