.visualisation-canvas {
  min-height: calc(100svh + var(--footer-height));
  padding-bottom: var(--footer-height);
}

.page.page-visualisation {
  position: relative;
  height: auto;
  min-height: 100svh;
  z-index: 1;
}

.page-visualisation {
  --viz-line: color-mix(in srgb, var(--text-main) 10%, transparent);
  --viz-line-strong: color-mix(in srgb, var(--text-main) 18%, transparent);
  --viz-surface: #e7b85c;
  --viz-core: var(--accent);
  --viz-target: color-mix(in srgb, var(--text-main) 56%, transparent);
}

.page-visualisation .page-main {
  position: relative;
  inset: auto;
  height: auto;
  min-height: 0;
  overflow: visible;
  background: var(--page-bg);
}

.visualisation-main {
  width: 100%;
  padding: calc(var(--header-height) + 28px) var(--page-gutter)
    clamp(56px, 6vw, 88px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.visualisation-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.visualisation-header-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.visualisation-eyebrow {
  margin: 0;
  font-size: 11px;
  line-height: 14px;
  text-transform: uppercase;
}

.visualisation-title {
  margin: 0;
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: clamp(34px, 4vw, 50px);
  font-weight: 540;
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.visualisation-tabs {
  display: flex;
  border: 1px solid var(--line);
}

.visualisation-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.visualisation-tab + .visualisation-tab {
  border-left: 1px solid var(--line);
}

.visualisation-tab-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.visualisation-tab-label {
  display: block;
  padding: 10px 22px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 430;
  line-height: 18px;
  text-transform: uppercase;
  transition:
    color 0.18s ease,
    background-color 0.18s ease;
}

.visualisation-tab-radio:checked + .visualisation-tab-label {
  color: var(--text-main);
  background: color-mix(in srgb, var(--text-main) 4%, transparent);
}

.visualisation-tab-radio:focus-visible + .visualisation-tab-label {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

@media (hover: hover) and (pointer: fine) {
  .visualisation-tab:hover .visualisation-tab-label {
    color: var(--accent);
  }
}

.visualisation-panel[hidden] {
  display: none !important;
}

.viz-workbench {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: max-content;
  border: 1px solid var(--viz-line);
  background: var(--page-bg);
}

.viz-rail,
.viz-stage {
  min-width: 0;
}

.viz-rail {
  padding: 22px 22px 24px;
  border-right: 1px solid var(--viz-line);
}

.viz-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--viz-line);
}

.viz-rail-title,
.viz-group-label,
.viz-field-value,
.viz-metric-label,
.viz-chart-axis,
.viz-reset {
  font-family: var(--font-code);
}

.viz-rail-title,
.viz-group-label,
.viz-metric-label,
.viz-chart-axis {
  margin: 0;
}

.viz-rail-title {
  color: var(--text-main);
  font-size: 12px;
  line-height: 15px;
  text-transform: uppercase;
}

.viz-reset {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
  text-transform: uppercase;
  cursor: pointer;
}

.viz-reset:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .viz-reset:hover {
    color: var(--accent);
  }
}

.viz-group {
  display: flex;
  flex-direction: column;
  padding-top: 18px;
}

.viz-group + .viz-group {
  margin-top: 14px;
}

.viz-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 2px;
  cursor: pointer;
  list-style: none;
}

.viz-group-head::-webkit-details-marker {
  display: none;
}

.viz-group-head::marker {
  content: "";
}

.viz-group-head:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

.viz-group-label {
  color: color-mix(in srgb, var(--text-main) 58%, var(--text-muted) 42%);
  font-size: 13px;
  font-weight: 430;
  line-height: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.viz-group-toggle {
  position: relative;
  flex: none;
  width: 12px;
  height: 12px;
  color: color-mix(in srgb, var(--text-main) 54%, var(--text-muted) 46%);
}

.viz-group-toggle::before,
.viz-group-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
  transition: transform 0.18s ease;
}

.viz-group-toggle::before {
  width: 11px;
  height: 1px;
}

.viz-group-toggle::after {
  width: 1px;
  height: 11px;
}

.viz-group[open] .viz-group-toggle::after {
  transform: translate(-50%, -50%) scaleY(0);
}

.viz-group-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
}

.viz-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.viz-field-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.viz-field-label {
  color: var(--text-main);
  font-size: 13px;
  font-weight: 430;
  line-height: 1.35;
}

.viz-field-value {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}

.viz-range {
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  background: transparent;
}

.viz-range:focus {
  outline: none;
}

.viz-range::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--viz-line-strong);
}

.viz-range::-moz-range-track {
  height: 1px;
  background: var(--viz-line-strong);
}

.viz-range::-webkit-slider-thumb {
  appearance: none;
  width: 10px;
  height: 10px;
  margin-top: -4.5px;
  border: 1px solid var(--text-main);
  border-radius: 999px;
  background: var(--page-bg);
  box-shadow: none;
}

.viz-range::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 1px solid var(--text-main);
  border-radius: 999px;
  background: var(--page-bg);
  box-shadow: none;
}

.viz-stage {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.viz-stage-head,
.viz-chart-shell,
.viz-metrics,
.viz-context {
  padding-inline: clamp(20px, 2.3vw, 30px);
}

.viz-stage-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-top: 22px;
  padding-bottom: 18px;
}

.viz-stage-title {
  margin: 4px 0 0;
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: clamp(24px, 2.5vw, 36px);
  font-weight: 520;
  line-height: 1;
  letter-spacing: -0.03em;
}

.viz-stage-kicker {
  margin: 0;
  font-size: 11px;
  line-height: 14px;
  text-transform: uppercase;
}

.viz-legend {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
}

.viz-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}

.viz-legend-swatch {
  width: 22px;
  height: 1px;
  background: currentColor;
}

.viz-legend-swatch-core {
  color: var(--viz-core);
}

.viz-legend-swatch-surface {
  color: var(--viz-surface);
}

.viz-legend-swatch-target {
  color: var(--viz-target);
  border-top: 1px dashed currentColor;
  background: transparent;
}

.viz-chart-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 18px;
  padding-bottom: 20px;
  border-top: 1px solid var(--viz-line);
}

.viz-chart-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.viz-chart-note {
  margin: 0;
  color: var(--text-main);
  font-size: 17px;
  line-height: 1.3;
}

.viz-chart-frame {
  border: 1px solid var(--viz-line);
  background: color-mix(in srgb, var(--text-main) 2%, var(--page-bg) 98%);
  overflow: hidden;
}

.viz-chart {
  display: block;
  width: 100%;
  height: auto;
}

.viz-chart-grid {
  stroke: var(--viz-line);
  stroke-width: 1;
}

.viz-chart-grid-vertical {
  stroke-dasharray: 2 10;
}

.viz-chart-axis {
  fill: var(--text-secondary);
  font-size: 10px;
  letter-spacing: -0.01em;
}

.viz-chart-axis-temp {
  text-anchor: end;
}

.viz-chart-target {
  stroke: var(--viz-target);
  stroke-width: 1;
  stroke-dasharray: 5 7;
}

.viz-chart-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viz-chart-line-core {
  stroke: var(--viz-core);
  stroke-width: 2.4;
}

.viz-chart-line-surface {
  stroke: var(--viz-surface);
  stroke-width: 1.9;
}

.viz-chart-marker {
  fill: var(--viz-core);
  stroke: var(--page-bg);
  stroke-width: 1.5;
}

.viz-chart-marker-label {
  fill: var(--text-main);
}

.viz-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px 20px;
  padding-bottom: 20px;
}

.viz-metric {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 0;
}

.viz-metric-label {
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 14px;
  text-transform: uppercase;
}

.viz-metric-value {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(20px, 1.9vw, 28px);
  font-weight: 520;
  line-height: 1;
  letter-spacing: -0.03em;
}

.viz-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding-top: 18px;
  padding-bottom: 18px;
  border-top: 1px solid var(--viz-line);
}

.viz-context-block + .viz-context-block {
  border-left: 1px solid var(--viz-line);
  padding-left: 20px;
  margin-left: 20px;
}

.viz-context-title {
  margin: 0 0 8px;
  color: var(--text-main);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.viz-context-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.viz-context-copy mjx-container[jax="CHTML"] {
  margin-inline: 0.08em;
  font-size: 1em !important;
}

.viz-stage-sphere {
  display: flex;
  flex-direction: column;
  min-height: max-content;
}

.viz-stage-head-sphere {
  align-items: flex-end;
}

.viz-volume-shell {
  display: flex;
  flex-direction: column;
  min-height: max-content;
  border-top: 1px solid var(--viz-line);
}

.viz-volume-meta,
.viz-volume-controls,
.viz-sphere-metrics {
  padding-inline: clamp(20px, 2.3vw, 30px);
}

.viz-volume-meta {
  padding-top: 18px;
  padding-bottom: 14px;
}

.viz-thermal-scale-bar {
  width: clamp(120px, 16vw, 168px);
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #f0ece2 0%,
    #e0bf76 42%,
    #cf7045 74%,
    #7f2219 100%
  );
}

.viz-volume-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.9fr);
  align-items: stretch;
}

.viz-volume-frame {
  margin-inline: clamp(20px, 2.3vw, 30px);
  min-height: clamp(360px, 33vw, 520px);
  overflow: hidden;
}

.viz-volume-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.viz-volume-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 16px clamp(20px, 2.3vw, 30px) 14px;
}

.viz-volume-panel-title {
  margin: 0;
  color: var(--text-main);
  font-family: var(--font-code);
  font-size: 11px;
  line-height: 14px;
  text-transform: uppercase;
}

.viz-volume-panel-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
  text-align: right;
}

.viz-canvas-shell {
  display: flex;
  flex: 1;
  padding: 16px;
  min-height: clamp(300px, 28vw, 460px);
  background: transparent;
}

.viz-canvas-shell-volume {
  position: relative;
  align-items: stretch;
}

.viz-canvas-shell-slice {
  display: flex;
  align-items: center;
  justify-content: center;
}

.viz-volume-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.viz-slice-canvas {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
}

.viz-volume-status {
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 6px 8px;
  color: var(--text-secondary);
  font-family: var(--font-code);
  font-size: 10px;
  line-height: 13px;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--page-bg) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--text-main) 8%, transparent);
  pointer-events: none;
}

.viz-volume-status[hidden] {
  display: none;
}

.viz-volume-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 20px;
}

.viz-volume-controls-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.viz-play {
  min-width: 76px;
  padding: 11px 16px;
  border: 1px solid var(--viz-line-strong);
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-code);
  font-size: 11px;
  line-height: 14px;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    color 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease;
}

.viz-play[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--viz-line-strong));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.viz-play:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
  .viz-play:hover {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 34%, var(--viz-line-strong));
  }
}

.viz-inline-field {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.viz-inline-field-wide {
  min-width: 0;
}

.viz-inline-field > .viz-field-top {
  margin-bottom: 8px;
}

.viz-inline-hints {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-secondary);
  font-family: var(--font-code);
  font-size: 10px;
  line-height: 13px;
  text-transform: uppercase;
}

.viz-sphere-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 20px;
  padding-bottom: 20px;
}

.viz-sphere-metric {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 0;
}

@media (max-width: 1200px) {
  .viz-workbench {
    grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  }

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

  .viz-context {
    grid-template-columns: 1fr;
  }

  .viz-context-block + .viz-context-block {
    border-left: 0;
    border-top: 1px solid var(--viz-line);
    padding-left: 0;
    padding-top: 18px;
    margin-left: 0;
    margin-top: 18px;
  }

  .viz-volume-grid {
    grid-template-columns: 1fr;
  }

  .viz-volume-frame {
    min-height: 0;
  }

  .viz-canvas-shell {
    min-height: clamp(360px, 52vw, 560px);
  }

  .viz-slice-canvas {
    width: 66.666%;
    height: auto;
    max-height: none;
  }

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

  .viz-sphere-metric:nth-child(3) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 960px) {
  .page-visualisation .menu-center,
  .page-visualisation .menu-right {
    display: none;
  }

  .page-visualisation .hamburger {
    display: flex;
  }

  .page-visualisation .drawer {
    display: block;
  }

  .viz-workbench {
    grid-template-columns: 1fr;
  }

  .viz-rail {
    border-right: 0;
    border-bottom: 1px solid var(--viz-line);
  }

  .visualisation-tabs {
    width: 100%;
  }

  .visualisation-tab {
    flex: 1;
  }

  .visualisation-tab-label {
    width: 100%;
    text-align: center;
  }

  .viz-volume-controls-top {
    grid-template-columns: 1fr;
  }

  .viz-play {
    width: 100%;
  }

  .viz-chart-marker-label {
    display: none;
  }
}

@media (max-width: 720px) {
  .viz-stage-head,
  .viz-chart-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .viz-chart-meta .viz-chart-note {
    display: none;
  }

  .viz-metrics {
    grid-template-columns: 1fr;
  }

  .viz-stage-head-sphere,
  .viz-volume-panel-head {
    align-items: flex-start;
  }

  .viz-volume-panel-head {
    flex-direction: column;
  }

  .viz-sphere-metrics {
    grid-template-columns: 1fr;
  }

  .viz-canvas-shell {
    min-height: clamp(300px, 74vw, 520px);
  }
}

@media (max-width: 560px) {
  .visualisation-main {
    padding-top: calc(var(--header-height) + 24px);
    gap: 22px;
  }

  .visualisation-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
  }

  .viz-rail {
    padding: 18px;
  }

  .viz-stage-head,
  .viz-chart-shell,
  .viz-metrics,
  .viz-context,
  .viz-volume-meta,
  .viz-volume-controls,
  .viz-sphere-metrics {
    padding-inline: 18px;
  }

  .viz-stage-head {
    padding-top: 18px;
    padding-bottom: 14px;
  }

  .viz-stage-title {
    font-size: 30px;
  }

  .viz-chart-note {
    font-size: 16px;
  }

  .viz-metric-value {
    font-size: 24px;
  }

  .viz-canvas-shell {
    padding: 12px;
    min-height: clamp(280px, 78vw, 460px);
  }
}
