/*
 * Electron Beam Simulator - Scientific Workstation Design System (Version 2.0)
 * Author: Dr. Gerard Joseph Lim
 * Website: https://www.gerardjosephlim.com
 * Parent Standard: DESIGN_SYSTEM.md & LABASSIST_DESIGN_SYSTEM.md
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

: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 (Strict 5px Radius, Zero Bloom/Glow) */
    --card-bg: #0d1322;
    --card-border: #1e293b;
    --card-border-light: #334155;
    --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    --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;

    /* Workstation Framing Tokens */
    --header-height: 52px;
    --spacing-header-gap: 16px;
    --spacing-footer-gap: 16px;
    --spacing-viewport-edge: 20px;
}

[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 */
    --card-bg: #e8e2d5;
    --card-border: rgba(70, 60, 50, 0.25);
    --card-border-light: rgba(70, 60, 50, 0.4);
    --card-shadow: 0 4px 20px rgba(255, 255, 255, 0.95), 0 1px 4px rgba(255, 255, 255, 0.85);

    /* 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;
}

/* Base Reset */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
}

#simulation-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-color);
}

#simulationCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

/* ========================================================================== */
/* TOP DOCKED HEADER (52px)                                                   */
/* ========================================================================== */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--spacing-viewport-edge);
    z-index: 200;
}

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

.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;
    color: var(--text-main);
    transition: opacity 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}

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

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

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

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

.header-title-block h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    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 {
    color: var(--text-subtle);
}

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

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

.theme-btn, .assistant-btn, .help-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);
    padding: 0;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

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

.assistant-btn.active {
    background: #1e40af;
    color: #ffffff;
    border-color: #3b82f6;
}

[data-theme="light"] .assistant-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #1d4ed8;
}

/* ========================================================================== */
/* CHASSIS CARDS (5px Precision Standard)                                     */
/* ========================================================================== */

.chassis-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    color: var(--text-main);
    overflow: hidden;
    transition: none; /* Instant appearance */
}

/* Elevated Popups: Left Telemetry HUD Card */
.telemetry-card {
    position: fixed;
    top: calc(var(--header-height) + var(--spacing-header-gap));
    left: var(--spacing-viewport-edge);
    width: 280px;
    padding: 16px;
    z-index: 100;
    max-height: calc(100vh - var(--header-height) - 16px - 100px);
    overflow-y: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}

.panel-header h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.panel-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.telemetry-badge {
    font-size: 0.70rem;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: var(--card-radius);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-wien {
    background: rgba(52, 211, 153, 0.18);
    color: #10b981;
    border: 1px solid rgba(52, 211, 153, 0.4);
}

.badge-blocked {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.telemetry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.telemetry-item {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--card-radius);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.item-label {
    font-size: 0.70rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.item-val {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
}

.item-val.highlight {
    color: var(--primary);
}

.item-val.sub {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Elevated Popups: Right Hardware Properties Panel */
.property-panel {
    position: fixed;
    top: calc(var(--header-height) + var(--spacing-header-gap));
    right: var(--spacing-viewport-edge);
    width: 290px;
    padding: 16px;
    z-index: 100;
    max-height: calc(100vh - var(--header-height) - 16px - 100px);
    overflow-y: auto;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--card-radius);
}

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

.metric-meta-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--card-radius);
    padding: 6px 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.ctrl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.ctrl-row label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.value-display {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
}

.mt-3 {
    margin-top: 12px;
}

.action-btn-row {
    display: flex;
    gap: 8px;
}

.w-full {
    width: 100%;
}

/* Range Inputs */
input[type="range"] {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--input-border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin: 6px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid var(--card-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s ease;
}

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

/* ========================================================================== */
/* FULL-WIDTH DOCKED FOOTER                                                   */
/* ========================================================================== */

.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    border-top: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    padding: 10px var(--spacing-viewport-edge);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
}

.footer-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}

.control-group-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.footer-sep {
    width: 1px;
    height: 24px;
    background: var(--card-border);
    margin: 0 4px;
}

.footer-portfolio-link {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
    padding-top: 2px;
}

.footer-portfolio-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ========================================================================== */
/* BUTTONS & TOGGLE CONTROLS                                                  */
/* ========================================================================== */

.btn {
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--card-radius);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    user-select: none;
}

.btn:hover {
    background: var(--btn-hover-bg);
    border-color: var(--card-border-light);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.80rem;
}

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

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

[data-theme="light"] .btn-primary {
    color: #ffffff;
}

.btn-secondary {
    background: var(--btn-bg);
    border-color: var(--btn-border);
    color: var(--text-main);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: var(--error);
}

.btn-danger:hover {
    background: var(--error);
    border-color: var(--error);
    color: #ffffff;
}

/* Particle species toggle group */
.toggle-group {
    display: inline-flex;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--card-radius);
    padding: 2px;
    gap: 2px;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.toggle-btn.active {
    background: var(--btn-bg);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

#btn-type-electron.active {
    color: var(--primary);
}

#btn-type-positron.active {
    color: var(--positive);
}

.ctrl-slider-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--card-radius);
    padding: 4px 8px;
}

.toggle-label {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.ctrl-slider-group input[type="range"] {
    width: 75px;
    margin: 0;
}

/* Grid toggle switch */
.grid-toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--btn-border);
    transition: 0.2s;
    border-radius: 10px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(14px);
}

/* ========================================================================== */
/* FLAT INSTRUCTIONS MODAL                                                    */
/* ========================================================================== */

.splash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    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;
}

#get-started-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;
}

#get-started-btn:hover {
    background: var(--primary-dark);
}

/* ========================================================================== */
/* LABASSIST MODAL CARD (Draggable, Resizable, 5px Precision Standard)        */
/* ========================================================================== */

/* ==========================================================================
   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);
}

/* ========================================================================== */
/* FLOATING DELAYED HOVER TOOLTIP FOR BEAM TELEMETRY                          */
/* ========================================================================== */

.metric-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    max-width: 340px;
    padding: 11px 15px;
    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-family);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

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

.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;
    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 MathML Typography */
math {
    font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Cambria", "Times New Roman", serif;
    font-size: 1.05em;
    letter-spacing: 0.01em;
    font-style: normal;
    color: var(--text-main);
}

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

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

.math-eq-row {
    margin: 4px 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .telemetry-card {
        top: 58px;
        left: 10px;
        width: calc(100vw - 20px);
        max-height: 220px;
    }
    .property-panel {
        top: 290px;
        right: 10px;
        left: 10px;
        width: calc(100vw - 20px);
    }
    .lab-assistant-card {
        top: 56px;
        left: 8px;
        width: calc(100vw - 16px);
        height: 70vh;
    }
}
