/*
 * Semiconductor States Lab - Precision Scientific Workstation Styling
 * Version: 2.0 (Standardized Workstation Baseline)
 * Author: Dr. Gerard Joseph Lim
 */

:root {
    color-scheme: dark;

    /* Deep Space Dark Mode (Default) */
    --bg-color: #030712;
    --bg-secondary: #0a0a0a;

    --text-main: #ffffff;
    --text-muted: #cbd5e1;
    --text-subtle: #94a3b8;

    --primary: #38bdf8;
    --primary-dark: #0284c7;
    --primary-light: #7dd3fc;

    --positive: #ff4d4d;
    --negative: #4d94ff;
    --neutral: #9ca3af;
    --warning: #fbbf24;
    --error: #ef4444;

    /* Solid Chassis Cards & Panels (5px Precision Radius, No Bloom/Glow) */
    --card-bg: #0d1322;
    --card-border: #1e293b;
    --card-border-light: #334155;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    --card-radius: 5px;

    /* Inputs & Buttons */
    --input-bg: #0a0f1d;
    --input-border: rgba(255, 255, 255, 0.14);
    --btn-bg: #172033;
    --btn-border: rgba(255, 255, 255, 0.14);
    --btn-hover-bg: rgba(255, 255, 255, 0.15);

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-math: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Cambria", "Times New Roman", serif;

    /* Spacing & Layout Tokens */
    --header-height: 52px;
    --footer-height: 48px;
    --spacing-header-gap: 16px;
    --spacing-footer-gap: 16px;
    --spacing-viewport-edge: 20px;
    --spacing-card-gap: 16px;

    /* Semiconductor Palette Equivalents */
    --cyan: #38bdf8;
    --green: #34d399;
    --blue: #60a5fa;
    --red: #f87171;
    --amber: #fbbf24;
    --violet: #a78bfa;
}

[data-theme="light"] {
    color-scheme: light;

    /* Classic PC Beige Lab Workstation Mode */
    --bg-color: #f5f0e8;
    --bg-secondary: #ede7dc;

    --text-main: #000000;
    --text-muted: #1e293b;
    --text-subtle: #334155;

    --primary: #0284c7;
    --primary-dark: #0369a1;
    --primary-light: #0ea5e9;

    --positive: #dc2626;
    --negative: #2563eb;
    --neutral: #475569;
    --warning: #d97706;
    --error: #b91c1c;

    /* Solid PC Beige Chassis Cards (No White Glow) */
    --card-bg: #e8e2d5;
    --card-border: rgba(70, 60, 50, 0.25);
    --card-border-light: rgba(70, 60, 50, 0.4);
    --card-shadow: 0 1px 3px rgba(70, 60, 50, 0.12), 0 1px 2px rgba(70, 60, 50, 0.08);

    /* Inputs & Buttons */
    --input-bg: #fcfbf7;
    --input-border: rgba(70, 60, 50, 0.32);
    --btn-bg: #dfd8cb;
    --btn-border: rgba(70, 60, 50, 0.28);
    --btn-hover-bg: #d4ccbe;

    /* High-contrast semiconductor categories in light mode */
    --cyan: #0284c7;
    --green: #047857;
    --blue: #1d4ed8;
    --red: #dc2626;
    --amber: #b45309;
    --violet: #7c3aed;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg-color);
}

body {
    margin: 0;
    height: 100vh;
    font-family: var(--font-family);
    color: var(--text-main);
    background: var(--bg-color);
    overflow: hidden;
}

button, input, select {
    font: inherit;
}

button, select, input[type="range"], input[type="checkbox"] {
    cursor: pointer;
}

button:focus-visible, select:focus-visible, input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ========================================================================== */
/* FULL-WIDTH DOCKED WORKSTATION FRAMING                                      */
/* ========================================================================== */

/* Top Docked Header (Height 52px) */
.app-header {
    position: relative;
    flex-shrink: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--spacing-viewport-edge);
    z-index: 100;
    user-select: none;
    box-sizing: border-box;
}

[data-theme="light"] .app-header {
    box-shadow: 0 1px 3px rgba(70, 60, 50, 0.10);
}

.header-brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}

.brand-mark:hover {
    opacity: 0.85;
    transform: scale(1.04);
    background: transparent;
    border: none;
}

.brand-logo-svg {
    display: block;
}

.brand-path-top {
    fill: #ffffff;
}

[data-theme="light"] .brand-path-top {
    fill: #1E3A8A;
}

.brand-path-bottom {
    fill: #14B8A6;
}

.header-title-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-title-block h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-main);
    line-height: 1.2;
}

.header-meta {
    margin: 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.meta-sep {
    opacity: 0.45;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.presets {
    display: flex;
    gap: 6px;
}

.preset {
    border: 1px solid var(--btn-border);
    color: var(--text-muted);
    background: var(--btn-bg);
    border-radius: var(--card-radius);
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.preset:hover {
    color: var(--text-main);
    background: var(--btn-hover-bg);
    border-color: var(--card-border-light);
}

.preset.active {
    color: #ffffff;
    background: var(--primary-dark);
    border-color: var(--primary);
}

[data-theme="light"] .preset.active {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary-dark);
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Theme Toggle, Help & Assistant Buttons (Square 34x34 with 5px radius) */
.theme-btn,
.help-btn,
.assistant-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--card-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    color: var(--text-main);
    box-shadow: var(--card-shadow);
    padding: 0;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.theme-btn:hover,
.help-btn:hover,
.assistant-btn:hover {
    transform: scale(1.05);
    background: var(--btn-hover-bg);
    border-color: var(--card-border-light);
}

.assistant-btn.active {
    background: var(--primary-dark);
    color: #ffffff;
    border-color: var(--primary);
}

[data-theme="light"] .assistant-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary-dark);
}

.help-btn {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Bottom Docked Footer (Height 48px) */
.app-footer {
    position: relative;
    flex-shrink: 0;
    width: 100%;
    height: var(--footer-height);
    background: var(--card-bg);
    border-top: 1px solid var(--card-border);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.35);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 var(--spacing-viewport-edge);
    z-index: 100;
    user-select: none;
    font-size: 0.76rem;
    box-sizing: border-box;
}

[data-theme="light"] .app-footer {
    box-shadow: 0 -1px 3px rgba(70, 60, 50, 0.10);
}

.footer-center-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    text-align: center;
}

.signature-footer {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    padding: 4px 14px;
    border-radius: var(--card-radius);
    transition: all 0.2s ease;
}

.signature-footer:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .signature-footer:hover {
    color: var(--primary-dark);
    background: rgba(70, 60, 50, 0.08);
}

.footer-actions-zone {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-btn {
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    color: var(--text-main);
    border-radius: var(--card-radius);
    padding: 4px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.footer-btn:hover {
    background: var(--btn-hover-bg);
    border-color: var(--card-border-light);
}

/* ========================================================================== */
/* WORKSTATION WORKSPACE LAYOUT                                               */
/* ========================================================================== */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.workstation-main {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: var(--spacing-card-gap);
    align-items: stretch;
    padding: 10px var(--spacing-viewport-edge);
    margin: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.workspace {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 10px;
    overflow: hidden;
}

/* Solid Chassis Containers (5px Radius, No Blur Overuse) */
.liquid-glass {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    border-radius: var(--card-radius);
    position: relative;
    overflow: hidden;
    transition: none;
}

/* Summary Grid: 6 Metric Readout Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    flex-shrink: 0;
}

.metric {
    min-width: 0;
    min-height: 72px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    border-radius: var(--card-radius);
}

.metric span {
    color: var(--text-muted);
    font-size: 0.84rem;
    white-space: nowrap;
    font-weight: 600;
}

.metric strong {
    overflow: hidden;
    text-overflow: ellipsis;
    font: 700 1.02rem var(--font-mono);
    color: var(--text-main);
}

.metric small {
    color: var(--text-subtle);
    font-size: 0.78rem;
    font-weight: 500;
}

.metric.electron strong {
    color: var(--blue);
}

.metric.hole strong {
    color: var(--red);
}

[data-theme="light"] .metric strong {
    color: #000000;
}

[data-theme="light"] .metric.electron strong {
    color: var(--blue);
}

[data-theme="light"] .metric.hole strong {
    color: var(--red);
}

/* Plot Card and Canvas */
.canvas-card {
    position: relative;
    flex: 1;
    min-height: 320px;
    height: auto;
    overflow: hidden;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
}

.plot-toolbar {
    height: 40px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--card-border);
    font-size: 0.80rem;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .plot-toolbar {
    background: rgba(0, 0, 0, 0.04);
}

.plot-toolbar > div {
    display: flex;
    align-items: center;
    gap: 7px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
}

.status-dot.error {
    background: var(--error);
}

.plot-note {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
}

.plot-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.toolbar-button {
    padding: 4px 10px;
    border: 1px solid var(--btn-border);
    border-radius: var(--card-radius);
    color: var(--text-muted);
    background: var(--btn-bg);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toolbar-button:hover {
    color: var(--text-main);
    background: var(--btn-hover-bg);
    border-color: var(--card-border-light);
}

.toolbar-button.active {
    background: var(--primary-dark);
    color: #ffffff;
    border-color: var(--primary);
    font-weight: 600;
}

[data-theme="light"] .toolbar-button.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
}

/* ========================================================================== */
/* FLOATING HOVERING f(E) PLOT CARD (Overlays 4-Plot without blocking UI)     */
/* ========================================================================== */

.hover-fd-card {
    position: absolute;
    top: 54px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
    padding: 14px 16px;
    gap: 10px;
}

[data-theme="light"] .hover-fd-card {
    box-shadow: 0 8px 24px rgba(70, 60, 50, 0.18);
}

.hover-fd-card.hidden {
    display: none !important;
}

.hover-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
}

.hover-card-title-block h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.hover-card-subtitle {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 1px;
}

.hover-card-close-btn {
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    color: var(--text-muted);
    border-radius: var(--card-radius);
    padding: 2px 7px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hover-card-close-btn:hover {
    color: var(--text-main);
    background: var(--btn-hover-bg);
    border-color: var(--card-border-light);
}

.hover-card-canvas-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    background: var(--canvas-bg);
    overflow: hidden;
}

#hoverFdCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hover-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    padding-top: 2px;
}

.hover-card-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 3px;
    border-radius: 1px;
}

.legend-swatch.fd-swatch {
    background: var(--green);
    height: 3.5px;
}

.legend-swatch.hole-swatch {
    background: var(--amber);
    height: 3px;
}

.legend-swatch.mb-swatch {
    background: var(--cyan);
    height: 3px;
}

.legend-swatch.ef-swatch {
    background: var(--cyan);
    height: 8px;
    width: 2px;
}

canvas {
    display: block;
    width: 100%;
    height: calc(100% - 40px);
}

.plot-tooltip {
    display: none;
    position: absolute;
    z-index: 5;
    pointer-events: none;
    max-width: 260px;
    padding: 8px 11px;
    border: 1px solid var(--primary);
    border-radius: var(--card-radius);
    color: var(--text-main);
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    font: 500 0.76rem/1.55 var(--font-mono);
    white-space: pre-line;
}

/* Diagnostics Bar (Residual & Equilibrium Metrics) */
.diagnostics {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 16px;
    padding: 8px 14px;
    color: var(--text-muted);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    font-size: 0.84rem;
    font-weight: 500;
    flex-shrink: 0;
}

.diagnostics strong {
    margin-left: 5px;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-weight: 700;
}

/* Diagnostic & Metric Tooltip Interactive Targets */
.metric[data-tooltip-id],
.diag-item[data-tooltip-id],
.status-indicator[data-tooltip-id] {
    cursor: default;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.metric[data-tooltip-id]:hover {
    border-color: var(--primary);
}

.diag-item {
    cursor: default;
    padding: 3px 6px;
    border-radius: var(--card-radius);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.diag-item:hover {
    background: var(--input-bg);
    color: var(--text-main);
}

.status-indicator[data-tooltip-id] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px;
    border-radius: var(--card-radius);
    cursor: default;
    transition: background-color 0.15s ease;
}

.status-indicator[data-tooltip-id]:hover {
    background: var(--input-bg);
}

/* Delayed Floating Metric Tooltip Popup (0.5s Hover Delay) */
.metric-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    max-width: 380px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--primary);
    border-radius: var(--card-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    color: var(--text-main);
    font: 500 0.78rem/1.55 var(--font-sans);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.metric-tooltip.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(3px);
}

.metric-tooltip-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
    font-family: var(--font-sans);
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric-tooltip-body {
    color: var(--text-muted);
    font-size: 0.77rem;
    line-height: 1.55;
}

.metric-tooltip-body strong {
    color: var(--text-main);
}

.metric-tooltip-body code {
    font-family: var(--font-mono);
    color: var(--primary);
    background: var(--input-bg);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.72rem;
}

/* Authentic OMML / Cambria MathML Typography */
math, .math-omml, .math-text {
    font-family: var(--font-math);
    font-size: 1.08em;
    letter-spacing: 0.01em;
    font-style: normal;
    color: var(--text-main);
}

.metric span math,
.metric small math,
.diag-item math,
.range-heading label math,
.field-label math,
.check-row math,
.section-title math,
.splash-body math {
    font-family: var(--font-math);
    font-size: 1.04em;
    vertical-align: -0.06em;
}

math[display="block"], .math-omml-block {
    display: block;
    margin: 8px 0;
    padding: 4px 8px;
    text-align: center;
    background: var(--input-bg);
    border-radius: var(--card-radius);
}

math[display="inline"], .math-omml-inline {
    display: inline;
    vertical-align: -0.15em;
}

math mi, .math-omml var {
    font-style: italic;
    font-family: inherit;
}

math mo, math mn, .math-omml span.op, .math-omml span.num {
    font-style: normal;
    font-family: inherit;
}

math mfrac, .math-omml .frac {
    padding: 0 2px;
}

.math-eq-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 9px 0;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    text-align: center;
}

.math-eq-row math,
.math-eq-row .math-omml {
    font-size: 1.35em;
    line-height: 1.35;
    color: var(--text-main);
}

/* Parameter Controls Panel */
.controls {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    padding: 18px 18px 48px 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    scrollbar-width: thin;
    box-sizing: border-box;
}

.controls-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.controls-heading h2 {
    margin: 3px 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.eyebrow {
    color: var(--primary);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
}

.text-button {
    font-size: 0.76rem;
    font-weight: 600;
    border: 1px solid var(--btn-border);
    color: var(--text-muted);
    background: var(--btn-bg);
    border-radius: var(--card-radius);
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.text-button:hover {
    color: var(--text-main);
    background: var(--btn-hover-bg);
    border-color: var(--card-border-light);
}

.control-section {
    padding: 14px 0;
    border-top: 1px solid var(--card-border);
}

.control-section:first-of-type {
    border-top: 0;
}

.two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.two-column .range-field,
.two-column .range-field + .range-field {
    margin-top: 0;
}

.field-label, .range-heading label {
    color: var(--text-main);
    font-size: 0.84rem;
    font-weight: 600;
}

.model-selects {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 12px 0 0;
}

.model-selects select {
    font-size: 0.84rem;
    font-weight: 500;
}

select {
    width: 100%;
    margin-top: 6px;
    padding: 8px 10px;
    color: var(--text-main);
    border: 1px solid var(--input-border);
    border-radius: var(--card-radius);
    background: var(--input-bg);
    font-size: 0.84rem;
    outline: none;
    transition: border-color 0.2s;
}

select:focus {
    border-color: var(--primary);
}

.range-field {
    display: grid;
    gap: 6px;
}

.range-field + .range-field {
    margin-top: 14px;
}

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

output {
    color: var(--text-main);
    font: 700 0.86rem var(--font-mono);
    white-space: nowrap;
}

[data-theme="light"] output {
    color: #000000;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    margin: 4px 0;
    appearance: none;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--input-border);
    outline: none;
}

[data-theme="light"] input[type="range"] {
    background: rgba(70, 60, 50, 0.2);
}

input[type="range"]::-webkit-slider-thumb {
    width: 15px;
    height: 15px;
    appearance: none;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]:disabled {
    cursor: not-allowed;
    opacity: 0.25;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 500;
}

.check-row + .range-field, .range-field + .check-row {
    margin-top: 11px;
}

.check-row output {
    margin-left: auto;
}

input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--primary);
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.section-title span {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-main);
}

.section-title small {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
}

.dopant-control {
    margin: 10px 0 14px;
    padding-left: 9px;
    border-left: 2px solid var(--card-border);
}

.dopant-control.donor {
    border-color: var(--blue);
}

.dopant-control.acceptor {
    border-color: var(--red);
}

.dopant-control input[type="range"] {
    margin-top: 10px;
}

.ionization-controls {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 14px;
}

.ionization-controls.visible {
    display: grid;
}

.field-help {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.45;
}

#manual-ef-section {
    display: none;
}

#manual-ef-section.visible {
    display: block;
}

.display-options {
    display: grid;
    gap: 10px;
}

.display-options .section-title {
    margin-bottom: 0;
}

.occupation-controls {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--card-border);
}

.occupation-custom {
    display: none;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--card-radius);
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid var(--card-border);
}

.occupation-custom.visible {
    display: grid;
}

.width-scale-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    margin-top: 10px;
}

.width-scale-controls .text-button {
    min-height: 32px;
    white-space: nowrap;
}

.width-scale-controls .text-button:disabled {
    cursor: not-allowed;
    opacity: 0.35;
}

#occupation-scale-help.clipped {
    color: var(--warning);
}

.model-note {
    padding: 12px;
    border-radius: var(--card-radius);
    background: rgba(56, 189, 248, 0.05);
    border: 1px solid var(--primary-dark);
    margin-top: 14px;
}

.model-note strong {
    color: var(--primary);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.model-note p {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.5;
}

/* ========================================================================== */
/* STANDARDIZED FLAT SPLASH SCREEN POPUP                                      */
/* ========================================================================== */

.splash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
}

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

.splash-modal {
    width: 520px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-sizing: border-box;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius, 5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.65);
    animation: none;
}

[data-theme="light"] .splash-modal {
    box-shadow: 0 4px 20px rgba(70, 60, 50, 0.18);
}

.splash-header {
    text-align: center;
}

.splash-header h1,
.splash-header h2 {
    margin: 0 0 4px 0;
    font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-main);
    line-height: 1.25;
}

.splash-header .author {
    margin: 0;
    font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
    font-size: 0.80rem;
    font-weight: 500;
    color: var(--primary);
    line-height: 1.3;
}

.splash-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.splash-body h3 {
    margin: 0 0 4px 0;
    font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
    font-size: 0.88rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
}

.splash-body ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    margin: 0;
}

.splash-body li {
    font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    position: relative;
    padding-left: 18px;
}

.splash-body li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.splash-body strong {
    color: var(--text-main);
    font-weight: 600;
}

.splash-footer {
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

#splash-ok-btn {
    width: 100%;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #ffffff;
    border: 1px solid var(--primary-dark);
    border-radius: var(--card-radius, 5px);
    font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
    text-decoration: none;
}

#splash-ok-btn:hover {
    background: var(--primary-dark);
}

.btn {
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: var(--card-radius);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary-dark);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary);
}

/* ========================================================================== */
/* LABASSIST MODAL (Resizable, 5px Standard Radius)                           */
/* ========================================================================== */

/* ==========================================================================
   LABASSIST CARD AND DIALOGUE STYLES
   ========================================================================== */

.lab-assistant-card,
.lab-assistant-card button,
.lab-assistant-card input,
.lab-assistant-card select {
  font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
}

.lab-assistant-card ::selection,
.assistant-input::selection {
  background: rgba(56, 189, 248, 0.35);
  color: #ffffff;
}

[data-theme="light"] .lab-assistant-card ::selection,
[data-theme="light"] .assistant-input::selection {
  background: rgba(2, 132, 199, 0.25);
  color: #000000;
}

.lab-assistant-card {
  position: fixed;
  top: 60px;
  left: max(20px, calc(50vw - 310px));
  width: 620px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 80px);
  min-width: 320px;
  min-height: 280px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  padding: 14px 16px;
  gap: 10px;
  box-sizing: border-box;
  resize: both;
  overflow: hidden;
}

[data-theme="light"] .lab-assistant-card {
  box-shadow: 0 8px 24px rgba(70, 60, 50, 0.18);
}

.lab-assistant-card.hidden {
  display: none !important;
}

/* Corner Resizer Handle (Bottom-Right, Dual Diagonal Tactile Ridges) */
.lab-assistant-card::-webkit-resizer {
  background: transparent;
}

.lab-assistant-card::after {
  content: '';
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  pointer-events: none;
  background: linear-gradient(135deg,
      transparent 0%, transparent 40%,
      var(--text-subtle) 40%, var(--text-subtle) 50%,
      transparent 50%, transparent 70%,
      var(--text-subtle) 70%, var(--text-subtle) 80%,
      transparent 80%, transparent 100%);
  opacity: 0.65;
}

.assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--card-border);
  cursor: grab;
  user-select: none;
}

.assistant-header.is-dragging {
  cursor: grabbing;
}

.assistant-header a,
.assistant-header button {
  cursor: pointer;
  user-select: auto;
}

.assistant-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.assistant-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 5px;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.assistant-logo-icon:hover {
  background: var(--btn-hover-bg);
  border-color: var(--primary);
}

.assistant-title-block h3,
.assistant-title-row h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Close Button: Square with 5px Rounded Corners */
.hover-card-close-btn,
#close-assistant-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
  padding: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.hover-card-close-btn:hover,
#close-assistant-btn:hover {
  color: var(--text-main);
  background: var(--btn-hover-bg);
  border-color: var(--primary);
}

/* Starter Question Chips Ribbon */
.assistant-chips-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  padding: 4px 0;
}

.assistant-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 9px;
  box-sizing: border-box;
  font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 4px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.assistant-chip:hover {
  color: var(--text-main);
  background: var(--btn-hover-bg);
  border-color: var(--primary);
}

/* Scrollable Dialogue Log */
.assistant-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 4px 8px 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.assistant-welcome {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 12px 14px;
  color: var(--text-muted);
}

.assistant-welcome p {
  margin: 0 0 6px 0;
}

.assistant-welcome p:last-child {
  margin: 0;
}

/* Message Bubbles */
.assistant-message,
.assistant-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assistant-message.user,
.assistant-msg-user {
  align-items: flex-end;
}

.user-bubble,
.assistant-msg-user .msg-bubble {
  background: var(--primary-dark);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 5px;
  max-width: 85%;
  font-weight: 500;
  font-size: 0.80rem;
}

[data-theme="light"] .user-bubble,
[data-theme="light"] .assistant-msg-user .msg-bubble {
  background: var(--primary);
}

.assistant-message.assistant,
.assistant-msg-bot {
  align-items: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: 5px;
  padding: 10px 12px;
}

/* Assistant Thinking Indicator with 4 Scrolling / Pulsing Dots */
.assistant-message.assistant-thinking,
.assistant-thinking {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: 5px;
  width: fit-content;
}

.thinking-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 14px;
}

.thinking-dots span,
.thinking-dots .dot,
.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.3;
  animation: dot-wave 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1),
.thinking-dots .dot:nth-child(1),
.thinking-dot:nth-child(1) { animation-delay: 0.0s; }
.thinking-dots span:nth-child(2),
.thinking-dots .dot:nth-child(2),
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3),
.thinking-dots .dot:nth-child(3),
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }
.thinking-dots span:nth-child(4),
.thinking-dots .dot:nth-child(4),
.thinking-dot:nth-child(4) { animation-delay: 0.6s; }

@keyframes dot-wave {
  0%, 100% {
    transform: translateY(0) scale(0.85);
    opacity: 0.3;
  }
  30% {
    transform: translateY(-5px) scale(1.15);
    opacity: 1;
  }
  60% {
    transform: translateY(0) scale(0.95);
    opacity: 0.45;
  }
}

.assistant-reply-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 4px;
  width: 100%;
}

.assistant-reply-body,
.assistant-msg-bot .msg-bubble {
  color: var(--text-main);
}

.assistant-reply-body p,
.assistant-msg-bot .msg-bubble p {
  margin: 0 0 6px 0;
}

.assistant-reply-body p:last-child,
.assistant-msg-bot .msg-bubble p:last-child {
  margin: 0;
}

.assistant-reply-body ul,
.assistant-msg-bot .msg-bubble ul {
  margin: 4px 0 6px 0;
  padding-left: 18px;
}

.assistant-reply-body li,
.assistant-msg-bot .msg-bubble li {
  margin-bottom: 3px;
}

.assistant-reply-body code,
.assistant-msg-bot .msg-bubble code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Input Form */
.assistant-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--card-border);
  padding-top: 10px;
}

.prompt-symbol {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

.assistant-input,
.lab-assistant-card input[type="text"].assistant-input,
.assistant-form .assistant-input {
  flex: 1;
  width: 100%;
  max-width: 100%;
  text-align: left;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--card-radius);
  color: var(--text-main);
  padding: 7px 12px;
  font-size: 0.82rem;
  font-family: var(--font-family, 'Inter', system-ui, -apple-system, sans-serif);
  line-height: 1.4;
  outline: none;
  box-shadow: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.assistant-input:focus,
.lab-assistant-card input[type="text"].assistant-input:focus,
.assistant-form .assistant-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  outline: none;
}

[data-theme="light"] .assistant-input:focus,
[data-theme="light"] .lab-assistant-card input[type="text"].assistant-input:focus,
[data-theme="light"] .assistant-form .assistant-input:focus {
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 1px var(--primary-dark);
}

.assistant-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary-dark);
  border-radius: var(--card-radius);
  padding: 7px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.assistant-send-btn:hover {
  background: var(--primary-dark);
}

/* ========================================================================== */
/* RESPONSIVE BREAKPOINTS                                                     */
/* ========================================================================== */

@media (max-width: 1250px) {
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 980px) {
    body {
        overflow-y: auto;
        height: auto;
    }
    .app-shell {
        height: auto;
        overflow: visible;
    }
    .workstation-main {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
        margin-bottom: 24px;
    }
    .workspace {
        height: auto;
        overflow: visible;
    }
    .canvas-card {
        height: 560px;
        flex: none;
    }
    .controls {
        height: auto;
        max-height: none;
        overflow: visible;
        padding-bottom: 32px;
    }
}

@media (max-width: 640px) {
    .app-header {
        padding: 0 12px;
    }
    .header-meta {
        display: none;
    }
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .metric {
        min-height: 72px;
    }
    .canvas-card {
        height: 740px;
    }
    .plot-note {
        display: none !important;
    }
    .footer-status-text {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
