:root {
  --green: #22c670;
  --night: #061914;
  --ink: #18362c;
  --muted: #526b61;
  --line: #cfe2d8;
  --cream: #f3f9f5;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button,
select,
input[type="number"],
input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 36px;
}
button {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
button:hover {
  background: #e5f6ec;
  border-color: #70bd95;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: #167d50;
  color: white;
  border-color: #167d50;
}
button.primary:hover {
  background: #11663f;
}
button[aria-pressed="true"] {
  background: #d7f3e3;
  border-color: #167d50;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 3px solid #bd791a;
  outline-offset: 3px;
}
select {
  padding: 4px 8px;
}
a {
  color: #13744c;
}
label {
  font-size: 12px;
  font-weight: 600;
}
input[type="range"] {
  accent-color: #13824f;
  width: 100%;
  min-width: 40px;
  cursor: pointer;
}
input[type="number"] {
  width: 100px;
  padding: 4px 7px;
  font-variant-numeric: tabular-nums;
}
input[type="text"] {
  padding: 6px 8px;
}
kbd {
  font: 10px system-ui;
  margin-left: 6px;
  border: 1px solid #ffffff55;
  padding: 1px 4px;
  border-radius: 3px;
}
h1,
h2,
p {
  margin: 0;
}
.lab {
  height: 100vh;
  height: 100dvh;
  min-height: 540px;
  display: grid;
  grid-template-rows: auto auto auto minmax(160px, 1fr) auto auto;
  gap: 10px;
  padding: 0 18px 12px;
  max-width: 2400px;
  margin: auto;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  min-height: 62px;
}
.brand {
  display: flex;
  width: 91px;
  flex-shrink: 0;
}
.brand img {
  width: 100%;
  object-fit: contain;
  max-height: 42px;
}
.lab-name {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}
.lab-name span {
  font-weight: 450;
  color: var(--muted);
}
.toolbar {
  display: flex;
  gap: 6px;
}
#count {
  display: inline-block;
  font-size: 10px;
  background: #e0f4e8;
  border-radius: 8px;
  padding: 1px 5px;
  margin-left: 4px;
}
.experiment-heading {
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: space-between;
  min-height: 57px;
}
.eyebrow {
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #16804e;
  margin-bottom: 4px;
}
h1 {
  font-size: 26px;
  font-weight: 650;
  line-height: 1.2;
}
.quick-controls {
  display: flex;
  gap: 22px;
  padding: 1px 0 4px;
}
.control {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(100px, 1fr) 100px;
  align-items: center;
  min-width: 0;
}
.control label {
  grid-column: 1/-1;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.control label span {
  color: var(--muted);
  font-weight: 450;
}
.control select {
  grid-column: 1/-1;
  width: 100%;
}
.quick-controls .control {
  width: min(340px, 50%);
}
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  min-height: 0;
}
.scene-card,
.graph-card {
  background: var(--night);
  border: 1px solid #294a3d;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.card-label {
  padding: 13px 16px 4px;
  color: #96b5a8;
  letter-spacing: 1.5px;
  font-size: 10px;
  font-weight: 650;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.card-label span {
  font-size: 9px;
  letter-spacing: 0.5px;
  color: #6c9483;
}
canvas {
  display: block;
  min-height: 0;
  min-width: 0;
  width: 100%;
  flex: 1;
  outline-offset: -4px !important;
}
#scene,
#live-graph {
  touch-action: none;
}
.readings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.reading {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  padding: 10px 13px;
  min-width: 0;
}
.reading span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 5px;
}
.reading strong {
  display: block;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.bench-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}
.transport,
.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.transport {
  flex-shrink: 0;
}
.speed-label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.speed-label select {
  min-height: 31px;
  font-size: 12px;
}
#phase-label {
  font-size: 11px;
  color: var(--muted);
}
#hint {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.actions {
  margin-left: auto;
}
dialog {
  border: 1px solid #b8d3c3;
  border-radius: 15px;
  padding: 0;
  box-shadow: 0 20px 90px #001a1844;
  width: min(540px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  color: var(--ink);
  background: #f8fcf9;
  margin: 12px 12px 12px auto;
}
dialog::backdrop {
  background: #001a1844;
  backdrop-filter: blur(2px);
}
dialog[open] {
  display: flex;
  flex-direction: column;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: #f8fcf9;
}
.panel-heading h2 {
  font-size: 19px;
}
.panel-heading button {
  font-size: 23px;
  line-height: 1;
  padding: 2px 12px;
}
.panel-content {
  padding: 18px 20px;
  overflow: auto;
  overscroll-behavior: contain;
  min-height: 0;
  line-height: 1.55;
}
.panel-content .control {
  margin: 0 0 19px;
}
.panel-content p {
  font-size: 13px;
  margin: 9px 0;
}
.course-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 15px;
}
.workspace-choice {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: white;
}
.workspace-choice h3 {
  margin: 0;
}
.workspace-choice h3 button {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  font-size: 15px;
  padding: 12px;
}
.workspace-choice.active {
  border-color: #16804e;
}
.workspace-choice.active h3 button {
  background: #dff5e8;
}
.preset-list {
  padding: 0 10px 10px;
  display: grid;
  gap: 5px;
}
.preset-list button {
  white-space: normal;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
}
.scope {
  font-size: 10px;
  color: var(--muted);
  padding: 0 12px 8px;
}
.session-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 10px;
}
.small {
  font-size: 11px !important;
  color: var(--muted);
}
details {
  border-top: 1px solid var(--line);
  margin-top: 15px;
  padding-top: 12px;
  font-size: 13px;
}
summary {
  cursor: pointer;
  font-weight: 650;
}
li {
  margin-bottom: 7px;
}
ol,
ul {
  padding-left: 21px;
}
.notebook-panel {
  width: min(860px, calc(100vw - 24px));
}
.notebook-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  margin: 8px 0;
}
.notebook-toolbar label {
  display: grid;
  gap: 5px;
}
.notebook-toolbar label.check {
  display: flex;
  align-items: center;
  min-height: 36px;
}
.notebook-toolbar input[type="checkbox"] {
  width: 18px;
  height: 18px;
}
#notebook-graph {
  background: var(--night);
  height: 300px;
  border-radius: 10px;
  flex: none;
}
.table-wrap {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
}
table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 11px;
}
th,
td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: #e6f4eb;
}
td details {
  margin: 0;
  border: 0;
  padding: 0;
}
td button {
  font-size: 11px;
  min-height: 28px;
  padding: 2px 6px;
}
.toast {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #123f2e;
  color: white;
  border-radius: 10px;
  padding: 10px 17px;
  box-shadow: 0 8px 30px #0003;
  z-index: 8;
  max-width: calc(100vw - 24px);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
}
.toast.visible {
  opacity: 1;
}
body.teacher .reading strong {
  font-size: 27px;
}
body.teacher #hint {
  display: none;
}
body.teacher .lab-name {
  display: none;
}
body.teacher .toolbar {
  margin-left: auto;
}
body.teacher .card-label {
  font-size: 12px;
}
@media (min-width: 1700px) {
  .lab {
    padding: 0 28px 18px;
    gap: 15px;
  }
  .topbar {
    min-height: 74px;
  }
  button {
    font-size: 15px;
    min-height: 41px;
  }
  .reading {
    padding: 14px 18px;
  }
  .card-label {
    font-size: 12px;
  }
  #hint {
    font-size: 14px;
  }
}
@media (max-width: 1150px) {
  .lab-name span {
    display: none;
  }
  .actions {
    margin-left: 0;
  }
  .card-label span {
    display: none;
  }
  .quick-controls {
    gap: 18px;
  }
  .lab {
    gap: 8px;
  }
  .reading {
    padding: 8px 10px;
  }
}
@media (max-width: 620px) {
  .lab {
    padding: 0 8px 8px;
    gap: 7px;
    min-height: 700px;
    grid-template-rows: auto auto auto minmax(290px, 1fr) auto auto;
  }
  .topbar {
    min-height: 55px;
    gap: 8px;
  }
  .brand {
    width: 65px;
  }
  .lab-name {
    display: none;
  }
  .toolbar {
    gap: 4px;
    margin-left: auto;
  }
  .toolbar button {
    font-size: 11px;
    padding: 7px;
  }
  .toolbar #fullscreen {
    padding: 7px 9px;
  }
  #count {
    margin-left: 1px;
  }
  .experiment-heading {
    min-height: 54px;
    gap: 7px;
  }
  h1 {
    font-size: 17px;
  }
  .experiment-heading button {
    font-size: 11px;
    padding: 7px;
    white-space: normal;
    max-width: 90px;
  }
  kbd {
    display: none;
  }
  .quick-controls {
    gap: 12px;
  }
  .quick-controls .control {
    grid-template-columns: minmax(0, 1fr) 72px;
    width: 50%;
    gap: 2px;
  }
  .control label {
    font-size: 10px;
    line-height: 1.4;
    min-height: 27px;
  }
  .quick-controls input[type="number"] {
    width: 72px;
    font-size: 11px;
    padding: 2px 4px;
  }
  .workbench {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(105px, 0.7fr) minmax(180px, 1.3fr);
    gap: 7px;
  }
  .card-label {
    font-size: 9px;
    padding: 8px 12px 0;
  }
  .readings {
    gap: 5px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .reading {
    padding: 6px 9px;
    display: flex;
    justify-content: space-between;
    gap: 6px;
    align-items: center;
  }
  .reading span {
    font-size: 9px;
    margin: 0;
  }
  .reading strong {
    font-size: 13px;
  }
  .bench-footer {
    gap: 6px;
  }
  .bench-footer button {
    font-size: 11px;
    padding: 5px 8px;
    min-height: 32px;
  }
  .speed-label {
    font-size: 10px;
  }
  .speed-label select {
    min-height: 29px;
  }
  #phase-label {
    font-size: 10px;
  }
  #hint {
    font-size: 10px;
    line-height: 1.3;
  }
  .actions {
    gap: 5px;
  }
  .actions button {
    white-space: normal;
  }
  .panel-content {
    padding: 14px;
  }
  .panel-heading {
    padding: 10px 14px;
  }
  dialog {
    margin: 12px auto;
  }
  .course-label {
    flex-wrap: wrap;
  }
  .notebook-toolbar label {
    max-width: 100%;
  }
  #notebook-graph {
    height: 260px;
  }
  body.teacher .reading strong {
    font-size: 16px;
  }
}
@media (max-height: 600px) and (min-width: 621px) {
  .lab {
    min-height: 480px;
    gap: 5px;
    padding-bottom: 5px;
  }
  .topbar {
    min-height: 44px;
  }
  .experiment-heading {
    min-height: 42px;
  }
  h1 {
    font-size: 19px;
  }
  .reading {
    padding: 5px 9px;
  }
  .reading strong {
    font-size: 16px;
  }
  .reading span {
    margin-bottom: 2px;
  }
  .control label {
    font-size: 11px;
  }
  .quick-controls {
    padding: 0;
  }
  .card-label {
    padding-top: 7px;
  }
  .bench-footer button {
    min-height: 29px;
    padding: 4px 8px;
  }
  #hint {
    font-size: 10px;
  }
}
[hidden] {
  display: none !important;
}
html,
body {
  height: 100%;
  overflow: hidden;
}
.lab {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#life-detail {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 15px;
  background: #e8f4ec;
  padding: 7px 10px;
  border-radius: 8px;
}
#life-detail label {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
#life-detail p {
  font-size: 11px;
  line-height: 1.4;
}
.stage-selector {
  display: flex;
  align-items: center;
  gap: 5px;
}
.stage-selector select {
  max-width: 270px;
  font-size: 12px;
}
body[data-workspace="life"] .actions {
  margin-left: 0;
}
body[data-workspace="life"] #hint {
  font-size: 11px;
}
body[data-workspace="life"] .workbench {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
@media (max-width: 620px) {
  #life-detail {
    display: block;
  }
  #life-detail p {
    margin-top: 5px;
  }
  #life-detail label {
    font-size: 10px;
  }
  #life-detail select {
    font-size: 11px;
  }
  .stage-selector select {
    max-width: 230px;
  }
  body[data-workspace="life"] .workbench {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 1fr) minmax(190px, 1fr);
  }
  body[data-workspace="life"] .lab {
    grid-template-rows: auto auto auto minmax(380px, 1fr) auto auto;
  }
  body[data-workspace="life"] #hint {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* Keep the narrow bench within its own width; overflow is vertical only. */
.topbar,
.toolbar,
.experiment-heading > div,
.transport,
.actions {
  min-width: 0;
}
.transport {
  max-width: 100%;
  flex-shrink: 1;
}
@media (max-width: 620px) {
  .quick-controls .control {
    flex: 1;
    width: 0;
  }
  .experiment-heading > button {
    flex-shrink: 0;
    width: 80px;
  }
  .stage-selector {
    max-width: 100%;
  }
  .stage-selector select {
    min-width: 0;
    max-width: calc(100vw - 70px);
  }
}
@media (max-width: 360px) {
  .brand {
    width: 46px;
  }
  .topbar {
    gap: 5px;
  }
  .toolbar {
    gap: 3px;
  }
  .toolbar button {
    font-size: 10px;
    padding: 6px 5px;
  }
  .toolbar #fullscreen {
    padding: 6px;
  }
  #count {
    padding: 1px 3px;
  }
  .reading strong {
    font-size: 12px;
  }
}

/* The star viewport is a physical-radius projection over a procedural sky. */
#star-surface {
  position: absolute;
  left: 0;
  z-index: 0;
  pointer-events: none;
}
#scene {
  position: relative;
  z-index: 1;
}
.star-tools {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.star-tools button {
  background: #122035df;
  border-color: #61728e66;
  color: #d6e2f3;
  font-size: 10px;
  min-height: 28px;
  padding: 4px 9px;
  backdrop-filter: blur(8px);
}
.star-tools button:hover {
  background: #253653;
}
.star-tools button[aria-pressed="true"] {
  background: #dae7f2;
  color: #102536;
  border-color: #dae7f2;
}
.star-view-switch,
.star-camera-tools {
  display: flex;
  gap: 3px;
}
.star-camera-tools {
  margin-left: auto;
}
.star-camera-tools button {
  padding: 4px 7px;
}
body:is(
    [data-workspace="life"],
    [data-workspace="stellar"],
    [data-workspace="hr"]
  )
  .scene-card {
  background: #030713;
  border-color: #364760;
}
body:is(
    [data-workspace="life"],
    [data-workspace="stellar"],
    [data-workspace="hr"]
  )
  .scene-card
  > .card-label {
  display: none;
}
body:is([data-workspace="life"], [data-workspace="hr"]) .graph-card {
  background: #07101e;
  border-color: #364760;
}
body[data-workspace="life"] .workbench {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}
body:is([data-workspace="life"], [data-workspace="hr"])
  .graph-card
  > .card-label {
  padding-bottom: 7px;
}
@media (max-width: 620px) {
  .star-tools {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 5px;
  }
  .star-tools button {
    font-size: 9px;
    min-height: 27px;
    padding: 3px 6px;
  }
  .star-camera-tools {
    margin-left: 0;
  }
  body:is(
      [data-workspace="life"],
      [data-workspace="stellar"],
      [data-workspace="hr"]
    )
    .workbench {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 1.1fr) minmax(260px, 1fr);
  }
  body:is(
      [data-workspace="life"],
      [data-workspace="stellar"],
      [data-workspace="hr"]
    )
    .lab {
    grid-template-rows: auto auto auto minmax(568px, 1fr) auto auto;
  }
}
@media (min-width: 621px) and (max-height: 650px) {
  body:is(
      [data-workspace="life"],
      [data-workspace="stellar"],
      [data-workspace="hr"]
    )
    .lab {
    grid-template-rows: auto auto auto minmax(320px, 1fr) auto auto;
  }
  body:is(
      [data-workspace="life"],
      [data-workspace="stellar"],
      [data-workspace="hr"]
    )
    .workbench {
    min-height: 320px;
  }
}

/* Stage descriptions and numeric readings must not resize the star's viewport
   mid-transition. Longer explanations flow below the same steady bench. */
body[data-workspace="life"] .lab {
  grid-template-rows: auto auto auto clamp(
      330px,
      calc(100dvh - 420px),
      800px
    ) auto auto;
  align-content: start;
}
@media (max-width: 620px) {
  body[data-workspace="life"] .lab {
    grid-template-rows: auto auto auto 568px auto auto;
  }
}

.survey-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  flex-basis: 100%;
}
#hubble-line-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  width: 100%;
}
#hubble-line-controls label {
  display: flex;
  flex: 1;
  min-width: 200px;
  gap: 7px;
  align-items: center;
}
#hubble-line-controls input {
  min-width: 80px;
  flex: 1;
}
#hubble-line-values {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}
.bench-guide {
  flex-basis: 100%;
  background: #e8f3ed;
  padding: 9px 12px;
  border-radius: 8px;
}
.bench-guide summary {
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.bench-guide p {
  font-size: 11px;
  line-height: 1.6;
  margin: 6px 0 0;
}
.investigation-step {
  border-top: 1px solid var(--line);
  margin-top: 15px;
  padding-top: 12px;
}
.investigation-step h3 {
  font-size: 16px;
}
.investigation-step p {
  font-size: 13px;
  line-height: 1.6;
}
.pupil-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.pupil-inputs label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pupil-inputs input {
  width: 100%;
}
#hubble-table {
  margin: 15px 0;
}
#hubble-dialog {
  max-width: 900px;
}
body:is([data-workspace="parallax"], [data-workspace="universe"]) .scene-card {
  background: #07101e;
}
body:is([data-workspace="parallax"], [data-workspace="universe"]) .workbench {
  min-height: 330px;
}
body:is([data-workspace="parallax"], [data-workspace="universe"]) .lab {
  grid-template-rows: auto auto auto minmax(330px, 1fr) auto auto;
}
@media (max-width: 620px) {
  body:is([data-workspace="parallax"], [data-workspace="universe"]) .workbench {
    grid-template-rows: minmax(290px, 1fr) minmax(300px, 1fr);
  }
  body:is([data-workspace="parallax"], [data-workspace="universe"]) .lab {
    grid-template-rows: auto auto auto minmax(598px, 1fr) auto auto;
  }
  .pupil-inputs {
    grid-template-columns: 1fr;
  }
}
