#stage {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: clamp(16px, 3vw, 36px);
  background: radial-gradient(ellipse at 50% 45%, #111d29, #05070d 75%);
}
.scene-header, .scene-select, .scene-footer, .plot-wrap { width: 100%; max-width: 1080px; margin: 0 auto; }
.scene-header { display: flex; align-items: center; justify-content: space-between; }
.scene-topic { color: var(--accent); font-size: 13px; margin: 0 0 1px; }
.scene-header h2 { font-size: 18px; margin: 0; }
.seg button, .control, #panelToggle { min-height: 44px; color: var(--accent); font-weight: 600; }
.seg button { padding-inline: 14px; }
.scene-select { display: flex; align-items: center; }
.scene-select button { flex: 0 1 auto; }

.plot-wrap { display: grid; place-items: center; container-type: size; }
#plot {
  position: relative;
  width: min(100cqw, 160cqh);
  aspect-ratio: 8 / 5;
  background: #142838 url("landscape.svg") center / 100% 100% no-repeat;
  border-radius: 14px;
  isolation: isolate;
  box-shadow: 0 0 0 1px #334657, 0 15px 58px #030508a6;
}
#section, #steps { position: absolute; inset: 0; width: 100%; height: 100%; }
#section { border-radius: inherit; }
.process-btn, .terrain-label { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; }
.process-btn {
  --tone: #d6ecf8;
  border: 0;
  color: var(--tone);
  background: none;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.process-btn span, .terrain-label {
  display: inline-block;
  background: #0a1320ee;
  border: 1px solid #8399b25c;
  border-radius: 5px;
  padding: 4px 6px;
}
.process-btn:hover span, .process-btn[aria-pressed="true"] span {
  color: #111927;
  background: var(--accent);
  border-color: var(--accent);
}
.terrain-label { left: 26%; top: 79%; font-size: 12px; color: #cff3fc; pointer-events: none; }
.scene-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.process-info { min-height: 66px; padding: 10px 14px; border-left: 2px solid #ffc94a99; background: #121b27; border-radius: 0 9px 9px 0; }
.process-info h3 { margin: 0 0 2px; color: var(--accent); font-size: 14px; }
.process-info p { margin: 0; color: #c1cfdf; font-size: 13px; }
.scene-actions { display: flex; gap: 8px; align-items: center; }
.control, #panelToggle, .scene-actions .learn-fab {
  background: #111723;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 0 12px;
  cursor: pointer;
}
.scene-actions .learn-fab { position: static; transform: none; display: grid; place-items: center; min-height: 44px; }
.control:hover, #panelToggle:hover, .scene-actions .learn-fab:hover { border-color: var(--accent); }

#panel { --panel-w: 304px; }
#panel h2 { font-size: 15px; }
.panel-intro { margin: 0 0 15px; font-size: 13px; color: #c4cfdd; }
.panel-intro strong, .range-row output { color: var(--accent); }
.range-row, .endpoints { display: flex; justify-content: space-between; align-items: center; }
.range-row { font-size: 13px; }
.range-row output { font-weight: 700; font-variant-numeric: tabular-nums; }
#paved { display: block; width: 100%; min-height: 44px; accent-color: var(--accent); margin: 0; }
.endpoints { color: #a4b0c0; font-size: 11px; margin: -7px 0 12px; }
#samplePresets { display: flex; }
#samplePresets button { flex: 1; }
.budget { display: flex; height: 9px; margin: 21px 0 10px; overflow: hidden; border-radius: 5px; }
#runoffBar { width: 35%; background: #43cafa; }
#infiltrationBar { flex: 1; background: #84e5c3; }
.water-values { grid-template-columns: 1fr auto; gap: 5px 12px; }
.water-values dt i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #43cafa; }
.water-values dt:nth-of-type(2) i { background: #84e5c3; }
.water-values dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.panel-note { font-size: 12px; margin: 12px 0 0; color: #a4b0c0; }
#panel [hidden] { display: none; }

@media (max-width: 960px) {
  .scene-footer { grid-template-columns: 1fr; gap: 8px; }
  .scene-actions { justify-content: space-between; }
}
@media (max-width: 760px) {
  #app { --mobile-plot-h: min(calc((100vw - 22px) * .625), max(125px, calc(100dvh - 285px))); }
  #stage {
    padding: 9px 11px 11px;
    gap: 10px;
    grid-template-rows: auto auto auto 1fr;
    align-items: start;
  }
  #panelToggle { position: static; white-space: nowrap; }
  .scene-topic { font-size: 11px; }
  .scene-header h2 { font-size: 16px; }
  .scene-select button { flex: 1; padding-inline: 4px; }
  .plot-wrap { container-type: normal; }
  #plot { width: calc(var(--mobile-plot-h) * 1.6); margin-block: 3px 2px; border-radius: 9px; }
  .process-btn { font-size: 11px; }
  .process-btn span, .terrain-label { padding: 3px 4px; }
  .terrain-label { font-size: 10px; }
  .process-info { padding: 8px 10px; min-height: 78px; }
  .process-info p { font-size: 12px; }
  #panel { max-height: min(440px, calc(100% - 120px - var(--mobile-plot-h))); }
  #panel.collapsed { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
}
