.workbench {
  --wb-cols: 256px minmax(0, 1.6fr) minmax(0, 300px);
  --wb-cols-lg: 244px minmax(0, 1.4fr) minmax(0, 280px);
  --wb-cols-md: minmax(0, 1fr) minmax(0, 1fr);
}

/* Character, clip, poses, bake. */
#loadSample { margin-top: var(--sp-3); }
.clip-files .file-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.clip-files .file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.clip-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field + .clip-grid, .clip-files + .field { margin-top: var(--sp-3); }
.pose-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pose-grid + .note { margin-top: var(--sp-2); }
.control-group > .seg + .pose-grid { margin-top: var(--sp-3); }
#charHealth:not(:empty) { margin-top: var(--sp-3); }
#bake { margin-top: var(--sp-3); }
#bake + .btn-grid { margin-top: var(--sp-2); }

/* The viewport: the preview, the handles drawn over it. */
.viewport-pane .pane-head { flex-wrap: wrap; gap: 8px; }
.viewport-pane .pane-head .seg { margin-top: 0; }
.viewport-pane .pane-head .tool-seg span { min-height: calc(var(--control-h-sm) - 8px); }
#overlay { pointer-events: none; }
.preview-stage { --stage-ratio: 16 / 11; }
.preview-stage.is-dragging > #previewCanvas { cursor: grabbing; }
.preview-stage.is-hover > #previewCanvas { cursor: pointer; }

/* The transport under the preview, and the timeline under that. */
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.transport-time { flex: 1; min-width: 110px; color: var(--muted); font-family: var(--font-mono); font-size: var(--fs-xs); white-space: nowrap; }
#playPause[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.timeline-block { padding: 0 12px 12px; background: var(--panel-2); }
.timeline-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; }
.timeline-head .view-tabs { flex: 1 1 200px; padding: 0; border: 0; }
.timeline-head select { flex: none; min-height: var(--control-h-xs); font-size: var(--fs-xs); }
#timeline { display: block; width: 100%; height: 176px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--well); touch-action: none; cursor: default; }
#timeline:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#timeline.is-scrub { cursor: ew-resize; }
#timeline.is-key { cursor: grab; }

/* The inspector: four sections, the tabs pick one. */
.inspector:has(input[name="inspector"][value="control"]:checked) [data-inspector="control"],
.inspector:has(input[name="inspector"][value="diagnostics"]:checked) [data-inspector="diagnostics"],
.inspector:has(input[name="inspector"][value="script"]:checked) [data-inspector="script"],
.inspector:has(input[name="inspector"][value="history"]:checked) [data-inspector="history"] { display: block; }
@supports not selector(:has(*)) {
  [data-inspector="control"] { display: block; }
}
#diagCount:not(:empty) { margin-left: 4px; color: var(--warn); font-weight: 600; }
#diagCount.is-error { color: var(--error); }

/* The body picker: a figure of buttons, mirrored as seen from the front. */
.picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-areas:
    ".     look  look  eyes  ."
    ".     jaw   head  .     ."
    "shR   shR   neck  shL   shL"
    "armR  .     chest .     armL"
    "handR .     spine .     handL"
    ".     hips  hips  cog   ."
    ".     legR  .     legL  ."
    ".     footR .     footL ."
    ".     root  root  root  .";
  gap: 3px;
}
.picker button {
  min-height: var(--control-h-xs);
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--well);
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-2xs);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker button:hover { border-color: var(--line-bright); color: var(--ink); }
.picker button.is-keyed { color: var(--ink); border-color: var(--line-strong); }
.picker button.is-keyed::after { content: " ◆"; color: var(--dim); }
.picker button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.picker button:disabled { opacity: .3; cursor: default; }
.p-look { grid-area: look; } .p-eyes { grid-area: eyes; } .p-head { grid-area: head; } .p-jaw { grid-area: jaw; }
.p-neck { grid-area: neck; } .p-shR { grid-area: shR; } .p-shL { grid-area: shL; } .p-armR { grid-area: armR; }
.p-chest { grid-area: chest; } .p-armL { grid-area: armL; } .p-handR { grid-area: handR; } .p-spine { grid-area: spine; }
.p-handL { grid-area: handL; } .p-hips { grid-area: hips; } .p-cog { grid-area: cog; } .p-legR { grid-area: legR; }
.p-legL { grid-area: legL; } .p-footR { grid-area: footR; } .p-footL { grid-area: footL; } .p-root { grid-area: root; }
.picker-tools { display: flex; gap: 6px; margin-top: 6px; }

.limb-switch { margin-bottom: var(--sp-3); }
.limb-switch .btn-grid { margin-top: var(--sp-2); }

/* A channel: its key mark, its name, its editor. */
.channels { display: grid; gap: 4px; }
.chan-row { display: grid; grid-template-columns: 18px minmax(64px, 0.8fr) minmax(0, 2fr); gap: 6px; align-items: center; }
.chan-name { overflow: hidden; color: var(--muted); font-family: var(--font-mono); font-size: var(--fs-xs); text-overflow: ellipsis; white-space: nowrap; }
.chan-row.is-keyed .chan-name { color: var(--ink); }
.chan-edit { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.chan-edit input, .chan-edit select { width: 100%; min-width: 0; min-height: var(--control-h-xs); padding: 0 5px; font-family: var(--font-mono); font-size: var(--fs-xs); }
.chan-edit input.is-error { border-color: var(--error); }
.key-mark { width: 18px; height: 18px; padding: 0; border: 0; background: none; color: var(--dim); font-size: 12px; line-height: 1; cursor: pointer; }
.key-mark::before { content: "◇"; }
.chan-row.is-animated .key-mark { color: var(--warn); }
.chan-row.is-animated .key-mark::before { content: "◇"; }
.chan-row.is-key .key-mark { color: var(--accent); }
.chan-row.is-key .key-mark::before { content: "◆"; }
.chan-group { margin: 10px 0 2px; color: var(--dim); font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: var(--ls-caps); text-transform: uppercase; }

/* Checks and history. */
.diag-list { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: 4px; }
.diag-item { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 8px; align-items: baseline; width: 100%; padding: 5px 6px; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--ink); font: inherit; font-size: var(--fs-sm); line-height: 1.4; text-align: left; cursor: pointer; }
.diag-item:hover { border-color: var(--line); background: var(--panel-2); }
.diag-list li.is-info .health-dot { background: var(--ok); }
.diag-list li.is-warn .health-dot { background: var(--warn); }
.diag-list li.is-error .health-dot { background: var(--error); }
.diag-list li.is-error .diag-text { color: var(--error); }
.diag-text b { font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: 600; }
#script { width: 100%; min-height: 220px; margin: var(--sp-3) 0; padding: 8px; resize: vertical; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--well); color: var(--ink); font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.5; }
.history-list { margin: var(--sp-3) 0 0; padding-left: 22px; color: var(--muted); font-family: var(--font-mono); font-size: var(--fs-2xs); line-height: 1.6; }
.history-list li { overflow-wrap: anywhere; }

@media (max-width: 940px) {
  .toolrail { grid-template-rows: auto 1fr; }
  .toolrail > .rail-section:is(:nth-child(2), :nth-child(3)) { grid-row: span 2; }
  .toolrail > .rail-section:last-child { border-right: 1px solid var(--line); }
}
@media (max-width: 700px) {
  .toolrail { grid-template-rows: none; }
  .toolrail > .rail-section:is(:nth-child(2), :nth-child(3)) { grid-row: auto; }
  .toolrail > .rail-section:last-child { border-right: 0; }
}
