/* === Classical Stark Effect — Dark Scientific UI === */

:root {
  --bg-base: #0f1117;
  --bg-surface: #1a1d24;
  --bg-elevated: #22252e;
  --border: #2e3240;
  --border-focus: #5591c7;
  --text-primary: #c8cad0;
  --text-secondary: #8b8f9a;
  --text-muted: #5c6070;
  --accent: #5591c7;
  --accent-dim: #3a6a9e;
  --green: #4caf7a;
  --red: #e05555;
  --yellow: #d4a940;
  --magenta: #c06abb;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 8px;
  --radius-sm: 4px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.app-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 12px 24px;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon { flex-shrink: 0; }
.header-title h1 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #e8eaef;
}
.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-weight: 400;
}

/* Main layout */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}
.sim-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  margin-bottom: 40px;
}

/* Plot */
.plot-section {
  min-width: 0;
}
.plot-container {
  width: 100%;
  height: 560px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Controls panel */
.controls-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: fit-content;
  position: sticky;
  top: 20px;
}
.panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

/* Slider controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.control-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--text-primary);
  font-weight: 500;
}
.control-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  min-width: 50px;
  text-align: right;
}

/* Range slider styling */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-base);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px rgba(85, 145, 199, 0.25);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-base);
  cursor: pointer;
}

/* Buttons */
.button-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary.running {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #1a1d24;
}
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border); }

/* Readout */
.readout-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}
.readout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.readout-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.readout-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.readout-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}
.readout-status {
  grid-column: 1 / -1;
}
.readout-status .readout-value {
  font-size: 0.8rem;
}
.readout-status .readout-value.bound { color: var(--green); }
.readout-status .readout-value.ionized { color: var(--red); }
.readout-status .readout-value.computing { color: var(--yellow); }

/* Physics section */
.physics-section {
  max-width: 800px;
}
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e8eaef;
  margin-bottom: 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.physics-block {
  margin-bottom: 28px;
}
.physics-block h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}
.physics-block p {
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.7;
}
.physics-block .MathJax {
  color: #e8eaef !important;
}
.credit-block {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 32px;
}
.credit-block p {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 1400px;
  margin: 0 auto;
}
.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.app-footer a:hover { color: var(--accent); }

/* Responsive */
@media (max-width: 900px) {
  .sim-layout {
    grid-template-columns: 1fr;
  }
  .controls-panel {
    position: static;
  }
  .plot-container {
    height: 400px;
  }
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

@media (max-width: 480px) {
  .app-main { padding: 12px 12px 32px; }
  .plot-container { height: 320px; }
  .controls-panel { padding: 14px; }
  .readout-grid { grid-template-columns: 1fr; }
  .app-footer { flex-direction: column; gap: 4px; text-align: center; }
  html { font-size: 14px; }
}

/* WebGL warning banner */
.webgl-banner {
  background: #2a1f0e;
  border-bottom: 1px solid #6b4f1a;
  padding: 10px 24px;
}
.banner-inner {
  max-width: 1400px;
  margin: 0 auto;
  font-size: 0.82rem;
  color: #e8c76a;
  line-height: 1.5;
  position: relative;
  padding-right: 32px;
}
.banner-inner em { color: #f0d680; }
.banner-inner strong { color: #f0d680; }
.banner-close {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  color: #8b7a4a;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.banner-close:hover { color: #e8c76a; }

/* Projection plane controls (2D fallback) */
.projection-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.proj-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}
.proj-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.proj-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.proj-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Technology section code styling */
.tech-section code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
  color: #c8cad0;
}
.tech-section a {
  text-decoration: none;
  transition: opacity 0.15s;
}
.tech-section a:hover { opacity: 0.8; }

/* MathJax overrides for dark theme */
mjx-container {
  color: #e8eaef !important;
}
/* Prevent MathJax display equations from overflowing on mobile */
mjx-container[jax="CHTML"][display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}
.physics-block p {
  overflow-wrap: break-word;
}
