* {
  box-sizing: border-box;
}

:root {
  --page: #eef2f7;
  --panel: #ffffff;
  --panel-strong: #e2e7ee;
  --ink: #172033;
  --muted: #5c687a;
  --line: #d3dae5;
  --teal: #1f7a8c;
  --teal-dark: #155767;
  --amber: #d99b16;
  --green: #2f8f5b;
  --shadow: 0 18px 44px rgba(23, 32, 51, 0.14);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--page);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.experiment-page {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 28px;
  margin-bottom: 26px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 830px;
  font-size: 34px;
  line-height: 1.18;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

p {
  color: var(--muted);
  line-height: 1.72;
}

p + p {
  margin-top: 12px;
}

.intro {
  max-width: 850px;
  margin-top: 14px;
  font-size: 16px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
  min-width: 240px;
}

.status-strip span {
  padding: 7px 10px;
  color: var(--teal-dark);
  background: #d8eef2;
  border: 1px solid #b8dbe2;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 370px;
  gap: 22px;
  align-items: start;
  margin-bottom: 24px;
}

.visual-panel,
.control-panel,
.info-panel,
.teacher-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.visual-panel {
  padding: 22px;
}

.control-panel {
  padding: 20px;
  background: var(--panel-strong);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading.compact {
  align-items: center;
}

.panel-heading p {
  margin-top: 6px;
  font-size: 14px;
}

.canvas-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: #6d4502;
  background: #fff1cc;
  border: 1px solid #e9c465;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.canvas-shell {
  width: 500px;
  max-width: 100%;
  margin: 0 auto;
}

#interferogram {
  width: 500px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  background: #000000;
  border: 1px solid #bac4d2;
  border-radius: 8px;
  box-shadow: 0 20px 48px rgba(23, 32, 51, 0.28);
}

.sample-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.sample-panel div {
  padding: 12px;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sample-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sample-panel strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.control-group {
  display: grid;
  gap: 9px;
}

.control-group + .control-group {
  margin-top: 18px;
}

label {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

output {
  font-variant-numeric: tabular-nums;
}

.dual-control {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  align-items: center;
}

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

input[type="number"] {
  width: 100%;
  height: 34px;
  padding: 0 8px;
  color: var(--ink);
  background: #f9fbfd;
  border: 1px solid #bfc8d6;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 20px;
  padding: 4px;
  background: #ccd4df;
  border-radius: 8px;
}

.segmented-control label {
  position: relative;
  display: block;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: block;
  padding: 9px 8px;
  text-align: center;
  color: #455366;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.segmented-control input:checked + span {
  color: #ffffff;
  background: var(--teal);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: #334155;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.button-grid button,
.preset-row button,
.text-button {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #b4bfce;
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.button-grid button:hover,
.preset-row button:hover,
.text-button:hover {
  border-color: var(--teal);
}

.button-grid button:first-child {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.text-button {
  min-height: 32px;
  color: var(--teal-dark);
  background: #eef8fa;
  border-color: #b8dbe2;
}

.live-readout {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #c2cad6;
}

.live-readout h2 {
  font-size: 16px;
}

.live-readout dl,
.formula-values {
  display: grid;
  gap: 8px;
  margin: 0;
}

.live-readout dl {
  margin-top: 8px;
}

.live-readout dl div,
.formula-values div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(104, 116, 135, 0.2);
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.teacher-board {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

.experiment-page:not(.teacher-mode-enabled) .teacher-board,
.experiment-page:not(.teacher-mode-enabled) .quiz-panel {
  display: none;
}

.teacher-card {
  padding: 20px;
}

.teacher-card ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.teacher-readout {
  display: grid;
  gap: 8px;
  margin: 0;
}

.teacher-readout div {
  display: grid;
  gap: 4px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.misconception-card {
  border-left: 5px solid var(--amber);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px;
}

.site-footer {
  margin-top: 24px;
  padding: 18px 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.site-footer p {
  font-size: 13px;
  line-height: 1.6;
}

.site-footer p + p {
  margin-top: 4px;
}

.info-panel {
  padding: 22px;
}

.info-panel:nth-child(1),
.info-panel:nth-child(2),
.info-panel:nth-child(3) {
  grid-column: span 2;
}

.workflow-panel {
  grid-column: span 2;
}

.data-panel {
  grid-column: span 4;
}

.quiz-panel,
.report-panel {
  grid-column: span 3;
}

.formula-block {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: #f2f7f8;
  border-left: 4px solid var(--teal);
  border-radius: 7px;
}

.formula-block p {
  color: var(--ink);
  line-height: 1.55;
}

.model-diagram {
  width: 100%;
  height: auto;
  margin-bottom: 14px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.diagram-ray {
  stroke: var(--amber);
  stroke-width: 4;
  fill: none;
  marker-end: url("#arrow");
}

.diagram-return {
  stroke: var(--teal);
  stroke-dasharray: 8 7;
}

.diagram-source {
  fill: #ffd166;
  stroke: #ad7800;
  stroke-width: 3;
}

.diagram-splitter {
  fill: rgba(31, 122, 140, 0.24);
  stroke: var(--teal);
  stroke-width: 3;
}

.diagram-mirror {
  fill: #d5dae3;
  stroke: #58677a;
  stroke-width: 3;
}

.diagram-screen {
  fill: #ffffff;
  stroke: var(--ink);
  stroke-width: 3;
}

.diagram-angle {
  fill: none;
  stroke: #7d5ab6;
  stroke-width: 3;
}

.diagram-label,
.diagram-note {
  fill: #243044;
  font-size: 16px;
  font-weight: 700;
}

.diagram-note {
  fill: var(--muted);
  font-size: 14px;
}

.workflow-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.quiz-question {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.quiz-question legend {
  padding: 0 4px;
  color: var(--ink);
  font-weight: 700;
}

.quiz-question label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--muted);
  font-weight: 600;
}

.quiz-feedback,
.copy-status {
  min-height: 24px;
  color: var(--teal-dark);
  font-weight: 700;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.report-label {
  display: block;
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 12px;
  color: var(--ink);
  background: #f9fbfd;
  border: 1px solid #bfc8d6;
  border-radius: 8px;
  line-height: 1.55;
}

textarea + textarea {
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: #435066;
  background: #f3f6fa;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1100px) {
  .page-header {
    display: block;
  }

  .status-strip {
    justify-content: start;
    margin-top: 16px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-width: 620px;
    margin: 0 auto;
  }

  .content-grid {
    grid-template-columns: 1fr 1fr;
  }

  .teacher-board {
    grid-template-columns: 1fr;
  }

  .info-panel:nth-child(1),
  .info-panel:nth-child(2),
  .info-panel:nth-child(3),
  .workflow-panel,
  .data-panel,
  .quiz-panel,
  .report-panel {
    grid-column: span 1;
  }

  .data-panel {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .experiment-page {
    width: min(100vw - 20px, 1220px);
    padding: 24px 0 40px;
  }

  h1 {
    font-size: 27px;
  }

  .visual-panel,
  .control-panel,
  .info-panel {
    padding: 16px;
  }

  .sample-panel,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .data-panel {
    grid-column: span 1;
  }

  .mini-actions {
    justify-content: start;
  }

  .dual-control {
    grid-template-columns: 1fr;
  }

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

  .live-readout dl div,
  .formula-values div {
    display: grid;
    gap: 4px;
  }
}
