.control-layout-toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:8px 14px; margin:0 0 12px; }
.control-layout-toolbar strong { font-size:13px; }
.control-layout-toolbar .layout-status { flex:1; font-size:12px; color:var(--muted); margin:0; }
.layout-instructions { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.control-panel-layout { position:relative; display:grid; grid-template-columns:repeat(12,minmax(0,1fr)); column-gap:18px; row-gap:0; align-items:start; }
.control-panel-layout.layout-receiving-drop { padding-bottom:100px; }
.layout-insertion-marker { position:absolute; z-index:6; left:0; right:0; height:36px; transform:translateY(-50%); pointer-events:none; display:grid; place-items:center; border:2px dashed var(--teal); border-radius:8px; background:var(--mint); color:var(--teal-dark); font-size:12px; font-weight:650; }
.layout-insertion-marker[hidden] { display:none; }
.layout-empty-drop-zones { position:absolute; inset:0; z-index:6; pointer-events:none; }
.layout-empty-drop-zone { position:absolute; display:grid; place-items:center; padding:18px; border:2px dashed var(--teal); border-radius:var(--radius); background:#e6f3eead; color:var(--teal-dark); text-align:center; font-size:14px; font-weight:650; box-sizing:border-box; }
.layout-empty-drop-zone>span { max-width:28em; padding:10px 14px; border-radius:8px; background:#ffffffdf; overflow-wrap:anywhere; }
.layout-empty-drop-zone.active { border:3px solid var(--teal); background:#cce7de; box-shadow:inset 0 0 0 3px #ffffffa8; }
.layout-empty-drop-zone.active>span { color:white; background:var(--teal); }
.layout-empty-drop-zone.compact { padding:6px; font-size:12px; }
.layout-empty-drop-zone.compact>span { padding:6px 4px; }
.layout-empty-drop-zone[data-zone="stack"] { min-height:42px; padding:10px; }
.layout-target-hints { display:none; position:absolute; inset:4px; z-index:6; pointer-events:none; }
.layout-dragging .layout-item:not(.layout-drag-source)>.layout-target-hints { display:block; }
.layout-target-hints>span { position:absolute; display:grid; place-items:center; padding:4px; border:2px dashed #63978b; border-radius:8px; color:var(--teal-dark); background:#f3faf6e8; font-size:12px; font-weight:650; box-sizing:border-box; }
.layout-target-hints>[data-zone="top"] { inset:0 25% auto; height:40px; }
.layout-target-hints>[data-zone="bottom"] { inset:auto 25% 0; height:40px; }
.layout-target-hints>[data-zone="left"] { inset:44px 75% 44px 0; }
.layout-target-hints>[data-zone="right"] { inset:44px 0 44px 75%; }
.layout-item { grid-column:span var(--panel-span,12); min-width:0; min-height:220px; position:relative; display:flex; flex-direction:column; border:1px solid var(--line); border-radius:var(--radius); background:var(--paper); box-shadow:0 3px 14px #244b3505; scroll-margin-top:160px; }
.layout-item[data-layout-id="joints"] { background:transparent; border:0; border-radius:0; box-shadow:none; }
.layout-item[data-layout-id="joints"]:not([data-fixed-height="true"])>.layout-item-body { overflow:visible; border-radius:0; }
.joint-layout-actions { display:inline-flex; align-items:center; flex:none; gap:4px; }
.joint-layout-actions .layout-move-handle { min-width:28px; padding-inline:4px; color:#627b6f; }
.joint-layout-actions .layout-fit-height { white-space:nowrap; }
.layout-item[data-layout-id="favorites"]:has(.sequence-library:not([open])) { min-height:0; height:auto!important; }
.layout-item[data-library-collapsed="true"]>.layout-resize-height,
.layout-item[data-library-collapsed="true"]>.layout-resize-both { display:none; }
.layout-item-tools { flex:none; min-height:32px; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:3px 12px; border-bottom:1px solid #e7ece8; border-radius:var(--radius) var(--radius) 0 0; background:var(--canvas); }
.layout-item-tools-clickable { cursor:pointer; }
.layout-item-tools-clickable:hover { background:var(--mint); }
.layout-move-handle,.layout-fit-height { min-height:32px; border:0; border-radius:4px; background:transparent; color:var(--muted); font-size:12px; padding:4px 6px; }
.layout-move-handle { touch-action:none; cursor:grab; }
.layout-move-handle:hover,.layout-fit-height:hover { background:var(--mint); color:var(--teal-dark); }
.layout-move-handle:focus-visible,.layout-fit-height:focus-visible,.layout-resize-handle:focus-visible { outline:2px solid var(--teal); outline-offset:2px; }
.layout-item-body { flex:1; min-width:0; min-height:0; overflow:auto; border-radius:0 0 var(--radius) var(--radius); }
.layout-item-body>.panel { border:0; border-radius:0; box-shadow:none; margin:0; overflow:visible; }
.layout-resize-handle { position:absolute; z-index:5; border:0; padding:0; background:transparent; touch-action:none; color:#74968a; }
.layout-resize-width { top:42px; bottom:30px; right:-8px; width:16px; cursor:ew-resize; }
.layout-resize-height { left:14px; right:30px; bottom:-8px; height:16px; cursor:ns-resize; }
.layout-resize-both { bottom:1px; right:1px; width:32px; height:32px; border-radius:0 0 var(--radius) 0; cursor:nwse-resize; background:transparent; }
.layout-resize-both::before { content:''; position:absolute; right:5px; bottom:5px; width:10px; height:10px; background:repeating-linear-gradient(135deg,transparent 0 3px,currentColor 3px 4px); clip-path:polygon(100% 0,100% 100%,0 100%); opacity:.7; }
.layout-resize-both:hover { background:#14776e12; color:var(--teal); }
.layout-resize-both:hover::before,.layout-resize-both:focus-visible::before { opacity:1; }
.layout-resize-width:hover,.layout-resize-height:hover { background:#14776e28; }
.layout-dragging,.layout-resizing { user-select:none; }
.layout-dragging .layout-move-handle { cursor:grabbing; }
.layout-drag-source { opacity:.5; }
.layout-drag-ghost { position:fixed; z-index:100; pointer-events:none; padding:10px 16px; border-radius:8px; color:white; background:var(--teal); box-shadow:0 6px 24px #152d3933; font-size:13px; }
.layout-item[data-drop-zone]::after { content:attr(data-drop-label); display:grid; place-items:center; padding:12px; text-align:center; font-size:13px; font-weight:650; color:var(--teal-dark); position:absolute; z-index:7; pointer-events:none; border:3px solid var(--teal); border-radius:8px; background:#d3eadeeb; }
.layout-item[data-drop-zone="left"]::after { inset:4px 50% 4px 4px; }
.layout-item[data-drop-zone="right"]::after { inset:4px 4px 4px 50%; }
.layout-item[data-drop-zone="top"]::after { inset:4px 4px 78% 4px; }
.layout-item[data-drop-zone="bottom"]::after { inset:78% 4px 4px 4px; }
.layout-item[data-drop-zone="stack"]::after { inset:78% 4px 4px 4px; }
/* Contents respond to their panel width, including when the screen stays wide. */
.layout-item .servo-grid,.layout-item .servo-grid[data-filter="arms"] { grid-template-columns:repeat(auto-fit,minmax(min(230px,100%),1fr)); padding:14px 18px 20px; }
.layout-item .joint-toolbar,.layout-item .robot3d-toolbar { flex-wrap:wrap; }
.layout-item .joint-control-options { margin-left:auto; }
.layout-item .position-catalog .position-picker-group,.layout-item .position-catalog .position-picker-group-items:not(.sequence-user-groups) { grid-template-columns:repeat(auto-fill,minmax(min(116px,100%),1fr)); }
.layout-item .dance-choices { grid-template-columns:repeat(auto-fit,minmax(min(240px,100%),1fr)); }
.layout-item[data-fixed-height="true"]>.layout-item-body>.sequence-panel { display:flex; flex-direction:column; min-height:100%; height:100%; }
.layout-item[data-fixed-height="true"]>.layout-item-body>.sequence-panel>.table-scroller { flex:1 0 150px; min-height:150px; max-height:none; }
/* The library's two scroll areas share the manually resized panel's free height. */
.layout-item[data-layout-id="favorites"][data-fixed-height="true"]>.layout-item-body>.quick-poses-panel { display:flex; flex-direction:column; height:100%; min-height:100%; box-sizing:border-box; }
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .gallery-persistence { flex:none; }
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .position-catalog,
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .position-picker-popup,
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .position-picker-list,
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .sequence-library[open] { display:flex; flex-direction:column; flex:1; min-height:0; }
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .position-picker-popup { overflow:visible; }
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .sequence-library[open]::details-content { display:contents; }
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .sequence-library-heading,
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .sequence-favorites { flex:none; }
.layout-item[data-layout-id="favorites"][data-fixed-height="true"] .sequence-library-browser { flex:1 0 120px; min-height:120px; height:auto; }
.layout-item .sequence-panel>.panel-heading,.layout-item .sequence-title-row,.layout-item .heading-actions,.layout-item .playback-footer,.layout-item .playback-buttons { flex-wrap:wrap; }
.layout-item .sequence-panel>.panel-heading,.layout-item .sequence-title-row,.layout-item .sequence-actions,.layout-item .playback-footer { padding-inline:18px; }
.layout-item .table-hint { overflow-wrap:anywhere; }
.layout-item .empty-state { min-height:200px; padding:24px 18px; }
.layout-item .sequence-panel>.table-scroller:has(#emptySequence:not([hidden])) { display:flex; flex-direction:column; }
.layout-item .empty-state { flex:1; }
.layout-item[data-fixed-height="true"] .joint-panel { min-height:100%; height:100%; display:flex; flex-direction:column; }
.layout-item[data-fixed-height="true"] .joint-dual-view { flex:1; min-height:0; align-items:stretch; }
.layout-item[data-fixed-height="true"] #graphicalJointView:not([hidden]):not(.expanded) { display:flex; flex-direction:column; flex:1; }
.layout-item[data-fixed-height="true"] #graphicalJointView:not(.expanded) .robot3d-viewport { flex:1 0 420px; height:auto; }
.layout-item:not([data-panel-width="large"]) .joint-panel>.joint-panel-heading { grid-template-columns:1fr auto; gap:12px; padding:18px; }
.layout-item:not([data-panel-width="large"]) .joint-panel-heading>h2 { grid-column:1; grid-row:1; }
.layout-item:not([data-panel-width="large"]) .joint-panel-heading>.joint-transition-time { grid-column:2; grid-row:1; }
.layout-item:not([data-panel-width="large"]) .joint-panel-heading>.joint-view-tabs { grid-column:1/-1; grid-row:2; }
.layout-item:not([data-panel-width="large"]) .joint-toolbar { padding:0 18px 12px; }
.layout-item:not([data-panel-width="large"]) .position-catalog .position-picker-favorites>.position-catalog-toolbar { position:static; justify-content:flex-end; flex-wrap:wrap; padding-bottom:8px; }
.layout-item:not([data-panel-width="large"]) .position-catalog .position-picker-favorites>.position-picker-disclosure>summary { min-height:38px; line-height:1.5; padding-right:0; }
.layout-item:not([data-panel-width="large"]) .position-visual-picker.position-catalog { margin-inline:8px; }
.layout-item:not([data-panel-width="large"]) .factory-dances { margin-inline:18px; }
.layout-item[data-panel-width="small"] .joint-panel>.joint-panel-heading { grid-template-columns:1fr; }
.layout-item[data-panel-width="small"] .joint-panel-heading>.joint-transition-time { grid-column:1; grid-row:2; justify-self:start; }
.layout-item[data-panel-width="small"] .joint-toolbar,.layout-item[data-panel-width="small"] .joint-control-options { justify-content:flex-start; margin-left:0; }
.layout-item[data-panel-width="small"] .sequence-title-row>span { white-space:normal; }
.layout-item[data-panel-width="small"] .robot3d-joint-control { gap:12px; padding:14px; }
@media(max-width:650px) {
  .control-panel-layout { column-gap:16px; }
  .layout-item:not([data-panel-width="large"]) .position-visual-picker.position-catalog { margin-inline:8px; }
  .layout-item { scroll-margin-top:235px; }
  .control-layout-toolbar .layout-status { flex-basis:100%; order:3; }
}
.servo-card { position:relative; }
.servo-card-top>.servo-title { flex:1; }
.joint-card-move { flex:none; width:28px; min-height:28px; padding:0; border-radius:4px; background:transparent; color:var(--muted); cursor:grab; touch-action:none; font-size:15px; }
.joint-card-move:hover,.joint-card-move:focus-visible { color:white; background:var(--teal); }
.joint-card-dragging-page { user-select:none; }
.joint-card-dragging .joint-card-move { cursor:grabbing; }
.joint-card-drag-source { opacity:.4; }
.joint-card-dragging .servo-card:not(.joint-card-drag-source) { outline:1px dashed #82b4a6; outline-offset:2px; }
.servo-card[data-joint-drop]::after { position:absolute; z-index:8; display:grid; place-items:center; pointer-events:none; padding:6px; border:3px solid var(--teal); border-radius:8px; color:var(--teal-dark); background:#d3eadeeb; font-size:12px; font-weight:650; text-align:center; }
.servo-card[data-joint-drop="before"]::after { content:'Place before'; inset:0 50% 0 0; }
.servo-card[data-joint-drop="after"]::after { content:'Place after'; inset:0 0 0 50%; }

/* Collapsible panels: the title bar names the panel and folds it away. */
.layout-item-actions { display:flex; align-items:center; gap:4px; margin-left:auto; }
.layout-move-handle { font-weight:600; color:var(--ink); }
.layout-collapse { display:grid; place-items:center; width:26px; height:24px; padding:0; border:0; border-radius:4px; background:transparent; color:var(--muted); font-size:14px; line-height:1; cursor:pointer; }
.layout-collapse:hover { background:var(--mint); color:var(--teal-dark); }
.layout-collapse:focus-visible { outline:2px solid var(--teal); outline-offset:2px; }
.layout-item[data-collapsed="true"] { height:auto !important; min-height:0; }
.layout-item[data-collapsed="true"] .layout-item-tools { border-bottom:0; border-radius:var(--radius); }
.layout-item[data-collapsed="true"] .layout-resize-handle { display:none; }

/* A larger, easy-to-hit collapse control. */
.layout-collapse { width:78px; height:32px; font-size:20px; border-radius:8px; }
@media(pointer:coarse),(max-width:650px) {
  .layout-move-handle,.layout-fit-height,.layout-collapse { min-height:44px; }
  .joint-card-move,.joint-sliders-pane .joint-card-move { width:44px; height:44px; min-height:44px; }
  .layout-resize-width { right:-12px; width:24px; }
  .layout-resize-height { bottom:-12px; height:24px; }
  .layout-resize-both { width:44px; height:44px; }
}
