/*
 * Exploratory A: source rail → uninterrupted artwork/timing → persistent inspector.
 * identity.css remains the canonical neutral/type system. The red is a Studio-local
 * accent sampled from the owner's BLAC reference at their request; it is not a
 * global Kinoe token. No renderer or project behavior belongs in this file.
 */
body.workbench {
  --studio-workbench-accent: #fe433e;
  --accent: var(--studio-workbench-accent);
  --studio-signal: var(--studio-workbench-accent);
  --signal: var(--studio-workbench-accent);
  --on-accent: #111315;
  --w-head-height: 56px;
  --w-rail-width: 216px;
  --w-inspector-width: clamp(304px, 23vw, 344px);
  --w-time-label-width: 118px;
  --w-time-label-gap: 8px;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: var(--w-head-height) minmax(0, 1fr);
  background: var(--bg);
  font-family: var(--ui);
}

.workbench .s-top {
  min-height: var(--w-head-height);
  padding: 6px 16px;
  gap: 12px;
  flex-wrap: nowrap;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.workbench .mark { font: 400 26px/1 var(--poster); letter-spacing: .03em; }
.workbench .s-top > .label { display: none; }
.workbench .s-top-right { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; width: auto; }
.workbench .s-top .local,
.workbench .s-top .s-ico,
.workbench .s-top .s-ext,
.workbench #add-media { display: none; }
.workbench .s-top .s-act { min-height: 38px; padding: 7px 11px; flex-direction: row; font-size: 13px; white-space: nowrap; }
.workbench #proj-save { background: transparent; border-color: var(--line); color: var(--text); }
.workbench #export-open { background: var(--studio-workbench-accent); border-color: var(--studio-workbench-accent); color: var(--on-accent); }
.workbench #export-open:hover { filter: brightness(1.06); }
.workbench .s-save-status { max-width: 210px; font-size: 11px; }
.workbench .w-project-title {
  min-width: 0;
  max-width: min(320px, 26vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 600 14px var(--ui);
  text-align: left;
  cursor: pointer;
}
.workbench .w-project-title:hover { text-decoration: underline; text-underline-offset: 4px; }
.workbench .w-project-menu { position: relative; }
.workbench .w-project-menu > summary { list-style: none; cursor: pointer; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius-control); font-size: 12px; }
.workbench .w-project-menu > summary::-webkit-details-marker { display: none; }
.workbench .w-project-actions { position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; min-width: 180px; padding: 8px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 12px 32px #0009; }
.workbench .w-project-actions button { width: 100%; text-align: left; }

.workbench .s-main {
  position: relative;
  display: grid;
  grid-template-columns: var(--w-rail-width) minmax(0, 1fr) var(--w-inspector-width);
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}
.workbench .w-structure {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 14px 12px 10px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.workbench .w-rail-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.workbench .w-rail-title h2 { margin: 0; font: 600 14px var(--ui); letter-spacing: -.01em; }
.workbench .w-rail-title span { color: var(--muted); font: 11px var(--mono); white-space: nowrap; }
.workbench .w-rail-close { display: none; }
.workbench .w-rail-layers { min-height: 0; flex: 1 1 auto; overflow: auto; overscroll-behavior: contain; }
.workbench .w-rail-layers .s-group { gap: 8px; }
.workbench .w-rail-layers .s-row-head { align-items: center; flex-wrap: wrap; gap: 6px; }
.workbench .w-rail-layers .s-row-head h2 { font-size: 11px; }
.workbench .w-rail-layers .s-layers { display: grid; gap: 5px; margin: 6px 0 0; overflow: visible; }
.workbench .s-layer { grid-template-columns: minmax(0, 1fr); min-width: 0; padding: 7px; gap: 5px; border-radius: 4px; }
.workbench .s-layer[aria-selected="true"] { background: var(--selection); border-color: var(--studio-workbench-accent); }
.workbench .s-layer .name { font-size: 12px; }
.workbench .s-layer .kind { font-size: 10px; }
.workbench .s-layer .acts { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 3px; }
.workbench .s-layer:not([aria-selected="true"]) .acts { display: none; }
.workbench .s-layer .acts button { width: auto; min-width: 38px; min-height: 32px; padding: 4px 6px; font-size: 11px; }
.workbench .s-layer .acts button::before { display: none; }
.workbench .w-rail-import { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.workbench .w-rail-import #add-media,
.workbench .w-rail-import #add-layer { display: inline-flex; justify-content: center; min-height: 36px; padding: 6px; font-size: 12px; }
.workbench .w-rail-import #add-media .s-ico { display: none; }
.workbench .w-resource-heading { padding-top: 8px; border-top: 1px solid var(--line); }
.workbench .w-resource-nav { display: grid; gap: 2px; }
.workbench .w-resource-nav [data-tab],
.workbench .w-resource-button {
  min-height: 36px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: 500 13px var(--ui);
  text-align: left;
  cursor: pointer;
}
.workbench .w-resource-nav [data-tab]:hover,
.workbench .w-resource-button:hover { background: var(--surface-hover); color: var(--text); }
.workbench .w-resource-nav [aria-selected="true"] { border-left-color: var(--studio-workbench-accent); background: var(--surface-2); color: var(--text); }
.workbench .w-resource-nav .w-phone-time-button { display: none; }
.workbench .w-canvas-tools { border-top: 1px solid var(--line); }
.workbench .w-canvas-tools > summary { min-height: 38px; display: flex; align-items: center; cursor: pointer; font-size: 12px; color: var(--muted); }
.workbench .w-canvas-content { padding: 4px 0 8px; }
.workbench .w-canvas-content .s-canvas-details { display: block; border: 0; }
.workbench .w-canvas-content .s-canvas-details > summary { display: none; }
.workbench .w-canvas-content .s-group { padding: 0; }
.workbench .w-canvas-content .s-row3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.workbench .w-canvas-content .s-row3 .s-field:last-child { grid-column: 1 / -1; }
.workbench .w-canvas-content .s-row2 { grid-template-columns: minmax(0, 1fr); }
.workbench .w-canvas-content .s-group > h2 { display: none; }
.workbench .w-canvas-content .s-field { font-size: 11px; }
.workbench .w-canvas-content input,
.workbench .w-canvas-content select { min-height: 34px; padding: 6px; font-size: 12px; }
.workbench .w-rail-bottom { display: grid; gap: 12px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.workbench .w-open-recover { display: grid; gap: 8px; }
.workbench .w-open-recover h3 { margin: 0; font-size: 10px; }
.workbench .w-open-recover #proj-open { width: 100%; min-height: 36px; text-align: left; }
.workbench .w-open-recover .s-recover { padding: 8px; border: 1px solid var(--studio-workbench-accent); }
.workbench .w-open-recover .s-recover .s-row2 { grid-template-columns: minmax(0, 1fr); }
.workbench .w-open-recover .s-recover .s-row2 .s-btn { min-height: 36px; white-space: nowrap; }
.workbench .w-open-recover #recover-pick { max-width: 100%; text-overflow: ellipsis; }
.workbench .w-help { display: grid; gap: 5px; }
.workbench .w-help .label { font-size: 10px; }
.workbench .w-help-button { justify-self: start; min-height: 32px; padding: 4px 0; border: 0; background: transparent; color: var(--text); font: 12px var(--ui); cursor: pointer; }

.workbench .w-center { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) 222px; background: var(--bg); }
.workbench .s-view {
  position: relative;
  top: auto;
  height: 100%;
  min-height: 0;
  padding: 62px 18px 62px;
  background: #101113;
  border-bottom: 1px solid var(--line);
}
.workbench .s-view > #view { max-width: 100%; max-height: 100%; object-fit: contain; }
.workbench .s-viewbar { top: 8px; left: 12px; right: 12px; min-height: 38px; padding: 0; gap: 6px; z-index: 3; }
.workbench .s-view-title { display: none; }
.workbench .s-viewbar button { min-height: 32px; padding: 5px 8px; font-size: 11px; }
.workbench .s-viewbar .s-comp { margin-left: auto; position: static; color: var(--muted); font-size: 11px; }
.workbench #preview-toggle { display: none; }
.workbench #w-layer-list-open { display: none; }
.workbench .s-comparison { top: 44px; left: 12px; right: 12px; z-index: 2; }
.workbench .s-comparison p { display: none; }
.workbench .s-comparison #compare-scope { max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workbench .s-layer-strip { display: none; }
.workbench .s-preview-playback {
  left: 12px;
  right: 12px;
  bottom: 8px;
  grid-template-columns: 44px 68px minmax(40px, 1fr);
  height: 42px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}
.workbench #play { width: 40px; min-height: 34px; font: 12px var(--ui); }
.workbench #play::before { display: none; }
.workbench .s-time { min-width: 0; font-size: 11px; }
.workbench .s-scrub { height: 30px; }
.workbench .s-keys { display: none; }

.workbench .w-time-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: 38px minmax(0, 1fr); overflow: hidden; background: var(--surface); border-top: 1px solid var(--line); }
.workbench .w-time-expand { display: none; }
.workbench .w-time-tabs { display: flex; align-items: stretch; gap: 0; border-bottom: 1px solid var(--line); }
.workbench .w-time-tab { min-width: 76px; min-height: 36px; padding: 6px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: 500 12px var(--ui); cursor: pointer; }
.workbench .w-time-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--studio-workbench-accent); }
.workbench .w-time-view { min-width: 0; min-height: 0; position: relative; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 4px; padding: 7px 12px 8px; overflow: auto; }
.workbench .w-time-view[hidden] { display: none; }
.workbench .w-property-lane-label,
.workbench .w-time-ruler { display: grid; grid-template-columns: var(--w-time-label-width) minmax(0, 1fr) auto; align-items: center; gap: var(--w-time-label-gap); min-width: 0; }
.workbench .w-property-lane-label .label,
.workbench .w-time-ruler .label { font-size: 9px; letter-spacing: .05em; }
.workbench .w-property-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11px var(--ui); color: var(--text); }
.workbench .w-property-units { color: var(--muted); font: 9px var(--mono); }
.workbench .w-property-track { position: relative; height: 18px; min-width: 0; margin-left: calc(var(--w-time-label-width) + var(--w-time-label-gap)); border-radius: 2px; background: var(--surface-2); }
.workbench .w-property-line { position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--line); }
.workbench .w-property-track .s-keys { display: block; position: absolute; top: 3px; left: 5px; right: 5px; height: 12px; }
.workbench .w-property-track .s-keys button { top: 2px; width: 9px; height: 9px; background: var(--text); }
.workbench .w-time-cursor { position: absolute; top: -3px; bottom: -3px; left: 0; width: 1px; background: var(--studio-workbench-accent); pointer-events: none; z-index: 2; }
.workbench .w-time-ruler { grid-template-columns: var(--w-time-label-width) minmax(0, 1fr); margin-top: 2px; }
.workbench .w-ruler-ticks { min-width: 0; display: flex; justify-content: space-between; color: var(--muted); font: 9px var(--mono); font-variant-numeric: tabular-nums; }
.workbench .w-composition-lane-wrap { min-height: 0; position: relative; overflow: auto; }
.workbench .w-lane-list { display: grid; gap: 2px; min-height: 18px; }
.workbench .w-lane { position: relative; z-index: 1; display: grid; grid-template-columns: var(--w-time-label-width) minmax(0, 1fr); align-items: center; gap: var(--w-time-label-gap); min-width: 0; min-height: 20px; padding: 0; border: 0; background: transparent; text-align: left; font: 10px var(--ui); cursor: pointer; }
.workbench .w-lane > span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.workbench .w-lane-track { position: relative; display: block; min-width: 0; min-height: 17px; overflow: hidden; border-radius: 2px; background: #121417; }
.workbench .w-lane-bar { display: block; min-height: 17px; padding: 2px 5px; overflow: hidden; border-radius: 2px; background: #353a40; color: var(--text); font: 9px var(--mono); white-space: nowrap; text-overflow: ellipsis; }
.workbench .w-lane[aria-pressed="true"] > span:first-child { color: var(--text); }
.workbench .w-lane[aria-pressed="true"] .w-lane-bar { background: #4a4f55; outline: 1px solid var(--studio-workbench-accent); }
.workbench .w-composition-lane-wrap > #w-composition-cursor { top: 0; bottom: 0; z-index: 3; }
.workbench .w-animation-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding-top: 5px; border-top: 1px solid var(--line); }
.workbench .s-timeline { display: contents; }
.workbench .s-timeline .s-playhead { display: flex; align-items: center; gap: 6px; }
.workbench .s-timeline .s-playhead #add-key { white-space: nowrap; }
.workbench .s-timeline .s-menu { z-index: 20; }
.workbench .s-timeline .s-res,
.workbench .s-timeline .s-loop { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font: 10px var(--mono); }
.workbench .s-timeline .s-res select,
.workbench .s-timeline .s-loop input { min-height: 30px; padding: 4px 6px; font-size: 11px; }
.workbench .s-timeline .s-loop input { width: 56px; }
.workbench .s-tl-export { display: none; }
.workbench .w-time-empty { margin: auto; max-width: 46ch; color: var(--muted); font-size: 12px; text-align: center; }
.workbench .w-frame-content,
.workbench .w-rail-content { min-width: 0; min-height: 0; overflow: auto; }
.workbench .w-frame-content .s-group,
.workbench .w-rail-content .s-rails { padding: 0; }
.workbench .w-frame-content .s-source-frame { max-height: 118px; }
.workbench .w-frame-content #source-frame-view { max-height: 110px; }
.workbench .w-frame-content .s-frame-selected-tools { display: none; }
.workbench .w-frame-content .s-frames,
.workbench .w-frame-content .s-video-frames { display: flex; gap: 6px; overflow: auto; }
.workbench .w-rail-content #rails-disclosure { border: 0; }
.workbench .w-rail-content #rails-disclosure > summary { display: none; }
.workbench .w-rail-content .s-rails { display: block; }

.workbench .s-panel { min-width: 0; min-height: 0; height: 100%; margin: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-left: 1px solid var(--line); border-radius: 0; background: var(--surface); }
.workbench .s-context { position: static; min-width: 0; min-height: 64px; padding: 10px 14px; gap: 2px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.workbench #context-kicker { display: block; color: var(--muted); font: 9px var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.workbench #context-name { overflow-wrap: anywhere; font: 600 14px var(--ui); }
.workbench #context-detail { display: block; overflow-wrap: anywhere; color: var(--muted); font: 11px/1.3 var(--ui); }
.workbench .s-tabs { display: none; }
.workbench .w-phone-resource-return { display: none; }
.workbench .s-tabpanel { min-height: 0; padding: 12px 14px; gap: 10px; overflow: auto; align-content: start; }
.workbench .s-tabpanel[hidden] { display: none !important; }
.workbench #tab-output { padding: 0; }
.workbench .s-output-scroll { min-height: 0; padding: 12px 14px; overflow: auto; }
.workbench .s-output-footer { padding: 10px 14px; background: var(--surface); }
.workbench .s-media-import-alert {
  position: static;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  min-width: 0;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--signal);
  border-radius: var(--radius-control);
  background: #362421;
  color: var(--text);
}
.workbench .s-media-import-alert[hidden] { display: none !important; }
.workbench .s-media-import-copy { min-width: 0; }
.workbench .s-media-import-copy strong { display: block; font-size: 12px; }
.workbench .s-media-import-copy p { max-height: min(20dvh, 180px); margin: 4px 0 0; overflow: auto; overflow-wrap: anywhere; white-space: pre-wrap; font: 12px/1.45 var(--ui); }
.workbench #media-import-error-dismiss { min-width: 44px; min-height: 36px; align-self: start; white-space: nowrap; }
.workbench #tab-output .s-output-scroll #out-summary { margin: 0; padding: 0; border: 0; color: var(--muted); font: 500 12px/1.65 var(--display); }
.workbench.output-mode .s-tl-export,
.workbench.output-mode #export-open { display: none; }
.workbench.output-mode .w-time-panel { display: none; }

/* Stack navigation filters presentation only; the selected inspector remains intact. */
.workbench .s-stack-search { display: grid; gap: 4px; min-width: 0; margin-bottom: 7px; }
.workbench .s-stack-search > label { font-size: 11px; color: var(--muted); }
.workbench .s-stack-search-row { display: flex; gap: 4px; min-width: 0; }
.workbench .s-stack-search input { flex: 1; min-width: 0; width: 100%; min-height: 32px; padding: 5px 7px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); font: inherit; font-size: 12px; }
.workbench .s-stack-search .s-btn { flex: none; min-height: 32px; padding: 4px 7px; font-size: 11px; }
.workbench .s-stack-search p { margin: 0; font-size: 11px; line-height: 1.4; }
.workbench .s-stack-search p:empty { display: none; }
.workbench .s-effect-help-toggle { grid-column: 1 / -1; justify-self: start; min-height: 30px; padding: 3px 6px; font-size: 11px; }
.workbench #fx-list > [hidden], .workbench #layers > [hidden] { display: none; }
.workbench [data-stack-filtered="true"] .s-effect-drag-handle { display: none; }
@media (max-width: 899px) {
  .workbench .s-stack-search input { min-height: 44px; font-size: 16px; }
  .workbench .s-stack-search .s-btn, .workbench .s-effect-help-toggle { min-height: 44px; }
}

/* The ordered stack is always present above the selected effect's real controls. */
.workbench .s-stack-bar { position: static; display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; padding: 0 0 7px; margin: 0; border: 0; background: transparent; }
.workbench .s-stack-heading { display: contents; }
.workbench .s-stack-title { width: auto; min-width: 0; }
.workbench .s-stack-title .label { font: 600 11px var(--ui); letter-spacing: 0; text-transform: none; color: var(--text); }
.workbench .s-stack-count { color: var(--muted); font: 10px var(--mono); }
.workbench .s-add-effect { min-height: 32px; padding: 4px 8px; font-size: 11px; }
.workbench .s-add-effect .s-ico { display: none; }
.workbench #fx-layer { display: none; }
.workbench .s-stack-added { grid-column: 1 / -1; margin: 0; padding: 0; color: var(--muted); font-size: 10px; line-height: 1.3; }
.workbench .s-stack-added:empty { display: none; }
.workbench .s-stack-added .s-link { display: inline; min-height: 0; padding: 0; }
.workbench .s-fx { display: grid; gap: 0; margin: 0; padding: 0; }
.workbench .s-fx-card { min-width: 0; min-height: 0; overflow: visible; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.workbench .s-fx-card.is-selected { border-left: 2px solid var(--studio-workbench-accent); background: #1c1d20; }
.workbench .s-fx-card.off { opacity: .76; }
.workbench .s-fx-head { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; min-height: 31px; padding: 3px 6px; background: transparent; }
.workbench .s-fx-head .s-fx-disclosure { min-width: 0; min-height: 28px; flex: 1 1 110px; padding: 4px 3px; font: 500 11px var(--ui); text-align: left; }
.workbench .s-fx-family,
.workbench .s-fx-chevron { display: none; }
.workbench .s-fx-head > button:not(.s-fx-disclosure) { display: none; min-width: 0; min-height: 27px; width: auto; padding: 3px 5px; border: 1px solid var(--line); border-radius: 4px; font: 10px var(--ui); }
.workbench .s-fx-card.is-selected .s-fx-head > button:not(.s-fx-disclosure) { display: inline-flex; }
.workbench .s-fx-head button::before,
.workbench .s-fx-head button::after,
.workbench .s-key::before,
.workbench .s-mod::before,
.workbench .s-lock::before { content: none; display: none; }
.workbench .s-enabled-row { align-items: center; flex-wrap: wrap; gap: 6px; padding: 0 7px 6px; }
.workbench .s-enabled-row .s-check { margin-right: auto; font-size: 11px; }
.workbench .s-enabled-row .s-key { min-width: 58px; }
.workbench .s-fx-body { padding: 6px 9px 10px; gap: 8px; }
.workbench .s-param { min-width: 0; padding-top: 7px; border-top: 1px solid var(--line); }
.workbench .s-param-top { min-height: 22px; gap: 8px; font: 12px var(--ui); color: var(--text); }
.workbench .s-param-top output { color: var(--text); font: 11px var(--mono); font-variant-numeric: tabular-nums; }
.workbench .s-param-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto auto; gap: 5px; align-items: center; }
.workbench .s-param-row > input[type="range"] { grid-column: 1 / -1; order: 0; min-width: 0; width: 100%; margin: 2px 0; accent-color: var(--studio-workbench-accent); }
.workbench .w-exact { width: 76px; min-width: 64px; min-height: 34px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: #111315; color: var(--text); font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.workbench .s-param-row > select,
.workbench .s-param-row > textarea { min-width: 0; width: 100%; grid-column: 1 / -1; }
.workbench .s-key,
.workbench .s-mod,
.workbench .s-lock { width: auto; min-width: 52px; height: auto; min-height: 32px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: transparent; font: 10px var(--ui); }
.workbench .s-key.on,
.workbench .s-mod.on,
.workbench .s-lock.on { border-color: var(--studio-workbench-accent); color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.workbench .w-key-state { margin: 2px 0 0; color: var(--muted); font: 10px/1.35 var(--ui); }
.workbench .s-mod-row { gap: 5px; padding: 7px; border-color: var(--line); }
.workbench .s-mod-row input,
.workbench .s-mod-row select { min-height: 32px; }
.workbench .w-disclosure { margin: 10px 0; border-top: 1px solid var(--line); }
.workbench .w-disclosure > summary { padding: 9px 0; cursor: pointer; font-size: 12px; }
.workbench .w-disclosure > div { margin-bottom: 8px; }
.workbench .s-btn,
.workbench button,
.workbench input,
.workbench select { touch-action: manipulation; }
.workbench :is(button, input, select, summary, textarea):focus-visible { outline: 2px solid var(--studio-workbench-accent); outline-offset: 2px; }
.workbench .s-drop { inset: 62px 18px 62px; }

/* Keep long save receipts inside the fixed desktop toolbar. The status remains
   fully available by scrolling or keyboard focus without moving the actions. */
@media (min-width: 900px) {
  .workbench .s-top-right { min-width: 0; }
  .workbench .s-top .s-act,
  .workbench .w-project-menu,
  .workbench .mark { flex-shrink: 0; }
  .workbench .s-save-status {
    min-width: 0;
    max-height: 40px;
    overflow: auto;
    overflow-wrap: anywhere;
    white-space: normal;
    line-height: 1.3;
    overscroll-behavior: contain;
  }
  .workbench .s-save-status:focus-visible { outline: 2px solid var(--studio-workbench-accent); outline-offset: 2px; }
}

@media (max-width: 1120px) and (min-width: 900px) {
  body.workbench { --w-rail-width: 190px; --w-inspector-width: 310px; }
  .workbench .s-top { padding-inline: 10px; }
  .workbench .s-save-status { max-width: 115px; }
  body.workbench { --w-time-label-width: 92px; }
}

@media (max-width: 899px) {
  body.workbench { --w-head-height: 58px; grid-template-rows: var(--w-head-height) minmax(0,1fr); padding-top: env(safe-area-inset-top); }
  .workbench .s-top { padding: 5px 8px; gap: 6px; }
  .workbench .mark { font-size: 23px; }
  .workbench .s-top-right { margin-left: auto; gap: 5px; }
  .workbench .s-top .s-act { min-height: 40px; padding: 6px 8px; font-size: 12px; }
  .workbench .w-project-title { max-width: 24vw; padding-inline: 2px; font-size: 12px; }
  .workbench .w-project-menu > summary { min-height: 38px; padding: 7px; font-size: 11px; }
  .workbench .s-top-right #save-status { position: static; order: 0; grid-column: auto; flex: 0 1 60px; width: 60px; min-width: 0; max-width: 60px; overflow: hidden; white-space: nowrap; text-overflow: clip; pointer-events: auto; font-size: 0; line-height: 1; }
  .workbench .s-top-right #save-status::after { content: attr(data-compact); display: block; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font: 9px/1.2 var(--ui); }
  .workbench .s-top-right #save-status[data-kind="error"]::after { color: #ff7771; }
  .workbench .s-top-right #save-status[data-kind="pending"]::after { color: var(--text); }
  @media (max-width: 360px) { .workbench .s-save-status { flex-basis: 38px; max-width: 38px; } }
  .workbench .s-main { grid-template-columns: 1fr; grid-template-rows: minmax(180px, 32dvh) minmax(96px, 14dvh) minmax(220px, 1fr); overflow: hidden; }
  .workbench .w-structure { display: none; position: absolute; inset: 0; z-index: 25; width: min(90vw, 360px); padding: 12px; border: 1px solid var(--line); box-shadow: 0 14px 36px #000b; }
  .workbench.structure-open .w-structure { display: flex; }
  .workbench .w-rail-close { display: block; align-self: flex-start; min-height: 40px; }
  .workbench .w-center { display: contents; }
  .workbench .s-view { grid-row: 1; grid-column: 1; padding: 44px 8px 44px; }
  .workbench .s-viewbar { top: 4px; left: 7px; right: 7px; gap: 4px; }
  .workbench .s-viewbar button { min-height: 36px; padding: 5px 7px; font-size: 11px; }
  .workbench .s-viewbar .s-comp { max-width: 28vw; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .workbench #w-layer-list-open { display: inline-flex; }
  .workbench .s-comparison { top: 39px; left: 7px; right: 7px; }
  .workbench .s-comparison #compare-scope { max-width: 44%; font-size: 10px; }
  .workbench .s-comparison button { min-height: 32px; padding: 4px 7px; font-size: 11px; }
  .workbench .s-preview-playback { left: 7px; right: 7px; bottom: 5px; height: 38px; grid-template-columns: 42px 57px minmax(32px,1fr); }
  .workbench #play { width: 38px; min-height: 32px; }
  .workbench .s-time { font-size: 10px; }
  .workbench .w-time-panel { grid-row: 2; grid-column: 1; grid-template-rows: 34px minmax(0,1fr); border-top: 0; border-bottom: 1px solid var(--line); }
  .workbench .w-time-tabs { height: 34px; }
  .workbench .w-time-tab { flex: 1; min-width: 0; min-height: 32px; padding: 4px 6px; font-size: 11px; }
  .workbench .w-time-view { padding: 5px 8px; gap: 2px; }
  body.workbench { --w-time-label-width: 76px; --w-time-label-gap: 5px; }
  .workbench .w-property-track { height: 15px; }
  .workbench .w-property-lane-label .label,
  .workbench .w-time-ruler .label { font-size: 8px; }
  .workbench .w-property-name { font-size: 10px; }
  .workbench .w-property-units { font-size: 8px; }
  .workbench .w-ruler-ticks { font-size: 8px; }
  .workbench .w-lane { min-height: 18px; font-size: 9px; }
  .workbench .w-lane-track, .workbench .w-lane-bar { min-height: 15px; }
  .workbench .w-animation-controls { gap: 4px 6px; padding-top: 3px; }
  .workbench .s-timeline .s-playhead { gap: 4px; }
  .workbench .s-timeline #split-clip,
  .workbench .s-timeline #add-key { min-height: 32px; padding: 4px 6px; font-size: 10px; }
  .workbench .s-timeline .s-res,
  .workbench .s-timeline .s-loop { font-size: 9px; }
  .workbench .s-timeline .s-res select,
  .workbench .s-timeline .s-loop input { min-height: 30px; font-size: 10px; }
  .workbench .s-panel { grid-row: 3; grid-column: 1; grid-template-rows: auto minmax(0,1fr) auto; border: 0; }
  .workbench .s-context { min-height: 52px; padding: 6px 10px; }
  .workbench #context-kicker { font-size: 8px; }
  .workbench #context-name { font-size: 12px; }
  .workbench #context-detail { font-size: 10px; }
  .workbench .s-tabpanel { padding: 8px 10px; gap: 8px; }
  .workbench .w-resource-nav { grid-row: 3; display: flex; align-items: stretch; gap: 0; min-height: 48px; padding: 2px 4px max(2px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
  .workbench .w-resource-nav [data-tab],
  .workbench .w-resource-button { display: inline-flex; align-items: center; justify-content: center; flex: 1 1 20%; min-width: 0; min-height: 44px; padding: 4px 2px; border: 0; border-top: 2px solid transparent; font-size: 11px; text-align: center; white-space: nowrap; }
  .workbench .w-resource-nav [aria-selected="true"] { border-top-color: var(--studio-workbench-accent); border-left-color: transparent; background: var(--surface-2); }
  .workbench.output-mode .s-main { grid-template-rows: minmax(180px, 32dvh) minmax(0,1fr); }
  .workbench.output-mode .w-time-panel { display: none; }
  .workbench.output-mode .s-panel { grid-row: 2; }
  .workbench .s-output-scroll { padding: 8px 10px; }
  .workbench .s-output-footer { padding: 8px 10px max(8px, env(safe-area-inset-bottom)); }
  .workbench .s-dialog { width: calc(100vw - 16px); max-width: calc(100vw - 16px); max-height: calc(100dvh - env(safe-area-inset-top) - 12px); }
  .workbench .s-drop { inset: 54px 8px 50px; }
  .workbench.w-focus-mode .s-main { grid-template-rows: minmax(132px, 23dvh) minmax(86px, 12dvh) minmax(220px, 1fr); }
  .workbench.text-entry-held .s-main { grid-template-rows: minmax(112px, 16dvh) minmax(72px, 10dvh) minmax(240px, 1fr); }
}

@media (max-width: 599px) {
  .workbench .w-project-menu { display: none; }
  .workbench .w-project-title { max-width: 23vw; }
  .workbench .s-top-right { gap: 4px; }
  .workbench .s-top .s-act { padding-inline: 6px; font-size: 11px; }
  .workbench #proj-save { min-width: 50px; width: auto; padding-inline: 10px; }
  .workbench #proj-save .s-long { display: none; }
  .workbench .w-time-view { overflow-y: auto; }
  .workbench .w-frame-content .s-frame-nav { min-height: 38px; }
  .workbench .w-frame-content .s-frame-nav button { min-height: 36px; }
  .workbench .w-frame-content .s-row2,
  .workbench .w-frame-content .s-row3 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .workbench .w-rail-layers .s-layer .acts button { min-height: 40px; }
  /* On/Key sit above the compact effect name row. Reserve their full painted
     touch height so a one-line name cannot leave the controls clipped. */
  .workbench.w-effect-stack-open .s-fx-head { min-height: 50px; }
  .workbench.w-effect-stack-open .s-enabled-row .s-key { min-height: 44px; }
}

@media (min-width: 361px) and (max-width: 599px) {
  /* Keep the compact pending label readable instead of shrinking its flex item
     to the exact text width. The long title remains ellipsized independently. */
  .workbench .s-top-right #save-status { flex: 0 0 38px; width: 38px; min-width: 38px; max-width: 38px; }
}

@media (max-width: 360px) {
  .workbench .mark { font-size: 21px; }
  .workbench .w-project-title { flex: 0 1 52px; max-width: 52px; font-size: 10px; }
  .workbench .s-top-right { gap: 3px; }
  .workbench .s-top .s-act { min-height: 36px; padding-inline: 4px; font-size: 10px; }
  .workbench #proj-save { min-height: 40px; min-width: 50px; width: auto; padding-inline: 10px; font-size: 11px; }
  .workbench #export-open { width: 58px; }
  .workbench .s-top-right #save-status { flex: 0 0 34px; width: 34px; flex-basis: 34px; max-width: 34px; }
  .workbench .s-top-right #save-status::after { font-size: 8px; }
}

@media (min-width: 900px) {
  /* Sequence batch controls remain the same always-visible desktop rows;
     the disclosure is only a compact-phone presentation. */
  .workbench .s-sequence-settings,
  .workbench .s-sequence-settings-body { display: contents; }
  .workbench .s-sequence-settings > summary { display: none; }
}

@media (min-width: 600px) and (max-width: 899px) and (max-height: 600px) {
  body.workbench { --w-head-height: 50px; --w-rail-width: 138px; --w-inspector-width: 302px; padding-top: env(safe-area-inset-top); }
  .workbench .s-main { grid-template-columns: var(--w-rail-width) minmax(0,1fr) var(--w-inspector-width); grid-template-rows: minmax(0,1fr); align-items: stretch; }
  .workbench .w-structure { display: flex; position: relative; inset: auto; width: auto; padding: 8px 7px; border: 0; border-right: 1px solid var(--line); box-shadow: none; }
  .workbench .w-rail-close { display: none; }
  .workbench .w-rail-title { display: grid; gap: 2px; }
  .workbench .w-rail-title h2 { font-size: 12px; }
  .workbench .w-rail-title span { font-size: 9px; }
  .workbench .w-rail-layers { flex: 0 0 148px; }
  .workbench .w-rail-import { grid-template-columns: 1fr; }
  .workbench .w-resource-nav { display: grid; }
  .workbench .w-resource-nav [data-tab], .workbench .w-resource-button { min-height: 31px; font-size: 11px; }
  .workbench .w-center { display: grid; grid-template-rows: minmax(0,1fr) 116px; }
  .workbench .s-view { grid-row: auto; padding: 46px 8px 46px; }
  .workbench .s-viewbar { top: 4px; left: 8px; right: 8px; }
  .workbench .s-viewbar .s-comp { display: none; }
  .workbench .s-comparison { top: 38px; }
  .workbench .w-time-panel { grid-row: auto; grid-template-rows: 30px minmax(0,1fr); }
  .workbench .w-time-tabs { height: 30px; }
  .workbench .w-time-tab { min-height: 28px; font-size: 10px; }
  .workbench .w-time-view { padding: 3px 6px; gap: 1px; }
  body.workbench { --w-time-label-width: 60px; --w-time-label-gap: 3px; }
  .workbench .w-property-track { height: 12px; }
  .workbench .w-property-name { font-size: 9px; }
  .workbench .w-lane { min-height: 14px; font-size: 8px; }
  .workbench .w-lane-track, .workbench .w-lane-bar { min-height: 12px; }
  .workbench .w-animation-controls { padding-top: 2px; gap: 3px 5px; }
  .workbench .s-timeline #split-clip, .workbench .s-timeline #add-key { min-height: 26px; padding: 2px 5px; font-size: 9px; }
  .workbench .s-timeline .s-res, .workbench .s-timeline .s-loop { font-size: 8px; }
  .workbench .s-panel { grid-row: 1; grid-column: 3; grid-template-rows: auto minmax(0,1fr); }
  .workbench .s-context { min-height: 49px; padding: 5px 9px; }
  .workbench .s-tabpanel { padding: 6px 8px; gap: 6px; }
  .workbench .w-resource-nav [data-tab], .workbench .w-resource-button { border-left: 2px solid transparent; border-top: 0; text-align: left; justify-content: flex-start; }
  .workbench .w-resource-nav [aria-selected="true"] { border-left-color: var(--studio-workbench-accent); border-top-color: transparent; }
  .workbench #w-layer-list-open { display: none; }
  .workbench.output-mode .w-time-panel { display: none; }
  .workbench.output-mode .s-panel { grid-column: 3; grid-row: 1; }
}


@media (prefers-reduced-motion: reduce) {
  .workbench *, .workbench *::before, .workbench *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Exploratory A refinement: compact stack summaries with one real inspector. */
.workbench[data-inspector="effects"] .s-context { display: none; }
.workbench #tab-effects { gap: 7px; }
.workbench .s-stack-bar { grid-template-columns: minmax(0,1fr) auto auto; align-items: center; padding-bottom: 4px; }
.workbench .s-stack-title { display: flex; align-items: baseline; gap: 8px; }
.workbench .s-stack-title .label { font-size: 12px; }
.workbench .w-stack-toggle { display: none; width: max-content; min-width: max-content; flex: none; min-height: 30px; padding: 4px 7px; font-size: 11px; white-space: nowrap; }
.workbench .s-fx { max-height: clamp(130px, 25vh, 250px); overflow: auto; overscroll-behavior: contain; border-bottom: 1px solid var(--line); }
.workbench .s-fx-card { position: relative; scroll-margin: 0; border-top-color: #303236; }
.workbench .s-fx-head { display: flex; min-height: 36px; gap: 3px 8px; padding: 3px 124px 3px 5px; }
.workbench .s-fx-head .s-fx-disclosure { min-width: 0; min-height: 28px; flex: 1 1 auto; font-size: 12px; }
.workbench .s-effect-drag-handle { min-width: 42px; min-height: 27px; padding: 3px 5px; border-color: var(--line); font-size: 10px; }
.workbench #fx-list .s-fx-card.is-drop-before { box-shadow: inset 0 2px 0 var(--studio-workbench-accent); }
.workbench #fx-list .s-fx-card.is-drop-after { box-shadow: inset 0 -2px 0 var(--studio-workbench-accent); }
.workbench #fx-list .s-fx-card.is-dragging { opacity: .48; }
.workbench .s-fx-card.source .s-fx-head { padding-right: 5px; }
.workbench .s-fx-family { display: none; }
.workbench .s-fx-chevron { display: inline-block; width: 6px; height: 6px; margin: 0 7px 2px 2px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(-45deg); }
.workbench .s-fx-disclosure[aria-expanded="true"] .s-fx-chevron { transform: rotate(45deg); }
.workbench .s-enabled-row { position: absolute; top: 4px; right: 4px; display: inline-flex; align-items: center; flex-wrap: nowrap; gap: 4px; padding: 0; }
.workbench .s-enabled-row .s-check { margin: 0; gap: 4px; white-space: nowrap; font-size: 10px; }
.workbench .s-enabled-row .s-check input { width: 14px; height: 14px; }
.workbench .s-enabled-row .s-key { min-width: 44px; min-height: 26px; padding: 2px 4px; font-size: 9px; }
.workbench .s-fx-card.is-selected { border-left: 2px solid var(--studio-workbench-accent); background: #1b1c1f; }
.workbench .s-fx-card.is-selected .s-fx-head > button:not(.s-fx-disclosure) { display: none; }
.workbench .w-effect-inspector { min-width: 0; min-height: 0; padding-top: 2px; }
.workbench .w-effect-collapsed-note { margin: 10px 0 6px; font-size: 11px; line-height: 1.4; }
.workbench .w-selected-effect { min-width: 0; border: 0; background: transparent; }
.workbench .w-selected-effect-head { display: grid; grid-template-columns: minmax(0,1fr); align-items: center; gap: 4px; padding: 2px 0 7px; border-bottom: 1px solid var(--line); }
.workbench .w-selected-effect-title { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr); align-items: baseline; gap: 3px 8px; }
.workbench .w-selected-effect-title .label { grid-column: 1 / -1; color: var(--muted); font-size: 9px; letter-spacing: .04em; }
.workbench .w-selected-effect-title h3 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13px var(--ui); }
.workbench .w-selected-effect-title .s-muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 10px var(--ui); }
.workbench .s-stack-added { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workbench .w-selected-effect-actions { display: flex; justify-content: flex-start; flex-wrap: nowrap; gap: 4px; }
.workbench .w-selected-effect-actions .s-btn { min-width: 0; min-height: 28px; padding: 3px 6px; font-size: 10px; }
.workbench .w-selected-effect-actions .s-btn:disabled { opacity: .42; }
.workbench .w-selected-effect .s-fx-body { padding: 2px 0 8px; gap: 0; }
.workbench .w-selected-effect .s-enabled-row { display: none; }
.workbench .w-selected-effect .s-param { padding: 7px 0 6px; border-top: 1px solid #2d3033; }
.workbench .w-selected-effect .s-param-top { min-height: 30px; display: flex; align-items: center; gap: 7px; font-size: 12px; }
.workbench .w-selected-effect .s-param-top > span:first-child { min-width: 0; flex: 1 1 auto; }
.workbench .w-selected-effect .s-param-tools { display: inline-flex; align-items: center; gap: 4px; }
.workbench .w-selected-effect .w-exact { width: 76px; min-width: 64px; min-height: 32px; margin-left: auto; }
.workbench .w-selected-effect .s-param-row { display: grid; grid-template-columns: minmax(0,1fr); gap: 5px; align-items: center; }
.workbench .w-selected-effect .s-param-row > input[type="range"] { grid-column: 1; width: 100%; min-height: 25px; margin: 2px 0 0; }
.workbench .w-selected-effect .s-param-row > select,
.workbench .w-selected-effect .s-param-row > textarea { min-width: 0; width: 100%; }
.workbench .w-selected-effect .s-key,
.workbench .w-selected-effect .s-mod,
.workbench .w-selected-effect .s-lock { min-width: 34px; width: auto; min-height: 27px; padding: 3px 5px; font-size: 9px; }
.workbench .w-selected-effect .w-key-state { margin: 1px 0 0; font-size: 9px; }
.workbench .w-effect-empty { margin: 18px 0; text-align: left; }
.workbench .w-rail-layers { flex: 0 1 auto; max-height: min(38vh, 350px); }
.workbench .w-rail-layers .s-group { gap: 4px; }
.workbench .w-rail-layers .s-row-head { flex-wrap: nowrap; }
.workbench .w-rail-layers .s-row-head h2 { margin: 0; }
.workbench .w-rail-layers .s-layers { gap: 3px; margin-top: 4px; }
.workbench .w-rail-layers .s-layer { grid-template-columns: minmax(0,1fr); align-items: center; padding: 5px 6px; gap: 2px; }
.workbench .w-rail-layers .s-layer .kind { grid-column: 1; grid-row: 1; }
.workbench .w-rail-layers .s-layer .name { grid-column: 1; grid-row: 2; }
.workbench .w-rail-layers .s-layer .acts { grid-column: 1; grid-row: 3; flex-wrap: nowrap; justify-content: flex-start; gap: 2px; overflow-x: auto; }
.workbench .w-rail-layers .s-layer .acts button { flex: 0 0 auto; min-width: 29px; min-height: 25px; padding: 2px 4px; font-size: 9px; }
@media (min-width: 900px) {
  /* Keep every labeled layer action reachable in the narrow desktop rail.
     A one-line scroller clipped Remove on sequence rows at 901–1024 px. */
  .workbench .w-rail-layers .s-layer .acts {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    align-content: flex-start;
  }
}

@media (hover: none), (pointer: coarse) {
  .workbench .s-effect-drag-handle { display: none; }
}

/* On desktop, the empty-state outline starts below both composition controls
   (not through the selected-layer/effect scope and Before/After row). */
@media (min-width: 900px) {
  .workbench[data-workspace="empty"] .s-view > .s-drop { top: 104px; }
}
.workbench .w-help { display: block; }

/* Keep effect identity, drag affordance and the New badge in predictable
   columns. Long names wrap to two lines rather than losing the effect name. */
@media (min-width: 900px) {
  .workbench .s-fx-head { display: grid; grid-template-columns: minmax(0,1fr) auto auto; grid-template-rows: minmax(28px,auto); align-items: center; gap: 4px; flex-wrap: initial; }
  .workbench .s-fx-head .s-fx-disclosure { grid-column: 1; grid-row: 1; min-width: 0; overflow: hidden; overflow-wrap: anywhere; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .workbench .s-fx-head .s-effect-drag-handle { grid-column: 2; grid-row: 1; min-width: 42px; }
  .workbench .s-fx-head .s-fx-new { grid-column: 3; grid-row: 1; margin: 0; white-space: nowrap; }
  .workbench .s-fx-card.source .s-fx-head { grid-template-columns: minmax(0,1fr); }
}
.workbench .w-effect-collapsed-note.has-expand-action { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.workbench .w-effect-expand-controls { min-height: 44px; padding: 6px 12px; white-space: nowrap; }
.workbench .w-help .label { display: none; }
.workbench .w-help-button { display: inline-flex; align-items: center; }
.workbench .s-view { padding-top: 92px; }
.workbench .s-viewbar { display: flex; flex-wrap: wrap; align-content: flex-start; align-items: center; min-height: 68px; }
.workbench .s-comparison { position: static; z-index: auto; display: flex; flex: 1 0 100%; min-width: 0; align-items: center; justify-content: space-between; gap: 6px; margin: 1px 0 0; padding: 2px 0; background: transparent; }
.workbench .s-comparison #compare-scope { min-width: 0; max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.workbench .s-comparison [role="group"] { flex: 0 0 auto; display: flex; gap: 3px; }
.workbench .s-comparison button { min-height: 27px; padding: 3px 7px; font-size: 10px; }

@media (max-width: 899px) {
  .workbench .s-main { grid-template-rows: minmax(165px,36dvh) 38px minmax(235px,1fr); }
  .workbench.w-time-expanded .s-main { grid-template-rows: minmax(170px,29dvh) 118px minmax(235px,1fr); }
  /* Empty-state preview sizing must yield to the selected timing row while the
     tour teaches Animation, otherwise the canvas can cover the time tabs. */
  body.workbench.w-tour-time-focus[data-workspace="empty"] .s-view { height: 100%; min-height: 0; }
  .workbench .w-time-panel:not(.w-time-expanded) { grid-template-rows: 36px 0; }
  .workbench .w-time-panel:not(.w-time-expanded) .w-time-view { display: none; }
  .workbench .w-time-expanded #w-time-animation:not([hidden]) { grid-template-rows: min-content 15px min-content 36px min-content; }
  .workbench .w-time-view { scrollbar-width: thin; scrollbar-color: var(--muted) transparent; }
  .workbench .w-time-view::-webkit-scrollbar { width: 4px; height: 4px; }
  .workbench .w-time-view::-webkit-scrollbar-thumb { background: var(--muted); }
  .workbench .w-time-tabs { position: relative; padding-right: 86px; }
  .workbench .w-time-expand { display: inline-flex; position: absolute; right: 5px; top: 2px; min-height: 30px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--text); font: 10px var(--ui); }
  .workbench .s-view { padding-top: 83px; }
  .workbench .s-viewbar { min-height: 72px; }
  .workbench .s-comparison { top: auto; left: auto; right: auto; }
  .workbench .s-comparison button { min-height: 26px; }
  .workbench .s-panel { grid-template-rows: minmax(0,1fr) auto; }
  .workbench .s-context { display: none; }
  .workbench .s-tabpanel { padding: 7px 10px; }
  .workbench .s-stack-bar { grid-template-columns: minmax(0,1fr) auto auto; }
  .workbench .w-stack-toggle { display: inline-flex; }
  .workbench #fx-list { display: none; }
  .workbench.w-effect-stack-open #fx-list { display: grid; }
  .workbench.w-effect-stack-open .w-effect-inspector,
  .workbench.w-effect-stack-open .s-enabled-history,
  .workbench.w-effect-stack-open #effect-state-status { display: none; }
  .workbench .s-fx { max-height: none; }
  .workbench .w-selected-effect-head { gap: 4px; padding-bottom: 5px; }
  .workbench .w-selected-effect-actions { gap: 3px; }
  .workbench .w-selected-effect-actions .s-btn { min-height: 32px; }
  .workbench .w-selected-effect .s-param { padding-block: 5px; }
  .workbench .w-selected-effect .s-param-top { min-height: 31px; }
  .workbench .w-selected-effect .w-key-state { display: block; }
  .workbench .w-selected-effect .s-param-row > input[type="range"] { min-height: 28px; }
  .workbench .w-rail-layers { max-height: 42vh; flex: 0 1 auto; }
  .workbench .s-viewbar .s-comparison #compare-scope { max-width: 40%; }
  .workbench .s-viewbar .s-comparison button { min-height: 28px; }
  .workbench.output-mode .s-main { grid-template-rows: minmax(165px,36dvh) minmax(0,1fr); }
}

@media (min-width: 600px) and (max-width: 899px) and (max-height: 600px) {
  .workbench .s-main { grid-template-columns: var(--w-rail-width) minmax(0,1fr) var(--w-inspector-width); grid-template-rows: minmax(0,1fr); }
  /* Keep Focus controls from restoring the portrait three-row layout in
     short landscape. The preview/playhead must not cover time-view tabs. */
  .workbench.w-focus-mode .s-main { grid-template-rows: minmax(0,1fr); }
  .workbench .w-structure { grid-column: 1; grid-row: 1; }
  .workbench .w-center { grid-column: 2; grid-row: 1; }
  .workbench .w-center { display: grid; grid-template-rows: minmax(0,1fr) 30px; }
  .workbench.w-time-expanded .w-center { grid-template-rows: minmax(0,1fr) 116px; }
  .workbench.output-mode .w-center { grid-template-rows: minmax(0,1fr) 0; }
  .workbench .s-panel { grid-column: 3; grid-row: 1; }
  .workbench .w-rail-layers { flex: 0 0 180px; min-height: 180px; max-height: 180px; overflow: auto; }
  .workbench .w-rail-layers .s-layer .acts { flex-wrap: wrap; gap: 2px; overflow: visible; max-width: 100%; }
  .workbench .w-rail-layers .s-layer .acts button { flex: 0 0 auto; min-width: 0; min-height: 28px; padding: 3px 4px; font-size: 9px; white-space: nowrap; }
  .workbench .w-time-panel { grid-template-rows: 30px minmax(0,1fr); }
  .workbench .w-time-panel:not(.w-time-expanded) { grid-template-rows: 30px 0; }
  .workbench .w-time-expand { min-height: 25px; font-size: 9px; }
  .workbench .s-view { padding: 40px 8px 46px; }
  .workbench .s-viewbar { min-height: 32px; flex-wrap: nowrap; gap: 4px; }
  .workbench .s-viewbar button { min-height: 28px; padding: 3px 5px; font-size: 10px; }
  .workbench .s-viewbar .s-comparison { flex: 0 1 auto; min-width: 0; margin: 0 0 0 auto; gap: 4px; }
  .workbench .s-viewbar .s-comparison #compare-scope { max-width: 105px; font-size: 9px; }
  .workbench .s-viewbar .s-comparison button { min-height: 25px; padding: 2px 5px; font-size: 9px; }
  .workbench .s-panel { grid-template-rows: minmax(0,1fr); }
  .workbench .s-tabpanel[data-tab="effects"] { overflow-y: auto; }
  .workbench #fx-list { display: none; }
  .workbench .w-stack-toggle { display: inline-flex; }
  .workbench.w-effect-stack-open #fx-list { display: grid; }
  .workbench.w-effect-stack-open .w-effect-inspector { display: none; }
  .workbench .w-effect-inspector { padding-top: 0; }
  .workbench .w-selected-effect-head { padding-top: 0; }
}

/* Compact screens use one lower editing workspace at a time. The artwork,
   comparison scope, and transport stay in a dedicated stage; resource panels
   and Animation/Frames/Rails share the lower inspector area. */
@media (max-width: 899px) {
  .workbench .s-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(150px, 52dvh) minmax(0, 1fr);
    overflow: hidden;
  }
  .workbench .w-center { display: contents; }
  .workbench .s-view {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-rows: 40px 44px minmax(0, 1fr) 44px;
    gap: 4px;
    align-items: center;
    justify-items: center;
    height: auto;
    min-height: 0;
    padding: 6px;
    overflow: hidden;
  }
  .workbench .s-viewbar {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    grid-template-rows: 40px 44px;
    align-items: center;
    gap: 2px 5px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    padding: 0;
    overflow: hidden;
    grid-row: 1 / span 2;
    align-self: start;
  }
  .workbench .s-viewbar button { min-height: 40px; padding: 5px 8px; font-size: 11px; }
  .workbench #w-layer-list-open { display: inline-flex; }
  .workbench .s-viewbar .s-comp {
    position: static;
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
    max-width: none;
    margin: 0;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }
  .workbench .s-comparison {
    position: static;
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
    height: 44px;
    margin: 0;
    padding: 0;
    background: transparent;
  }
  .workbench .s-comparison #compare-scope,
  .workbench .s-comparison #compare-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .workbench .s-comparison [role="group"] { display: flex; gap: 5px; }
  .workbench .s-comparison button { min-width: 68px; min-height: 44px; padding: 6px 9px; font-size: 11px; }
  .workbench .s-view > #view { grid-column: 1; grid-row: 3; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
  .workbench .s-preview-playback {
    position: relative;
    grid-column: 1;
    grid-row: 4;
    inset: auto;
    width: 100%;
    height: 44px;
    min-width: 0;
    margin: 0;
    grid-template-columns: 44px 68px minmax(40px, 1fr);
    padding: 0 5px;
  }
  .workbench .s-preview-playback #play { min-width: 44px; min-height: 44px; }
  .workbench .s-preview-playback .s-scrub { min-width: 0; min-height: 44px; }
  .workbench .s-preview-playback .s-time { min-width: 0; font-size: 11px; }
  .workbench .s-view > #track-overlay { pointer-events: none; }
  .workbench .s-view > .s-drop { inset: 104px 8px 58px; }

  .workbench .s-panel {
    grid-column: 1;
    grid-row: 2;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    overflow: hidden;
    border: 0;
  }
  .workbench .s-context {
    display: grid;
    grid-row: 1;
    min-height: 46px;
    padding: 4px 10px;
    gap: 1px;
  }
  .workbench #context-kicker { font-size: 8px; }
  .workbench #context-name { min-width: 0; font-size: 12px; line-height: 1.25; overflow-wrap: anywhere; }
  .workbench #context-detail { font-size: 10px; line-height: 1.2; }
  .workbench .s-panel > .s-tabpanel,
  .workbench .s-panel > .w-time-panel { grid-row: 2; min-height: 0; }
  .workbench .s-tabpanel { padding: 8px 10px; overflow: auto; overscroll-behavior: contain; }
  .workbench .s-panel > .w-resource-nav { grid-row: 3; display: flex; align-items: stretch; gap: 0; min-height: 50px; padding: 2px 3px max(2px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
  .workbench .w-resource-nav [data-tab],
  .workbench .w-resource-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 4px 2px;
    border: 0;
    border-top: 2px solid transparent;
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
  }
  .workbench .w-resource-nav .w-phone-time-button { display: inline-flex; }
  .workbench .w-resource-nav [aria-selected="true"] { border-top-color: var(--studio-workbench-accent); border-left-color: transparent; background: var(--surface-2); }
  .workbench .w-time-panel { display: none; grid-template-rows: 44px minmax(0, 1fr); border: 0; overflow: hidden; }
  .workbench.w-phone-time-mode .s-panel > .s-tabpanel { display: none !important; }
  .workbench.w-phone-time-mode .s-panel > .w-time-panel { display: grid; }
  .workbench.w-phone-time-mode .s-panel > .s-context { display: none; }
  .workbench .w-time-tabs { position: relative; display: flex; align-items: stretch; gap: 0; min-height: 44px; height: 44px; padding: 0; border-bottom: 1px solid var(--line); }
  .workbench .w-time-view-tabs { display: flex; align-items: stretch; flex: 1 1 auto; min-width: 0; }
  .workbench .w-phone-resource-return { display: none; }
  .workbench .w-time-tab { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 6px 5px; font-size: 11px; }
  .workbench .w-time-expand { display: none; }
  .workbench .w-time-view { min-width: 0; min-height: 0; padding: 8px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .workbench .w-time-view::-webkit-scrollbar { width: 4px; }
  .workbench .w-frame-content,
  .workbench .w-rail-content,
  .workbench .w-composition-lane-wrap { min-width: 0; min-height: 0; overflow: visible; }
  .workbench .w-frame-content #frames-props { max-height: none; margin: 0; padding: 0; }
  /* Sequence thumbnails are already the source-frame preview surface on a
     phone. Keep Previous/Next and the large-preview action, but reclaim the
     duplicate canvas slot so more ordered frame cards remain in view. */
  .workbench .w-frame-content #frames-props[data-frame-mode="sequence"] .s-source-frame { display: none; }
  .workbench .w-frame-content .s-source-frame { max-height: min(22dvh, 150px); }
  .workbench .w-frame-content #source-frame-view { max-width: 100%; max-height: min(22dvh, 150px); }
  .workbench .w-frame-content #frames-list { display: grid; grid-template-columns: minmax(0, 1fr); max-height: none; overflow: visible; }
  .workbench .w-frame-content #frames-list > li { min-width: 0; grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-rows: 56px 44px; align-items: center; gap: 4px 6px; padding: 5px; }
  .workbench .w-frame-content #frames-list .s-frame-open { grid-column: 1; grid-row: 1; display: grid; place-items: center; width: 56px; height: 56px; }
  .workbench .w-frame-content #frames-list .s-frame-open canvas { display: block; width: 56px; height: 56px; }
  .workbench .w-frame-content #frames-list .s-frame-info { grid-column: 2; grid-row: 1; min-width: 0; }
  .workbench .w-frame-content #frames-list .s-frame-delay { grid-column: 3; grid-row: 1; justify-self: end; }
  .workbench .w-frame-content #frames-list .acts { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; overflow: visible; }
  .workbench .w-frame-content #frames-list .acts button { flex: 0 0 44px; min-width: 44px; min-height: 44px; padding: 5px 6px; }
  .workbench .w-frame-content #frames-list input,
  .workbench .w-frame-content #video-frame-time,
  .workbench .w-frame-content #frames-all { min-height: 44px; font-size: 16px; }
  .workbench .w-frame-content #frames-large,
  .workbench .w-frame-content #frames-collapse,
  .workbench .w-frame-content #frames-apply,
  .workbench .w-frame-content #frames-reverse,
  .workbench .w-frame-content #frames-pingpong,
  .workbench .w-frame-content #frame-prev,
  .workbench .w-frame-content #frame-next { min-height: 44px; }
  .workbench .w-frame-content .s-frame-nav { flex-wrap: wrap; min-height: 44px; }
  .workbench .w-frame-content .s-video-frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 6px; overflow: visible; }
  .workbench .w-frame-content .s-video-frames button { min-height: 72px; }
  .workbench.output-mode .s-panel > .w-time-panel { display: none; }
  .workbench.output-mode .s-panel > #tab-output { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
  .workbench .s-output-scroll { flex: 1 1 auto; min-height: 0; padding: 8px 10px; overflow: auto; }
  .workbench .s-output-footer { position: static; padding: 8px 10px max(8px, env(safe-area-inset-bottom)); }
  .workbench .s-media-import-alert { gap: 6px; padding: 8px; }
  .workbench .s-media-import-copy p { max-height: min(20dvh, 140px); font-size: 12px; }
  .workbench #media-import-error-dismiss { min-height: 44px; }

  /* The control mode gives numeric fields room while keeping a real preview
     and the same transport visible; the ordinary stage remains larger. */
  .workbench.w-focus-mode .s-main { grid-template-rows: minmax(145px, 26dvh) minmax(0, 1fr); }
  .workbench.text-entry-held .s-main { grid-template-rows: minmax(140px, 24dvh) minmax(0, 1fr); }
  .workbench.output-mode .s-main { grid-template-rows: minmax(150px, 38dvh) minmax(0, 1fr); }
  /* The older timeline-expansion rules have greater selector weight. On the
     compact composition, expanded means the Time workspace is open inside the
     inspector; it must not reinstate the former three-row stack. */
  .workbench.w-time-expanded .s-main,
  .workbench.w-phone-time-mode .s-main { grid-template-rows: minmax(150px, 52dvh) minmax(0, 1fr); }
}

@media (max-width: 760px) and (max-height: 700px) {
  /* On a short phone, give an import failure enough panel height to remain
     readable above the persistent resource tabs. This is temporary while the
     warning is present; dismissing or resolving it restores the full preview. */
  .workbench.media-import-alert-active .s-main { grid-template-rows: minmax(160px, 28dvh) minmax(0, 1fr); }
}

/* fitView writes the intended on-screen size independently of the adaptive
   backing-store resolution. Keep that size and let the grid track clamp it
   proportionally; resetting width/height to auto shrinks low-resolution
   previews to their backing bitmap (notably on 320px phones). */
@media (max-width: 899px) {
  .workbench .s-view > #view {
    max-width: 100%;
    max-height: 100%;
  }
}

@media (max-width: 599px) {
  .workbench.w-phone-time-mode .s-panel > .w-resource-nav { display: none; }
  .workbench.w-phone-time-mode .s-main { grid-template-rows: minmax(190px, 58dvh) minmax(0,1fr); }
  .workbench.w-phone-time-mode.w-focus-mode .s-main { grid-template-rows: minmax(170px, 40dvh) minmax(0,1fr); }
  .workbench.w-phone-time-mode .w-phone-resource-return { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 56px; min-width: 56px; min-height: 44px; padding: 5px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--text); font: 600 11px var(--ui); cursor: pointer; }
  .workbench.w-phone-time-mode .w-time-view-tabs .w-time-tab { flex: 1 1 0; }
  .workbench .w-structure { display: none; position: absolute; inset: 0; z-index: 25; width: min(90vw, 360px); padding: 12px; border: 1px solid var(--line); box-shadow: 0 14px 36px #000b; }
  .workbench.structure-open .w-structure { display: flex; }
  .workbench .w-rail-close { display: block; align-self: flex-start; min-height: 44px; }
  body.workbench { --w-time-label-width: 76px; --w-time-label-gap: 5px; }
  .workbench .w-time-view { padding: 8px; }
  .workbench #w-time-frame-panel { grid-template-columns: minmax(0,1fr); width: 100%; max-width: 100%; }
  .workbench .w-frame-content,
  .workbench .w-frame-content #frames-props,
  .workbench .w-frame-content #sequence-controls { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
  .workbench .w-time-tabs { padding-right: 0; }
  .workbench .w-time-panel:not(.w-time-expanded) { grid-template-rows: 44px minmax(0,1fr); }
  .workbench .s-drop { inset: 104px 8px 58px; }

  /* One compact phone toolbar keeps layer access, preview focus and the real
     Before/After comparison together. This replaces the former stacked title
     and comparison rows while leaving their project state and controls intact. */
  .workbench .s-view { grid-template-rows: 44px minmax(0,1fr) 44px; gap: 4px; }
  .workbench .s-viewbar {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 54px auto minmax(0,1fr);
    grid-template-rows: 44px;
    align-items: center;
    gap: 4px;
    width: 100%;
    height: 44px;
    overflow: hidden;
  }
  .workbench .s-viewbar #w-layer-list-open { grid-column: 1; grid-row: 1; width: 54px; min-width: 54px; min-height: 44px; padding: 4px; }
  .workbench .s-viewbar #w-focus { grid-column: 2; grid-row: 1; justify-self: center; width: max-content; min-width: 118px; min-height: 44px; padding: 4px 6px; white-space: nowrap; font-size: 10px; }
  .workbench .s-viewbar #preview-toggle { display: none; }
  .workbench .s-viewbar .s-comp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .workbench .s-viewbar .s-comparison {
    position: static;
    inset: auto;
    grid-column: 3;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    width: auto;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    background: transparent;
  }
  .workbench .s-viewbar .s-comparison [role="group"] { display: flex; gap: 3px; }
  .workbench .s-viewbar .s-comparison button { min-width: 44px; width: 48px; min-height: 44px; padding: 4px 3px; font-size: 10px; }
  .workbench .s-viewbar .s-comparison #compare-scope,
  .workbench .s-viewbar .s-comparison #compare-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .workbench .s-view > #view { grid-column: 1; grid-row: 2; }
  .workbench .s-view > .s-preview-playback { grid-column: 1; grid-row: 3; }

  /* Sequence tools collapse to one horizontal, touch-scrollable filmstrip and
     one selected-frame editor. The full desktop rows remain unchanged. */
  .workbench .w-frame-content .s-sequence-settings { margin: 0 0 6px; }
  .workbench .w-frame-content .s-sequence-settings > summary { display: flex; align-items: center; min-height: 44px; padding: 4px 8px; border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 12px; }
  .workbench .w-frame-content .s-sequence-settings[open] > .s-sequence-settings-body { display: grid; gap: 6px; padding: 6px 0; }
  .workbench .w-frame-content #frames-list { display: flex; flex: 0 0 100%; flex-flow: row nowrap; align-items: stretch; gap: 7px; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 2px 1px 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .workbench .w-frame-content #frames-list > li { flex: 0 0 92px; width: 92px; min-width: 92px; grid-template-columns: minmax(0,1fr); grid-template-rows: 48px 20px 44px; justify-items: center; gap: 1px; padding: 3px; scroll-snap-align: start; }
  .workbench .w-frame-content #frames-list .s-frame-open { grid-column: 1; grid-row: 1; width: 48px; height: 48px; }
  .workbench .w-frame-content #frames-list .s-frame-open canvas { width: 48px; height: 48px; }
  .workbench .w-frame-content #frames-list .s-frame-info { grid-column: 1; grid-row: 2; display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; min-width: 0; overflow: hidden; white-space: nowrap; }
  .workbench .w-frame-content #frames-list .s-frame-info .n { max-width: 56px; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
  .workbench .w-frame-content #frames-list .s-frame-position { display: none; }
  .workbench .w-frame-content #frames-list .s-frame-delay,
  .workbench .w-frame-content #frames-list .acts [data-frame-act] { display: none !important; }
  .workbench .w-frame-content #frames-list .acts { grid-column: 1; grid-row: 3; display: flex; align-items: center; justify-content: center; width: 100%; }
  .workbench .w-frame-content #frames-list .acts [data-frame-select] { flex: 0 0 84px; min-width: 84px; min-height: 44px; padding: 4px; }
  .workbench .w-frame-content #frames-list > li.is-current { outline: 1px solid var(--studio-workbench-accent); outline-offset: -1px; background: var(--surface-2); }
  .workbench .w-frame-content #frames-props[data-frame-mode="sequence"] .s-frame-nav,
  .workbench .w-frame-content #frames-props[data-frame-mode="sequence"] .s-source-frame,
  .workbench .w-frame-content #frames-props[data-frame-mode="sequence"] #frames-large { display: none; }
  .workbench .w-frame-content #frames-props[data-frame-mode="sequence"] #frame-inspection-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .workbench .w-frame-content .s-frame-selected-tools { display: grid; gap: 4px; width: 100%; min-width: 0; box-sizing: border-box; margin: 4px 0 8px; padding: 6px; border-top: 1px solid var(--line); background: var(--surface); }
  .workbench .w-frame-content .s-frame-selected-tools[hidden] { display: none; }
  .workbench .w-frame-content .s-frame-selected-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
  .workbench .w-frame-content .s-frame-selected-name { display: grid; flex: 1 1 auto; align-content: center; min-width: 0; gap: 2px; margin-right: auto; }
  .workbench .w-frame-content .s-frame-selected-name .label { min-width: 0; max-width: 150px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
  .workbench .w-frame-content .s-frame-selected-caption { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
  .workbench .w-frame-content .s-frame-selected-name strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
  .workbench .w-frame-content .s-frame-selected-name .mono { color: var(--muted); font-size: 10px; }
  .workbench .w-frame-content .s-frame-selected-head .s-frame-delay { display: grid; gap: 2px; justify-items: end; font-size: 10px; }
  .workbench .w-frame-content .s-frame-selected-head .s-frame-delay input { width: 76px; min-height: 44px; font-size: 16px; }
  .workbench .w-frame-content .s-frame-selected-actions { display: grid; grid-template-columns: repeat(6,minmax(44px,1fr)); gap: 4px; }
  .workbench .w-frame-content .s-frame-selected-actions button { min-width: 44px; min-height: 44px; }
  .workbench .w-frame-content .s-frame-selected-actions button[data-frame-act],
  .workbench .w-frame-content .s-frame-selected-actions .s-frame-step { padding: 3px; font-size: 9px; white-space: nowrap; }
  .workbench .w-frame-content .s-frame-selected-actions button[disabled] { opacity: .45; }
  .workbench .w-rail-layers .s-layer .acts button { min-height: 44px; }
}

@media (max-width: 360px) {
  .workbench .s-viewbar { grid-template-columns: auto auto minmax(0, 1fr); gap: 2px; }
  .workbench .s-viewbar button { padding-inline: 5px; font-size: 10px; }
  .workbench .s-comparison button { min-width: 64px; padding-inline: 7px; }
  .workbench .w-resource-nav [data-tab],
  .workbench .w-resource-button { padding-inline: 1px; font-size: 10px; }
  body.workbench { --w-time-label-width: 68px; }
}

@media (min-width: 600px) and (max-width: 899px) and (max-height: 600px) {
  .workbench .s-main { grid-template-columns: var(--w-rail-width) minmax(0, 1fr) var(--w-inspector-width); grid-template-rows: minmax(0, 1fr); }
  .workbench.w-time-expanded .s-main,
  .workbench.w-phone-time-mode .s-main,
  .workbench.output-mode .s-main { grid-template-columns: var(--w-rail-width) minmax(0, 1fr) var(--w-inspector-width); grid-template-rows: minmax(0, 1fr); }
  .workbench .w-structure { display: flex; position: relative; inset: auto; width: auto; padding: 8px 7px; border: 0; border-right: 1px solid var(--line); box-shadow: none; }
  .workbench .w-rail-close { display: none; }
  .workbench .w-rail-title { display: grid; gap: 2px; }
  .workbench .w-rail-title h2 { font-size: 12px; }
  .workbench .w-rail-title span { font-size: 9px; }
  .workbench .w-rail-layers { flex: 0 0 142px; max-height: 142px; overflow: auto; }
  .workbench .w-rail-import { grid-template-columns: 1fr; }
  .workbench .w-resource-nav { display: grid; gap: 1px; }
  .workbench .w-resource-nav [data-tab],
  .workbench .w-resource-button { display: inline-flex; min-height: 40px; padding: 4px 6px; font-size: 11px; }
  .workbench .w-center { display: grid; grid-template-rows: minmax(0, 1fr) 0; }
  .workbench.w-time-expanded .w-center,
  .workbench.output-mode .w-center { grid-template-rows: minmax(0, 1fr) 0; }
  .workbench .s-view {
    grid-row: 1;
    grid-column: 1;
    align-self: stretch;
    height: 100%;
    min-height: 0;
    max-height: 100%;
  }
  .workbench .s-panel { grid-column: 3; grid-row: 1; grid-template-rows: auto minmax(0, 1fr); }
  .workbench .s-panel > .w-resource-nav { display: none; }
  .workbench .s-panel > .s-tabpanel,
  .workbench .s-panel > .w-time-panel { grid-row: 2; }
  .workbench.w-phone-time-mode .s-panel > .s-tabpanel { display: none !important; }
  .workbench.w-phone-time-mode .s-panel > .w-time-panel { display: grid; grid-template-rows: 44px minmax(0, 1fr); }
  .workbench .w-time-tabs { height: 44px; min-height: 44px; }
  .workbench .w-time-tab { min-height: 44px; font-size: 11px; }
  .workbench .s-viewbar button { min-height: 40px; }
  .workbench .s-viewbar .s-comparison { grid-column: 1 / -1; }
  .workbench .s-comparison button { min-height: 44px; }
  .workbench .s-preview-playback { height: 44px; }
  .workbench .w-time-view { overflow: auto; }
  .workbench .w-frame-content,
  .workbench .w-rail-content,
  .workbench .w-composition-lane-wrap { overflow: visible; }
}

/* Empty guidance occupies the same mobile grid cell as the canvas. It never
   contributes a second height or overlaps the persistent transport. */
@media (max-width: 899px) {
  .workbench[data-workspace="empty"] .s-view {
    position: relative;
    height: 100%;
    min-height: 0;
  }
  .workbench .s-view > .s-drop {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 3;
    align-self: stretch;
    justify-self: stretch;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: none;
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    gap: 7px;
  }
  .workbench .s-drop-main {
    max-width: 34ch;
    margin-inline: auto;
    font-size: 20px;
    line-height: 1.2;
  }
  .workbench .s-drop-sub {
    max-width: 54ch;
    margin: 0 auto;
    font-size: 13px;
    line-height: 1.35;
  }
  .workbench .s-drop-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 420px);
    gap: 6px;
    justify-self: center;
  }
  .workbench .s-drop-actions > :is(.s-btn, .primary) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 7px;
    font-size: 12px;
    white-space: normal;
  }
}

/* The rail's recovery card is out of sight in the closed drawer on compact
   layouts; its mirror sits first in the empty canvas. Wide layouts show the card. */
.workbench .w-recover-notice { display: none; }
@media (max-width: 899px) {
  /* Centred content that overflows a short drop zone is clipped above its scroll origin. */
  .workbench .s-view > .s-drop:has(> .w-recover-notice:not([hidden])) { align-content: start; }
  .workbench .w-recover-notice:not([hidden]) {
    display: grid;
    gap: 6px;
    width: min(100%, 420px);
    justify-self: center;
    margin-bottom: 6px;
    padding: 10px;
    border: 1px solid var(--studio-workbench-accent);
    border-radius: 6px;
    text-align: left;
  }
  .workbench .w-recover-notice p { margin: 0; }
  .workbench .w-recover-notice-title { font-size: 15px; font-weight: 600; }
  .workbench .w-recover-notice-text { font-size: 13px; line-height: 1.35; }
  .workbench .w-recover-notice-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .workbench .w-recover-notice-actions > .s-btn { min-height: 44px; }
  .workbench .w-recover-notice-actions > [hidden] { display: none; }
}

/* Keep the Composition drawer close action discoverable while its recovery
   and layer content scrolls on a short phone. */
@media (max-width: 599px) {
  .workbench .w-structure {
    z-index: 25;
    overscroll-behavior: contain;
  }
  .workbench .w-rail-title {
    position: sticky;
    top: 0;
    z-index: 2;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    margin: -12px -12px 0;
    padding: 4px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  .workbench .w-rail-title h2 { flex: 0 0 auto; }
  .workbench .w-rail-title #w-comp-summary { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .workbench .w-rail-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    min-height: 44px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface-2);
    color: var(--text);
    white-space: nowrap;
  }
  .workbench .w-rail-close:hover { border-color: var(--studio-workbench-accent); background: var(--surface-hover); }
  .workbench .w-rail-close:focus-visible { outline: 2px solid var(--studio-workbench-accent); outline-offset: 2px; }
  .workbench .w-close-glyph { font-size: 18px; line-height: 1; }
  .workbench .w-rail-layers {
    flex: 0 0 auto;
    min-height: 0;
    max-height: min(38vh, 350px);
    box-sizing: border-box;
  }
}

@media (max-width: 599px) {
  /* The phone grid has one toolbar row, the canvas row, and one transport row. */
  .workbench .s-view > .s-drop { grid-row: 2; }
  /* The Open action already says what it does. Keep its full explanation in
     the accessible description without spending a second visual line in the
     short canvas stage. */
  .workbench .s-drop-note {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }
}

/* Keep navigation reachable when a finished result is taller than the inspector.
   One scroll owner lets settings and results share the available height. */
.workbench.output-mode .s-panel > #tab-output { display: block; overflow: auto; scroll-padding-top: 72px; }
.workbench #tab-output .s-output-scroll { overflow: visible; }
.workbench #tab-output .s-output-footer { position: static; }
.workbench .s-output-nav { position: sticky; top: 0; z-index: 26; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
.workbench .s-output-nav .s-btn { flex: 1 1 auto; min-height: 44px; }
.workbench.exporting .s-output-nav #return-edit { display: block; }
