/* Scoped clinical extension: two source leads beside four peel groups. */
#editWorkbench.edit-workbench{grid-template-columns:clamp(320px,27vw,440px) minmax(0,1fr)}
#editWorkbench .edit-left-stack{grid-column:1;grid-row:1;grid-template-rows:240px auto auto;align-content:start}
#editWorkbench .edit-class-panel{min-height:0}
#editWorkbench .edit-class-content>#editScatterCanvas{min-height:0}
#editWorkbench .edit-main-stack{grid-column:2;grid-row:1}
#editWorkbench .edit-density-panel{padding:8px;background:#102631;color:#e4eeee;border:0;border-radius:8px}
#editWorkbench .edit-density-panel .edit-panel-heading{padding:0 0 8px;height:auto;min-height:0;gap:8px;flex-wrap:wrap;flex-shrink:0}
#editWorkbench .edit-density-panel .edit-panel-heading h2{color:#e4eeee;font-size:13px}
#editWorkbench .edit-density-panel .edit-panel-heading p{display:block;color:#c2d6dc;font-size:11px;margin:4px 0 0}
#editWorkbench .edit-density-panel #editMorphologyCount{font-size:10px;max-width:none;color:#e4eeee;background:#25434e;padding:3px 6px}
.morph-leads{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:0 0 8px}
.edit-density-panel .morph-lead-picker{margin:0 0 7px}
.morph-lead-dialog{width:min(480px,calc(100vw - 32px));max-height:calc(100vh - 40px);box-sizing:border-box;padding:18px;border:1px solid #6b9298;border-radius:8px;background:#f7fbfb;color:#193b45;font:13px/1.5 var(--ui-font,sans-serif);box-shadow:0 12px 45px #14313f40;overflow:auto}
.morph-lead-dialog::backdrop{background:#19333f66}
.morph-lead-dialog>header{display:flex;justify-content:space-between;align-items:center;gap:12px}
.morph-lead-dialog h2{margin:0;font-size:18px}
.morph-lead-dialog>p{margin:10px 0}
.morph-lead-choices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px 10px;margin:12px 0;padding:14px;border:1px solid #bed2d5;border-radius:5px}
.morph-lead-choices legend{padding:0 5px;font-size:12px;color:#446774}
.morph-lead-choices label{display:flex;gap:5px;align-items:center;white-space:nowrap}
.morph-lead-choices input{margin:0;accent-color:#087f7a}
.morph-lead-choices label:has(input:disabled){color:#85999d}
.morph-lead-positions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.morph-lead-positions label{display:grid;gap:4px}
.morph-lead-dialog select,.morph-lead-dialog button{font:inherit;color:#193b45;background:#fff;border:1px solid #9bb9be;border-radius:4px;padding:5px 10px;min-height:32px}
.morph-lead-dialog button{cursor:pointer}
.morph-lead-dialog button:disabled{color:#85999d;cursor:default}
.morph-lead-dialog small{display:block;font-size:11px;color:#55717c}
.morph-lead-dialog footer{display:flex;gap:8px;margin-top:16px;align-items:center}
.morph-lead-dialog footer>span{flex:1}
.morph-lead-dialog :is(button,input,select):focus-visible{outline:2px solid #087f7a;outline-offset:2px}
@media(max-width:480px){.morph-lead-choices{grid-template-columns:repeat(3,minmax(0,1fr))}.morph-lead-dialog{padding:12px}.morph-lead-positions{gap:5px}.morph-lead-dialog select{padding:5px}}
.morph-leads label,.morph-keyboard-range label,.morph-template-form label{display:grid;gap:4px;min-width:0;font-size:11px;color:#d6e6ea}
.edit-density-panel .morph-leads select,.edit-density-panel .morph-keyboard-range select,.edit-density-panel input,.edit-density-panel .morph-template-form select{width:100%;min-width:0;min-height:30px;background:#f6fafa;color:#163640;border:1px solid #7d9ba5;border-radius:4px;padding:4px 6px;font:inherit}
.morph-peeling-grid{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(124px,1fr);grid-template-rows:minmax(0,1fr);gap:6px;height:320px;min-height:320px;flex:none}
.morph-source-stack{display:grid;grid-template-rows:repeat(2,minmax(0,1fr));gap:7px;min-width:0;min-height:0}
.morph-source-stack figure{margin:0;background:#020b09;display:flex;flex-direction:column;min-width:0;overflow:hidden}
#editWorkbench .edit-density-panel .morph-source-stack figcaption{display:flex;align-items:center;justify-content:space-between;gap:4px;height:24px;min-height:24px;padding:4px;color:#e0efe8;font-size:10px}
#editWorkbench .edit-density-panel .morph-source-stack figcaption small{font-size:10px;color:#bfd4ca;white-space:nowrap}
#editWorkbench #editMorphCanvasWrap,.morph-source-canvas{height:auto;min-height:0;flex:1;position:relative}
#editWorkbench .edit-density-panel #editDensityPrimary,#editWorkbench .edit-density-panel #editDensitySelection{position:absolute;inset:0;height:100%;min-height:0;width:100%;display:block;touch-action:none;cursor:crosshair}
.morph-group-stack{display:grid;grid-template-rows:repeat(4,minmax(0,1fr));gap:5px;min-width:0;min-height:0}
.morph-group{display:grid;grid-template-rows:24px minmax(0,1fr);min-width:0;min-height:0;background:#020b09;border:1px solid #47616b;overflow:hidden}
.morph-group[data-active="true"]{outline:2px solid #40ccc4;outline-offset:-2px}
.morph-group header{display:flex;justify-content:space-between;gap:2px;align-items:center;padding:0 3px;min-width:0}
.morph-group header b{font-size:13px;color:#fff}
.morph-group header span{font-size:11px;color:#d6e6dd;white-space:nowrap;font-variant-numeric:tabular-nums}
.morph-group header [data-group-state]{font-size:10px;color:#c5d5cc}
.morph-group[data-saved="true"] header [data-group-state]{color:#77ddd0}
.edit-density-panel button{cursor:pointer;font:inherit;font-size:11px;min-height:28px;padding:4px 6px;border:1px solid #69858f;border-radius:4px;background:#1c3c48;color:#edf6f7;white-space:normal}
.edit-density-panel button:hover:not(:disabled){background:#315764}
.edit-density-panel button:disabled{color:#a7bdc5;border-color:#3d5863;background:#16303a;cursor:default;opacity:1}
.edit-density-panel :is(button,select,input,canvas,summary):focus-visible{outline:2px solid #56d7d0;outline-offset:2px}
.edit-density-panel .morph-group header button{height:22px;min-height:0;line-height:20px;padding:0;white-space:nowrap;flex-shrink:0}
.morph-group button[data-group-select]{border:0;background:none;text-align:left;display:flex;align-items:center;gap:2px;min-width:0}
.morph-group button[data-group-move]{font-size:11px}
#editWorkbench .morph-group canvas{display:block;width:100%;height:100%;min-height:0;min-width:0;border:0;border-radius:0}
.morph-group-tools{display:flex;align-items:center;flex-wrap:wrap;gap:4px;padding:6px 0;border-bottom:1px solid #29434e}
.morph-group-tools>span{flex:1;min-width:100px;font-size:11px;color:#dfede8;overflow-wrap:anywhere}
#editWorkbench .edit-density-panel .morph-status{color:#c6dfda;font-size:11px;line-height:1.5;margin:6px 0;min-height:0;overflow-wrap:anywhere}
.morph-status[data-error="true"]{color:#ffd5b5}
.morph-actions{display:flex;align-items:center;gap:5px;flex-wrap:wrap}
.morph-actions>span{flex:1 0 auto;font-size:11px;color:#fff}
.morph-keyboard-range,.morph-method-details{margin-top:4px;font-size:11px}
.morph-keyboard-range summary,.morph-method-details summary{padding:4px 0;cursor:pointer;color:#c9e6e4}
.morph-keyboard-range>div{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;padding:8px 0}
.morph-keyboard-range output{grid-column:1/-1;color:#bfd7dd}
.morph-template-form{margin-top:12px;padding-top:12px;border-top:1px solid #526b74;display:grid;gap:8px}
.morph-template-form>strong{font-size:12px;color:#fff}
.morph-template-form>p,.morph-method{margin:0;font-size:11px;color:#bed3d8;line-height:1.6}
.morph-template-form>div{display:flex;gap:8px}
.morph-method{margin:4px 0}
@media(max-width:1100px){#editWorkbench.edit-workbench{grid-template-columns:320px minmax(0,1fr)}}
@media(max-width:820px){
  html:has(#page-edit.active),body:has(#page-edit.active){min-width:0}
  #editWorkbench.edit-workbench{grid-template-columns:minmax(0,1fr)}
  #editWorkbench .edit-left-stack{grid-column:1;grid-row:1;grid-template-rows:240px auto auto}
  #editWorkbench .edit-main-stack{grid-column:1;grid-row:2;grid-template-rows:100px auto auto}
  #editWorkbench .edit-overview-panel{grid-template-columns:minmax(0,1fr)}
  #page-edit .edit-heading-actions{flex-wrap:wrap}
  #page-edit .edit-title-line>p{max-width:100%;white-space:normal}
}
@media(max-width:480px){#editWorkbench .edit-density-panel .edit-panel-heading{display:grid;grid-template-columns:minmax(0,1fr);justify-items:start}.morph-peeling-grid{grid-template-columns:minmax(0,1fr) minmax(124px,.85fr);gap:4px}.morph-leads{gap:4px}.morph-source-stack figcaption{flex-wrap:wrap}#editWorkbench .edit-density-panel .morph-source-stack figcaption{height:36px;min-height:36px}}

/* Local scope and action consequences; density selection is distinct from beat editing. */
#editWorkbench .edit-density-panel .morph-scope,
#editWorkbench .edit-density-panel .morph-impact{font-size:11px;line-height:1.5;overflow-wrap:anywhere;margin:0 0 8px;color:#d6e6ea;font-variant-numeric:tabular-nums}
#editWorkbench .edit-density-panel .morph-scope{padding:6px 0;border-bottom:1px solid #29434e}
#editWorkbench .edit-density-panel .morph-impact{margin:5px 0}
#editWorkbench .edit-density-panel .morph-scope:is([data-state="error"],[data-state="stale"]){color:#ffd5b5}
#editWorkbench .morph-group-tools>span{font-variant-numeric:tabular-nums}
#editWorkbench .edit-density-panel .morph-scope-summary{margin:3px 0 6px;font-size:12px;line-height:18px;color:#d6e6ea;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
#editWorkbench .edit-density-panel .morph-scope-summary:is([data-state="error"],[data-state="stale"],[data-state="insufficient"]){color:#ffd5b5}
#editWorkbench .edit-density-panel .morph-method-details .morph-scope,
#editWorkbench .edit-density-panel .morph-group-sources{margin:4px 0;padding:0;border:0;font-size:12px;line-height:1.6;color:#bed3d8;overflow-wrap:anywhere}
#templateLinkedOpen{height:20px;min-height:20px;padding:0 6px;max-width:170px;font-size:11px;line-height:18px;color:#086b69;white-space:nowrap;flex:0 0 auto}
.template-linked-status{font-size:11px;line-height:1.5;margin:5px 0;color:#c6e4de;overflow-wrap:anywhere}
.template-linked-status[data-error="true"]{color:#ffd5b5}
.template-linked-nn{font-size:11px;line-height:1.4;margin:3px 0;color:#53727c;overflow-wrap:anywhere}
.template-linked-selected:popover-open{position:fixed;inset:76px 16px auto auto;margin:0;width:min(840px,calc(100vw - 110px));max-height:calc(100vh - 92px);box-sizing:border-box;padding:16px;overflow:auto;overscroll-behavior:contain;border:1px solid #9dbfc1;border-radius:9px;background:#f7fbfb;color:#173741;box-shadow:0 10px 40px #183b4a38;font-size:13px;line-height:1.5}
.template-linked-selected>header{display:flex;align-items:center;justify-content:space-between;gap:12px}
.template-linked-selected h2{margin:0;font-size:18px;line-height:1.4}
.template-linked-selected>p{margin:10px 0;color:#3f6470;overflow-wrap:anywhere}
.template-linked-card-tools{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
.template-linked-card-tools button{padding:5px 10px;font:inherit;border:1px solid #b3ccce;border-radius:4px;background:white;color:#18565b;cursor:pointer}
.template-linked-card-tools button:disabled{color:#8d9a9f;cursor:default}
#templateLinkedCardGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.template-linked-card{min-width:0;border:1px solid #bdd4d5;border-radius:5px;padding:8px;background:white}
.template-linked-card[data-focused="true"]{outline:2px solid #d68b27;outline-offset:-2px}
.template-linked-card>header{display:flex;flex-wrap:wrap;justify-content:space-between;gap:5px;margin-bottom:5px}
.template-linked-card>header button{border:0;background:none;padding:0;color:#086d6b;font:inherit;text-align:left;cursor:pointer}
.template-linked-card label{display:flex;align-items:center;gap:4px;font-size:11px;color:#526c79}
.template-linked-card input{accent-color:#775899}
.template-linked-card svg{display:block;width:100%;height:96px}
.template-linked-card small{display:block;margin-top:4px;font-size:11px;color:#627985}
.template-linked-selected :is(button,input):focus-visible{outline:2px solid #087f7a;outline-offset:2px}
@media(max-width:650px){.template-linked-selected:popover-open{inset:66px 8px auto auto;width:calc(100vw - 90px);max-height:calc(100vh - 80px);padding:10px}#templateLinkedCardGrid{grid-template-columns:minmax(0,1fr)}}
/* Preserve full text/control boxes inside the existing scrollable density pane. */
#editWorkbench .edit-density-panel> :is(p,details,.morph-leads,.morph-group-tools,.morph-actions,.morph-template-form){flex-shrink:0}
/* Cluster controls occupy their content height; spare space belongs to wave/card rows. */
@media(min-width:1100px){
  #mainContent #page-edit.active:not(.workspace-library) #editWorkbench .edit-gallery-panel{grid-template-rows:28px max-content 28px max-content;align-content:start}
}
