/* Berlin 26 — studies-directory desk + centre stage + PDF-style toolkits */

body.berlin-desk {
  overflow: hidden;
}

body.berlin-desk.desk-pending .studiesDeskIcons,
body.berlin-desk.desk-pending .berlinStage {
  opacity: 0;
}

.archiveNodeHeader {
  position: fixed;
  left: 18px;
  top: 16px;
  z-index: 80;
  margin: 0;
  padding: 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--green);
  text-transform: lowercase;
  text-align: left;
  pointer-events: none;
}

/* Desk intro — keep above wallpaper; clear of stage */
.berlinDesk .studyDeskIntro {
  z-index: 18;
}

@media (min-width: 641px) {
  .berlinDesk .studyDeskIntro {
    display: block;
    position: fixed;
    left: 18px;
    top: calc(env(safe-area-inset-top, 0px) + 92px);
    max-width: min(34ch, calc(100vw - 520px));
  }

  /* Portrait flush covers this column. Desktop offset stage shows it again below. */
  .berlinDesk.is-stage-mounted .studyDeskIntro {
    display: none;
  }
}

/* Desktop stage sits right of the intro, so the column can stay visible */
@media (min-width: 1025px), (min-width: 641px) and (orientation: landscape) {
  .berlinDesk.is-stage-mounted .studyDeskIntro {
    display: block;
  }

  /* Virtual plot runs on the page, left of the desk, under the stage */
  .berlinPlotterSheet.is-page-backdrop {
    position: fixed;
    z-index: 11;
    left: 0;
    top: 0;
    pointer-events: none;
    opacity: 1;
    visibility: visible;
    background: transparent;
  }
}

@media (max-width: 640px) {
  .berlinDesk .studyDeskIntro {
    display: none;
  }

  /* Strip desk — no studies-directory “study summary” jump over the header */
  body.berlin-desk .studyIntroJump {
    display: none !important;
  }
}

.berlinStage {
  position: fixed;
  z-index: 12;
  display: flex;
  flex-direction: column;
  /* Left edge clears the SEO column; the box grows down and to the right */
  --berlin-stage-clear: calc(18px + min(244.8px, 100vw - 520px) + 28px);
  left: var(--berlin-stage-clear);
  right: 32px;
  top: max(172px, 18vh);
  bottom: 28px;
  width: auto;
  height: auto;
  max-height: none;
  transform: none;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.94);
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.72);
  pointer-events: auto;
}

html.mode-invert .berlinStage {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.2);
}

/* Desktop keeps the boxed desk when mounted — flush field is portrait-only */

/* Plotter field uses the sheet on the grid — suppress folder wallpaper */
.berlinDesk.is-stage-mounted:has(.berlinPlotterLayout) .studiesFeatureLayer[data-feature="plotter"],
.berlinDesk.is-stage-mounted:has(.berlinPlotterLayout) .studiesFeatureScrim,
.berlinDesk.is-stage-mounted:has(.berlinPlotterLayout) .studiesFeatureGrain {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Tool panes sit on the desk grid — no feature wallpaper behind */
.berlinDesk.is-tool-open .studiesFeature,
.berlinDesk.is-tool-open .studiesFeatureLayer {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Plot mode — centred landscape stage (copy | booth); sheet anchored to desk left edge */
.berlinHdmiWall {
  position: fixed;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  border: 0;
  /* Black ground — iframe defaults to white otherwise (shows as a white field once translated) */
  background: #000000;
  color-scheme: dark;
  pointer-events: none;
  overflow: hidden;
  /* JS shifts so the sheet centre sits on the desk's left edge */
  transform: translate(0, 0);
  will-change: transform;
}

.berlinHdmiWall[hidden] {
  display: none !important;
}

body.berlin-plot-wall,
.berlinDesk.is-plot-booth,
html.mode-invert body.berlin-plot-wall,
html.mode-invert .berlinDesk.is-plot-booth {
  /* Match the rest of the site — black desk; wall ink is white (+ red / blue) */
  background: #000000 !important;
  --bg: #000000;
  --text: #ffffff;
  --fg: #ffffff;
  --dim: rgba(255, 255, 255, 0.62);
  --border: rgba(255, 255, 255, 0.18);
  --panel: rgba(255, 255, 255, 0.06);
  --shadow: rgba(0, 0, 0, 0.45);
  --grid: rgba(0, 255, 0, 0.18);
}

body.berlin-plot-wall .archiveNodeHeader {
  color: var(--green);
}

.berlinDesk.is-plot-booth .studiesDeskGrid {
  opacity: 0.55;
  z-index: 4;
}

.berlinDesk.is-plot-booth.has-feature .studiesDeskGrid {
  opacity: 0.55;
}

/*
 * Plot mode: wall HDMI sits under the feature stack so other toolkit
 * hover previews (audio mosaic, etc.) still glitch in. Keep the plotter's
 * own wallpaper suppressed — the wall sheet is that surface.
 */
.berlinDesk.is-plot-booth .berlinHdmiWall {
  z-index: 2;
}

.berlinDesk.is-plot-booth .studiesFeature {
  z-index: 3;
  background: transparent;
}

.berlinDesk.is-plot-booth .studiesFeatureLayer[data-feature="plotter"] {
  opacity: 0 !important;
  visibility: hidden !important;
}

.berlinDesk.is-plot-booth .studiesFeatureScrim,
.berlinDesk.is-plot-booth .studiesFeatureGrain {
  opacity: 0;
  visibility: hidden;
}

.berlinDesk.is-plot-booth:has(
  .studiesFeatureLayer.is-active:not([data-feature="plotter"])
) .studiesFeatureScrim {
  opacity: 1;
  visibility: visible;
}

.berlinDesk.is-plot-booth:has(
  .studiesFeatureLayer.is-active:not([data-feature="plotter"])
) .studiesFeatureGrain {
  opacity: 0.12;
  visibility: visible;
}

.berlinDesk.is-plot-booth .berlinStage {
  left: var(--berlin-stage-clear);
  right: 32px;
  top: max(172px, 18vh);
  bottom: 28px;
  transform: none;
  width: auto;
  height: auto;
  max-height: none;
}

html.mode-invert .berlinDesk.is-plot-booth .berlinStage {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.2);
}

.berlinDesk.is-plot-booth .berlinStageViewport {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: block;
  place-items: stretch;
  background: #050505;
  overflow: hidden;
}

html.mode-invert .berlinDesk.is-plot-booth .berlinStageViewport {
  background: #f4f4f4;
}

.berlinDesk.is-plot-booth .berlinStageNote {
  display: none;
}

.berlinPlotLayout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  width: 100%;
  height: 100%;
  min-height: min(68vh, 640px);
}

.berlinPlotCopy {
  padding: 20px 22px 18px;
  border-right: 1px solid #1a1a1a;
  color: #e8e8e8;
  font-size: 13px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  overflow: auto;
}

.berlinPlotCopy p {
  margin: 0 0 0.9em;
}

.berlinPlotCopy p:last-child {
  margin-bottom: 0;
}

.berlinPlotCopy p:first-child {
  color: var(--green, #00ff00);
  text-transform: lowercase;
}

html.mode-invert .berlinPlotCopy {
  border-right-color: rgba(0, 0, 0, 0.18);
  color: #111111;
}

html.mode-invert .berlinPlotBoothFrame {
  background: #e8e8e8;
}

html.mode-invert .berlinPlotBooth {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.08),
    inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.berlinStageChrome {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  text-transform: lowercase;
}

html.mode-invert .berlinStageChrome {
  background: rgba(0, 0, 0, 0.04);
}

.berlinStageTitle {
  color: var(--green);
}

.berlinStageStatus {
  color: var(--dim);
  font-size: 11px;
}

.berlinStageViewport {
  position: relative;
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  min-height: 0;
  background: #050505;
  overflow: hidden;
}

/* Plotter / audio use the same offset stage box — do not cap them shorter */
.berlinStage:has(.berlinPlotterLayout),
.berlinStage:has(.berlinAudioLayout) {
  height: auto;
  max-height: none;
}

.berlinStageViewport:has(.berlinPlotterLayout),
.berlinStageViewport:has(.berlinAudioLayout) {
  flex: 1 1 auto;
  display: block;
  place-items: stretch;
  min-height: 0;
  height: auto;
  overflow: hidden;
}

.berlinStageViewport:has(.berlinAudioLayout) {
  background: transparent;
}

html.mode-invert .berlinStageViewport {
  background: #f2f2f2;
}

html.mode-invert .berlinStageViewport:has(.berlinAudioLayout) {
  background: transparent;
}

.berlinStageViewport img,
.berlinStageViewport video:not(.berlinWavePixel):not(.berlinProcessWavePixel):not(.berlinFilmFrame):not(.berlinFilmMosaic):not(.berlinPrintVideo) {
  display: block;
  width: 100%;
  height: 100%;
  max-height: min(58vh, 540px);
  object-fit: contain;
  background: #000;
}

html.mode-invert .berlinStageViewport img,
html.mode-invert .berlinStageViewport video:not(.berlinWavePixel):not(.berlinProcessWavePixel):not(.berlinFilmFrame):not(.berlinFilmMosaic):not(.berlinPrintVideo) {
  background: #e8e8e8;
}

.berlinStageViewport audio {
  width: calc(100% - 28px);
  margin: 18px 14px;
}

/* Combined plotter desk — full-bleed ink on the grid; tools match audio panes */
.berlinPlotterLayout {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: transparent;
  overflow: hidden;
}

html.mode-invert .berlinPlotterLayout {
  background: transparent;
}

.berlinPlotterSheet {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  pointer-events: none;
}

.berlinPlotterLayout[data-tool-view]:not([data-tool-view=""]) .berlinPlotterSheet {
  opacity: 0;
  visibility: hidden;
}

.berlinPlotterColumns {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 14px 14px 12px;
  box-sizing: border-box;
  pointer-events: none;
  overflow: hidden;
}

.berlinPlotterCentre {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  pointer-events: auto;
}

.berlinPlotterLayout[data-tool-view]:not([data-tool-view=""]) .berlinPlotterCentre {
  display: none;
}

.berlinPlotterTools {
  pointer-events: auto;
  display: none;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.berlinPlotterLayout[data-tool-view]:not([data-tool-view=""]) .berlinPlotterTools {
  display: flex;
}

.berlinPlotterLayout[data-tool-view="bed-noise"] [data-berlin-tool="bed-noise"] {
  display: flex;
}

.berlinPlotterTools .berlinAudioTool {
  height: 100%;
}

.berlinPlotterTools .berlinAudioDeck {
  flex: 1 1 auto;
  min-height: 0;
}

.berlinPlotterTools .berlinWaveStage {
  height: min(28vh, 220px);
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .berlinPlotterTools .berlinWaveStage {
    height: min(22vh, 180px);
  }
}

/* Process desk — empty field + full-width bottom noise toolbar */
.berlinProcessLayout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: min(42vh, 360px);
  background: #050505;
}

html.mode-invert .berlinProcessLayout {
  background: #f2f2f2;
}

.berlinProcessField {
  flex: 1 1 auto;
  min-height: 0;
}

.berlinProcessToolbar {
  position: relative;
  flex: 0 0 auto;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

html.mode-invert .berlinProcessToolbar {
  background: rgba(0, 0, 0, 0.04);
}

.berlinProcessWaveStage {
  position: relative;
  width: 100%;
  height: min(9vh, 70px);
  border-bottom: 1px solid var(--border);
  background: #000;
  overflow: hidden;
}

html.mode-invert .berlinProcessWaveStage {
  background: #111;
}

.berlinProcessWavePixel {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: fill;
  object-position: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 0.8;
  filter: grayscale(1) contrast(1.05) brightness(1.05);
  pointer-events: none;
}

html.mode-invert .berlinProcessWavePixel {
  opacity: 0.8;
  filter: grayscale(1) contrast(1.08) brightness(0.95);
}

.berlinProcessWave {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: ew-resize;
  background: transparent;
}

.berlinProcessWave:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: -1px;
}

.berlinProcessChrome {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px 18px;
  flex-wrap: wrap;
  padding: 10px 12px 12px;
}

.berlinProcessControls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.berlinProcessNote {
  flex: 1 1 18rem;
  margin: 0;
  max-width: 54ch;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.berlinProcessPlay {
  appearance: none;
  margin: 0;
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--green);
  background: transparent;
  color: var(--green);
  cursor: pointer;
}

.berlinProcessPlay:hover,
.berlinProcessPlay:focus-visible {
  background: var(--green);
  color: #000;
  outline: none;
}

.berlinProcessIcon {
  display: block;
  width: 12px;
  height: 12px;
}

.berlinProcessIcon--pause,
.berlinProcessPlay.is-playing .berlinProcessIcon--play {
  display: none;
}

.berlinProcessPlay.is-playing .berlinProcessIcon--pause {
  display: block;
}

.berlinProcessClock {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

/* Desk grid chatter while any stage audio plays */
body.is-grid-vibrate .studiesDeskGrid {
  animation: deskGridVibrate 0.09s steps(2, end) infinite;
  will-change: transform, background-position;
}

@keyframes deskGridVibrate {
  0% {
    transform: translate(0, 0);
    background-position: 0 0;
  }
  25% {
    transform: translate(1px, -1px);
    background-position: 1px -1px;
  }
  50% {
    transform: translate(-1px, 1px);
    background-position: -1px 1px;
  }
  75% {
    transform: translate(1px, 0);
    background-position: 1px 0;
  }
  100% {
    transform: translate(0, -1px);
    background-position: 0 -1px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.is-grid-vibrate .studiesDeskGrid {
    animation: none;
  }
}

/* Portrait booth — framed screen inset in the right column */
.berlinPlotBoothFrame {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 18px 16px 18px 14px;
  box-sizing: border-box;
  background: #0a0a0a;
}

.berlinPlotBooth {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid #2a2a2a;
  background: #000;
  box-shadow:
    0 0 0 1px #000,
    inset 0 0 0 1px rgba(0, 255, 0, 0.08);
}

/* Audio stage — field by default; tools load full-pane when chosen from strip */
.berlinAudioLayout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 14px 14px 12px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Desk wallpaper when hovering audio — mosaic stretched, letterbox cropped */
.berlinDesk .studiesFeatureLayer--pixel {
  object-fit: fill;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: grayscale(0.12) contrast(1.08) brightness(1.1);
  /* Match waveform crop so hover wallpaper loses the same bars */
  inset: -16% 0;
  width: 100%;
  height: 132%;
}

/* Digital plot face — sharper stroke blow-up, not mosaic */
.berlinDesk .studiesFeatureLayer--pixel.studiesFeatureLayer--clear {
  object-fit: cover;
  image-rendering: auto;
  filter: none;
  inset: 0;
  width: 100%;
  height: 100%;
}

.berlinAudioCentre {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.berlinAudioCentre::-webkit-scrollbar {
  width: 8px;
}

.berlinAudioCentre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

html.mode-invert .berlinAudioCentre::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(0, 0, 0, 0.12);
}

.berlinAudioLayout[data-tool-view]:not([data-tool-view=""]) .berlinAudioCentre {
  display: none;
}

.berlinAudioTools {
  display: none;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.berlinAudioLayout[data-tool-view]:not([data-tool-view=""]) .berlinAudioTools {
  display: flex;
}

.berlinAudioTool {
  display: none;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.berlinAudioLayout[data-tool-view="soundtrack"] [data-berlin-tool="soundtrack"],
.berlinAudioLayout[data-tool-view="listen"] [data-berlin-tool="listen"] {
  display: flex;
}

/*
 * Desktop — two-column desks: field / copy left, tools right (always visible).
 * Portrait keeps strip-driven field-first + full-pane tools (rules above).
 */
@media (min-width: 641px) {
  .berlinAudioLayout {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 34%);
    gap: 18px 24px;
    align-items: start;
    overflow: auto;
  }

  .berlinAudioLayout[data-tool-view]:not([data-tool-view=""]) .berlinAudioCentre,
  .berlinAudioCentre {
    display: flex;
  }

  .berlinAudioTools {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
    height: auto;
    max-height: 100%;
    overflow: auto;
    align-self: start;
  }

  .berlinAudioLayout[data-tool-view]:not([data-tool-view=""]) .berlinAudioTools {
    display: flex;
  }

  .berlinAudioTool,
  .berlinAudioLayout[data-tool-view="soundtrack"] [data-berlin-tool="soundtrack"],
  .berlinAudioLayout[data-tool-view="listen"] [data-berlin-tool="listen"] {
    display: flex;
    height: auto;
    flex: 0 0 auto;
  }

  .berlinAudioTools .berlinWaveStage {
    height: min(22vh, 180px);
  }

  /* Tools column — room so controls clear the vertical bar */
  .berlinAudioTools {
    padding-right: 18px;
  }

  .berlinPlotterColumns {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 34%);
    gap: 18px 24px;
    align-items: stretch;
    height: 100%;
    pointer-events: auto;
    overflow: hidden;
  }

  .berlinPlotterLayout[data-tool-view]:not([data-tool-view=""]) .berlinPlotterCentre,
  .berlinPlotterCentre {
    display: block;
  }

  /* Plot sits on the page ground (see .is-page-backdrop), not through the reading */

  .berlinPlotterTools {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-self: stretch;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-bottom: 28px;
  }

  .berlinPlotterTools::-webkit-scrollbar {
    width: 8px;
  }

  .berlinPlotterTools::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
  }

  html.mode-invert .berlinPlotterTools::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.28);
    border-color: rgba(0, 0, 0, 0.12);
  }

  .berlinReading {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 4px 8px 24px 2px;
    color: var(--dim);
    font-size: 13px;
    line-height: 1.7;
    text-transform: lowercase;
  }

  .berlinReading::-webkit-scrollbar {
    width: 8px;
  }

  .berlinReading::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
  }

  html.mode-invert .berlinReading::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.28);
    border-color: rgba(0, 0, 0, 0.12);
  }

  .berlinReading p.berlinReadingK,
  .berlinReading p.berlinReadingFig {
    margin: 0 0 14px;
    color: var(--green);
    font-size: 13px;
    font-style: italic;
    font-weight: 500;
    letter-spacing: 0;
  }

  .berlinReading p {
    margin: 0 0 14px;
    max-width: 80%;
  }

  .berlinReadingPart,
  .berlinFigMenu {
    margin: 16px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .berlinFigToggle {
    display: block;
    width: 100%;
    margin: 0;
    padding: 7px 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--green);
    font: inherit;
    font-size: 12px;
    letter-spacing: 0.03em;
    text-align: left;
    text-transform: lowercase;
    cursor: pointer;
  }

  .berlinFigToggle::before {
    content: "> ";
  }

  .berlinFigItem.is-open .berlinFigToggle::before {
    content: "– ";
  }

  .berlinFigToggle:hover,
  .berlinFigItem.is-open .berlinFigToggle {
    color: var(--fg);
  }

  .berlinFigPanel {
    padding: 10px 0 6px 16px;
  }

  .berlinFigPanel[hidden] {
    display: none;
  }

  .berlinFigPile {
    position: relative;
    flex: 1 1 auto;
    min-height: 180px;
    margin: 0;
    container-type: size;
  }

  .berlinFigStage {
    display: none;
  }

  .berlinFigRail {
    display: contents;
  }

  /* Sheet is A3 portrait (297 × 420). The column no longer stretches it square. */
  .berlinFigCard {
    position: absolute;
    inset: auto;
    top: 0;
    left: 0;
    right: 0;
    width: min(100cqi, calc((100cqb - 28px) * 297 / 420));
    margin-inline: auto;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: #fff;
    overflow: hidden;
    transition: transform 280ms linear;
  }

  .berlinFigCard.is-front {
    border-color: #f3f3ec;
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.7),
      0 14px 28px rgba(0, 0, 0, 0.48);
  }

  .berlinFigCard img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 297 / 420;
    object-fit: contain;
    background: #fff;
  }

  .berlinFigCard figcaption {
    position: static;
    padding: 3px 6px 4px;
    background: #000;
    color: var(--green);
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: lowercase;
  }

  @media (prefers-reduced-motion: reduce) {
    .berlinFigCard {
      transition: none;
    }
  }

  .berlinPlotterLayout[data-tool-view]:not([data-tool-view=""]) .berlinPlotterTools {
    display: flex;
  }

  .berlinPlotterLayout[data-tool-view="bed-noise"] [data-berlin-tool="bed-noise"],
  .berlinPlotterTools .berlinAudioTool {
    display: flex;
    height: auto;
    flex: 0 0 auto;
  }

  .berlinPlotterTools .berlinWaveStage {
    height: min(22vh, 180px);
  }
}

.berlinAudioTool .berlinAudioK {
  margin: 0;
  flex: 0 0 auto;
}

.berlinAudioTools .berlinWaveStage {
  height: min(28vh, 220px);
  flex: 0 0 auto;
}

.berlinAudioTool .berlinAudioDeck {
  flex: 1 1 auto;
  min-height: 0;
}

.berlinAudioTool .berlinListenPhone {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.berlinToolNote {
  margin: 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.5;
  max-width: 36ch;
  flex: 0 0 auto;
}

.berlinAudioCopy {
  max-width: 58ch;
  color: var(--dim);
  /* Keep authored capitals on names/titles (Berlin, Sawe, We Who Believed). */
  text-transform: none;
}

.berlinAudioCopy h2 {
  margin: 0 0 8px;
  color: var(--fg);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}

.berlinAudioCopy em {
  font-style: italic;
  color: var(--fg);
  text-transform: none;
}

.berlinFilm {
  position: relative;
  margin: 0;
  width: 100%;
  flex: 0 0 auto;
}

.berlinFilmPoster {
  appearance: none;
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  background: #000;
  color: inherit;
  cursor: pointer;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.berlinFilmPoster img,
.berlinStageViewport .berlinFilm .berlinFilmFrame {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 0;
  background: transparent;
}

.berlinStageViewport .berlinFilm .berlinFilmFrame[hidden],
.berlinStageViewport .berlinFilm .berlinFilmPoster[hidden],
.berlinStageViewport .berlinFilm .berlinFilmMore[hidden] {
  display: none;
}

.berlinFilmMosaic {
  position: absolute;
  left: 0;
  top: 50%;
  z-index: 1;
  width: 100%;
  height: 132%;
  transform: translateY(-50%);
  object-fit: fill;
  opacity: 0;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: grayscale(0.15) contrast(1.05) brightness(1.25);
}

.berlinFilmPoster:hover .berlinFilmMosaic,
.berlinFilmPoster:focus-visible .berlinFilmMosaic {
  opacity: 0.72;
  animation: featureGlitch 0.28s steps(2, end);
}

@media (prefers-reduced-motion: reduce) {
  .berlinFilmPoster:hover .berlinFilmMosaic,
  .berlinFilmPoster:focus-visible .berlinFilmMosaic {
    animation: none;
    opacity: 0;
  }
}

.berlinFilmMore {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  padding: 10px 14px;
  border: 1px solid var(--green);
  background: rgba(0, 0, 0, 0.72);
  color: var(--green);
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-decoration: none;
  text-transform: lowercase;
  transform: translate(-50%, -50%);
}

.berlinFilmMore:hover,
.berlinFilmMore:focus-visible {
  background: var(--green);
  color: #000;
  outline: none;
}

.berlinFilmPlay {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--green);
  background: rgba(0, 0, 0, 0.55);
  color: var(--green);
  transform: translate(-50%, -50%);
}

.berlinFilmPoster:hover .berlinFilmPlay,
.berlinFilmPoster:focus-visible .berlinFilmPlay {
  background: var(--green);
  color: #000;
}

.berlinFilmPoster[hidden],
.berlinFilmFrame[hidden],
.berlinFilmMore[hidden] {
  display: none;
}

.berlinFilmPoster:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: 3px;
}

.berlinFilmIcon {
  display: block;
  width: 14px;
  height: 14px;
  margin-left: 2px;
}

.berlinAudioK {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.berlinAudioCopy p {
  margin: 0 0 14px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.7;
}

.berlinAudioCopy .berlinAudioHint {
  margin-top: 4px;
  margin-bottom: 0;
  font-size: 11px;
  line-height: 1.45;
}

.berlinAudioSteps {
  margin: 0.4em 0 0;
  padding: 0;
  list-style-position: inside;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.55;
}

.berlinAudioSteps li {
  margin: 0 0 0.25em;
  padding: 0;
}

.berlinAudioEm {
  color: var(--green);
}

.berlinAudioDeck {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.berlinWaveStage {
  position: relative;
  width: 100%;
  height: min(20vh, 160px);
  border: 1px solid var(--border);
  background: #000;
  overflow: hidden;
}

html.mode-invert .berlinWaveStage {
  background: #111;
}

/* Mosaic confined to waveform box — stretch full width/height, crop letterbox bars */
.berlinWavePixel {
  position: absolute;
  left: 0;
  width: 100%;
  /* Scale past the box so top/bottom letterbox in the source is clipped */
  top: 50%;
  height: 132%;
  transform: translateY(-50%);
  z-index: 0;
  object-fit: fill;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 0.72;
  filter: grayscale(0.15) contrast(1.05) brightness(1.25);
  pointer-events: none;
}

html.mode-invert .berlinWavePixel {
  opacity: 0.58;
  filter: grayscale(0.2) contrast(1.1) brightness(1.1);
}

.berlinWave {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: ew-resize;
  background: transparent;
}

.berlinWave:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: 2px;
}

.berlinAudioChrome {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.berlinAudioPlay {
  appearance: none;
  margin: 0;
  padding: 6px 14px 5px;
  border: 1px solid var(--green);
  background: transparent;
  color: var(--green);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  cursor: pointer;
}

.berlinAudioPlay:hover,
.berlinAudioPlay:focus-visible {
  background: var(--green);
  color: #000;
  outline: none;
}

.berlinAudioClock {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.berlinAudioHint {
  margin: 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.45;
  text-transform: lowercase;
}

/* Exhibition listen page — tool surface in the right column */
.berlinListenPhone {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.berlinListenBezel {
  width: 100%;
  max-width: none;
  border: 1px solid var(--border);
  background: #000;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35);
}

html.mode-invert .berlinListenBezel {
  background: #111;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.18);
}

.berlinListenScreen {
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  text-align: center;
  box-sizing: border-box;
  background-image:
    linear-gradient(rgba(0, 255, 0, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 0, 0.12) 1px, transparent 1px);
  background-size: 18px 18px;
}

.berlinListenTitle {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.berlinListenBtn {
  appearance: none;
  position: relative;
  overflow: hidden;
  width: 100%;
  margin: 0;
  padding: 12px 10px 16px;
  border: 1px solid var(--green);
  background: var(--green);
  color: #000;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  cursor: pointer;
}

.berlinListenBtn[aria-pressed="true"] {
  filter: brightness(1.05);
}

.berlinListenLabel {
  position: relative;
  z-index: 1;
}

.berlinListenWave {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 18px;
  pointer-events: none;
}

.berlinListenMeta {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.berlinListenMeta.is-live {
  color: var(--text);
}

.berlinListenNudge {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}

.berlinListenNudge span {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid var(--green);
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: lowercase;
  line-height: 1.2;
}

.berlinListenCaption {
  margin: 0;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: lowercase;
  text-align: center;
}

@media (max-width: 900px) {
  .berlinListenBezel {
    max-width: 280px;
  }
}

@media (max-width: 640px) {
  .berlinAudioLayout {
    padding: 12px;
  }

  .berlinAudioLayout[data-tool-view]:not([data-tool-view=""]) .berlinWaveStage {
    height: min(22vh, 180px);
  }

  .berlinListenBezel {
    max-width: none;
  }
}

.berlinStageViewport:has(.berlinOverviewField) {
  display: block;
  overflow: hidden;
}

.berlinOverviewField {
  box-sizing: border-box;
  height: 100%;
  overflow: auto;
  scrollbar-width: none;
  padding: 18px 16px 28px;
}

.berlinOverviewField::-webkit-scrollbar {
  display: none;
}

.berlinOverview {
  box-sizing: border-box;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  overflow: visible;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.7;
  /* Keep authored capitals on names/places (Sawe, Berlin, Science of Sawe). */
  text-transform: none;
}

.berlinOverviewPrints {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

/* Stacked layout: plotter loop, then the egg, then the stills in their existing order. */
.berlinOverviewPrints [data-print="print_06"] {
  order: -2;
}

.berlinOverviewPrints [data-print="print_07"] {
  order: -1;
}

.berlinPrint {
  position: relative;
  margin: 0;
  padding: 6px 6px 22px;
  background: #e9e9e2;
  color: #000;
  border: 1px solid rgba(0, 0, 0, 0.26);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  user-select: none;
}

.berlinPrint img,
.berlinPrint video {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border: 1px solid rgba(0, 0, 0, 0.18);
  pointer-events: none;
  background: #d8d8d2;
}

.berlinPrint video {
  filter: grayscale(1) contrast(1.05);
}

.berlinPrint video.berlinPrintVideo--color {
  filter: none;
}

.berlinPrint figcaption {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 8px;
  line-height: 1.1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.72);
}

.berlinPrint figcaption span:last-child {
  color: rgba(0, 0, 0, 0.46);
}

.berlinOverview h2 {
  margin: 0 0 8px;
  color: var(--fg);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}

.berlinOverviewK {
  margin: 0 0 20px;
  color: var(--green);
  font-style: italic;
}

.berlinOverview p {
  margin: 0 0 14px;
}

@media (min-width: 1025px), (min-width: 641px) and (orientation: landscape) {
  .berlinOverviewField {
    display: flex;
    align-items: center;
    padding: 12px 0 12px 4%;
    /* Field stays clipped so prints stay pinned; copy scrolls inside .berlinOverview */
    overflow: hidden;
  }

  .berlinOverview {
    width: 56%;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-right: 10px;
    box-sizing: border-box;
  }

  .berlinOverview::-webkit-scrollbar {
    width: 8px;
  }

  .berlinOverview::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
  }

  html.mode-invert .berlinOverview::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.28);
    border-color: rgba(0, 0, 0, 0.12);
  }

  .berlinOverviewPrints {
    position: absolute;
    inset: 0;
    display: block;
    margin: 0;
    pointer-events: none;
  }

  .berlinPrint {
    position: absolute;
    left: var(--place-x);
    top: var(--place-y);
    width: calc(clamp(118px, 15%, 176px) * 1.2);
    padding: 8px 8px 28px;
    cursor: grab;
    pointer-events: auto;
    touch-action: none;
    transform: translate3d(var(--x), var(--y), 0) rotate(var(--r));
    box-shadow:
      0 16px 34px rgba(0, 0, 0, 0.5),
      inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  }

  .berlinPrint--loop {
    width: calc(clamp(118px, 15%, 176px) * 1.44);
    z-index: 3;
  }

  .berlinPrint.is-dragging {
    cursor: grabbing;
    box-shadow:
      0 22px 48px rgba(0, 0, 0, 0.58),
      inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  }

  .berlinPrint figcaption {
    left: 8px;
    right: 8px;
    bottom: 8px;
    font-size: 9px;
  }
}

.berlinOverview strong {
  color: var(--fg);
  font-weight: 500;
}

.berlinStageIdle {
  margin: 0;
  padding: 22px 18px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.65;
  max-width: 36ch;
}

.berlinStageK {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--green);
}

.berlinStageActions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

.berlinStageActions[hidden] {
  display: none;
}

.berlinStageLink {
  color: var(--green);
  font-size: 12px;
  text-transform: lowercase;
  text-decoration: underline;
}

.berlinStageLink:hover {
  color: var(--text);
}

.berlinStageLink[aria-disabled="true"] {
  color: var(--dim);
  text-decoration: none;
  pointer-events: none;
}

.berlinStageNote {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--dim);
  font-size: 11px;
}

/*
 * Desktop — floating toolkits on the desk (scatter / drag).
 * Portrait strip styles live in the portrait media query below.
 */
.berlinDesk .studiesDeskIcons {
  position: absolute !important;
  inset: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  z-index: 20;
  display: block !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  scroll-snap-type: none;
  touch-action: auto !important;
  pointer-events: none;
  cursor: auto;
}

.berlinDesk .studiesDeskIcons::before,
.berlinDesk .studiesDeskIcons::after {
  content: none !important;
  display: none !important;
}

.berlinDesk .berlinToolkit {
  position: absolute !important;
  left: var(--icon-x, 20%);
  top: var(--icon-y, 30%);
  z-index: 1;
  flex: none;
  width: 113px;
  scroll-snap-align: none;
  user-select: none;
  touch-action: none !important;
  pointer-events: auto;
}

.berlinDesk .mobileSwipeCue {
  display: none !important;
}

.berlinToolkit.is-dragging {
  z-index: 40;
  cursor: grabbing;
}

.berlinToolkit.is-preview .berlinToolkitBtn {
  filter: brightness(1.05);
}

/* Mounted toolkit — inverted caption marks the open node */
.berlinToolkit.is-mounted .berlinToolkitCaption {
  background: #000;
  color: var(--green);
}

.berlinToolkitBtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #000;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.berlinToolkitBtn:hover {
  text-decoration: none;
  filter: brightness(1.05);
  outline: 1px solid var(--green);
  outline-offset: 4px;
}

.berlinToolkitBtn:focus,
.berlinToolkitBtn:focus-visible {
  outline: none;
}

.berlinToolkitBtn:active {
  transform: translate(1px, 1px);
}

.berlinToolkitIcon {
  position: relative;
  display: block;
  width: 92px;
  height: 74px;
  filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.35));
}

.berlinToolkitTab {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  min-width: 40px;
  height: 16px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  background: var(--green);
  border: 2px solid #000;
  border-bottom: 0;
  color: #000;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: lowercase;
}

.berlinToolkitFace {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 14px 14px 12px;
  background: var(--green);
  border: 2px solid #000;
  overflow: hidden;
}

.berlinToolkitFace img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.15) contrast(1.05);
}

/* Audio mosaic face — fill entire folder face, stretch, crop letterbox */
.berlinToolkitFaceVideo {
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 155%;
  transform: translateY(-50%);
  object-fit: fill;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 1;
  filter: grayscale(0.1) contrast(1.1) brightness(1.15);
  pointer-events: none;
}

.berlinToolkitFaceVideo--clear {
  top: 0;
  height: 100%;
  transform: none;
  object-fit: cover;
  image-rendering: auto;
  filter: none;
}

.berlinToolkitFace:has(img),
.berlinToolkitFace:has(.berlinToolkitFaceVideo) {
  padding: 0;
  gap: 0;
  background: #000;
}

.berlinToolkitLine {
  display: block;
  height: 3px;
  background: #000;
}

.berlinToolkitCaption {
  display: block;
  min-width: 92px;
  max-width: 14ch;
  padding: 7px 8px 6px;
  border: 2px solid #000;
  background: var(--green);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35);
  color: #000;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  line-height: 1.2;
  text-align: center;
}

.berlinToolkitHandle {
  appearance: none;
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  width: 92px;
  height: 74px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateX(-50%);
  cursor: grab;
}

.berlinToolkit.is-dragging .berlinToolkitHandle {
  cursor: grabbing;
}

.berlinToolkitHandleLabel {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.berlinToolkit--stripTool.is-tool-active .berlinToolkitFace {
  outline: 1px solid var(--green, #7cff9a);
  outline-offset: -1px;
}

.berlinToolkitFace--back {
  display: grid;
  place-items: center;
  background: #0a0a0a;
}

.berlinToolkitBackMark {
  color: var(--green, #7cff9a);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

[data-berlin-tool].is-tool-active {
  outline: none;
  border: 1px solid rgba(124, 255, 154, 0.35);
  padding: 10px 12px 12px;
  box-sizing: border-box;
}

/*
 * Portrait tablet / phone — flush field; app shell (no page scroll) when a node is mounted
 */
@media (max-width: 1024px) and (orientation: portrait), (max-width: 640px) {
  /* Idle desk may scroll; mounted node locks to app viewport */
  html:has(.berlinDesk:not(.is-stage-mounted)),
  body.berlin-desk:not(:has(.berlinDesk.is-stage-mounted)),
  body:has(.berlinDesk:not(.is-stage-mounted)) {
    height: auto !important;
    min-height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
  }

  html:has(.berlinDesk.is-stage-mounted),
  body.berlin-desk:has(.berlinDesk.is-stage-mounted),
  body:has(.berlinDesk.is-stage-mounted) {
    height: 100% !important;
    overflow: hidden !important;
    /* keep strip trackpad/mouse pan; page itself does not scroll */
    touch-action: manipulation;
  }

  .archiveNodeHeader {
    left: 12px;
    top: 10px;
    font-size: 10px;
  }

  .berlinDesk.studiesDesk,
  .berlinDesk {
    --berlin-strip-top: calc(env(safe-area-inset-top, 0px) + 108px);
    --berlin-strip-h: 152px;
    --berlin-strip-gap: 10px;
    --berlin-strip-lead-peek: 16px;
    --berlin-strip-pad-left: 0px;
    --berlin-strip-pad-right: max(24px, 14vw);
    --berlin-stage-top: calc(
      var(--berlin-strip-top) + var(--berlin-strip-h) + var(--berlin-strip-gap)
    );
    --berlin-stage-bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
    position: relative;
    height: auto !important;
    min-height: 100dvh;
    overflow: visible !important;
  }

  .berlinDesk.is-stage-mounted {
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  /* Portrait toolkit strip */
  .berlinDesk .studiesDeskIcons {
    position: fixed !important;
    top: var(--berlin-strip-top) !important;
    bottom: auto !important;
    left: 0 !important;
    right: 0 !important;
    inset: auto 0 auto 0;
    z-index: 70;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    align-content: flex-start !important;
    justify-content: flex-start !important;
    gap: 16px !important;
    width: 100% !important;
    height: var(--berlin-strip-h) !important;
    min-height: 0 !important;
    max-height: var(--berlin-strip-h) !important;
    margin: 0 !important;
    padding: 4px var(--berlin-strip-pad-right) 8px var(--berlin-strip-pad-left) !important;
    box-sizing: border-box;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0 var(--berlin-strip-pad-right);
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x !important;
    pointer-events: auto;
    cursor: grab;
  }

  .berlinDesk .studiesDeskIcons.is-strip-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
    user-select: none;
  }

  .berlinDesk .studiesDeskIcons::before {
    content: none !important;
    display: none !important;
  }

  .berlinDesk .studiesDeskIcons::after {
    content: "" !important;
    display: block !important;
    flex: 0 0 max(55vw, calc(100% - 96px)) !important;
    width: max(55vw, calc(100% - 96px));
    height: 1px;
    min-height: 1px;
    pointer-events: none;
    scroll-snap-align: none;
  }

  .berlinDesk .studiesDeskIcons::-webkit-scrollbar {
    height: 0;
  }

  .berlinDesk .studiesDeskIcons {
    scrollbar-width: none;
  }

  .berlinDesk .berlinToolkit {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    z-index: 1;
    flex: 0 0 113px;
    width: 113px;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    user-select: none;
    touch-action: pan-x !important;
    pointer-events: auto;
  }

  .berlinDesk:not(.is-tool-strip) .berlinToolkit[data-feature]:first-of-type,
  .berlinDesk .berlinToolkit--back {
    scroll-margin-inline-start: calc(-1 * var(--berlin-strip-lead-peek));
  }

  .berlinToolkitHandle {
    display: none !important;
  }

  /* Flush field below toolkits — no framed stage panel */
  .berlinStage {
    position: absolute;
    top: var(--berlin-stage-top);
    left: 0;
    right: 0;
    bottom: auto;
    width: auto;
    min-height: calc(100dvh - var(--berlin-stage-top) - var(--berlin-stage-bottom));
    height: auto;
    max-height: none;
    transform: none;
    z-index: 12;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: hidden;
  }

  .berlinDesk.is-stage-mounted .berlinStage {
    position: fixed;
    top: var(--berlin-stage-top);
    bottom: var(--berlin-stage-bottom);
    left: 0;
    right: 0;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: hidden;
  }

  .berlinDesk.is-plot-booth .berlinStage {
    left: 0;
    right: 0;
    width: auto;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .berlinStageChrome {
    display: none;
  }

  .berlinStageViewport {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    place-items: stretch;
    min-height: 0;
    height: 100%;
    max-height: none;
    background: transparent;
    overflow: hidden;
  }

  .berlinStage:has(.berlinPlotterLayout),
  .berlinStageViewport:has(.berlinPlotterLayout) {
    height: 100%;
    min-height: 0;
    max-height: none;
  }

  .berlinDesk.is-plot-booth .berlinStageViewport {
    background: transparent;
    overflow: hidden;
  }

  .berlinStageActions {
    border-top: 0;
    padding: 8px 14px 10px;
  }

  .berlinStageIdle {
    padding: 18px 16px;
    max-width: 42ch;
  }

  .berlinAudioLayout,
  .berlinFigPile {
    display: none;
  }

  .berlinAudioLayout {
    display: grid;
  }

  .berlinPlotterColumns {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    overflow: hidden;
    height: 100%;
    max-height: none;
    min-height: 0;
    padding-bottom: 12px;
  }

  /* Portrait: field-first; chosen strip tool takes the full pane */
  .berlinAudioLayout[data-tool-view]:not([data-tool-view=""]):not([data-tool-view="desktop"]) .berlinAudioCentre,
  .berlinPlotterLayout[data-tool-view]:not([data-tool-view=""]):not([data-tool-view="desktop"]) .berlinPlotterCentre {
    display: none;
  }

  .berlinAudioTools,
  .berlinPlotterTools {
    display: none;
    height: 100%;
    gap: 0;
  }

  .berlinAudioLayout[data-tool-view]:not([data-tool-view=""]):not([data-tool-view="desktop"]) .berlinAudioTools,
  .berlinPlotterLayout[data-tool-view]:not([data-tool-view=""]):not([data-tool-view="desktop"]) .berlinPlotterTools {
    display: flex;
  }

  .berlinAudioTool {
    display: none;
    height: 100%;
  }

  .berlinAudioLayout[data-tool-view="soundtrack"] [data-berlin-tool="soundtrack"],
  .berlinAudioLayout[data-tool-view="listen"] [data-berlin-tool="listen"],
  .berlinPlotterLayout[data-tool-view="bed-noise"] [data-berlin-tool="bed-noise"] {
    display: flex;
  }

  .berlinPlotterLayout[data-tool-view]:not([data-tool-view=""]):not([data-tool-view="desktop"]) .berlinPlotterSheet {
    opacity: 0;
    visibility: hidden;
  }

  /* Bed noise and soundtrack — the drawn wave fills ~80% of this strip and scrolls as the playhead reaches the edge */
  .berlinPlotterLayout[data-tool-view="bed-noise"] [data-berlin-tool="bed-noise"] {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .berlinPlotterLayout[data-tool-view="bed-noise"] .berlinAudioDeck {
    display: contents;
  }

  .berlinPlotterLayout[data-tool-view="bed-noise"] .berlinWaveStage {
    flex: 0 0 80%;
    height: 80%;
    min-height: 80%;
    max-height: 80%;
  }

  .berlinPlotterLayout[data-tool-view="bed-noise"] .berlinAudioK,
  .berlinPlotterLayout[data-tool-view="bed-noise"] .berlinAudioChrome,
  .berlinPlotterLayout[data-tool-view="bed-noise"] .berlinAudioHint,
  .berlinPlotterLayout[data-tool-view="bed-noise"] .berlinToolNote {
    flex: 0 0 auto;
    margin: 0;
  }

  .berlinPlotterLayout {
    position: relative;
    inset: auto;
    min-height: 0;
    height: 100%;
    background: transparent;
    overflow: hidden;
  }

  .berlinDesk.is-stage-mounted .berlinPlotterSheet {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
  }

  .berlinPlotterColumns {
    position: relative;
    z-index: 1;
  }

  .berlinPlotLayout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(240px, 1fr);
    min-height: 0;
  }

  .berlinPlotCopy {
    border-right: 0;
    border-bottom: 1px solid #1a1a1a;
    padding: 12px 14px;
    font-size: 12px;
    max-height: none;
  }

  .berlinPlotBooth {
    min-height: min(40vh, 360px);
  }

  .berlinDesk .mobileSwipeCue {
    display: block;
    top: calc(var(--berlin-stage-top) - 12px);
    bottom: auto;
    z-index: 65;
  }

  .berlinDesk.is-stage-mounted .mobileSwipeCue {
    display: none;
  }
}

.berlinPlotStory {
  display: none;
}

/* Phone portrait plotter: reading fills the stage, swipe right into the plot story */
@media (max-width: 640px) and (orientation: portrait) {
  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinPlotterColumns {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    height: 100%;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinPlotterColumns::-webkit-scrollbar {
    display: none;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinPlotterCentre,
  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinPlotStory {
    display: flex;
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    height: 100%;
    min-height: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinPlotterCentre {
    flex-direction: column;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 18px 16px 28px;
    touch-action: pan-y;
    scrollbar-width: none;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinPlotterCentre::-webkit-scrollbar {
    display: none;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinFigMenu {
    display: none;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinReading {
    height: auto;
    overflow: visible;
    padding: 0;
    color: var(--dim);
    font-size: 13px;
    line-height: 1.7;
    text-transform: lowercase;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinReading p {
    max-width: none;
    margin: 0 0 14px;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinReading p.berlinReadingK {
    color: var(--green);
    font-style: italic;
    font-weight: 500;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinFigPile {
    display: none;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinPlotStory {
    position: relative;
    padding: 0;
    overflow: hidden;
    background: transparent;
  }

  .berlinPlotterLayout:not([data-tool-view="bed-noise"]) .berlinPlotStoryVideo {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
    object-position: center;
    background: transparent;
    border: 0;
    pointer-events: none;
  }

  .berlinDesk.is-stage-mounted:not(.is-tool-open):has(.berlinPlotterLayout:not(.is-plot-story)) .mobileSwipeCue {
    display: block !important;
    top: auto;
    bottom: calc(var(--berlin-stage-bottom) + 6px);
    z-index: 65;
  }

  /* Bed noise is a short strip: no green box, no pane scroll */
  .berlinPlotterLayout[data-tool-view="bed-noise"] [data-berlin-tool="bed-noise"].is-tool-active {
    border: 0;
    outline: none;
    padding: 8px 16px 12px;
    overflow: hidden;
  }

  .berlinPlotterLayout[data-tool-view="bed-noise"] .berlinWaveStage {
    flex: 0 0 128px;
    height: 128px;
    min-height: 0;
    max-height: 128px;
  }
}

/* Phone: green archive lines sit at the bottom, same as the other study desks. */
@media (max-width: 640px) {
  .archiveNodeHeader {
    top: auto !important;
    bottom: 38px !important;
    left: 12px !important;
    right: auto !important;
    width: min(78vw, 420px);
    max-width: none;
    font-size: 9px;
    line-height: 1.42;
    z-index: 70;
  }

  body.studies-open .archiveNodeHeader {
    opacity: 0;
    pointer-events: none;
  }

  .berlinDesk.studiesDesk,
  .berlinDesk {
    /* Closed app menu is ~40px. Same clearance under it as the other desks. */
    --berlin-strip-top: calc(env(safe-area-inset-top, 0px) + 62px);
  }
}
