.lab {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: 28px;
  align-items: start;
}

.viewport {
  position: relative;
  padding: 0;
  overflow: hidden;
}

#scene {
  width: 100%;
  aspect-ratio: 4 / 3;
  touch-action: none;
  cursor: grab;
}

#scene:active {
  cursor: grabbing;
}

.viewport-hint {
  margin: 0;
  padding: 8px 14px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
}

.viewport-error {
  margin: 0;
  padding: 40px 20px;
}

.controls {
  display: grid;
  gap: 22px;
}

.slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.slider-head label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.slider-head output {
  color: var(--muted);
}

.toggles {
  display: grid;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}

.key-dot {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  vertical-align: -1px;
}

.slider-head .key-dot {
  margin-right: 0;
}

.key-dot.a {
  background: #89a482;
}

.key-dot.b {
  background: #c0612b;
}

.key-dot.s {
  background: #d4b72c;
}

.numbers {
  margin-top: 36px;
  overflow-x: auto;
}

.volume-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.volume-table th,
.volume-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: right;
}

.volume-table th:first-child {
  padding-left: 0;
  text-align: left;
}

.volume-table thead th {
  font-weight: 700;
  vertical-align: bottom;
}

.volume-table tbody th {
  color: var(--muted);
  font-weight: 600;
}

.volume-table tr.total th,
.volume-table tr.total td {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}

.volume-table tr.slice th,
.volume-table tr.slice td {
  border-bottom: 0;
}

.numbers .hint {
  margin-top: 8px;
}

.explain {
  max-width: 680px;
  margin-top: 48px;
}

.explain h2 {
  margin-bottom: 12px;
  font-size: 1.6rem;
}

.formula {
  margin: 16px 0;
  padding: 14px 18px;
  border-left: 0;
  border-radius: 16px;
  background: var(--surface);
  font-size: 1.1rem;
  overflow-x: auto;
}

@media (max-width: 860px) {
  .lab {
    grid-template-columns: 1fr;
  }

  #scene {
    aspect-ratio: 1;
  }
}

.explain h2 + p {
  margin-top: 0;
}

.explain h2:not(:first-child) {
  margin-top: 40px;
}

.cuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0 8px;
}

.cut {
  margin: 0;
  padding: 12px 12px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.cut svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.cut figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-weight: 700;
}

.cut figcaption .num {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.cut-sphere {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.6;
}

.cut-ring.a {
  fill: #89a482;
}

.cut-ring.b {
  fill: #c0612b;
}

.cut-edge {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.cut-triangle,
.cut-right {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.cut-right {
  stroke-width: 1;
}

.cut-center {
  fill: var(--text);
}

.cut-label {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  font-style: italic;
}

.cases {
  display: grid;
  gap: 10px;
  margin: 12px 0 16px;
  padding-left: 20px;
}

@media (max-width: 560px) {
  .cuts {
    grid-template-columns: 1fr;
  }
}
