/* Per-lab styling. Each lab's rules are scoped under its [data-lab] world. */

/* ---------- Shared lab controls ---------- */

.btn--small { min-height: 40px; padding: 0.5em 1em 0.42em; font-size: var(--step--1); box-shadow: 0 4px 0 var(--ink); }
.btn--small:active { box-shadow: 0 1px 0 var(--ink); transform: translateY(3px); }

.spinner {
  flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  border: 5px solid rgba(255, 244, 224, 0.2); border-top-color: var(--sky);
  animation: spin 0.9s linear infinite;
}

/* ---------- Lab 1: LEGO Words ---------- */

.tk { display: grid; gap: 18px; padding: clamp(14px, 2.2vw, 24px); }
.tk-top { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }

.tk-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tk-label { font: 400 var(--step-1)/1 var(--font-display); }
.tk-input {
  flex: 1; width: 100%; min-height: 118px; resize: vertical;
  padding: 14px 16px;
  font: 800 clamp(1.3rem, 1.05rem + 1vw, 1.9rem)/1.25 var(--font-ui); color: var(--ink);
  background: #fff;
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: inset 0 4px 0 rgba(26, 16, 51, 0.1), 0 5px 0 var(--ink);
}
.tk-input:focus-visible { outline: 3px solid var(--brick-blue); outline-offset: 3px; }

.tk-meter {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start;
  padding: 12px;
  background: var(--paper);
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.tk-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 6px 4px;
  background: #FFE7A8; border: 2px solid var(--ink); border-radius: 14px;
}
.tk-stat--hot { background: var(--brick-red); }
.tk-stat__num { font: 400 2.5rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.tk-stat__label { font-weight: 800; font-size: var(--step--1); }
.tk-cost { grid-column: 1 / -1; font-size: var(--step--1); font-weight: 700; }
.tk-cost p { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 2px; }
.tk-cost b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tk-rate {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px;
  margin-top: 6px; padding-top: 8px;
  color: rgba(26, 16, 51, 0.78);
  border-top: 2px dashed rgba(26, 16, 51, 0.25);
}
.tk-rate__box { display: inline-flex; align-items: center; gap: 3px; font: 700 var(--step--1) var(--font-mono); color: var(--ink); }
.tk-rate input {
  width: 5.4em; min-height: 32px; padding: 2px 6px;
  font: 700 var(--step--1) var(--font-mono); color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 8px;
}

.tk-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 800; }
.tk-preset {
  max-width: 100%; min-height: 38px; padding: 3px 13px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 800 var(--step--1)/1 var(--font-ui); color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  transition-property: background-color, transform, box-shadow;
  transition-duration: 0.15s, 0.08s, 0.08s;
}
.tk-preset:hover { background: var(--sun); }
.tk-preset:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* The green LEGO baseplate the bricks snap onto */
.tk-plate {
  position: relative; min-height: 190px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.3) 0 5px, rgba(26, 16, 51, 0.16) 5.5px 7px, transparent 7.5px) 0 0 / 26px 26px,
    var(--mint);
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: inset 0 -6px 0 rgba(26, 16, 51, 0.15), 0 6px 0 var(--ink);
}
.tk-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px;
  padding: 16px; text-align: center;
  font: 400 var(--step-1)/1.2 var(--font-display); color: var(--ink);
}
.tk-loading[hidden] { display: none; }
.tk-loading .spinner { border-color: rgba(26, 16, 51, 0.2); border-top-color: var(--ink); }

.tk-bricks { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 20px 6px; margin: 0; padding: 26px 16px 16px; list-style: none; }

.brick {
  position: relative;
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 46px; padding: 7px 10px 6px;
  color: var(--on); background: var(--c);
  border: var(--stroke) solid var(--ink); border-radius: 8px;
  box-shadow: inset 0 -6px 0 rgba(26, 16, 51, 0.2), inset 0 3px 0 rgba(255, 255, 255, 0.35), 0 4px 0 var(--ink);
}
.brick__studs { position: absolute; top: -11px; left: 6px; right: 6px; display: flex; justify-content: space-evenly; }
.brick__studs i {
  width: 15px; height: 10px;
  background: var(--c);
  border: var(--stroke) solid var(--ink); border-bottom: 0; border-radius: 6px 6px 0 0;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35);
}
.brick__text { font: 800 1.3rem/1.1 var(--font-ui); white-space: pre; }
.brick__sp { opacity: 0.55; }
.brick__id {
  padding: 1px 6px 0;
  font: 700 0.72rem/1.3 var(--font-mono); color: var(--ink);
  background: rgba(255, 251, 243, 0.9); border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
/* Byte crumbs: tokens that are only part of a character */
.brick--crumb { border-style: dashed; background: repeating-linear-gradient(-45deg, var(--c) 0 7px, color-mix(in oklab, var(--c) 55%, white) 7px 14px); }
.brick--crumb .brick__studs i { border-style: dashed; }

.tk-bricks--mini { gap: 15px 4px; padding: 18px 0 6px; }
.tk-bricks--mini .brick { min-width: 34px; padding: 4px 7px; }
.tk-bricks--mini .brick__text { font-size: 1rem; }
.tk-bricks--mini .brick__id { display: none; }
.tk-bricks--mini .brick__studs { top: -9px; }
.tk-bricks--mini .brick__studs i { width: 11px; height: 8px; border-width: 2px; }

.tk-compare {
  padding: 14px 16px 16px;
  background: var(--paper);
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.tk-compare__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.tk-compare__title { margin: 0; font: 400 var(--step-2)/1 var(--font-display); }
.tk-compare__head p { margin: 4px 0 0; font-weight: 700; }
.tk-compare__body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.tk-compare__body[hidden] { display: none; }
.tk-lang { min-width: 0; padding: 10px 12px; background: #FFF1D6; border: 2px solid var(--ink); border-radius: 14px; }
.tk-lang__name { margin: 0; font: 400 1.2rem/1 var(--font-display); }
.tk-lang__text { margin: 4px 0 0; font-weight: 700; }
.tk-lang__count { margin: 6px 0 0; font-weight: 800; }
.tk-lang__count b { font: 400 1.7rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.tk-sticker {
  grid-column: 1 / -1; justify-self: center;
  margin: 8px 0 14px; /* room for the tilt */
  padding: 10px 22px 5px;
  font: 400 var(--step-3)/1 var(--font-display); color: var(--ink);
  background: var(--sun);
  border: var(--stroke) solid var(--ink); border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink);
  transform: rotate(-6deg);
}
.tk-sticker:empty { display: none; }
.tk-why { grid-column: 1 / -1; margin: 0; font-weight: 700; }

@media (max-width: 860px) {
  .tk-top, .tk-compare__body { grid-template-columns: 1fr; }
  .brick__text { font-size: 1.15rem; }
}
@media (max-width: 560px) {
  .tk-sticker { font-size: var(--step-2); }
}

/* ---------- Lab 3: Creativity Thermostat ---------- */

.th {
  --zone: var(--sun);
  position: relative;
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px;
  padding: clamp(14px, 2.2vw, 24px);
}
.th[data-zone="ice"]  { --zone: var(--sky); }
.th[data-zone="cool"] { --zone: var(--mint); }
.th[data-zone="warm"] { --zone: var(--sun); }
.th[data-zone="fire"] { --zone: var(--flame); }

.th-loading {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px;
  padding: 24px; text-align: center;
  font: 400 var(--step-1)/1.2 var(--font-display);
  background: var(--lab-stage); border-radius: inherit;
}
.th-loading[hidden] { display: none; }
.th-loading .spinner { border-color: rgba(26, 16, 51, 0.2); border-top-color: var(--flame); }

/* The thermometer */
.th-dial { display: flex; flex-direction: column; align-items: center; gap: 8px; user-select: none; }
.th-end { margin: 0; text-align: center; font: 400 1.2rem/1 var(--font-display); }
.th-end span { display: block; margin-top: 2px; font: 800 var(--step--1)/1.1 var(--font-ui); color: rgba(26, 16, 51, 0.7); }
.th-meter { position: relative; width: 120px; height: 330px; margin: 6px 0 34px; touch-action: none; cursor: ns-resize; }
.th-tube {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 46px; transform: translateX(-50%);
  overflow: hidden;
  background: repeating-linear-gradient(to top, transparent 0 31px, rgba(26, 16, 51, 0.14) 31px 33px), var(--paper);
  border: var(--stroke) solid var(--ink); border-radius: 999px;
  box-shadow: inset 6px 0 0 rgba(255, 255, 255, 0.7), 0 5px 0 var(--ink);
}
.th-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 50%;
  background: linear-gradient(to top, var(--sky) 0%, var(--mint) 33%, var(--sun) 58%, var(--flame) 79%, var(--brick-red) 100%) bottom / 100% 330px no-repeat;
  border-top: var(--stroke) solid var(--ink);
}
.th-bulb {
  position: absolute; left: 50%; bottom: -36px; width: 64px; height: 64px; transform: translateX(-50%);
  background: var(--zone);
  border: var(--stroke) solid var(--ink); border-radius: 50%;
  box-shadow: inset -6px -8px 0 rgba(26, 16, 51, 0.15), 0 5px 0 var(--ink);
  transition: background-color 0.2s;
}
.th-ticks {
  position: absolute; right: -6px; top: 0; bottom: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  font: 700 0.75rem/1 var(--font-mono); color: rgba(26, 16, 51, 0.65);
  pointer-events: none;
}
.th-ticks span { transform: translateY(-50%); }
.th-ticks span:first-child { transform: none; }
.th-ticks span:last-child { transform: translateY(-100%); }
.th-knob {
  position: absolute; left: 50%; bottom: calc(var(--k, 0.5) * 100%);
  width: 76px; height: 30px; transform: translate(-50%, 50%);
  background: repeating-linear-gradient(90deg, transparent 0 22px, rgba(26, 16, 51, 0.35) 22px 25px, transparent 25px 30px) center / 30px 14px no-repeat, var(--cream);
  border: var(--stroke) solid var(--ink); border-radius: 12px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: grab;
  transition: transform 0.1s var(--ease-out);
}
.th-knob.is-dragging { cursor: grabbing; transform: translate(-50%, 50%) scale(1.08); }
.th-knob:focus-visible { outline: 3px solid var(--grape); outline-offset: 3px; }
.th-readout { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.th-readout__num { font: 400 3rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.th-readout__zone {
  padding: 3px 12px 1px;
  font: 400 1.15rem/1.2 var(--font-display);
  background: var(--zone); border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
  transition: background-color 0.2s;
}
.th-quick { display: flex; gap: 6px; }
.th-quick button {
  min-height: 36px; padding: 2px 10px 0;
  font: 800 var(--step--1)/1 var(--font-ui); color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink); cursor: pointer;
}
.th-quick button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* Story so far and the odds */
.th-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.th-prompt {
  align-self: flex-start; margin: 0; padding: 6px 14px 3px;
  font-weight: 700; background: var(--paper);
  border: 2px solid var(--ink); border-radius: 999px;
}
.th-story {
  padding: 12px 16px;
  background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.th-story__label { margin: 0; font-weight: 800; font-size: var(--step--1); color: rgba(26, 16, 51, 0.7); }
.th-story__text { margin: 4px 0 0; font: 700 var(--step-1)/1.4 var(--font-ui); }
.th-blank {
  display: inline-block; min-width: 3.2em; padding: 0 10px;
  text-align: center; font-weight: 800;
  color: var(--ink); background: var(--zone);
  border: 2px dashed var(--ink); border-radius: 10px;
  animation: blank-blink 1.1s steps(2) infinite;
}
.th-blank.is-filled { border-style: solid; animation: none; }
@keyframes blank-blink { 50% { background: transparent; } }

.th-odds {
  padding: 12px 16px 10px;
  background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.th-odds__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 8px; font: 400 var(--step-1)/1.1 var(--font-display); }
.th-odds__title span { font: 800 var(--step--1)/1 var(--font-ui); color: rgba(26, 16, 51, 0.65); }
.th-bars { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.th-bar { display: grid; grid-template-columns: 8.5em minmax(0, 1fr) 4.2em; align-items: center; gap: 10px; padding: 1px 4px; border-radius: 8px; cursor: default; }
.th-bar:hover, .th-bar:focus-visible { background: rgba(26, 16, 51, 0.07); outline: none; }
.th-bar__word { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; text-align: right; }
.th-bar__track { height: 20px; background: rgba(26, 16, 51, 0.08); border-radius: 6px; overflow: hidden; }
.th-bar__fill {
  display: block; height: 100%; width: 0;
  background: var(--zone); border-right: 2px solid var(--ink);
  transition: width 0.14s var(--ease-out), background-color 0.2s;
}
.th-bar__pct { font: 700 var(--step--1)/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.th-bar--other { margin-top: 4px; padding-top: 6px; border-top: 2px dashed rgba(26, 16, 51, 0.25); border-radius: 0; }
.th-bar--other .th-bar__word { font-weight: 700; font-style: italic; font-size: var(--step--1); line-height: 1.15; white-space: normal; }
.th-bar--other .th-bar__fill { background: repeating-linear-gradient(-45deg, var(--lilac) 0 6px, var(--grape) 6px 12px); }
.th-source { margin: 8px 0 0; font-size: var(--step--1); font-weight: 700; color: rgba(26, 16, 51, 0.65); }

/* Generate ×3 */
.th-gen {
  grid-column: 1 / -1;
  padding: 14px 16px 16px;
  background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.th-gen__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.th-gen__title { margin: 0; font: 400 var(--step-2)/1 var(--font-display); }
.th-gen__head p { margin: 4px 0 0; font-weight: 700; }
.th-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.th-card {
  --card: var(--sun);
  display: flex; flex-direction: column; gap: 8px;
  padding: 0 14px 12px;
  background: #fff; border: var(--stroke) solid var(--ink); border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
}
.th-card[data-zone="ice"] { --card: var(--sky); }
.th-card[data-zone="fire"] { --card: var(--flame); }
.th-card__temp {
  margin: 0 -14px; padding: 6px 14px 3px;
  font: 400 1.25rem/1.1 var(--font-display);
  background: var(--card); border-bottom: var(--stroke) solid var(--ink); border-radius: 13px 13px 0 0;
}
.th-card__text { margin: 0; font-weight: 600; line-height: 1.45; white-space: pre-line; }
.th-card.is-writing .th-card__text { color: rgba(26, 16, 51, 0.55); animation: writing 0.9s ease-in-out infinite alternate; }
@keyframes writing { to { opacity: 0.45; } }
.th-card__badge {
  align-self: flex-start; margin: auto 0 0; padding: 2px 10px 0;
  font: 800 0.8rem/1.4 var(--font-ui);
  border: 2px solid var(--ink); border-radius: 999px;
}
.th-card__badge.is-live { background: var(--acid); }
.th-card__badge.is-recorded { background: var(--lilac); }
.th-card__badge[hidden] { display: none; }

@media (max-width: 860px) {
  .th { grid-template-columns: 1fr; }
  .th-dial { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "meter hot" "meter readout" "meter quick" "meter cold"; align-items: center; justify-items: center; column-gap: 16px; }
  .th-meter { grid-area: meter; height: 240px; margin: 4px 0 34px; }
  .th-fill { background-size: 100% 240px; }
  .th-end--hot { grid-area: hot; }
  .th-end--cold { grid-area: cold; }
  .th-readout { grid-area: readout; }
  .th-quick { grid-area: quick; }
  .th-cards { grid-template-columns: 1fr; }
  .th-bar { grid-template-columns: 6.5em minmax(0, 1fr) 3.8em; gap: 8px; }
}

/* ---------- Lab 4: X-Ray Vision ---------- */

.xr { display: grid; gap: 16px; padding: clamp(14px, 2.2vw, 24px); }
.xr-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.xr-samples { display: flex; flex-wrap: wrap; gap: 10px; }
.xr-sample {
  position: relative; width: 104px; height: 72px; padding: 0; overflow: hidden;
  background: #000; border: var(--stroke) solid var(--ink); border-radius: 14px;
  box-shadow: 0 4px 0 var(--ink); cursor: pointer;
  transition: transform 0.1s var(--ease-out), box-shadow 0.1s;
}
.xr-sample img { width: 100%; height: 100%; object-fit: cover; opacity: 0.8; }
.xr-sample span {
  position: absolute; left: 6px; bottom: 5px; padding: 1px 7px 0;
  font: 800 0.78rem/1.3 var(--font-ui); color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px;
}
.xr-sample:hover img, .xr-sample[aria-pressed="true"] img { opacity: 1; }
.xr-sample[aria-pressed="true"] { outline: 3px solid var(--acid); outline-offset: 2px; }
.xr-sample:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.xr-upload { cursor: pointer; }
.xr-upload:focus-within { outline: 3px solid var(--sky); outline-offset: 3px; }
.xr-privacy { flex-basis: 100%; margin: 0; font-weight: 700; color: rgba(230, 255, 208, 0.85); }

.xr-main { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.xr-view { margin: 0; min-width: 0; }
.xr-frame {
  position: relative; overflow: hidden;
  min-height: 240px;
  background: #000;
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 0 0 3px rgba(184, 255, 0, 0.35), 0 6px 0 var(--ink);
}
.xr-frame::after { /* faint night-vision scanlines */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(184, 255, 0, 0.05) 0 2px, transparent 2px 4px);
}
.xr-img { display: block; width: 100%; height: auto; }
.xr-hud { position: absolute; inset: 0; }
.xr-box {
  position: absolute;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  background:
    linear-gradient(var(--c), var(--c)) top left / 20px 4px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 4px 20px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 20px 4px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 4px 20px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 20px 4px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 4px 20px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 20px 4px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 4px 20px no-repeat;
  filter: drop-shadow(0 0 6px var(--c));
}
.xr-box.is-unsure { border-style: dashed; opacity: 0.75; }
.xr-box__tag {
  position: absolute; left: -1px; bottom: 100%; margin-bottom: 3px;
  padding: 2px 7px 1px; white-space: nowrap;
  font: 700 0.8rem/1.2 var(--font-mono); color: var(--ink);
  background: var(--c); border-radius: 6px;
}
.xr-box[style*="top:0%"] .xr-box__tag, .xr-box[style*="top:-"] .xr-box__tag { bottom: auto; top: 4px; left: 4px; }
.xr-scan {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: linear-gradient(to bottom, transparent 0 46%, rgba(184, 255, 0, 0.25) 49%, rgba(184, 255, 0, 0.85) 50%, transparent 51%) 0 0 / 100% 200%;
  transition: opacity 0.2s;
}
.xr-frame.is-scanning .xr-scan { opacity: 1; animation: xr-sweep 1.1s linear infinite; }
@keyframes xr-sweep { from { background-position: 0 100%; } to { background-position: 0 -100%; } }
.xr-status {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 28px); padding: 8px 16px 6px;
  font-weight: 800; color: var(--ink);
  background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}
.xr-status[hidden] { display: none; }
.xr-status.is-error { border-radius: 16px; }
.xr-status .spinner { width: 24px; height: 24px; border-width: 4px; border-color: rgba(26, 16, 51, 0.2); border-top-color: var(--ink); }
.xr-status .spinner[hidden] { display: none; }
.xr-credit { margin-top: 8px; font-size: var(--step--1); font-weight: 700; color: rgba(230, 255, 208, 0.75); }
.xr-credit a { color: var(--acid); }

.xr-side { display: grid; gap: 14px; }
.xr-panel {
  padding: 12px 14px;
  color: var(--ink); background: var(--paper);
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.xr-panel__title { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 8px; font: 400 1.25rem/1.1 var(--font-display); }
.xr-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.xr-row { display: grid; grid-template-columns: 6.6em minmax(0, 1fr) 3em; align-items: center; gap: 8px; font-weight: 800; }
.xr-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xr-row__track { height: 14px; background: rgba(26, 16, 51, 0.1); border-radius: 999px; overflow: hidden; }
.xr-row__fill { display: block; height: 100%; background: var(--c); border-right: 2px solid var(--ink); transition: width 0.25s var(--ease-out); }
.xr-row__pct { font: 700 var(--step--1)/1 var(--font-mono); text-align: right; }
.xr-row.is-unsure .xr-row__name { opacity: 0.7; }
.xr-drop, .xr-gone {
  grid-column: 1 / -1; justify-self: start; margin-top: -2px; padding: 0 8px;
  font: 800 0.78rem/1.5 var(--font-ui); color: var(--ink);
  background: #FFD9E8; border: 2px solid var(--ink); border-radius: 999px;
}
.xr-row.is-gone .xr-row__name { text-decoration: line-through; opacity: 0.6; }
.xr-new { background: #E2FFB0; }
.xr-gone { grid-column: 2 / -1; margin: 0; }
.xr-empty, .xr-more { font-weight: 700; color: rgba(26, 16, 51, 0.7); }
.xr-mist__val { font: 700 1rem/1 var(--font-mono); padding: 3px 8px 1px; background: #E6E1F5; border-radius: 8px; }
.xr-mist__range { width: 100%; height: 28px; accent-color: var(--grape); cursor: pointer; }
.xr-mist__hint { margin: 4px 0 0; font-size: var(--step--1); font-weight: 700; color: rgba(26, 16, 51, 0.7); }

@media (max-width: 860px) {
  .xr-main { grid-template-columns: 1fr; }
  .xr-sample { width: 88px; height: 62px; }
}

/* ---------- Lab 5: Hall of Mirrors ---------- */

.mr { display: grid; gap: 16px; padding: clamp(14px, 2.2vw, 24px); }
.mr-defs { position: absolute; }
.mr-ask {
  padding: 12px 16px 14px;
  background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.mr-label { display: block; margin-bottom: 6px; font: 400 var(--step-1)/1 var(--font-display); }
.mr-row { display: flex; gap: 10px; }
.mr-input {
  flex: 1; min-width: 0; min-height: 48px; padding: 8px 14px 5px;
  font: 800 var(--step-1)/1.2 var(--font-ui); color: var(--ink);
  background: #fff; border: var(--stroke) solid var(--ink); border-radius: 14px;
  box-shadow: inset 0 3px 0 rgba(26, 16, 51, 0.1);
}
.mr-input[readonly] { background: #FFF7FD; }
.mr-input:focus-visible { outline: 3px solid var(--grape); outline-offset: 2px; }
.mr-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mr-preset {
  min-height: 36px; padding: 3px 12px 0;
  font: 800 var(--step--1)/1.2 var(--font-ui); color: var(--ink); text-align: left;
  background: #FFE3F3; border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink); cursor: pointer;
}
.mr-preset:hover { background: var(--lilac); }
.mr-preset:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.mr-note { margin: 10px 0 0; font-weight: 700; color: rgba(26, 16, 51, 0.75); }
.mr-note[hidden] { display: none; }

.mr-mode { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: stretch; }
.mr-switch {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  font: inherit; color: var(--ink);
  background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink); cursor: pointer;
}
.mr-switch:focus-visible { outline: 3px solid var(--grape); outline-offset: 3px; }
.mr-switch__label { font: 400 1.2rem/1 var(--font-display); }
.mr-switch__track {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; align-items: center;
  width: 132px; height: 44px;
  font: 400 1.05rem/1 var(--font-display);
  background: var(--pink); border: var(--stroke) solid var(--ink); border-radius: 999px;
  transition: background-color 0.2s;
}
.mr-switch__off, .mr-switch__on { position: relative; z-index: 1; text-align: center; padding-top: 3px; }
.mr-switch__thumb {
  position: absolute; top: 3px; left: 3px; width: calc(50% - 3px); height: calc(100% - 6px);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px;
  transition: transform 0.25s var(--ease-spring);
}
.mr[data-mode="on"] .mr-switch__track { background: var(--mint); }
.mr[data-mode="on"] .mr-switch__thumb { transform: translateX(100%); }
.mr-instruction {
  padding: 10px 16px;
  background: #1A1033; color: var(--cream);
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.mr-instruction__label { margin: 0 0 4px; font: 800 var(--step--1)/1 var(--font-ui); color: var(--lilac); text-transform: uppercase; letter-spacing: 0.06em; }
.mr-instruction__text { margin: 0; font: 600 var(--step--1)/1.45 var(--font-mono); }

.mr-results { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.mr-col {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 12px 14px 14px;
  background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.mr-col__title { margin: 0; font: 400 var(--step-1)/1.1 var(--font-display); }
.mr-placeholder { margin: 0; font-weight: 700; color: rgba(26, 16, 51, 0.6); }

/* The funhouse mirror */
.mr-mirror {
  position: relative; padding: 14px;
  background: conic-gradient(from 20deg, var(--pink), var(--lilac), var(--sun), var(--pink));
  border: var(--stroke) solid var(--ink); border-radius: 46% 46% 22px 22px / 30% 30% 22px 22px;
}
.mr-mirror__glass {
  padding: 22px 16px 14px;
  background: linear-gradient(135deg, #F6F3FF 0%, #E9E2FF 40%, #FDF2FF 60%, #EDE6FF 100%);
  border: var(--stroke) solid var(--ink); border-radius: 44% 44% 14px 14px / 26% 26% 14px 14px;
  box-shadow: inset 8px 8px 0 rgba(255, 255, 255, 0.7);
}
.mr-answer--off { filter: url(#mr-warp); }
.mr-col--off.is-caught .mr-mirror { animation: mr-wobble 2.6s ease-in-out infinite; }
@keyframes mr-wobble { 0%, 100% { transform: skewX(0deg) scaleY(1); } 25% { transform: skewX(-1.2deg) scaleY(1.01); } 75% { transform: skewX(1.2deg) scaleY(0.995); } }
.mr-col--off.is-caught .mr-mirror::after {
  content: "NO SOURCES!"; position: absolute; right: -10px; top: -14px;
  padding: 6px 12px 2px;
  font: 400 1.1rem/1 var(--font-display); color: var(--ink);
  background: var(--sun); border: var(--stroke) solid var(--ink); border-radius: 10px;
  box-shadow: 0 4px 0 var(--ink); transform: rotate(8deg);
}
.mr-answer p { margin: 0 0 8px; font-weight: 600; line-height: 1.5; }
.mr-answer p:last-child { margin-bottom: 0; }

.mr-reading { margin: 0; font-weight: 800; color: var(--grape); }
.mr-reading[hidden] { display: none; }
.mr-sources { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.mr-source {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px;
  padding: 8px 10px;
  background: #EFFFF5; border: 2px solid var(--ink); border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
}
.mr-source__n {
  grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px;
  font: 400 1rem/1 var(--font-display); background: var(--mint); border: 2px solid var(--ink); border-radius: 50%;
}
.mr-source__title { font-weight: 800; color: var(--ink); }
.mr-source__snippet {
  margin: 0; font-size: var(--step--1); font-weight: 600; line-height: 1.4; color: rgba(26, 16, 51, 0.8);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.mr-answer--on { padding: 10px 12px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; }
.mr-cite {
  display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; margin: 0 1px; padding: 0 4px;
  font: 800 0.78em/1 var(--font-ui); color: var(--ink); text-decoration: none; vertical-align: 0.15em;
  background: var(--mint); border: 2px solid var(--ink); border-radius: 999px;
}
.mr-cite:hover, .mr-cite:focus-visible { background: var(--sun); }
.mr-badge { align-self: flex-start; margin: 0; padding: 2px 10px 0; font: 800 0.8rem/1.4 var(--font-ui); border: 2px solid var(--ink); border-radius: 999px; }
.mr-badge.is-live { background: var(--acid); }
.mr-badge.is-recorded { background: var(--lilac); }
.mr-badge[hidden] { display: none; }
.mr-credit { margin: 0; font-size: var(--step--1); font-weight: 700; color: rgba(26, 16, 51, 0.65); }

@media (max-width: 860px) {
  .mr-mode, .mr-results { grid-template-columns: 1fr; }
  .mr-switch { flex-direction: row; justify-content: space-between; }
}
@media (max-width: 560px) {
  .mr-row { flex-direction: column; }
}

/* ---------- Lab 6: Attention Spotlight ---------- */

.at { display: grid; gap: 16px; padding: clamp(14px, 2.2vw, 24px); }
.at-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.at-question { margin: 0; font: 400 var(--step-2)/1.1 var(--font-display); color: var(--cream); }
.at-it { padding: 0 10px; color: var(--ink); background: var(--sun); border: 2px solid var(--ink); border-radius: 10px; }
.at-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.at-preset {
  min-height: 36px; padding: 3px 13px 0;
  font: 800 var(--step--1)/1 var(--font-ui); color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink); cursor: pointer;
}
.at-preset[aria-pressed="true"] { background: var(--sun); }
.at-preset:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.at-stage {
  position: relative;
  padding: 170px 16px 28px;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 79, 163, 0.18), transparent 60%), #1A0B36;
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: inset 0 0 0 2px rgba(255, 210, 63, 0.15);
}
.at-beams { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.at-beam { fill: none; stroke: url(#at-beam); stroke-linecap: round; filter: url(#at-glow); }
.at-beam.is-top { stroke: #FFF4A8; }
.at-sentence {
  position: relative; margin: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 10px;
}
.at-tile {
  --w: 0;
  padding: 8px 14px 4px;
  font: 400 clamp(1.15rem, 0.9rem + 1vw, 1.7rem)/1.1 var(--font-display); color: var(--ink);
  background: color-mix(in oklab, var(--pink) calc(var(--w) * 70%), var(--cream));
  border: var(--stroke) solid var(--ink); border-radius: 14px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  transition: background-color 0.25s, transform 0.15s var(--ease-out), box-shadow 0.15s;
}
.at-tile.is-it { background: var(--sun); }
.at-tile.is-swap { text-decoration: underline wavy var(--grape) 2px; text-underline-offset: 5px; }
.at-tile.is-source { transform: translateY(-6px); box-shadow: 0 11px 0 var(--ink), 0 0 0 4px rgba(255, 210, 63, 0.6); }
.at-tile.is-top { box-shadow: 0 5px 0 var(--ink), 0 0 22px 4px rgba(255, 79, 163, 0.85); }
.at-tile:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }

.at-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.at-readout {
  display: grid; gap: 4px; padding: 10px 14px;
  color: var(--ink); background: var(--paper);
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.at-readout__title { margin: 0 0 2px; font: 400 1.1rem/1.1 var(--font-display); }
.at-readout__row { display: grid; grid-template-columns: 7em minmax(0, 1fr) 3em; align-items: center; gap: 10px; margin: 0; font-weight: 800; }
.at-readout__bar { height: 12px; background: rgba(26, 16, 51, 0.1); border-radius: 999px; overflow: hidden; }
.at-readout__bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--sun), var(--pink)); }
.at-readout__row b { font: 700 var(--step--1)/1 var(--font-mono); text-align: right; }
.at-label { margin: 0; font-size: var(--step--1); font-weight: 600; color: rgba(255, 244, 224, 0.8); }

@media (max-width: 860px) {
  .at-stage { padding-top: 130px; }
  .at-controls { grid-template-columns: 1fr; }
}

/* ---------- Lab 2: Galaxy of Meaning ---------- */

[data-lab="galaxy"] .lab__stage { height: min(80vh, 760px); min-height: 600px; }

.galaxy { position: absolute; inset: 0; }
.gx-canvas { position: absolute; inset: 0; z-index: 0; } /* contains the label z-indexes CSS2DRenderer sets */
.gx-canvas canvas { width: 100% !important; height: 100% !important; }
.gx-labels { position: absolute; inset: 0; touch-action: none; }
.gx-nogl { display: grid; place-items: center; height: 100%; padding: 32px; text-align: center; font-weight: 700; }

.gx-loading {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font: 400 var(--step-2)/1.1 var(--font-display); color: var(--cream);
  background: var(--lab-stage);
}

.gx-panel {
  position: absolute; z-index: 2;
  color: var(--ink); background: rgba(255, 251, 243, 0.96);
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-m);
  box-shadow: 0 5px 0 var(--ink);
}
.gx-panel__title { margin: 0 0 6px; font: 400 1.15rem/1 var(--font-display); color: var(--grape); }

.gx-words { top: 16px; left: 16px; width: 252px; padding: 12px 12px 10px; }
.gx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
.gx-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 4px 0 10px;
  font-weight: 800; color: var(--ink); background: var(--c);
  border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 0 2px 0 var(--ink);
}
.gx-chip button {
  position: relative;
  width: 22px; height: 22px; padding: 0;
  font: 900 15px/1 var(--font-ui); color: var(--ink);
  background: none; border: 0; border-radius: 50%; cursor: pointer;
}
.gx-chip button::before { content: ""; position: absolute; inset: -9px; }
.gx-chip button:hover { background: rgba(26, 16, 51, 0.15); }
.gx-add { display: flex; gap: 8px; }
.gx-hint { margin: 8px 0 0; font-size: var(--step--1); font-weight: 700; color: rgba(26, 16, 51, 0.7); }

.gx-input {
  width: 100%; min-width: 0; min-height: 40px;
  padding: 6px 10px 3px;
  font: 800 var(--step-0)/1.2 var(--font-ui); color: var(--ink);
  background: #fff;
  border: var(--stroke) solid var(--ink); border-radius: 12px;
  box-shadow: inset 0 3px 0 rgba(26, 16, 51, 0.12);
}
.gx-input:focus-visible { outline: 3px solid var(--grape); outline-offset: 2px; }

.gx-reset { position: absolute; z-index: 2; top: 16px; right: 16px; }

.gx-math {
  left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(820px, calc(100% - 32px));
  padding: 12px 14px 10px;
}
.gx-eq { display: flex; align-items: center; gap: 8px; }
.gx-eq .gx-input { flex: 1 1 0; text-align: center; }
.gx-op { flex: none; font: 400 2rem/1 var(--font-display); color: var(--grape); }
.gx-answer {
  flex: 1 1 0; min-width: 96px; min-height: 44px;
  display: grid; place-items: center;
  padding: 4px 10px 0;
  font: 400 1.5rem/1 var(--font-display); color: var(--ink);
  background: repeating-linear-gradient(-45deg, #EEE6FF 0 8px, #fff 8px 16px);
  border: var(--stroke) dashed var(--grape); border-radius: 12px;
}
.gx-answer.is-revealed { background: var(--sun); border: var(--stroke) solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.gx-launch { flex: none; }
.gx-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font-weight: 800; font-size: var(--step--1); }
.gx-preset {
  min-height: 32px; padding: 2px 10px 0;
  font: 800 var(--step--1)/1 var(--font-ui); color: var(--ink);
  background: #EEE6FF; border: 2px solid var(--ink); border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s;
}
.gx-preset:hover { background: var(--lilac); }
.gx-runners { margin: 8px 0 0; font-weight: 700; font-size: var(--step--1); color: rgba(26, 16, 51, 0.8); }
.gx-runners span { display: inline-block; margin: 0 4px 2px 0; padding: 0 8px; background: #EEE6FF; border-radius: 999px; font-variant-numeric: tabular-nums; }

/* Star labels (positioned by Three.js CSS2DRenderer) */
.gx-label { pointer-events: none; white-space: nowrap; font-family: var(--font-ui); font-weight: 800; }
.gx-label--sign { font-size: 12px; color: rgba(255, 244, 224, 0.55); }
.gx-label--near { font-size: 12px; color: rgba(255, 244, 224, 0.85); text-shadow: 0 1px 2px #0B0620; }
.gx-label--user, .gx-label--math {
  padding: 1px 10px 0;
  font-size: 15px; color: var(--ink); background: var(--c);
  border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
}
.gx-label--sim {
  margin-left: 96px;
  padding: 0 7px; font-size: 11px; color: var(--ink);
  background: var(--cream); border: 2px solid var(--ink); border-radius: 999px;
}
.gx-label--hover {
  display: flex; flex-direction: column; align-items: center;
  padding: 3px 10px 2px; margin-top: -34px;
  font-size: 13px; color: var(--ink); background: var(--cream);
  border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 var(--ink);
}
.gx-label--hover span { font-size: 11px; font-weight: 700; opacity: 0.75; }
.gx-label--answer {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 16px 2px;
  font: 400 26px/1 var(--font-display); color: var(--ink); background: var(--sun);
  border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink);
}
.gx-label--answer small { font: 800 12px/1.4 var(--font-ui); }

@media (max-width: 860px) {
  /* Phones: the 3D view on top, the panels stacked underneath it. */
  [data-lab="galaxy"] .lab__stage { height: auto; min-height: 0; }
  .galaxy { position: relative; display: flex; flex-direction: column; gap: 14px; padding-bottom: 14px; }
  .gx-canvas { position: relative; height: 400px; }
  .gx-panel { position: relative; inset: auto; transform: none; width: auto; margin: 0 12px; }
  .gx-math { order: 1; }
  .gx-words { order: 2; }
  .gx-hint { display: none; }
  .gx-eq { flex-wrap: wrap; }
  .gx-eq .gx-input { flex-basis: 30%; }
  .gx-answer { flex-basis: 40%; }
  .gx-reset { top: 12px; right: 12px; }
}
