:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111111;
  background: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f7f7f7;
  --border: #d8d8d8;
  --border-strong: #a8a8a8;
  --muted: #686868;
  --accent: #0b8f6a;
  --danger: #c93636;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #ffffff;
}

body {
  min-width: 0;
}

button,
select,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

button,
select {
  min-height: 2rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.35rem;
  background: #ffffff;
  color: #111111;
}

button {
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #111111;
  background: #f3f3f3;
}

button.primary {
  border-color: #111111;
  font-weight: 700;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
output:focus-visible {
  outline: 2px solid #111111;
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.4rem;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 0.6rem;
  overflow: hidden;
}

.control-panel {
  display: grid;
  grid-template-columns:
    minmax(13.5rem, 1.35fr)
    auto auto auto
    minmax(12.5rem, 0.9fr)
    minmax(12.5rem, 0.9fr)
    minmax(9rem, 0.75fr);
  gap: 0.55rem;
  align-items: end;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}

.control {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.mode-toolbar {
  display: contents;
}
.mode-settings, .mode-settings label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.mode-settings { flex-wrap: wrap; gap: 0.4rem 0.7rem; }
.fusion-value-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.fusion-value-control input { flex-shrink: 0; }
.mode-settings input[type="number"] { width: 5rem; }
.mode-settings input[type="range"] { width: 6rem; }
.mode-settings input[type="color"] { width: 2rem; height: 1.6rem; padding: 0; }
#segmentation-smoothing { color: var(--muted); }
#fusion-wl-tool[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e5f5ef;
}
.image-plane.wl-active { cursor: crosshair; }
.viewer-tools { display: grid; grid-template-columns: repeat(3, max-content); gap: 0.35rem; font-size: 0.9rem; flex: none; align-self: center; }
#ruler-tool[aria-pressed="true"], #curve-tool[aria-pressed="true"] { background: #e5f5ef; border-color: var(--accent); }
.ruler-menu { position: relative; }
.ruler-menu summary { cursor: pointer; min-height: 2rem; padding: 0.35rem 0.5rem; border: 1px solid var(--border-strong); border-radius: 0.35rem; }
.ruler-menu summary:focus-visible { outline: 2px solid #111; outline-offset: 2px; }
.ruler-list-popover { position: fixed; z-index: 20; width: min(17rem, calc(100vw - 1rem)); max-height: 16rem; overflow: auto; padding: 0.5rem; border: 1px solid var(--border-strong); border-radius: 0.35rem; background: #fff; box-shadow: 0 3px 12px #0003; }
.ruler-list-popover ul { display: grid; gap: 0.35rem; list-style: none; margin: 0 0 0.4rem; padding: 0; }
.ruler-list-popover li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.ruler-list-popover > button { width: 100%; }
.image-plane.ruler-active { cursor: crosshair; }
.image-plane.ruler-active:focus-visible { outline: 2px solid #0d747b; outline-offset: -2px; }
.ruler-overlay, .curve-overlay { position: absolute; inset: 0; z-index: 8; width: 100%; height: 100%; pointer-events: none; overflow: hidden; }
.ruler-overlay line, .ruler-overlay circle { stroke-width: 2; fill: #ffe36a; }
.ruler-overlay circle { stroke: #ffe36a; }
.ruler-overlay text, .curve-overlay text { fill: #ffe36a; stroke: #000; stroke-width: 3; paint-order: stroke; font: bold 0.9rem ui-monospace, monospace; }
.curve-overlay text { fill: #ff858f; font-size: clamp(0.5rem, min(9cqw, 9cqh), 0.75rem); }
.curve-overlay path { fill: none; stroke: #ff858f; stroke-width: 2.5; stroke-linejoin: round; }
.curve-overlay path.curve-projection { opacity: 0.45; }
.curve-overlay circle { fill: #ff858f; stroke: #512029; stroke-width: 1.5; }
.curve-overlay .curve-preview { fill: #9af453; }
.curve-overlay circle:focus-visible { stroke: #fff; stroke-width: 3; }
.floating-panel { margin: 0; padding: 0.8rem; background: #fff; color: #111; overflow: auto; resize: none; font-size: 0.8rem; }
.floating-panel header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.detached-panel-host { overflow: auto; }
.detached-panel-host .floating-panel { position: static; inset: auto; width: 100% !important; max-width: none; height: 100dvh !important; max-height: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; resize: none; }
.floating-panel h2 { margin: 0; font-size: 1rem; }
.floating-panel p { color: var(--muted); }
.segmentation-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0; }
.segmentation-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
.segmentation-group { min-width: 0; padding: 0.4rem; border: 1px solid var(--border); border-radius: 0.3rem; }
.segmentation-group[data-category="T_only_masks"] { border-color: var(--accent); }
.segmentation-group[data-category="candidates"], .segmentation-group[data-category="simplified"] { grid-column: 1 / -1; }
.segmentation-group h3 { margin: 0 0 0.5rem; }
.segmentation-label { display: grid; grid-template-columns: 1.8rem 1.8rem minmax(0, 1fr); gap: 0.3rem; align-items: center; padding: 0.4rem 0; border-top: 1px solid var(--border); }
.segmentation-label > span { overflow-wrap: anywhere; font-size: 0.95rem; line-height: 1.4; }
.segmentation-label button { min-height: 1.6rem; padding: 0; }
.segmentation-label button[aria-pressed="false"] { opacity: 0.45; }
.segmentation-label input[type="color"] { width: 1.8rem; height: 1.6rem; padding: 0; border: 0; background: none; }
.segmentation-opacity { grid-column: 2 / -1; display: flex; gap: 0.3rem; align-items: center; font-size: 0.65rem; }
.segmentation-opacity input { min-width: 0; width: 100%; }
.segmentation-opacity output { min-width: 2rem; text-align: right; }
.segmentation-label.group-label { grid-template-columns: 1.8rem minmax(0, 1fr) auto; }
.segmentation-label .group-tf-open { padding: 0.25rem 0.6rem; }
.dicom-search { display: flex; align-items: center; gap: 0.5rem; margin: 0.8rem 0; }
.dicom-search input { flex: 1; min-width: 0; }
.dicom-content { overflow: auto; }
.dicom-content table { border-collapse: collapse; width: 100%; font: 0.7rem ui-monospace, monospace; }
.dicom-content th, .dicom-content td { text-align: left; vertical-align: top; padding: 0.3rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; max-width: 24rem; }
@media (max-width: 600px) { .segmentation-groups { grid-template-columns: 1fr; } }
.window-level-overlay {
  position: absolute;
  top: 0.4rem;
  left: 0.45rem;
  z-index: 7;
  max-width: calc(100% - 0.9rem);
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font: 0.9rem ui-monospace, monospace;
  pointer-events: none;
  overflow-wrap: anywhere;
}

.control > label,
.value-heading > label,
.slice-control,
.toggle {
  color: #1b1b1b;
  font-size: 0.85rem;
  font-weight: 650;
}

.inline {
  display: flex;
  min-width: 0;
  gap: 0.35rem;
}

.inline select {
  width: 100%;
  min-width: 0;
  padding: 0 0.55rem;
}

.toggle {
  display: flex;
  min-height: 2rem;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-size: 0.9rem;
}

input[type="checkbox"] {
  width: 0.95rem;
  height: 0.95rem;
  margin: 0;
  accent-color: #111111;
}

.range-control output {
  color: #111111;
  font-variant-numeric: tabular-nums;
}

.range-control > .value-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.editable-value {
  display: inline-grid;
  min-width: 5.5rem;
  justify-items: end;
}

.editable-value output {
  min-width: 100%;
  padding: 0.1rem 0.25rem;
  border-radius: 0.2rem;
  cursor: text;
  text-align: right;
  text-decoration: underline dotted #9a9a9a;
  text-underline-offset: 0.2rem;
}

.editable-value output[aria-disabled="true"] {
  cursor: default;
  text-decoration: none;
}

.editable-value input[type="number"] {
  width: 5.5rem;
  min-height: 1.6rem;
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.3rem;
  color: #111111;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.voxel-status {
  display: grid;
  min-width: 0;
  align-self: center;
  gap: 0.18rem;
  padding: 0.15rem 0;
}

.voxel-status span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 650;
}

.voxel-status strong {
  min-height: 1.9rem;
  color: #111111;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  white-space: pre-wrap;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: #111111;
}

.session-info {
  display: grid;
  justify-items: end;
  align-self: center;
  gap: 0.2rem;
  min-width: 0;
}

.gpu-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}

.gpu-status::before {
  width: 0.42rem;
  height: 0.42rem;
  flex: none;
  border-radius: 50%;
  background: #a0a0a0;
  content: "";
}

.gpu-status strong {
  color: #111111;
  font-size: 0.9rem;
}

.gpu-status[data-state="ready"]::before {
  background: var(--accent);
}

.gpu-status[data-state="error"]::before,
.gpu-status[data-state="context-lost"]::before {
  background: var(--danger);
}

.gpu-status:hover strong,
.gpu-status:focus-visible strong {
  text-decoration: underline;
}

.connection {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #111111;
  font-size: 0.9rem;
}

.connection span {
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  border-radius: 50%;
  background: #a0a0a0;
}

.connection[data-state="ready"] span {
  background: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(11, 143, 106, 0.12);
}

.connection[data-state="error"] span {
  background: var(--danger);
}

.coordinates {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  color: var(--muted);
  font-size: 0.7rem;
  white-space: normal;
}

.notice.error {
  top: 0.75rem;
  left: 50%;
  z-index: 20;
  width: min(38rem, calc(100vw - 2rem));
  height: auto;
  padding: 0.65rem 0.8rem;
  overflow: visible;
  clip: auto;
  clip-path: none;
  transform: translateX(-50%);
  border: 1px solid #e5adad;
  border-radius: 0.45rem;
  background: #fff7f7;
  color: var(--danger);
  box-shadow: 0 0.35rem 1.5rem rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.viewer-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.webgl-smoke-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.webgl-smoke-layer[hidden] {
  display: none;
}

.render-controls {
  --view-slider-width: calc((100vw - 2.1rem) / 3);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 140px;
  min-height: 140px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  font-size: 0.9rem;
}

.render-controls-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 0.6rem 0.9rem;
  min-width: 0;
  min-height: 0;
  padding: 1.5rem 0.8rem 0.6rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.render-controls .control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: none;
  max-width: 100%;
}

.render-controls[data-mode="segmentation"] .pet-suv-control,
.render-controls[data-mode="simplified"] .pet-suv-control {
  flex-basis: 100%;
}

.mode-toolbar > label,
.render-controls .control > label {
  white-space: nowrap;
  font-size: 0.85rem;
  font-weight: 650;
}

.mode-toolbar > select {
  max-width: 100%;
  min-width: 0;
}

.render-controls button,
.render-controls select,
.render-controls input[type="number"] {
  min-height: 44px;
  font-size: 0.9rem;
}

.sampling-control select {
  min-width: 6.5rem;
  padding-inline: 0.5rem;
}

.pet-suv-control,
.overlay-control {
  flex-wrap: wrap;
}

#pet-suv-max,
#fusion-opacity {
  flex: 0 0 var(--view-slider-width);
  width: var(--view-slider-width);
  min-width: 0;
  height: 40px;
}

.overlay-control output {
  min-width: 3rem;
  font-variant-numeric: tabular-nums;
}

.pet-suv-control .editable-value {
  min-width: 5.5rem;
  width: 5.5rem;
  font-variant-numeric: tabular-nums;
}

.pet-suv-control .editable-value output {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 44px;
}

.ct-tf-summary {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) auto auto;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
  min-height: 2.35rem;
  padding: 0.25rem 0.4rem;
  text-align: left;
}

.ct-tf-summary canvas {
  display: block;
  width: 100%;
  height: 1.55rem;
  border: 1px solid var(--border);
  border-radius: 0.2rem;
}

.ct-tf-summary span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ct-tf-summary strong {
  color: #111111;
  font-size: 0.66rem;
}

.trachea-tf-summary {
  width: 21rem;
  grid-template-columns: minmax(4rem, 1fr) auto auto;
}

.ct-tf-dialog {
  width: min(54rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: auto;
  border: 1px solid #8f8f8f;
  border-radius: 0.65rem;
  background: #ffffff;
  color: #111111;
  box-shadow: 0 1.2rem 4rem rgba(0, 0, 0, 0.2);
}

.ct-tf-dialog::backdrop {
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(2px);
}

.loading-dialog {
  width: min(28rem, calc(100vw - 2rem));
  padding: 1.2rem;
  border: 1px solid #8f8f8f;
  border-radius: 0.7rem;
  background: #ffffff;
  color: #111111;
  box-shadow: 0 1.2rem 4rem rgba(0, 0, 0, 0.24);
}

.loading-dialog::backdrop {
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(3px);
}

.loading-dialog-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.9rem;
  align-items: center;
}

.loading-spinner {
  width: 2.25rem;
  height: 2.25rem;
  border: 0.25rem solid #d8d8d8;
  border-top-color: #111111;
  border-radius: 50%;
  animation: loading-spin 750ms linear infinite;
}

.loading-kicker,
.loading-dialog h2,
.loading-dialog p {
  margin: 0;
}

.loading-kicker {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.loading-dialog h2 {
  margin-top: 0.18rem;
  font-size: 1.05rem;
}

.loading-dialog #loading-message {
  margin-top: 0.32rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.loading-dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.loading-dialog[data-state="error"] .loading-spinner {
  border: 0;
  animation: none;
}

.loading-dialog[data-state="error"] .loading-spinner::before {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border-radius: 50%;
  background: #fff0f0;
  color: var(--danger);
  content: "!";
  font-weight: 850;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation-duration: 1.8s;
  }
}

.ct-tf-dialog > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.ct-tf-dialog h2,
.ct-tf-dialog p {
  margin: 0;
}

.ct-tf-dialog h2 {
  font-size: 1rem;
}

.ct-tf-dialog p {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.ct-tf-graph {
  display: block;
  width: calc(100% - 2rem);
  height: min(15rem, 32vh);
  min-height: 9rem;
  margin: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  cursor: crosshair;
  touch-action: none;
}

.ct-tf-node-controls {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(9rem, 0.8fr) 5rem minmax(11rem, 1.2fr);
  gap: 0.75rem;
  padding: 0 1rem 1rem;
}

.ct-tf-node-controls label {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
}

.ct-tf-node-controls label > span {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.ct-tf-node-controls input,
.ct-tf-node-controls select {
  width: 100%;
  min-width: 0;
  min-height: 2rem;
}

.ct-tf-node-controls input[type="number"] {
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.35rem;
  color: #111111;
}

.ct-tf-node-controls input[type="color"] {
  padding: 0.15rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.35rem;
  background: #ffffff;
}

.ct-tf-dialog > footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

#group-tf-dialog > footer { flex-wrap: wrap; }

@media (max-width: 680px) {
  .ct-tf-node-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ct-tf-dialog > footer {
    justify-content: stretch;
  }

  .ct-tf-dialog > footer button {
    flex: 1;
  }
}

.viewport {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface);
  outline: none;
}

.viewport > header {
  display: flex;
  min-height: 1.9rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  color: #111111;
  font-size: 0.9rem;
}

.viewport > header > div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kind {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.1rem 0.3rem;
  border: 1px solid #cfcfcf;
  border-radius: 0.25rem;
  background: #ffffff;
  color: #111111;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.viewport[data-kind="fusion"] .kind {
  border-color: #a8a8a8;
  background: #e9e9e9;
  color: #111111;
}

.slice-readout {
  flex: none;
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.image-stage {
  container-type: size;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.image-plane {
  position: relative;
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  overflow: hidden;
  background: #ffffff;
  cursor: default;
  touch-action: none;
  user-select: none;
}

.image-plane img,
.crosshair {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.image-plane img {
  display: block;
  object-fit: contain;
}

.image-plane img:not([src]) {
  display: none;
}

.crosshair {
  z-index: 6;
  pointer-events: none;
}

.crosshair.is-hidden {
  display: none;
}

.crosshair line {
  vector-effect: non-scaling-stroke;
  stroke: #11b98a;
  stroke-width: 1;
  filter: none;
}

.interaction-hint {
  position: absolute;
  z-index: 7;
  right: 0.35rem;
  bottom: 0.35rem;
  left: 0.35rem;
  overflow: hidden;
  padding: 0.25rem 0.35rem;
  border-radius: 0.2rem;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 0.58rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}

.image-plane:hover .interaction-hint {
  opacity: 1;
}

.slice-control {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.35rem;
  align-items: center;
  min-height: 1.8rem;
  padding: 0.25rem 0.5rem;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

@media (max-width: 1280px) {
  .viewer-tools {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
  }

  .control-panel {
    display: flex;
    align-items: end;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .case-control {
    min-width: 13.5rem;
    flex: 1 0 13.5rem;
  }

  .toggle,
  .control-panel > button {
    flex: none;
  }

  .voxel-status {
    min-width: 15rem;
    flex: 0 0 15rem;
  }

  .session-info {
    min-width: 9rem;
    flex: 0 0 9rem;
  }

}

@media (max-height: 700px) {
  main {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0.25rem;
    padding: 0.35rem;
  }

  .control-panel {
    padding: 0.15rem 0.45rem;
  }

  .voxel-status {
    padding-block: 0;
  }

  .render-controls {
    --view-slider-width: calc((100vw - 1.6rem) / 3);
  }

  .viewport > header {
    min-height: 1.65rem;
    padding-block: 0.1rem;
  }

  .slice-control {
    min-height: 1.55rem;
    padding-block: 0.15rem;
  }
}

@media (max-height: 520px) {
  .control-panel .control > label,
  .control-panel .value-heading > label,
  .coordinates,
  .interaction-hint {
    display: none;
  }

  .control-panel {
    align-items: center;
  }

  .voxel-status span {
    display: none;
  }

}

@supports not (width: 1cqw) {
  .image-plane {
    width: 100%;
    height: 100%;
  }
}

/* Keep the active 2D tools within the panel even on a compact viewport. */
.render-controls[data-mode="fusion-2d"] .render-controls-body {
  column-gap: 0.6rem;
}

.render-controls[data-mode="fusion-2d"] #fusion-2d-controls:not([hidden]) {
  display: contents;
}
