:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #586273;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --line: #d8e0ea;
  --blue: #1769aa;
  --teal: #087f8c;
  --amber: #f4a62a;
  --red: #c33b32;
  --green: #267a4a;
  --shadow: 0 18px 45px rgba(25, 40, 60, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 520px);
  gap: 32px;
  align-items: center;
  min-height: 72vh;
  padding: 48px clamp(20px, 5vw, 72px) 36px;
  background: linear-gradient(135deg, #f8fbff 0%, #e7f2f5 48%, #fff7e5 100%);
  border-bottom: 1px solid var(--line);
}

.app-header img {
  width: 100%;
  aspect-ratio: 1.45;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.header-copy {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  max-width: 780px;
  font-size: clamp(2.1rem, 5vw, 4.6rem);
  line-height: 1.03;
  letter-spacing: 0;
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.2rem;
}

.learning-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto;
}

.module-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  background: rgba(247, 249, 251, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.nav-item {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-item:hover,
.nav-item:focus-visible {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.nav-item.active {
  background: var(--blue);
  color: #fff;
}

.module {
  display: none;
  padding: 34px 0 16px;
}

.module.active {
  display: block;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  letter-spacing: 0;
}

.two-column,
.interactive-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 22px;
  align-items: stretch;
}

.text-panel,
.note-panel,
.canvas-panel,
.image-panel,
.match-panel,
.quiz fieldset,
.simulator {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(25, 40, 60, 0.07);
}

.text-panel,
.note-panel,
.match-panel {
  padding: 24px;
}

.note-panel ul {
  margin: 0;
  padding-left: 22px;
}

.note-panel li + li {
  margin-top: 8px;
}

.fact-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.fact-strip span {
  padding: 8px 12px;
  border-radius: 6px;
  background: #fff1d2;
  color: #6b4300;
  font-weight: 700;
}

.image-panel {
  margin: 0;
  overflow: hidden;
}

.image-panel img {
  display: block;
  width: 100%;
  height: min(360px, 55vw);
  object-fit: contain;
  background: #fff;
}

.image-panel figcaption {
  padding: 12px 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.canvas-panel {
  padding: 16px;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1.81;
  border-radius: 6px;
  background: #fbfdff;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 14px;
}

.control-row label,
.controls-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

input[type="range"] {
  accent-color: var(--teal);
}

.icon-button,
.primary-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.icon-button {
  width: 44px;
  height: 44px;
  background: var(--amber);
  color: #1f1706;
}

.primary-button {
  min-height: 44px;
  padding: 0 16px;
  background: var(--blue);
  color: #fff;
}

.simulator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  padding: 24px;
}

.magnet-stage {
  display: grid;
  place-items: center;
  min-height: 320px;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #edf6f8 68%, #e6edf4 100%);
}

.core {
  width: min(80%, 520px);
  height: 74px;
  border-radius: 6px;
  background: linear-gradient(90deg, #1d76bd 0 48%, #f3f5f7 48% 52%, #c43e35 52% 100%);
  box-shadow: 0 0 0 var(--glow, 18px) rgba(8, 127, 140, 0.13);
}

.coil {
  width: min(72%, 460px);
  height: 116px;
  margin-top: -95px;
  background: repeating-linear-gradient(90deg, transparent 0 22px, rgba(28, 32, 42, 0.82) 22px 26px, transparent 26px 44px);
  border-radius: 999px;
  border: 3px solid rgba(28, 32, 42, 0.75);
}

.spark-meter {
  width: min(78%, 520px);
  height: 14px;
  margin-top: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce5ee;
}

.spark-meter span {
  display: block;
  width: 48%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--amber), var(--red));
}

.strength-label {
  margin: 10px 0 0;
  font-weight: 700;
}

.controls-panel {
  display: grid;
  align-content: center;
  gap: 18px;
}

.match-list {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(180px, 1.3fr);
  gap: 10px;
  align-items: center;
}

.match-row label {
  font-weight: 700;
}

.match-row select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.feedback {
  min-height: 28px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.feedback.success {
  color: var(--green);
}

.feedback.warn {
  color: var(--red);
}

.quiz {
  display: grid;
  gap: 14px;
}

.quiz fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 20px;
}

.quiz legend {
  padding: 0 6px;
  font-weight: 700;
}

.quiz label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.large {
  font-size: 1.1rem;
}

.app-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 36px;
  color: var(--muted);
}

@media (max-width: 860px) {
  .app-header,
  .two-column,
  .interactive-grid,
  .simulator {
    grid-template-columns: 1fr;
  }

  .app-header {
    min-height: auto;
    padding-top: 32px;
  }

  .module-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .match-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .module-nav {
    grid-template-columns: 1fr;
    position: static;
  }

  .learning-shell {
    width: min(100% - 20px, 1180px);
  }

  .text-panel,
  .note-panel,
  .match-panel,
  .simulator {
    padding: 18px;
  }
}
