:root {
  --navy: #2c3e50;
  --softgray: #e9ecef;
  --teal: #1abc9c;
  --gold: #f1c40f;
  --slate: #556366;
  --coral: #e74c3c;
  --white: #ffffff;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;
  --max-width: 1120px;
  --radius: 10px;
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  color: var(--navy);
  background: linear-gradient(135deg, #ecf0f1 0%, #d6dbdf 100%);
  padding: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

/* ─── HEADER ─────────────────────────────── */

.page-header {
  text-align: center;
  color: var(--navy);
  padding: 1rem 1rem 0.5rem;
}

.page-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.page-subtitle {
  margin: 4px 0 12px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--slate);
}

.tag-chips {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(44, 62, 80, 0.08);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}

.chip--gold {
  background: rgba(241, 196, 15, 0.25);
  color: #856404;
}

/* ─── AIM PANEL ──────────────────────────── */

.aim-panel {
  border-left: 4px solid var(--teal);
  background: var(--white);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.aim-panel p { margin: 0; }

/* ─── EXPERIMENT AREA ────────────────────── */

.experiment-area {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 20px;
}

.rheostat-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--slate);
}

.cols {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── CANVAS ─────────────────────────────── */

.sim-area {
  background: var(--softgray);
  border-radius: 8px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.sim-area canvas {
  width: 100%;
  display: block;
  border-radius: 6px;
  background: #fff;
}

/* ─── CONTROLS ───────────────────────────── */

.controls {
  background: var(--white);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.control-group {
  margin-bottom: 20px;
}

.control-group:last-child { margin-bottom: 0; }

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--slate);
  font-weight: 600;
}

/* Power switch */

.switch-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: 2px solid var(--softgray);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  transition: border-color 0.2s;
  width: 100%;
}

.switch-btn:focus {
  outline: 3px solid rgba(26, 188, 156, 0.3);
  outline-offset: 2px;
}

.switch-track {
  position: relative;
  width: 50px;
  height: 26px;
  background: var(--softgray);
  border-radius: 13px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch-lever {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch-btn[aria-pressed="true"] .switch-track { background: var(--teal); }
.switch-btn[aria-pressed="true"] .switch-lever { transform: translateX(24px); }
.switch-btn[aria-pressed="true"] .switch-label { color: var(--teal); }

/* Core material buttons */

.core-btns {
  display: flex;
  gap: 8px;
}

.core-btn {
  flex: 1;
  padding: 10px 8px;
  border: 2px solid var(--softgray);
  border-radius: 8px;
  background: var(--white);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  transition: all 0.2s;
}

.core-btn:focus {
  outline: 3px solid rgba(26, 188, 156, 0.3);
  outline-offset: 2px;
}

.core-btn:hover { border-color: var(--teal); }

.core-btn.active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}

/* Turns stepper */

.turns-row {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
}

.step-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--softgray);
  border-radius: 50%;
  background: var(--white);
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
}

.step-btn:hover {
  border-color: var(--teal);
  background: rgba(26, 188, 156, 0.08);
}

.step-btn:focus {
  outline: 3px solid rgba(26, 188, 156, 0.3);
  outline-offset: 2px;
}

.turns-value {
  font-size: 2rem;
  font-weight: 700;
  min-width: 60px;
  text-align: center;
  color: var(--navy);
}

/* ─── DIVIDER ────────────────────────────── */

.divider {
  border: none;
  border-top: 1px solid var(--softgray);
  margin: 24px 0;
}

/* ─── GUIDED INVESTIGATION ───────────────── */

.guided-investigation {
  margin-top: 0;
}

.investigation-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  background: var(--white);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.2s;
}

.investigation-toggle:hover {
  background: var(--gray-200);
}

.investigation-toggle:focus {
  outline: 3px solid rgba(26, 188, 156, 0.3);
  outline-offset: 2px;
}

.toggle-arrow {
  transition: transform 0.25s ease;
}

.investigation-toggle[aria-expanded="true"] .toggle-arrow {
  transform: rotate(180deg);
}

.investigation-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  background: var(--white);
  border-radius: 0 0 8px 8px;
  padding: 0 16px;
}

.investigation-content.open {
  max-height: 800px;
  padding: 16px;
}

.investigation-content h4 {
  margin: 16px 0 8px;
  font-size: 15px;
  color: var(--navy);
}

.investigation-content h4:first-child { margin-top: 0; }

.investigation-content p,
.investigation-content li {
  font-size: 14px;
  line-height: 1.7;
  color: var(--slate);
}

.investigation-content ol,
.investigation-content ul {
  padding-left: 20px;
}

/* ─── FOOTER ─────────────────────────────── */

.site-footer {
  background: var(--navy);
  color: var(--white);
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  margin: 32px -16px -16px;
}

.site-footer p { margin: 0; }

/* ─── FOCUS OUTLINES ─────────────────────── */

a:focus,
button:focus,
input:focus {
  outline: 3px solid rgba(26, 188, 156, 0.3);
  outline-offset: 2px;
}

/* ─── RESPONSIVE ─────────────────────────── */

@media (min-width: 768px) {
  body { padding: 24px; }
  .container { padding: 0; }
  .cols { flex-direction: row; }
  .sim-area { flex: 2; }
  .controls { flex: 1; }
  .page-title { font-size: 2.25rem; }
}

@media (max-width: 767px) {
  .page-title { font-size: 1.5rem; }
  .core-btns { flex-direction: column; }
}
