/* ─── Base ─────────────────────────────────────────────── */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #030712; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ─── Prose (lesson content) ───────────────────────────── */
.prose h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2rem 0 1rem;
  color: #f9fafb;
  border-bottom: 1px solid #1f2937;
  padding-bottom: 0.5rem;
}
.prose h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: #e5e7eb;
}
.prose p { margin: 0.75rem 0; line-height: 1.75; color: #d1d5db; }
.prose strong { color: #f9fafb; }
.prose em { color: #9ca3af; }
.prose ul { list-style: disc; padding-left: 1.5rem; margin: 0.75rem 0; }
.prose ol { list-style: decimal; padding-left: 1.5rem; margin: 0.75rem 0; }
.prose li { margin: 0.25rem 0; line-height: 1.6; color: #d1d5db; }
.prose code {
  background: #1f2937;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.875em;
  color: #60a5fa;
  font-family: ui-monospace, monospace;
}
.prose pre {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}
.prose pre code { background: none; padding: 0; color: #d1d5db; }

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}
.prose th {
  background: #1f2937;
  color: #9ca3af;
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid #374151;
}
.prose td {
  padding: 0.5rem 0.75rem;
  border: 1px solid #1f2937;
  color: #d1d5db;
}
.prose tr:nth-child(even) td { background: #0d1117; }

/* KaTeX display */
.prose .katex-display { margin: 1.25rem 0; overflow-x: auto; overflow-y: hidden; }
.prose .katex { color: #e5e7eb; }

/* ─── Callouts ─────────────────────────────────────────── */
.callout {
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  border-left: 4px solid;
  font-size: 0.9rem;
}
.callout-title {
  font-weight: 700;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.callout p { margin: 0.25rem 0; color: inherit; }

.callout-info  { background: #0c1a2e; border-color: #3b82f6; color: #93c5fd; }
.callout-tip   { background: #0a1f0a; border-color: #22c55e; color: #86efac; }
.callout-warning { background: #1f1500; border-color: #f59e0b; color: #fcd34d; }
.callout-danger  { background: #1f0a0a; border-color: #ef4444; color: #fca5a5; }
.callout-success { background: #0a1a0a; border-color: #10b981; color: #6ee7b7; }

/* ─── Formula box ──────────────────────────────────────── */
.formula-box {
  background: linear-gradient(135deg, #0c1a2e 0%, #0a1520 100%);
  border: 1px solid #1e40af;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  text-align: center;
}
.formula-box .formula-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #60a5fa;
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.formula-box .katex { font-size: 1.3em; }

/* ─── Animations ───────────────────────────────────────── */
@keyframes current-flow {
  0%   { stroke-dashoffset: 40; opacity: 0.4; }
  50%  { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0.4; }
}
.current-animated {
  stroke-dasharray: 10 5;
  animation: current-flow 1.5s linear infinite;
}
.current-animated-slow {
  stroke-dasharray: 8 4;
  animation: current-flow 2.5s linear infinite;
}

/* ─── Toast notifications ──────────────────────────────── */
.toast {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 240px;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: all;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}
.toast-xp { border-color: #3b82f6; }
.toast-badge { border-color: #f59e0b; }
.toast-success { border-color: #10b981; }

/* ─── Progress bar ─────────────────────────────────────── */
.xp-bar {
  height: 6px;
  background: #1f2937;
  border-radius: 3px;
  overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ─── Difficulty badges ────────────────────────────────── */
.badge-beginner     { background: #14532d; color: #86efac; }
.badge-intermediate { background: #1c3a6e; color: #93c5fd; }
.badge-advanced     { background: #4a1d96; color: #c4b5fd; }
.badge-pro          { background: #7f1d1d; color: #fca5a5; }

/* ─── Transition ───────────────────────────────────────── */
#app { transition: opacity 0.15s ease; }
#app.loading { opacity: 0; }

/* ─── 3D Lab viewer ─────────────────────────────────────── */
.lab3d-wrap {
  position: relative;
  width: 100%;
  height: 450px;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #0c1120;
  border: 1px solid #1f2937;
}
.lab3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.lab3d-canvas:active { cursor: grabbing; }
.lab3d-overlay {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
.lab3d-hint {
  background: rgba(0,0,0,0.55);
  color: #9ca3af;
  font-size: 0.7rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}
.lab3d-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(12,17,32,0.85);
  color: #9ca3af;
  font-size: 0.875rem;
}
.lab3d-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid #374151;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Virtual Lab ───────────────────────────────────────── */
.vlab-root {
  display: flex;
  height: 100%;
  background: #0c1120;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #1f2937;
}

.vlab-sidebar {
  width: 190px;
  flex-shrink: 0;
  background: #111827;
  border-right: 1px solid #1f2937;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.vlab-viewport {
  flex: 1;
  position: relative;
  min-width: 0;
}

.vlab-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.vlab-palette {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.vlab-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin: 0.1rem 0.25rem 0.2rem;
}

.vlab-tool-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  background: #1f2937;
  border: 1px solid transparent;
  color: #d1d5db;
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.vlab-tool-btn:hover  { background: #374151; }
.vlab-tool-btn.active { background: #1e3a5f; border-color: #3b82f6; color: #93c5fd; }

.vlab-tool-icon  { font-size: 1rem; line-height: 1; }
.vlab-tool-label { font-size: 0.7rem; }

.vlab-divider {
  border: none;
  border-top: 1px solid #1f2937;
  margin: 0.35rem 0;
}

.vlab-status {
  min-height: 1.8rem;
  font-size: 0.7rem;
  color: #9ca3af;
  padding: 0.2rem 0.25rem;
  border-radius: 4px;
  line-height: 1.4;
  transition: background 0.15s;
}
.vlab-status.active {
  background: #1a2b1a;
  color: #6ee7b7;
}

.vlab-sim-results {
  font-size: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.vlab-sim-row {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0.25rem;
  border-radius: 3px;
  background: #1f2937;
}
.vlab-sim-key  { color: #9ca3af; }
.vlab-sim-val  { color: #60a5fa; font-variant-numeric: tabular-nums; }
.vlab-sim-error { color: #f87171; font-size: 0.68rem; }
.vlab-sim-empty { color: #4b5563; font-size: 0.68rem; }

.vlab-clear-btn {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  background: #2d1515;
  border: 1px solid #4b1515;
  color: #f87171;
  font-size: 0.7rem;
  cursor: pointer;
  transition: background 0.15s;
}
.vlab-clear-btn:hover { background: #3d1f1f; }

.vlab-hint {
  margin-top: 0.5rem;
  font-size: 0.63rem;
  color: #4b5563;
  line-height: 1.5;
  padding: 0 0.25rem;
}
.vlab-hint kbd {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 3px;
  padding: 0 3px;
  font-size: 0.6rem;
}

/* ── Phase 2: params panel, editor, color picker ───────────────────────── */
.vlab-params-panel {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 6px;
  padding: 0.4rem 0.5rem 0.5rem;
  margin-top: 0.35rem;
}
.vlab-param-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.25rem;
}
.vlab-param-input {
  width: 80px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #f3f4f6;
  font-size: 0.72rem;
  padding: 2px 5px;
  outline: none;
}
.vlab-param-input:focus { border-color: #3b82f6; }
.vlab-param-unit {
  font-size: 0.68rem;
  color: #9ca3af;
}
.vlab-e12-select {
  width: 100%;
  margin-top: 0.3rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #d1d5db;
  font-size: 0.68rem;
  padding: 2px 4px;
  outline: none;
}
.vlab-e12-select:focus { border-color: #3b82f6; }
.vlab-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}
.vlab-quick-btn {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #9ca3af;
  font-size: 0.63rem;
  padding: 1px 5px;
  cursor: pointer;
  transition: background 0.15s;
}
.vlab-quick-btn:hover  { background: #374151; color: #f3f4f6; }
.vlab-quick-btn.active { background: #1e3a5f; border-color: #3b82f6; color: #93c5fd; }
.vlab-color-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}
.vlab-color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  padding: 0;
}
.vlab-color-dot:hover  { transform: scale(1.2); }
.vlab-color-dot.active { box-shadow: 0 0 0 2px #f3f4f6; transform: scale(1.15); }
.vlab-sel-type {
  font-size: 0.7rem;
  color: #93c5fd;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* ─── Exam mode ──────────────────────────────────────────── */
.exam-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}
.exam-filter-chip input[type="checkbox"] {
  accent-color: #3b82f6;
  width: 14px;
  height: 14px;
}
.exam-filter-chip span {
  font-size: 0.8rem;
  color: #d1d5db;
  user-select: none;
}
.exam-count-btn {
  cursor: pointer;
  font-size: 0.875rem;
}
.exam-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  text-align: left;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.exam-option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: #374151;
  color: #9ca3af;
  flex-shrink: 0;
}
.exam-option-idle {
  background: #1f2937;
  border-color: #374151;
  color: #d1d5db;
}
.exam-option-idle:hover {
  background: #263044;
  border-color: #3b82f6;
}
.exam-option-correct {
  background: #052e16;
  border-color: #22c55e;
  color: #86efac;
  cursor: default;
}
.exam-option-correct .exam-option-letter { background: #15803d; color: #f0fdf4; }
.exam-option-wrong {
  background: #2d0a0a;
  border-color: #ef4444;
  color: #fca5a5;
  cursor: default;
}
.exam-option-wrong .exam-option-letter { background: #991b1b; color: #fee2e2; }
.exam-option-disabled {
  background: #111827;
  border-color: #1f2937;
  color: #6b7280;
  cursor: default;
  opacity: 0.6;
}
.exam-feedback {
  padding: 0.875rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid transparent;
}
.exam-feedback-ok { background: #052e16; border-color: #22c55e; color: #86efac; }
.exam-feedback-ko { background: #2d0a0a; border-color: #ef4444; color: #fca5a5; }
