/* Quiet controls around a stable central model. Scope changes to opted-in pages. */
.surround-page { box-sizing: border-box; min-height: 100svh; }
.surround-page *, .surround-page *::before, .surround-page *::after { box-sizing: border-box; }
.surround-page .model-page-content { scrollbar-gutter: stable both-edges; }
.surround-page main { width: 100%; margin: 0; padding: 0; }
.surround-page button, .surround-page input, .surround-page select { font: inherit; }
.surround-page button { border: 0; background: transparent; color: inherit; cursor: pointer; }
.surround-page :is(button, input, select, [tabindex]):focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-radius: var(--radius-small); }
.surround-page .skip-link { position: fixed; top: 12px; left: 12px; z-index: 20; padding: 12px 18px; background: var(--ink); color: var(--on-accent); transform: translateY(-200%); }
.surround-page .skip-link:focus { transform: none; }
.surround-page .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.surround-stage.model-stage {
  --model-width: 33.333333vw;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--model-width) minmax(0, 1fr);
  grid-template-rows: minmax(max(64px, calc(var(--stage-height) * .25 - var(--stage-top-space))), auto) var(--model-height) auto auto;
  grid-template-areas: "top top top" "left model right" "actions editor tools" "data data data";
  align-items: center;
  align-content: start;
  column-gap: clamp(16px, 2.3vw, 36px);
  min-height: 0;
  padding: 0 28px 24px;
}
.surround-stage.model-stage:has(.model-stage__panel:not([hidden])) { padding-top: 0; padding-bottom: 24px; }
.surround-stage .model-stage__core { grid-area: model; position: relative; inset: auto; width: 100%; height: var(--model-height); min-width: 0; transform: none; }
.surround-stage .model-stage__core > .model { width: 100%; height: 100%; margin: 0; }
.surround-stage .model-stage__core svg { display: block; width: 100%; height: 100%; }
.surround-top { grid-area: top; display: flex; align-items: center; justify-content: center; align-self: end; gap: 14px; padding-bottom: 12px; min-height: 44px; }
.surround-top strong { font-weight: 500; font-size: 15px; }
.surround-top > span { font-size: 11px; color: var(--muted); }
.surround-top--presets { flex-direction: column; gap: 0; padding-bottom: 0; }
.surround-top .surround-tabs { min-width: 0; max-width: 100%; }
.surround-top .surround-tabs button { min-width: 44px; white-space: nowrap; }
.surround-top .surround-preset-status { min-height: 16px; line-height: 16px; }
.surround-left { grid-area: left; justify-self: end; width: min(200px, 100%); min-width: 0; }
.surround-right { grid-area: right; justify-self: start; width: min(216px, 100%); min-width: 0; }
.surround-stage .surround-choices { display: grid; gap: 6px; }
.surround-stage .surround-choice { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: baseline; gap: 8px; min-height: 44px; padding: 9px 4px; text-align: left; color: var(--muted); }
.surround-stage .surround-choice b { font: 400 20px Georgia, serif; text-align: center; }
.surround-stage .surround-choice span { font-size: 12px; }
.surround-stage .surround-choice [data-parameter-value] { white-space: nowrap; font-variant-numeric: tabular-nums; }
.surround-stage .surround-choice[aria-pressed="true"] { color: var(--accent); }
.surround-stage .surround-choice[aria-pressed="true"] b { font-weight: 600; }
.surround-stage .surround-choice[aria-pressed="true"] [data-parameter-value] { text-decoration: underline; text-underline-offset: 5px; }
.surround-stage .surround-choice:hover { color: var(--ink); }
.surround-readouts { display: grid; gap: 22px; margin: 0; }
.surround-readouts dt { margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.surround-readouts dd { margin: 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.surround-editor { grid-area: editor; min-width: 0; padding-top: 8px; }
.surround-editor-heading { display: flex; align-items: center; gap: 12px; min-height: 36px; }
.surround-editor-heading label { font-size: 14px; font-weight: 500; }
.surround-number { display: flex; align-items: baseline; gap: 4px; margin-left: auto; font-size: 12px; color: var(--muted); }
.surround-number input { width: 72px; padding: 5px 2px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; appearance: textfield; -moz-appearance: textfield; }
.surround-number input::-webkit-inner-spin-button, .surround-number input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.surround-number input:hover, .surround-number input:focus { border-color: var(--accent); }
.surround-number input[aria-invalid="true"] { border-bottom: 2px solid var(--orange); }
.surround-editor input[type="range"] { display: block; width: 100%; height: 32px; margin: 2px 0; padding: 0; appearance: none; background: transparent; accent-color: var(--accent); cursor: pointer; }
.surround-editor input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line-strong); border-radius: 1px; }
.surround-editor input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--accent); }
.surround-editor input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); }
.surround-editor input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--accent); }
.surround-hint { min-height: 20px; margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; text-align: center; }
.surround-actions { grid-area: actions; display: flex; gap: 10px; justify-self: end; }
.surround-stage .surround-icon { display: grid; place-items: center; width: 44px; height: 44px; padding: 10px; color: var(--muted); }
.surround-stage .surround-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 180ms ease; }
.surround-stage .surround-icon:hover { color: var(--ink); }
.surround-stage .surround-icon:hover svg { transform: scale(1.08); }
.surround-tools { grid-area: tools; justify-self: start; }
.surround-stage .surround-tools, .surround-stage .surround-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; max-width: 100%; }
.surround-stage :is(button, input):disabled { opacity: .4; cursor: default; }
.surround-stage .surround-icon[aria-pressed="true"] { color: var(--accent); }
.surround-stage .surround-icon[aria-pressed="true"]::after { content: ""; width: 12px; height: 2px; background: currentColor; position: absolute; bottom: 2px; }
.surround-stage .surround-icon { position: relative; }
.surround-stage .surround-icon .surround-pause, .surround-stage .surround-icon[aria-pressed="true"] .surround-play { display: none; }
.surround-stage .surround-icon[aria-pressed="true"] .surround-pause { display: block; }
.surround-stage .surround-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; }
.surround-stage .surround-tabs button, .surround-stage .surround-text { min-height: 44px; padding: 8px 4px; color: var(--muted); font-size: 12px; }
.surround-stage .surround-text, .surround-stage .surround-data-entry, .surround-stage .model-stage__close { min-width: 44px; min-height: 44px; }
.surround-stage .surround-tabs button[aria-pressed="true"], .surround-stage .surround-text[aria-pressed="true"] { color: var(--accent); text-decoration: underline; text-underline-offset: 6px; }
.surround-stage .surround-select { display: block; width: 100%; max-width: 100%; min-height: 44px; padding: 8px 2px; border: 0; border-radius: 0; background: transparent; color: var(--ink); font-size: 12px; cursor: pointer; }
.surround-stage .surround-select option { background: var(--surface); color: var(--ink); }
.surround-stage .surround-subtle { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.surround-stage .surround-status { margin: 8px 0 0; font-size: 12px; line-height: 1.7; color: var(--orange); text-align: center; }
.surround-stage .surround-data-entry { min-height: 44px; padding: 8px 6px; color: var(--muted); font-size: 12px; }
.surround-stage .surround-data-entry[aria-expanded="true"], .surround-stage .surround-data-entry:hover { color: var(--accent); }
.surround-stage .surround-data-entry::before { display: none; }
.surround-stage .surround-data { grid-area: data; position: static; width: min(680px, 100%); max-height: none; min-width: 0; margin: 28px auto 0; padding: 16px 0 0; overflow: visible; scrollbar-gutter: auto; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.surround-data .model-stage__panel-heading h2 { margin: 0; font-size: 15px; font-weight: 500; }
.surround-data .stage-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin: 0; }
.surround-data .stage-metrics > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.surround-data dt { color: var(--muted); font-size: 12px; }
.surround-data dd { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.surround-data > p { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
@media (max-width: 800px) {
  .surround-stage.model-stage {
    --model-height: clamp(260px, 43svh, 380px);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto var(--model-height) auto auto auto auto;
    grid-template-areas: "top top" "model model" "left right" "editor editor" "actions tools" "data data";
    column-gap: 20px;
    row-gap: 12px;
    padding-inline: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right));
  }
  .surround-top { padding-bottom: 0; }
  .surround-stage .model-stage__core { width: min(520px, 100%); justify-self: center; }
  .surround-left, .surround-right { width: min(200px, 100%); }
  .surround-editor { width: min(440px, 100%); justify-self: center; padding-top: 0; }
  .surround-stage .surround-choice { column-gap: 5px; }
  .surround-readouts { gap: 16px; }
  .surround-readouts dd { font-size: 16px; }
  .surround-stage .surround-data { margin-top: 6px; }
}
@media (max-width: 400px) {
  .surround-stage .surround-choice { grid-template-columns: 20px minmax(0, 1fr); row-gap: 1px; }
  .surround-stage .surround-choice [data-parameter-value] { grid-column: 2; }
  .surround-data .stage-metrics { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .surround-stage .surround-icon svg { transition: none; }
  .surround-stage .surround-icon:hover svg { transform: none; }
}
