:root {
  color-scheme: light;
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-soft: #f0fdfa;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #ccfbf1;
  --accent: #0284c7;
  --accent-light: #e0f2fe;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 25px -5px rgba(13, 148, 136, 0.15);
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-main: #091319;
  --bg-surface: #10202c;
  --bg-card: #132736;
  --bg-soft: rgba(13, 148, 136, 0.15);
  --border-color: #1e3a4e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --primary-light: rgba(45, 212, 191, 0.2);
  --accent: #38bdf8;
  --accent-light: rgba(56, 189, 248, 0.2);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.2);
  --success: #22c55e;
  --success-light: rgba(34, 197, 94, 0.2);
  --danger: #f87171;
  --danger-light: rgba(248, 113, 113, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
}

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

body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
}

.brand-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.brand-nav a:hover {
  color: var(--primary);
}

.badge-tag {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}

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

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

/* CONTAINER */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* HERO SECTION */
.hero-card {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08) 0%, rgba(2, 132, 199, 0.05) 100%);
  border: 1px solid var(--border-color);
  border-left: 6px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.hero-eyebrow {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.hero-lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 820px;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.tag-list {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* SECTION CARD */
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.schedule-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.schedule-pill {
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
}

/* CALLOUTS */
.notice-box {
  background: var(--bg-soft);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.95rem;
}

.warning-box {
  background: var(--warning-light);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.92rem;
  color: var(--text-main);
}

/* GRIDS */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin: 1.25rem 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.25rem 0;
}

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

.concept-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.concept-card h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.45rem;
}

/* HYDRAULIC ANALOGY SECTION */
.analogy-container {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.06) 0%, rgba(13, 148, 136, 0.06) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin: 1.5rem 0;
}

.analogy-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
  align-items: center;
}

@media (max-width: 860px) {
  .analogy-grid {
    grid-template-columns: 1fr;
  }
}

.analogy-canvas-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.analogy-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.analogy-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.9rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.analogy-stat strong {
  color: var(--primary);
}

/* CIRCUIT BENCH VIRTUAL */
.lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.25rem 0;
}

@media (max-width: 860px) {
  .lab-grid {
    grid-template-columns: 1fr;
  }
}

.bench-controls {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.bench-display {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.circuit {
  border: 3px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--bg-surface);
  transition: all 0.3s ease;
}

.circuit span {
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.88rem;
}

.bench.active .circuit {
  border: 3px solid var(--primary);
  box-shadow: 0 0 15px rgba(13, 148, 136, 0.2);
}

.reading {
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-top: 1.25rem;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-main);
}

/* FORM CONTROLS & RANGE */
label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.92rem;
  margin: 0.75rem 0 0.4rem;
}

input[type="range"] {
  width: 100%;
  height: 8px;
  accent-color: var(--primary);
  border-radius: 999px;
  cursor: pointer;
}

input:not([type="range"]), textarea {
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 0.65rem 0.9rem;
  transition: border-color 0.2s;
}

input:not([type="range"]):focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

textarea {
  min-height: 90px;
  resize: vertical;
}

/* DETAILS & ACCORDIONS */
details {
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.15rem;
  margin: 0.85rem 0;
  transition: background 0.2s;
}

details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--primary);
}

details p {
  margin-top: 0.5rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

/* CHALLENGES LIST */
#challenges article {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

#challenges h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.feedback {
  min-height: 1.75em;
  font-weight: 700;
  font-size: 0.92rem;
  margin-top: 0.5rem;
  color: var(--primary);
}

/* SERIES & PARALLEL INTERACTIVE CALCULATOR */
.calc-resistors-box {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin: 1.5rem 0;
}

.calc-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.calc-btn-toggle {
  flex: 1;
  padding: 0.65rem 1rem;
  font-weight: 700;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.calc-btn-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.calc-diagram-view {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

/* PROJECTOR MODE */
body.projector-mode {
  background: var(--bg-surface);
}

body.projector-mode .topbar,
body.projector-mode footer {
  background: var(--bg-surface);
}

body.projector-mode .container {
  max-width: 1400px;
}

body.projector-mode .section-card,
body.projector-mode .hero-card {
  font-size: 1.15rem;
  padding: 2.5rem;
}

body.projector-mode h1,
body.projector-mode h2 {
  font-size: 2.25rem;
}

/* PRINT STYLES */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10.5pt;
  }
  .topbar, button, #reset-lab, #reset-answers, #progress, .feedback, details {
    display: none !important;
  }
  .section-card, .hero-card, article {
    border: 1px solid #94a3b8 !important;
    box-shadow: none !important;
    break-inside: avoid;
    padding: 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }
  input, textarea {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #cbd5e1 !important;
  }
  .katex-display {
    overflow: visible !important;
  }
}

footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 2rem;
}
