:root {
  --page: #ececec;
  --panel: #ffffff;
  --panel-alt: #f5f5f5;
  --border: #a9a9a9;
  --border-dark: #666666;
  --text: #222222;
  --muted: #666666;
  --blue: #276ca8;
  --blue-light: #e8f2fa;
  --green: #2c7a45;
  --green-light: #eaf5ed;
  --orange: #9a5b13;
  --orange-light: #fff3df;
  --red: #a23030;
  --red-light: #fdeaea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--page);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 600;
}

h2 {
  font-size: 18px;
  font-weight: 600;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 32px;
  background: #ffffff;
  border-bottom: 2px solid var(--border-dark);
}

.eyebrow,
.kicker {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.equation {
  display: flex;
  gap: 24px;
  padding: 9px 13px;
  color: var(--text);
  background: #f4f4f4;
  border: 1px solid var(--border);
  font-family: "Times New Roman", Times, serif;
  font-size: 17px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(245px, 285px) minmax(500px, 1fr) minmax(245px, 285px);
  gap: 14px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
}

.controls-panel,
.readings-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 9px;
  border-bottom: 1px solid #d1d1d1;
}

.step-number {
  display: none;
}

.control {
  display: block;
  margin-bottom: 22px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.label-row strong,
output {
  padding: 3px 6px;
  color: var(--text);
  background: #f3f3f3;
  border: 1px solid #b8b8b8;
  font-size: 13px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

select {
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid #888888;
  border-radius: 2px;
  font: inherit;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  appearance: none;
  background: linear-gradient(90deg, var(--blue) var(--fill, 50%), #c8c8c8 var(--fill, 50%));
  border: 1px solid #8c8c8c;
  border-radius: 0;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 20px;
  appearance: none;
  background: #eeeeee;
  border: 1px solid #555555;
  border-radius: 2px;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 18px;
  background: #eeeeee;
  border: 1px solid #555555;
  border-radius: 2px;
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button {
  padding: 8px 10px;
  color: #ffffff;
  background: var(--blue);
  border: 1px solid #174e7c;
  border-radius: 2px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #1f5d90;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid #111111;
  outline-offset: 2px;
}

button.secondary {
  color: var(--text);
  background: #eeeeee;
  border-color: #888888;
}

button.secondary:hover {
  background: #dedede;
}

button span + span {
  margin-left: 5px;
}

.hint-card,
.principle-card {
  display: flex;
  gap: 9px;
  margin-top: 18px;
  padding: 10px;
  color: #333333;
  background: #f4f7f9;
  border: 1px solid #b6c4ce;
  font-size: 12px;
  line-height: 1.45;
}

.hint-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #ffffff;
  background: var(--blue);
  border-radius: 50%;
  font-weight: 600;
}

.simulation-panel {
  min-width: 0;
  overflow: hidden;
}

.sim-heading {
  margin: 0 18px;
  padding: 17px 0 9px;
}

.sim-heading .status-pill {
  margin-left: auto;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  color: var(--green);
  background: var(--green-light);
  border: 1px solid #8eb99b;
  font-size: 12px;
  font-weight: 600;
}

.status-pill span {
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.status-pill.blocked {
  color: var(--red);
  background: var(--red-light);
  border-color: #d4a0a0;
}

.status-pill.stopped {
  color: var(--orange);
  background: var(--orange-light);
  border-color: #d3b181;
}

.chamber-wrap {
  padding: 0 18px 18px;
}

#simulationSvg {
  display: block;
  width: 100%;
  height: auto;
  background: #fafafa;
  border: 1px solid #c8c8c8;
}

.svg-label {
  fill: #222222;
  font: 600 12px Arial, sans-serif;
}

.svg-small {
  fill: #555555;
  font: 400 10px Arial, sans-serif;
}

.meter-label {
  fill: #555555;
  font: 400 9px Arial, sans-serif;
}

.meter-value {
  fill: #1f6638;
  font: 600 18px Arial, sans-serif;
}

.field-label {
  fill: #8a4d0f;
  font: 600 10px Arial, sans-serif;
}

.polarity {
  fill: #222222;
  font: 600 22px Arial, sans-serif;
}

#lampBulb,
.photon,
.electron {
  filter: none;
}

.explanation-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  margin-top: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--green-light);
  border: 1px solid #8eb99b;
}

.explanation-banner.warning {
  background: var(--orange-light);
  border-color: #d3b181;
}

.explanation-banner.blocked {
  background: var(--red-light);
  border-color: #d4a0a0;
}

.banner-symbol {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  color: #ffffff;
  background: var(--green);
  border-radius: 50%;
  font-weight: 600;
}

.warning .banner-symbol {
  background: var(--orange);
}

.blocked .banner-symbol {
  background: var(--red);
}

.explanation-banner strong {
  font-size: 13px;
}

.explanation-banner p {
  margin-top: 3px;
  color: #555555;
  font-size: 12px;
}

.reading-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.reading {
  min-width: 0;
  padding: 10px;
  background: #f7f7f7;
  border: 1px solid #bcbcbc;
}

.reading.primary {
  background: var(--blue-light);
  border-color: #8cb3d1;
}

.reading span {
  display: block;
  min-height: 30px;
  color: #555555;
  font-size: 12px;
  line-height: 1.25;
}

.reading strong {
  font-size: 23px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.reading small {
  margin-left: 3px;
  color: var(--muted);
  font-size: 11px;
}

.current-reading strong {
  color: var(--green);
}

.energy-card {
  margin-top: 14px;
  padding: 11px;
  background: #f7f7f7;
  border: 1px solid #bcbcbc;
}

.energy-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #333333;
  font-size: 12px;
}

.energy-header span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.energy-bar {
  display: flex;
  height: 12px;
  margin: 11px 0 8px;
  overflow: hidden;
  background: #d2d2d2;
  border: 1px solid #999999;
}

.energy-bar span {
  height: 100%;
  transition: width 0.2s;
}

.work-bar {
  background: #477eb4;
}

.kinetic-bar {
  background: #d78436;
}

.energy-key {
  display: flex;
  gap: 14px;
  color: #555555;
  font-size: 11px;
}

.energy-key i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
}

.work-dot {
  background: #477eb4;
}

.kinetic-dot {
  background: #d78436;
}

.principle-card {
  display: block;
}

.principle-card p:last-child {
  color: #333333;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 260px 1fr;
  }

  .readings-panel {
    grid-column: 1 / -1;
  }

  .reading-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .reading span {
    min-height: 33px;
  }
}

@media (max-width: 780px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .equation {
    width: 100%;
    justify-content: space-between;
    font-size: 15px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .readings-panel {
    grid-column: auto;
  }

  .controls-panel {
    order: 2;
  }

  .simulation-panel {
    order: 1;
  }

  .readings-panel {
    order: 3;
  }

  .reading-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sim-heading {
    align-items: flex-start;
  }

  footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
