:root {
  color-scheme: dark;
  --bg: #0b0e0d;
  --surface: #111614;
  --surface-2: #171d1b;
  --surface-3: #202724;
  --line: #303a36;
  --line-strong: #46524e;
  --text: #eef3ef;
  --muted: #9da8a3;
  --dim: #6d7873;
  --cyan: #67d8ca;
  --cyan-soft: rgba(103, 216, 202, 0.13);
  --orange: #ec9655;
  --orange-soft: rgba(236, 150, 85, 0.14);
  --green: #75c991;
  --red: #e27668;
  --header-height: 62px;
  --dock-height: 0px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.app-shell {
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr) var(--dock-height);
  width: 100%;
  height: 100dvh;
  min-height: 0;
  background: var(--bg);
}

.app-header {
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 15, 14, 0.96);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--cyan);
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-copy small {
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(340px, 38vw);
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.mode-button {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.mode-button.is-active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.header-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.status-item {
  display: inline-flex;
  min-width: 62px;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border-left: 1px solid var(--line);
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.status-item svg {
  width: 15px;
  height: 15px;
}

.timer-status {
  color: var(--cyan);
}

.timer-status.is-urgent {
  color: var(--red);
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
  color: var(--text);
}

.mobile-panel-button,
.mobile-dock,
.panel-close {
  display: none;
}

.workspace {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: 282px minmax(0, 1fr) 322px;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 15;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  background: var(--surface);
}

.mission-panel {
  padding: 24px 20px;
  border-right: 1px solid var(--line);
}

.evidence-panel {
  display: flex;
  flex-direction: column;
  padding: 24px 20px 18px;
  border-left: 1px solid var(--line);
}

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

.panel-heading h1,
.panel-heading h2,
.dialog-header h2 {
  margin: 5px 0 0;
  font-size: 22px;
  font-weight: 640;
  letter-spacing: 0;
}

.panel-heading h2,
.dialog-header h2 {
  font-size: 19px;
}

.eyebrow {
  display: block;
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 650;
  text-transform: uppercase;
}

.mission-copy {
  margin: 14px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.sample-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-block: 1px solid var(--line);
}

.sample-meta > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  padding: 13px 0;
}

.sample-meta > div + div {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.sample-meta span,
.section-label,
.attempts-left span,
.report-sample-line span {
  color: var(--dim);
  font-size: 10px;
}

.sample-meta strong {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
}

.mission-section {
  margin-top: 22px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
}

.progress-track {
  height: 3px;
  overflow: hidden;
  background: var(--surface-3);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan);
  transition: width 280ms ease;
}

.objective-list {
  display: grid;
  gap: 1px;
  margin-top: 10px;
  background: var(--line);
}

.objective-item {
  display: grid;
  min-height: 44px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.objective-item small {
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.objective-item.is-complete {
  color: var(--text);
}

.science-note {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.science-note-icon {
  color: var(--orange);
}

.science-note strong {
  font-size: 11px;
  font-weight: 650;
}

.science-note p {
  margin: 5px 0 0;
  color: var(--dim);
  font-size: 10px;
  line-height: 1.65;
}

.stage {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.scene-container,
.scene-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scene-container {
  position: relative;
}

.scene-loading {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.02em;
  text-align: center;
  pointer-events: none;
  background: radial-gradient(circle at 50% 46%, rgba(35, 48, 45, 0.28), transparent 48%);
}

.scene-loading[hidden] {
  display: none;
}

.scene-loading.is-error {
  color: var(--red);
}

.scene-loading-spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto;
  border: 1px solid rgba(103, 216, 202, 0.24);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: scene-loading-spin 780ms linear infinite;
}

@keyframes scene-loading-spin {
  to { transform: rotate(360deg); }
}

.cut-gesture-feedback {
  --cut-start-x: 0px;
  --cut-start-y: 0px;
  --cut-tip-x: 0px;
  --cut-tip-y: 0px;
  --cut-progress: 0;
  --cut-scale: 0.72;
  --cut-alpha: 0.22;
  position: absolute;
  z-index: 6;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.cut-gesture-feedback i,
.cut-gesture-feedback b {
  position: absolute;
  display: block;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.cut-gesture-origin {
  left: var(--cut-start-x);
  top: var(--cut-start-y);
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(192, 223, 218, 0.58);
  background: rgba(16, 29, 28, 0.48);
}

.cut-gesture-tip {
  left: var(--cut-tip-x);
  top: var(--cut-tip-y);
  width: 13px;
  height: 13px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(226, 247, 243, 0.88);
  background: rgba(76, 177, 166, 0.3);
  box-shadow: 0 0 12px rgba(99, 220, 207, 0.4);
}

.cut-gesture-feedback b {
  left: var(--cut-tip-x);
  top: var(--cut-tip-y);
  width: 29px;
  height: 29px;
  transform: translate(-50%, -50%) scale(var(--cut-scale));
  border: 2px solid rgba(103, 216, 202, var(--cut-alpha));
}

.cut-gesture-feedback.is-active i,
.cut-gesture-feedback.is-active b {
  opacity: 1;
}

.cut-gesture-feedback.is-ready .cut-gesture-tip,
.cut-gesture-feedback.is-ready b {
  border-color: rgba(238, 166, 95, 0.94);
  box-shadow: 0 0 15px rgba(225, 132, 67, 0.45);
}

.cut-gesture-feedback.is-commit .cut-gesture-tip {
  opacity: 1;
  animation: cut-touch-confirm 180ms ease-out forwards;
}

@keyframes cut-touch-confirm {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.sample-identity {
  position: absolute;
  top: 22px;
  left: 22px;
  max-width: min(310px, calc(100% - 44px));
  pointer-events: none;
}

.sim-chip {
  display: inline-flex;
  height: 23px;
  align-items: center;
  gap: 6px;
  padding: 0 7px;
  border: 1px solid rgba(103, 216, 202, 0.38);
  color: var(--cyan);
  background: rgba(11, 14, 13, 0.65);
  font-size: 9px;
}

.sim-chip svg {
  width: 12px;
  height: 12px;
}

.sample-identity h2 {
  margin: 9px 0 3px;
  font-size: clamp(18px, 2.1vw, 28px);
  font-weight: 610;
  letter-spacing: 0;
  text-shadow: 0 2px 18px #000;
}

.sample-identity p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.view-hud {
  position: absolute;
  right: 22px;
  bottom: 116px;
  display: flex;
  align-items: center;
  gap: 1px;
  border: 1px solid rgba(70, 82, 78, 0.55);
  background: rgba(11, 14, 13, 0.66);
  pointer-events: none;
}

.view-hud span {
  display: inline-flex;
  height: 29px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.view-hud span + span {
  border-left: 1px solid var(--line);
}

.view-hud svg {
  width: 13px;
  height: 13px;
  color: var(--cyan);
}

.readout-panel {
  position: absolute;
  top: 22px;
  right: 22px;
  display: none;
  width: min(390px, calc(100% - 44px));
  padding: 14px 15px 15px;
  border: 1px solid var(--line-strong);
  background: rgba(17, 22, 20, 0.94);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(14px);
}

.readout-panel.is-visible {
  display: block;
  animation: readout-in 180ms ease-out;
}

@keyframes readout-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.readout-header {
  display: flex;
  height: 25px;
  align-items: flex-start;
  justify-content: space-between;
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.readout-header .icon-button {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  border: 0;
}

.readout-header svg {
  width: 14px;
  height: 14px;
}

.readout-panel > strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 640;
}

.readout-value {
  margin-top: 7px;
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
}

.readout-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.magnetic-meter {
  position: absolute;
  top: 50%;
  right: 28px;
  display: none;
  width: 126px;
  padding: 10px;
  transform: translateY(-50%);
  border: 1px solid rgba(103, 216, 202, 0.32);
  background: rgba(11, 14, 13, 0.78);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.magnetic-meter.is-visible {
  display: grid;
  gap: 7px;
}

.magnetic-meter > span {
  color: var(--dim);
  font-size: 8px;
}

.magnetic-meter > b {
  color: var(--cyan);
  font-size: 17px;
}

.meter-track {
  height: 3px;
  background: var(--surface-3);
}

.meter-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan);
  transition: width 700ms ease;
}

.reagent-dose-panel {
  position: absolute;
  top: 50%;
  right: 28px;
  display: none;
  width: 174px;
  padding: 10px;
  transform: translateY(-50%);
  border: 1px solid rgba(197, 219, 150, 0.34);
  background: rgba(11, 14, 13, 0.84);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.reagent-dose-panel.is-visible {
  display: grid;
  gap: 8px;
}

.reagent-dose-panel > span {
  color: #bdc9a6;
  font-size: 9px;
}

.reagent-dose-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.reagent-dose-options button {
  min-width: 0;
  height: 34px;
  border: 0;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font: inherit;
  font-size: 9px;
  cursor: pointer;
}

.reagent-dose-options button + button {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.reagent-dose-options button b {
  display: block;
  margin-top: 2px;
  color: inherit;
  font-size: 10px;
}

.reagent-dose-options button.is-active {
  background: rgba(177, 205, 128, 0.16);
  color: #d8e8b8;
}

.hydrogen-panel {
  position: absolute;
  /* Keep the verification controls in the HUD area.  The old centered
     position sat directly on top of the sample when a mobile breakpoint was
     missed (for example on an embedded 768px viewport). */
  top: 86px;
  right: 28px;
  display: none;
  width: min(270px, calc(100% - 44px));
  padding: 10px;
  transform: none;
  border: 1px solid rgba(100, 204, 235, 0.34);
  background: rgba(11, 14, 13, 0.88);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hydrogen-panel.is-visible {
  display: grid;
  gap: 8px;
}

.hydrogen-panel-header,
.hydrogen-volume-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hydrogen-panel-header > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #bfeef2;
  font-size: 9px;
}

.hydrogen-panel-header svg {
  width: 13px;
  height: 13px;
}

.hydrogen-panel-header > b {
  color: var(--dim);
  font-size: 8px;
  font-weight: 500;
  text-align: right;
}

.hydrogen-volume-row {
  color: var(--dim);
  font-size: 8px;
}

.hydrogen-volume-row strong {
  color: #a9eaf2;
  font-size: 13px;
  font-weight: 650;
}

.hydrogen-volume-track {
  height: 4px;
  overflow: hidden;
  background: rgba(139, 222, 232, 0.12);
}

.hydrogen-volume-track i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #51b7df, #b6f7ee);
  transition: width 120ms linear;
}

.hydrogen-panel p {
  min-height: 24px;
  margin: 0;
  color: var(--dim);
  font-size: 8px;
  line-height: 1.5;
}

.hydrogen-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.hydrogen-actions button {
  display: inline-flex;
  min-width: 0;
  height: 30px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(146, 222, 232, 0.24);
  background: rgba(92, 194, 220, 0.08);
  color: #bfeef2;
  font: inherit;
  font-size: 8px;
  cursor: pointer;
}

.hydrogen-actions button:hover:not(:disabled) {
  background: rgba(92, 194, 220, 0.18);
  color: #e4ffff;
}

.hydrogen-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

.hydrogen-actions button:last-child:not(:disabled) {
  border-color: rgba(75, 188, 255, 0.48);
  background: rgba(50, 148, 222, 0.14);
  color: #b9eaff;
}

.hydrogen-actions svg {
  width: 13px;
  height: 13px;
}

.waveform-canvas {
  position: absolute;
  bottom: 127px;
  left: 50%;
  display: none;
  width: min(480px, calc(100% - 52px));
  height: 76px;
  transform: translateX(-50%);
  opacity: 0.88;
  pointer-events: none;
}

.waveform-canvas.is-visible {
  display: block;
}

.tool-rail-shell {
  position: absolute;
  bottom: 18px;
  left: 50%;
  display: flex;
  width: min-content;
  max-width: calc(100% - 32px);
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform: translateX(-50%);
}

.tool-group-label {
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  text-transform: uppercase;
}

.tool-shell-heading {
  display: flex;
  width: 100%;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tool-reset {
  display: inline-flex;
  min-width: 72px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(17, 22, 20, 0.94);
  color: var(--dim);
  cursor: pointer;
}

.tool-reset:hover {
  border-color: var(--line-strong);
  color: var(--cyan);
}

.tool-reset svg {
  width: 15px;
  height: 15px;
}

.tool-reset span {
  font-size: 10px;
  font-weight: 650;
}

.tool-rail {
  display: flex;
  width: max-content;
  max-width: 100%;
  gap: 1px;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  background: var(--line);
  box-shadow: 0 13px 38px rgba(0, 0, 0, 0.4);
  scrollbar-width: none;
}

.tool-rail::-webkit-scrollbar {
  display: none;
}

.tool-button {
  position: relative;
  display: grid;
  width: 78px;
  height: 68px;
  flex: 0 0 78px;
  grid-template-rows: 26px 14px 10px;
  place-items: center;
  gap: 2px;
  padding: 7px 4px 5px;
  border: 0;
  border-radius: 0;
  background: rgba(17, 22, 20, 0.94);
  color: var(--muted);
  cursor: pointer;
}

.tool-button:hover,
.tool-button.is-active {
  background: var(--surface-3);
  color: var(--text);
}

.tool-button.is-active::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--cyan);
  content: "";
}

.tool-button.is-destructive:not(.is-active)::after {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 4px;
  height: 4px;
  background: var(--orange);
  content: "";
}

.tool-button:disabled {
  color: var(--dim);
  cursor: not-allowed;
  opacity: 0.46;
}

.tool-button svg {
  width: 21px;
  height: 21px;
}

.tool-button > span {
  overflow: hidden;
  max-width: 100%;
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tool-button > small {
  display: inline-flex;
  height: 13px;
  align-items: center;
  padding: 0 3px;
  background: var(--orange-soft);
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  line-height: 1;
  white-space: nowrap;
}

.tool-button > small.is-ready {
  background: rgba(103, 216, 202, 0.1);
  color: var(--cyan);
}

.tool-button.is-locked:not(:disabled) {
  color: var(--text);
}

.tool-button.is-busy {
  cursor: wait;
  opacity: 0.62;
}

.stage-toast {
  position: absolute;
  top: 90px;
  left: 50%;
  z-index: 20;
  padding: 8px 11px;
  transform: translate(-50%, -8px);
  border: 1px solid var(--line-strong);
  background: rgba(17, 22, 20, 0.95);
  color: var(--text);
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.stage-toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.evidence-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 9px;
}

.evidence-summary b {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.evidence-list {
  min-height: 150px;
  flex: 1;
  overflow-y: auto;
}

.empty-evidence {
  display: grid;
  min-height: 210px;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--dim);
  text-align: center;
}

.empty-evidence svg {
  width: 28px;
  height: 28px;
}

.empty-evidence p {
  max-width: 190px;
  margin: 0;
  font-size: 10px;
  line-height: 1.6;
}

.evidence-item {
  position: relative;
  padding: 13px 0 13px 22px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.evidence-item:hover,
.evidence-item:focus-visible {
  outline: none;
  background: var(--surface-2);
}

.evidence-item:focus-visible {
  box-shadow: inset 0 0 0 1px var(--cyan);
}

.evidence-item::before {
  position: absolute;
  top: 18px;
  left: 4px;
  width: 6px;
  height: 6px;
  border: 1px solid var(--cyan);
  background: var(--surface);
  content: "";
}

.evidence-item::after {
  position: absolute;
  top: 25px;
  bottom: -18px;
  left: 7px;
  width: 1px;
  background: var(--line-strong);
  content: "";
}

.evidence-item:last-child::after {
  display: none;
}

.evidence-item.is-strong::before {
  background: var(--cyan);
}

.evidence-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.evidence-item header span {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
}

.evidence-item header small {
  color: var(--dim);
  font-size: 8px;
}

.evidence-item strong {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 620;
  line-height: 1.45;
}

.evidence-item p {
  display: -webkit-box;
  overflow: hidden;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.evidence-open-hint {
  display: block;
  margin-top: 8px;
  color: var(--cyan);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.evidence-footer {
  margin-top: 12px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.attempts-left {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.attempts-left b {
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
}

.primary-command,
.secondary-command {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--cyan);
  border-radius: 0;
  background: var(--cyan);
  color: #08110f;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.primary-command:hover {
  background: #87e8dc;
}

.primary-command:disabled {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--dim);
  cursor: not-allowed;
}

.secondary-command {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--text);
}

.evidence-footer .primary-command,
.mission-panel > .primary-command {
  width: 100%;
}

.mission-panel > .primary-command {
  margin-top: 20px;
}

.identify-only {
  display: none;
}

.mode-identify .identify-only {
  display: flex;
}

.mode-identify .timer-status {
  display: inline-flex;
}

.mode-explore .timer-status {
  display: none;
}

dialog {
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(8px);
}

.report-dialog,
.result-dialog,
.evidence-dialog,
.image-zoom-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.55);
}

.evidence-dialog {
  overflow: hidden;
}

.evidence-dialog-content {
  max-height: min(760px, calc(100dvh - 28px));
  overflow-y: auto;
  padding: 22px;
}

.evidence-dialog-value {
  margin-top: 20px;
  padding: 12px 0;
  border-block: 1px solid var(--line);
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.evidence-dialog-detail {
  max-height: min(360px, 42vh);
  margin: 16px 0 0;
  overflow-y: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.evidence-dialog-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.evidence-dialog-reference {
  min-width: 0;
  margin: 0;
}

.reference-image-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  cursor: zoom-in;
}

.reference-image-button img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
}

.reference-image-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  background: rgba(8, 13, 12, 0.82);
  color: var(--text);
  font-size: 9px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.reference-image-button:hover .reference-image-zoom,
.reference-image-button:focus-visible .reference-image-zoom {
  opacity: 1;
}

.reference-image-button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}

.reference-image-zoom svg {
  width: 12px;
  height: 12px;
}

.reference-image-zoom em {
  font-style: normal;
}

.evidence-dialog-reference figcaption {
  margin-top: 6px;
  color: var(--dim);
  font-size: 9px;
  line-height: 1.45;
}

.image-zoom-dialog {
  width: min(1080px, calc(100vw - 28px));
}

.image-zoom-content {
  padding: 18px;
}

.image-zoom-content img {
  display: block;
  width: 100%;
  max-height: calc(100dvh - 120px);
  margin-top: 16px;
  object-fit: contain;
  background: #060807;
}

.report-dialog form {
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.report-sample-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 12px 0;
  border-block: 1px solid var(--line);
}

.report-sample-line strong {
  font-size: 12px;
}

fieldset {
  min-width: 0;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.classification-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.classification-option {
  position: relative;
  min-height: 50px;
  background: var(--surface-2);
  cursor: pointer;
}

.classification-option input {
  position: absolute;
  opacity: 0;
}

.classification-option span {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 50px;
  place-items: center;
  padding: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.classification-option input:checked + span {
  background: var(--cyan-soft);
  box-shadow: inset 0 -2px 0 var(--cyan);
  color: var(--text);
}

.classification-option input:focus-visible + span {
  outline: 2px solid var(--cyan);
  outline-offset: -3px;
}

.report-check {
  display: grid;
  min-height: 48px;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  line-height: 1.55;
}

.report-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--cyan);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.result-dialog {
  width: min(470px, calc(100vw - 28px));
}

.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 28px 26px;
  text-align: center;
}

.result-mark {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 17px;
  place-items: center;
  border: 1px solid var(--green);
  color: var(--green);
}

.result-mark.is-error {
  border-color: var(--red);
  color: var(--red);
}

.result-mark svg {
  width: 25px;
  height: 25px;
}

.result-content h2 {
  margin: 7px 0 0;
  font-size: 22px;
  font-weight: 650;
}

.result-content > p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.score-line {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 14px;
  padding: 13px 0;
  border-block: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.score-line strong {
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 19px;
}

.result-content .primary-command {
  width: 100%;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 250px minmax(0, 1fr) 285px;
  }

  .tool-button {
    width: 68px;
    flex-basis: 68px;
  }

  .readout-panel {
    width: min(340px, calc(100% - 44px));
  }
}

@media (max-width: 900px) {
  :root {
    --header-height: 56px;
    --dock-height: 54px;
  }

  .app-shell {
    min-height: 0;
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 0 10px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .brand-copy strong {
    font-size: 13px;
  }

  .brand-copy small {
    display: none;
  }

  .mode-switch {
    position: absolute;
    top: 9px;
    left: 50%;
    width: min(300px, 44vw);
    transform: translateX(-50%);
  }

  .header-status {
    gap: 1px;
  }

  .status-item {
    min-width: 52px;
    padding: 0 7px;
  }

  .mobile-panel-button {
    display: none;
  }

  .workspace {
    display: block;
  }

  .stage {
    width: 100%;
    height: 100%;
  }

  .sidebar {
    position: absolute;
    z-index: 35;
    top: 0;
    bottom: 0;
    display: none;
    width: min(360px, 100%);
    box-shadow: 18px 0 50px rgba(0, 0, 0, 0.42);
  }

  .mission-panel {
    left: 0;
  }

  .evidence-panel {
    right: 0;
  }

  .sidebar.is-open {
    display: flex;
    flex-direction: column;
  }

  .panel-close {
    display: inline-grid;
  }

  .mobile-dock {
    position: relative;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  .mobile-dock button {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--dim);
    cursor: pointer;
    font-size: 10px;
  }

  .mobile-dock button + button {
    border-left: 1px solid var(--line);
  }

  .mobile-dock button.is-active {
    color: var(--cyan);
    box-shadow: inset 0 2px 0 var(--cyan);
  }

  .tool-rail-shell {
    bottom: 12px;
  }

  .view-hud {
    bottom: 104px;
  }

  .waveform-canvas {
    bottom: 113px;
  }

  .hydrogen-panel {
    top: 102px;
    right: auto;
    left: 22px;
    width: min(220px, calc(100% - 44px));
    max-height: none;
    padding: 6px 8px;
    background: rgba(11, 14, 13, 0.72);
    backdrop-filter: blur(8px);
  }

  .hydrogen-panel.is-visible {
    gap: 4px;
  }

  .hydrogen-panel p {
    display: none;
  }

  .hydrogen-volume-row strong {
    font-size: 12px;
  }

  .hydrogen-actions {
    gap: 4px;
  }

  .hydrogen-actions button {
    height: 26px;
  }
}

@media (max-width: 620px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .brand-copy {
    display: none;
  }

  .mode-switch {
    left: 48px;
    width: min(250px, calc(100vw - 160px));
    transform: none;
  }

  .mode-button {
    font-size: 10px;
  }

  .status-item {
    min-width: 46px;
    padding: 0 5px;
    font-size: 10px;
  }

  .status-item svg {
    width: 13px;
    height: 13px;
  }

  .sample-identity {
    top: 14px;
    left: 14px;
  }

  .sample-identity h2 {
    margin-top: 7px;
    font-size: 18px;
  }

  .sample-identity p {
    max-width: 190px;
    line-height: 1.4;
  }

  .readout-panel {
    top: auto;
    right: 12px;
    bottom: 122px;
    width: calc(100% - 24px);
    max-height: 176px;
    overflow-y: auto;
    padding: 11px 12px;
  }

  .readout-panel p {
    font-size: 10px;
  }

  .readout-value {
    font-size: 10px;
  }

  .view-hud {
    top: 14px;
    right: 12px;
    bottom: auto;
  }

  .view-hud span:first-child {
    display: none;
  }

  .magnetic-meter {
    top: 82px;
    right: 12px;
    transform: none;
  }

  .reagent-dose-panel {
    top: 82px;
    right: 12px;
    transform: none;
  }

  .hydrogen-panel {
    top: 100px;
    left: 14px;
    width: min(220px, calc(100% - 28px));
  }

  .tool-rail-shell {
    bottom: 10px;
    max-width: calc(100% - 18px);
  }

  .tool-group-label {
    display: none;
  }

  .tool-button {
    width: 68px;
    height: 64px;
    flex-basis: 68px;
  }

  .waveform-canvas {
    bottom: 122px;
    height: 64px;
  }

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

  .report-dialog form {
    padding: 18px;
  }
}

@media (max-width: 390px) {
  .brand {
    display: none;
  }

  .mode-switch {
    left: 8px;
    width: calc(100vw - 78px);
  }

  .mode-button {
    padding: 0 3px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mode-explore .header-status .status-item:first-child {
    display: inline-flex;
  }

  .mode-identify .header-status .status-item:first-child {
    display: inline-flex;
  }

  .sample-identity p {
    max-width: 155px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Standalone NWA 11420 experiment */
.standalone .app-header {
  grid-template-columns: minmax(190px, 1fr) auto minmax(120px, 1fr);
}

.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.game-title strong {
  font-size: 12px;
  font-weight: 650;
}

.game-title span {
  color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
}

@media (max-width: 900px) {
  .standalone .app-header {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .standalone .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .standalone .brand-copy,
  .standalone .game-title span {
    display: none;
  }

  .standalone .game-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (max-width: 390px) {
  .standalone .brand {
    display: flex;
  }

  .standalone .game-title {
    display: none;
  }
}
