/* Canvas-first layout. Every rule is scoped to body.layout-canvas so the
   classic layout is untouched. Colours come from the tokens in style.css. */
body.layout-canvas{height:100dvh;overflow:hidden;margin:0;
  --cl-canvas:#fff;--cl-chip:#fff;--cl-ink:#1f2328;--cl-muted:#656d76;--cl-line:#d0d7de;--cl-field-line:#848d97;--cl-grid:#d0d7de;--cl-accent:#0969da;--cl-accent-bg:#ddf4ff;--cl-accent-ink:#0969da;--cl-on-accent:#fff;--cl-ok:#1a7f37;--cl-bad:#cf222e;--cl-warn:#9a6700;
  --cl-shadow:0 2px 10px rgba(31,35,40,.12),0 0 0 1px rgba(31,35,40,.06)}
body.layout-canvas.cl-dark{--cl-canvas:#161b22;--cl-chip:#1c2128;--cl-ink:#e6edf3;--cl-muted:#9198a1;--cl-line:#30363d;--cl-field-line:#6e7681;--cl-grid:#30363d;--cl-accent:#4493f8;--cl-accent-bg:#1f3a5f;--cl-accent-ink:#79c0ff;--cl-on-accent:#0d1117;--cl-ok:#3fb950;--cl-bad:#f85149;--cl-warn:#d29922;
  --cl-shadow:0 2px 12px rgba(0,0,0,.5),0 0 0 1px rgba(240,246,252,.08)}
body.layout-canvas>header,body.layout-canvas>footer,body.layout-canvas>main,body.layout-canvas>.document-menu{display:none!important}

/* Stage: the diagram fills the viewport on a dot grid. The canvas stays white
   in dark mode because Pikchr draws black ink. */
body.layout-canvas .cl-stage{position:fixed;inset:0;z-index:0}
body.layout-canvas #diagram{position:absolute;inset:0;height:auto!important;min-height:0!important;width:auto;border:0;margin:0;
  background-color:var(--cl-canvas);background-image:radial-gradient(var(--cl-grid) 1px,transparent 1px);background-size:24px 24px;outline-offset:-3px;color:var(--cl-ink)}
body.layout-canvas #diagram{box-sizing:border-box;padding:0}
body.layout-canvas #diagram:focus:not(:focus-visible),body.layout-canvas.cl-pointer #diagram:focus{outline:none}
body.layout-canvas #diagram.stale{opacity:.55}
body.layout-canvas #diagram svg{max-height:none}
body.layout-canvas #diagram.previewing{outline:none}

/* Floating chrome */
body.layout-canvas .cl-float{position:fixed;z-index:10;display:flex;align-items:center;gap:2px;padding:4px;background:var(--cl-chip);color:var(--cl-ink);
  border:0;border-radius:10px;box-shadow:var(--cl-shadow)}
body.layout-canvas .cl-float button,body.layout-canvas .cl-float summary{color:var(--cl-ink)}
body.layout-canvas :is(.cl-palette,.cl-doc,.cl-history,.cl-zoom,.cl-context,.cl-candidate,.cl-status) button{border:0;background:transparent;box-shadow:none}
body.layout-canvas :is(.cl-palette,.cl-doc,.cl-history,.cl-zoom,.cl-context,.cl-candidate,.cl-status) button:hover:not(:disabled){background:var(--cl-accent-bg)}
body.layout-canvas :is(.cl-history,.cl-zoom) button:disabled{color:var(--cl-muted);background:transparent}
body.layout-canvas .cl-float[hidden]{display:none!important}
body.layout-canvas .cl-float button{min-height:34px;min-width:34px;border-radius:7px}
body.layout-canvas .cl-sep{width:1px;height:22px;background:var(--cl-line);margin:0 4px;flex:none}
body.layout-canvas .cl-muted{color:var(--cl-muted);font-size:12px}
body.layout-canvas .cl-offstage{position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0 0 0 0)!important;white-space:nowrap!important;margin:-1px!important;padding:0!important;border:0!important}

body.layout-canvas .cl-doc{top:12px;left:12px}
body.layout-canvas .cl-title{padding:0 8px;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.layout-canvas .cl-icon{font-weight:600}

/* canvas-layout.js places the palette: in the top row between the document
   chip and the status chip when it fits there, else at the bottom (wrapped
   to rows when one row is too wide), with undo and zoom lifted above it. */
body.layout-canvas .cl-palette{top:12px;left:50%;transform:translateX(-50%);max-width:calc(100vw - 24px)}
body.layout-canvas.cl-palette-bottom .cl-palette{top:auto;bottom:12px}
body.layout-canvas.cl-palette-wrap .cl-palette{flex-wrap:wrap;justify-content:center}
body.layout-canvas.cl-palette-wrap .cl-palette .cl-sep{display:none}
body.layout-canvas .cl-palette button{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:40px;height:44px;padding:2px 6px}
body.layout-canvas .cl-palette button[aria-pressed=true]{background:var(--cl-accent-bg);color:var(--cl-accent-ink)}
body.layout-canvas .cl-palette button svg{width:18px;height:18px}
body.layout-canvas .cl-palette button[data-key]::after{content:attr(data-key);font-size:10px;line-height:1;color:var(--cl-muted);min-height:10px}
body.layout-canvas .cl-palette button[aria-pressed=true]::after{color:var(--cl-accent)}
body.layout-canvas .cl-palette .cl-tool span{font-size:18px;line-height:1}

body.layout-canvas .cl-status{top:12px;right:12px;flex-direction:column;align-items:stretch;max-width:min(360px,calc(100vw - 24px));padding:4px 10px;min-height:42px;justify-content:center}
body.layout-canvas .cl-status-line{display:flex;align-items:center;gap:8px;min-width:0}
body.layout-canvas .cl-dot-state{width:8px;height:8px;border-radius:50%;background:var(--cl-ok);flex:none}
body.layout-canvas .cl-status[data-state=invalid] .cl-dot-state{background:var(--cl-bad)}
body.layout-canvas .cl-status[data-state=invalid] .cl-summary{color:var(--cl-bad)}
body.layout-canvas .cl-summary{white-space:nowrap;font-size:12px;color:var(--cl-muted)}
body.layout-canvas .cl-status #state{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex:1}
body.layout-canvas .cl-status #diagnostic{color:var(--cl-bad);font-size:12px;padding:4px 2px;white-space:pre-wrap;max-height:30vh;overflow:auto}
body.layout-canvas .cl-status #diagnostic:empty{display:none}

body.layout-canvas .cl-history{bottom:var(--cl-chips-bottom,12px);left:12px}
body.layout-canvas .cl-zoom{bottom:calc(var(--cl-chips-bottom,12px) + var(--cl-zoom-lift,0px));right:12px}
body.layout-canvas .cl-zoom #zoom-level{min-width:44px;text-align:center;font-size:12px}

/* Contextual toolbar: the existing selection buttons, shown as icons. */
/* Wraps to a second row rather than scrolling actions out of reach; the
   selection buttons join the chip's own row so they wrap with it. */
body.layout-canvas .cl-context{z-index:11;max-width:calc(100vw - 16px);box-sizing:border-box;flex-wrap:wrap;justify-content:center}
body.layout-canvas .cl-context .selection-toolbar{display:contents!important}
body.layout-canvas .cl-context .selection-toolbar>:is(#multi-select,#clear-selection,.move-selection){display:none!important}
/* A group selection names itself in the toolbar; one object needs no count. */
body.layout-canvas .cl-context .selection-toolbar>#selection-count{display:none!important;margin:0 6px 0 2px;color:var(--cl-muted);font-size:12px;white-space:nowrap}
body.layout-canvas.has-multiple .cl-context .selection-toolbar>#selection-count{display:inline!important}
body.layout-canvas.has-multiple .cl-context .selection-toolbar>#appearance-selected{display:none!important}
body.layout-canvas .cl-context .selection-toolbar>button:disabled{display:none!important}
body.layout-canvas .cl-context .selection-toolbar>button{border-color:transparent;background:transparent;padding:0;display:inline-flex;align-items:center;justify-content:center}
body.layout-canvas .cl-context .selection-toolbar>button svg,body.layout-canvas .cl-more-button svg{width:20px;height:20px;flex:none;pointer-events:none}
body.layout-canvas .cl-context button{min-width:34px;height:34px}
body.layout-canvas .cl-more-button{display:inline-flex;align-items:center;justify-content:center;padding:0}

/* Candidate chip beside the object being changed. */
body.layout-canvas .cl-candidate{z-index:45;flex-wrap:nowrap;max-width:calc(100vw - 16px);gap:6px;padding:6px 8px;margin:0;font-size:13px;border:0}
body.layout-canvas .cl-candidate :is(.hint,#preview-label){display:none}
body.layout-canvas .cl-candidate .cl-check{color:var(--cl-ok);padding:0 2px}
body.layout-canvas .cl-candidate .cl-code{font:12px ui-monospace,monospace;background:var(--cl-accent-bg);color:var(--cl-accent-ink);padding:3px 7px;border-radius:5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;max-width:52vw}
body.layout-canvas .cl-candidate .cl-count{color:var(--cl-muted);white-space:nowrap}
body.layout-canvas .cl-candidate button{min-width:30px;height:30px;padding:0 8px}
body.layout-canvas #preview-actions.cl-candidate{border:0!important;background:var(--cl-chip)!important;outline:none}
body.layout-canvas .cl-candidate #preview-accept{background:transparent!important;color:var(--cl-accent)!important;border:0!important;font-weight:600}
body.layout-canvas .cl-candidate #preview-accept:hover{background:var(--cl-accent-bg)!important}

/* Popovers */
body.layout-canvas .cl-popover{z-index:40;display:block;padding:12px;overflow:auto}
body.layout-canvas .cl-menu{top:60px;left:12px;width:min(380px,calc(100vw - 24px));max-height:calc(100dvh - 130px)}
body.layout-canvas .cl-menu>*+*{margin-top:10px}
body.layout-canvas .cl-menu-row{display:flex;gap:10px;align-items:center}
body.layout-canvas .cl-menu details>summary{cursor:pointer;font-weight:600}
body.layout-canvas .cl-more{top:60px;right:12px;width:min(360px,calc(100vw - 24px));max-height:calc(100dvh - 130px)}
body.layout-canvas .cl-more aside{display:block!important;overflow:visible;position:static!important;padding:0;border:0;width:auto;height:auto;transform:none!important;box-shadow:none}

body.layout-canvas .cl-more .canvas-context-dock{display:block;margin:0 0 12px;position:static}
body.layout-canvas .cl-export{top:60px;left:12px;flex-direction:column;align-items:stretch;gap:6px;width:min(260px,calc(100vw - 24px))}
body.layout-canvas .cl-export:not([hidden]){display:flex}
body.layout-canvas .cl-export .cl-section{display:flex;flex-direction:column;gap:2px}
body.layout-canvas .cl-export .cl-export-item{justify-content:flex-start;width:100%;gap:10px}
body.layout-canvas .cl-export .cl-export-item svg{flex:none}
body.layout-canvas .cl-export .cl-export-scope{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:8px;border-top:1px solid var(--cl-line)}
body.layout-canvas .cl-export .cl-export-scope label:has(input:disabled){color:var(--cl-muted)}
body.layout-canvas .cl-export .cl-export-scope [hidden]{display:none}
body.layout-canvas .cl-export .cl-copy-fallback textarea{width:100%;font:12px/1.4 ui-monospace,monospace;resize:vertical}
body.layout-canvas .cl-help{bottom:var(--cl-above-chips,64px);right:12px;width:min(360px,calc(100vw - 24px));max-height:calc(100dvh - 140px)}
body.layout-canvas .cl-help h2{font-size:14px;margin:0 0 8px}
body.layout-canvas .cl-help dl{display:grid;grid-template-columns:max-content 1fr;gap:6px 12px;font-size:12px;margin:0 0 10px}
body.layout-canvas .cl-help dt{font-family:ui-monospace,monospace;color:var(--muted)}
body.layout-canvas .cl-help dd{margin:0}

/* Source drawer */
body.layout-canvas .cl-drawer{position:fixed;z-index:15;top:60px;bottom:60px;left:12px;width:min(380px,calc(100vw - 24px));display:flex;flex-direction:column;gap:8px;padding:12px;
  background:var(--cl-chip);color:var(--cl-ink);border:0;border-radius:10px;box-shadow:var(--cl-shadow);transform:translateX(calc(-100% - 24px));visibility:hidden;transition:transform .18s,visibility 0s .18s}
/* Visible at once on open so the textarea can take focus immediately. */
body.layout-canvas .cl-drawer.open{transform:none;visibility:visible;transition:transform .18s,visibility 0s}
body.layout-canvas .cl-drawer-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
body.layout-canvas .cl-drawer-head .cl-muted{flex:1}
body.layout-canvas .cl-drawer .source-pane{display:flex!important;flex-direction:column;flex:1;min-height:0;padding:0;border:0;margin:0}
body.layout-canvas .cl-drawer .source-pane .pane-heading{display:none}
body.layout-canvas .cl-drawer #source{flex:1;min-height:120px;height:auto;resize:none;width:100%;box-sizing:border-box}

/* Feedback: a screen-reader region, visible only when it offers choices. */
body.layout-canvas .cl-toast{position:fixed;left:50%;bottom:var(--cl-above-chips,72px);transform:translateX(-50%);z-index:12;max-width:calc(100vw - 24px);
  background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:10px;padding:6px 10px;box-shadow:0 2px 10px var(--shadow);display:flex;gap:6px;flex-wrap:wrap;align-items:center}
body.layout-canvas .cl-toast:not(:has(button)){position:fixed;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);padding:0;border:0;white-space:nowrap}

/* Transient status note, bottom-centre. */
body.layout-canvas .cl-note{position:fixed;left:50%;bottom:16px;transform:translateX(-50%);z-index:12;max-width:min(560px,calc(100vw - 200px));
  background:var(--cl-chip);color:var(--cl-ink);border-radius:10px;padding:8px 12px;box-shadow:var(--cl-shadow);font-size:12px;opacity:1;transition:opacity .4s}
body.layout-canvas .cl-note.cl-fade{opacity:0}
/* Why a shape cannot be dragged: follows the pointer, then stays where it was released. */
.drag-refusal{position:fixed;z-index:14;max-width:320px;background:var(--bg);color:var(--text);border:1px solid var(--error);border-left-width:4px;
  border-radius:8px;padding:6px 10px;box-shadow:0 2px 10px var(--shadow);font-size:12px;line-height:1.4;pointer-events:none}
.drag-refusal[hidden]{display:none}
body.layout-canvas.cl-palette-bottom .cl-note{bottom:var(--cl-above-chips,124px)}
/* Select multiple stays on until Done; the pill says so above undo and zoom. */
body.layout-canvas .cl-multi-pill{left:50%;transform:translateX(-50%);bottom:var(--cl-above-chips,64px);gap:8px;padding:4px 4px 4px 12px;font-size:13px;white-space:nowrap}
body.layout-canvas .cl-multi-pill button{padding:0 12px;color:var(--cl-accent);font-weight:600}
body.layout-canvas.cl-multi :is(.cl-note,.cl-toast){bottom:calc(var(--cl-above-chips,64px) + 60px)}
body.layout-canvas .cl-note[hidden]{display:none}

/* Selection: accent ink on the selected shape instead of a dashed box. */
body.layout-canvas #diagram [data-pikchr-id]:is(.cl-selected,.cl-target-shape) :is(path,polygon,polyline,circle,ellipse,rect,line):not([stroke=transparent]):not([fill=transparent]){stroke:var(--cl-accent)!important}
body.layout-canvas #diagram [data-pikchr-id].cl-target-shape :is(path,polygon,polyline,circle,ellipse,rect,line):not([stroke=transparent]){stroke-width:2.5px!important}
body.layout-canvas .studio-overlay:not(.preview-overlay)>rect{display:none}
body.layout-canvas .preview-overlay rect{stroke:var(--cl-accent);stroke-dasharray:none;opacity:.6}
/* Resize: one small corner handle; edge midpoints belong to the attach dots. */

/* Drag-to-connect */
body.layout-canvas .cl-dot{fill:var(--cl-canvas);stroke:var(--cl-accent);stroke-width:2;cursor:crosshair}
body.layout-canvas .cl-dot-hit{cursor:crosshair;pointer-events:all}
body.layout-canvas .cl-dots .cl-dot{pointer-events:none}
body.layout-canvas .cl-dots .cl-dot-hit:hover+.cl-dot{fill:var(--cl-accent)}
/* Endpoint handles outrank creation dots: they own the anchor they sit on. */
body.layout-canvas .arrow-overlay .endpoint-handle{pointer-events:all}
/* While a reconnect is targeting, chrome over the shapes steps aside. A drag
   also clears the inspector; armed anchors opened from the inspector keep it
   so its own Cancel reconnect stays reachable. Escape restores everything. */
body.layout-canvas.cl-targeting :is(.cl-context,.cl-textbar,.cl-menu,.cl-export,.cl-help){display:none!important}
body.layout-canvas.cl-targeting-drag :is(.cl-more){display:none!important}
body.layout-canvas .cl-rubber-line{fill:none;stroke:var(--cl-accent);stroke-width:2;stroke-dasharray:6 4}
body.layout-canvas .cl-head{fill:var(--cl-accent)}
body.layout-canvas .cl-dot.cl-snap{fill:var(--cl-accent)}
body.layout-canvas .cl-rubber{pointer-events:none}
body.layout-canvas .cl-badge{position:fixed;z-index:30;background:var(--cl-accent);color:#fff;font-size:12px;padding:3px 8px;border-radius:6px;pointer-events:none;white-space:nowrap}
body.layout-canvas.cl-dark .cl-badge{color:#0d1117}
body.layout-canvas .cl-badge[hidden]{display:none}

/* Phones: palette moves to the bottom, chrome stays inside the viewport. */
@media (max-width:700px){
  /* Pinch zooms on a phone; dropping the percentage keeps zoom clear of undo/redo. */
  body.layout-canvas .cl-zoom #zoom-level{display:none}
  body.layout-canvas .cl-title{display:none}
  body.layout-canvas .cl-status{top:62px;max-width:calc(100vw - 24px)}
  body.layout-canvas .cl-palette{gap:0;padding:3px}
  body.layout-canvas .cl-palette button{min-width:33px;padding:2px 1px}
  body.layout-canvas .cl-palette .cl-sep{margin:0 1px}
  body.layout-canvas .cl-status #state{display:none}
  body.layout-canvas .cl-note{max-width:calc(100vw - 24px)}
  body.layout-canvas .cl-candidate{flex-wrap:wrap}
  body.layout-canvas .cl-context .cl-endpoint-label{display:none}
}
body.layout-canvas.cl-palette-bottom .cl-drawer{bottom:var(--cl-above-chips,124px)}
@media (prefers-reduced-motion:reduce){body.layout-canvas :is(.cl-drawer,.cl-note,.cl-more){transition:none}}

/* ---- Panel kit: one flat visual language for every popover and dialog ----
   Flat chip surfaces, no nested borders, small uppercase section labels,
   32px controls, 8px rhythm. Scoped to the canvas layout. */
body.layout-canvas :is(.cl-popover,.cl-drawer,dialog){font-size:13px;color:var(--cl-ink)}
body.layout-canvas .cl-popover{padding:12px 14px;border-radius:10px;scrollbar-width:thin;overscroll-behavior:contain}
body.layout-canvas .cl-popover :is(section,fieldset,aside,.queue-panel,#inspector,details,.canvas-context-dock,.canvas-context,.arrow-editor,.route-editor,.appearance-editor){border:0!important;background:transparent!important;box-shadow:none!important;padding:0;margin:0}
body.layout-canvas .cl-popover :is(h2,h3,.cl-section-title){font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--cl-muted);margin:0 0 8px}
body.layout-canvas .cl-popover h4{font-size:12px;margin:8px 0 4px}
body.layout-canvas .cl-popover p{margin:0 0 8px;color:var(--cl-muted);font-size:12px;line-height:1.45}
/* Controls */
body.layout-canvas :is(.cl-popover,.cl-drawer,dialog) :is(button,.cl-link){display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:32px;padding:0 10px;border-radius:7px;
  border:1px solid var(--cl-line);background:transparent;color:var(--cl-ink);font:inherit;font-size:13px;cursor:pointer;text-decoration:none;white-space:nowrap;box-shadow:none}
body.layout-canvas :is(.cl-popover,.cl-drawer,dialog) :is(button,.cl-link):hover:not(:disabled){background:var(--cl-accent-bg);border-color:var(--cl-accent)}
body.layout-canvas :is(.cl-popover,.cl-drawer,dialog) button:disabled{color:var(--cl-muted);border-color:var(--cl-line);opacity:1;cursor:default}
body.layout-canvas :is(.cl-popover,.cl-drawer,dialog) :is(#accept,[data-use],.primary,button[type=submit]):not(:disabled){background:var(--cl-accent);border-color:var(--cl-accent);color:var(--cl-on-accent)}
body.layout-canvas :is(.cl-popover,.cl-drawer,dialog) :is(input:not([type=checkbox]):not([type=radio]),select,textarea){min-height:32px;box-sizing:border-box;padding:4px 8px;border-radius:7px;border:1px solid var(--cl-field-line);
  background:var(--cl-canvas);color:var(--cl-ink);font:inherit;font-size:13px;max-width:100%}
body.layout-canvas :is(.cl-popover,.cl-drawer,dialog) :is(input,select,textarea):focus-visible{outline:2px solid var(--cl-accent);outline-offset:1px}
body.layout-canvas :is(.cl-popover,dialog) input[type=checkbox]{accent-color:var(--cl-accent);width:16px;height:16px;margin:0}
body.layout-canvas :is(.cl-popover,dialog) label{display:inline-flex;align-items:center;gap:6px;flex-wrap:wrap;color:var(--cl-ink);font-size:13px}
body.layout-canvas .cl-popover details>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:6px;min-height:32px;font-weight:600;color:var(--cl-ink)}
body.layout-canvas .cl-popover details>summary::-webkit-details-marker{display:none}
/* Lucide chevron-right / chevron-left as masks, so they take the text colour. */
body.layout-canvas .cl-popover details>summary::before{content:'';display:inline-block;flex:none;width:14px;height:14px;background:var(--cl-muted);transition:transform .12s;
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center/contain no-repeat;
  mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center/contain no-repeat}
body.layout-canvas .cl-popover details[open]>summary::before{transform:rotate(90deg)}
body.layout-canvas .cl-popover dl{display:grid;grid-template-columns:96px 1fr;gap:4px 10px;font-size:12px;margin:0}
body.layout-canvas .cl-popover dt{color:var(--cl-muted)}
body.layout-canvas .cl-popover dd{margin:0;overflow-wrap:anywhere}
body.layout-canvas .cl-popover pre{background:var(--cl-canvas);border-radius:7px;padding:8px;margin:4px 0 0;font:12px/1.5 ui-monospace,monospace;white-space:pre-wrap;overflow-wrap:anywhere;max-height:160px;overflow:auto}
body.layout-canvas .cl-popover pre:empty{display:none}

/* ☰ menu sections */
body.layout-canvas .cl-menu{width:min(360px,calc(100vw - 24px));padding:6px 14px 10px}
body.layout-canvas .cl-menu>*+*{margin-top:0}
body.layout-canvas .cl-section{padding:10px 0!important;border-top:1px solid var(--cl-line)!important;display:flex;flex-direction:column;gap:8px}
body.layout-canvas .cl-section:first-child{border-top:0!important}
body.layout-canvas .cl-section>.cl-section-title{margin:0}
body.layout-canvas .cl-section:not(:has(> :not(.cl-section-title):not([hidden]):not(.cl-offstage))){display:none}
body.layout-canvas .cl-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
body.layout-canvas .cl-check-row{min-height:28px}
body.layout-canvas .cl-field{display:flex!important;flex-direction:column;align-items:stretch!important;gap:4px}
body.layout-canvas .cl-field select{width:100%}
body.layout-canvas .cl-field-name{font-size:12px;color:var(--cl-muted);margin-top:4px}
body.layout-canvas .cl-queue-text{flex:1 1 100%;font-size:13px;font-weight:600}
body.layout-canvas .cl-adding #creation-tools{display:none}
body.layout-canvas.creation-open .cl-adding #creation-tools{display:block!important;position:static!important;inset:auto!important;max-height:none!important;background:transparent!important;border:0!important;padding:0!important}
body.layout-canvas .cl-adding #mobile-add[aria-pressed=true],body.layout-canvas.creation-open .cl-adding #mobile-add{background:var(--cl-accent-bg);border-color:var(--cl-accent)}

/* ⋯ inspector popover */
body.layout-canvas .cl-more{width:min(340px,calc(100vw - 24px));padding-top:8px}
/* Above pressed segmented buttons (z-index 1) that scroll under it. */
body.layout-canvas .cl-popover-head{position:sticky;top:-8px;z-index:3;display:flex;align-items:center;gap:8px;margin:-8px -14px 8px;padding:10px 8px 8px 14px;background:var(--cl-chip);border-bottom:1px solid var(--cl-line)}
body.layout-canvas .cl-popover-head .cl-muted{flex:1}
body.layout-canvas .cl-more .cl-grab{display:none}
body.layout-canvas .cl-more-title{flex:1;font-size:14px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.layout-canvas .cl-popover-head .cl-popover-kind{flex:0 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.layout-canvas .cl-popover-head .cl-close{flex:none}
/* One bounded view at a time: properties or the object outline. */
body.layout-canvas .cl-view[hidden]{display:none!important}
body.layout-canvas .cl-view-objects{display:flex;flex-direction:column;gap:8px;min-height:0}
body.layout-canvas .cl-back{border-color:transparent!important;padding-left:0;color:var(--cl-accent);align-self:flex-start}
body.layout-canvas .cl-back{display:inline-flex;align-items:center;gap:2px}
body.layout-canvas .cl-back::before{content:'';flex:none;width:16px;height:16px;background:currentColor;
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
  mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E") center/contain no-repeat}
body.layout-canvas .cl-objects-head{display:flex;align-items:baseline;justify-content:space-between;gap:8px;font-size:12px;color:var(--cl-muted)}
body.layout-canvas .cl-empty{margin:0;font-size:12px;color:var(--cl-muted)}
body.layout-canvas .cl-view-objects #object-search{width:100%}
/* The outline itself: one searchable row per object, never a pill wall. */
body.layout-canvas #objects{display:flex;flex-direction:column;gap:2px;margin:2px 0 0;min-height:0}
body.layout-canvas #objects .object-row{display:flex;align-items:center;justify-content:flex-start;gap:8px;min-height:34px;padding:0 8px;border:0!important;border-radius:7px;
  background:transparent;color:var(--cl-ink);font:inherit;font-size:13px;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}
body.layout-canvas #objects .object-row[hidden]{display:none!important}
body.layout-canvas #objects .object-row:hover:not(:disabled){background:var(--cl-accent-bg)}
body.layout-canvas #objects .object-row[aria-pressed=true]{background:var(--cl-accent-bg);color:var(--cl-accent-ink);font-weight:600}
body.layout-canvas #objects .object-row::before{content:'';flex:none;width:8px;height:8px;border:1.5px solid var(--cl-line);border-radius:2px}
body.layout-canvas #objects .object-row[aria-pressed=true]::before{border-color:var(--cl-accent);background:var(--cl-accent)}
/* Route choices: shape previews before route detail text. */
body.layout-canvas .cl-popover .cl-route-choices{display:flex;flex-direction:column;gap:8px;margin:0 0 10px!important;padding:0 0 10px!important;border:0!important;border-bottom:1px solid var(--cl-line)!important}
body.layout-canvas .cl-route-choices h4{font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--cl-muted);margin:0}
body.layout-canvas .cl-route-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px}
body.layout-canvas .cl-route-option{flex-direction:column!important;gap:1px!important;min-width:0;min-height:52px!important;height:auto;padding:4px 2px!important;white-space:normal!important;font-size:11px!important;line-height:1.2}
body.layout-canvas .cl-route-option svg{width:100%;max-width:44px;height:20px}
body.layout-canvas .cl-route-option[aria-pressed=true]{background:var(--cl-accent-bg);border-color:var(--cl-accent)!important;color:var(--cl-accent-ink)}
body.layout-canvas .cl-route-elbow{display:flex;flex-wrap:wrap;gap:6px}
body.layout-canvas .cl-route-elbow[hidden]{display:none}
body.layout-canvas .cl-route-note{margin:0;font-size:12px;color:var(--cl-muted);line-height:1.4}
/* Advanced facts stay collapsed until asked for. The panel kit zeroes every
   details border and margin, so the separator is set here explicitly. */
body.layout-canvas .cl-more .inspector-advanced{margin:10px 0 0!important;padding:8px 0 0!important;border-top:1px solid var(--cl-line)!important}
body.layout-canvas .cl-more .inspector-advanced>summary{font-weight:600;color:var(--cl-muted)}
body.layout-canvas .cl-more .inspector-advanced dl{margin:6px 0 8px}
body.layout-canvas .cl-more .inspector-advanced button{justify-content:flex-start}
body.layout-canvas .cl-more #inspector>.inspector-status{order:-1;border:0;padding:0;margin:0 0 12px}
body.layout-canvas .cl-more .inspector-advanced{order:10}
/* Group actions: one labelled section for a multiple selection. */
body.layout-canvas .cl-more .cl-group{display:flex;flex-direction:column;gap:8px}
body.layout-canvas .cl-more .cl-group[hidden]{display:none!important}
body.layout-canvas .cl-more .cl-group-head{display:flex;align-items:baseline;justify-content:space-between;gap:8px;flex-wrap:wrap}
body.layout-canvas .cl-more .cl-group-head .cl-muted{flex:1 1 100%;font-size:12px}
body.layout-canvas .cl-more .cl-group .move-selection{display:flex!important;gap:4px;padding:0;border:0;margin:0}
body.layout-canvas .cl-more .cl-group .move-selection button{min-width:40px;height:36px;border:1px solid var(--cl-line)}
body.layout-canvas .cl-more .cl-group-arrange{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
body.layout-canvas .cl-more .cl-group .arrange-selection{display:flex!important;align-items:center;gap:6px;flex:1 1 200px;min-width:0}
body.layout-canvas .cl-more .cl-group .arrange-selection select{flex:1 1 auto;min-width:0;width:auto}
body.layout-canvas .cl-popover .cl-close{border:0!important;min-width:32px;padding:0;font-size:18px;color:var(--cl-muted)}
body.layout-canvas .cl-more aside>section{padding:0 0 10px!important;margin:0 0 10px!important;border-bottom:1px solid var(--cl-line)!important}
body.layout-canvas .cl-more aside>section:last-child{border-bottom:0!important;margin-bottom:0!important}
body.layout-canvas .cl-more aside>section>h2{display:none}
body.layout-canvas .cl-more #inspector>*+*{margin-top:8px}
body.layout-canvas .cl-more .canvas-context-dock{margin:0 0 10px!important;padding-bottom:10px!important;border-bottom:1px solid var(--cl-line)!important}
body.layout-canvas .cl-more .canvas-context-dock :is(.canvas-context,.resize-controls,.context-panel,form,div){display:flex;flex-wrap:wrap;gap:8px;align-items:center;min-width:0;max-width:100%}
body.layout-canvas .cl-more .canvas-context-dock label{flex-wrap:nowrap}
body.layout-canvas .cl-more .canvas-context-dock input:not([type=checkbox]){width:72px}
body.layout-canvas .cl-more .canvas-context-dock .context-toggle{display:none}
body.layout-canvas .cl-more .canvas-context>label:first-child{display:none}
body.layout-canvas .cl-more .context-hint{color:var(--cl-muted);font-size:12px}
body.layout-canvas .cl-more .route-style-thumb,body.layout-canvas .route-style-thumb{background:var(--cl-canvas)}
body.layout-canvas .cl-more [role=listbox] button,body.layout-canvas .cl-more .route-styles button{flex-direction:column;height:auto;padding:6px;white-space:normal;line-height:1.25;font-size:11px}
/* Inspector rows: a muted name, the value, then its action. */
body.layout-canvas .cl-more .inspector-row{display:grid;grid-template-columns:68px minmax(0,1fr) auto;align-items:center;gap:8px;min-height:32px}
body.layout-canvas .cl-more .row-name{font-size:12px;color:var(--cl-muted)}
body.layout-canvas .cl-more .inspector-row>:is(.cl-seg,.size-fields){grid-column:2/-1;justify-self:start}
body.layout-canvas .cl-more .label-preview{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.layout-canvas .cl-more .connector-rows{display:flex;flex-direction:column;gap:8px}
body.layout-canvas .cl-more .connector-rows code{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;justify-self:start;max-width:100%;padding:2px 6px;border-radius:5px;background:var(--cl-canvas);border:1px solid var(--cl-line);font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}
body.layout-canvas .cl-more .connector-reverse{align-self:flex-start}
body.layout-canvas .cl-more .cl-seg{display:inline-flex;max-width:100%}
body.layout-canvas .cl-more .cl-seg>button{min-height:30px;padding:0 9px;border-radius:0;margin-left:-1px;font-size:12px}
body.layout-canvas .cl-more .cl-seg>button:first-child{margin-left:0;border-radius:7px 0 0 7px}
body.layout-canvas .cl-more .cl-seg>button:last-child{border-radius:0 7px 7px 0}
body.layout-canvas .cl-more .cl-seg>button[aria-pressed=true]{position:relative;z-index:1;background:var(--cl-accent-bg);border-color:var(--cl-accent);color:var(--cl-accent-ink);font-weight:600}
body.layout-canvas .cl-more .chip-row button[aria-pressed=true]{background:var(--cl-accent-bg);border-color:var(--cl-accent);color:var(--cl-accent-ink);font-weight:600}
body.layout-canvas .cl-more .canvas-sizing{display:flex;flex-direction:column;align-items:stretch;flex-wrap:nowrap;overflow:visible;gap:8px;margin:0;padding:0}
body.layout-canvas .cl-more .canvas-sizing[hidden]{display:none}
body.layout-canvas .cl-more .size-fields{display:flex;align-items:center;gap:6px}
body.layout-canvas .cl-popover .size-fields input[type=number]{width:68px}
body.layout-canvas .cl-more .size-fields input[aria-invalid]{border-color:var(--cl-bad)}
body.layout-canvas .cl-more .size-lock{min-width:32px;padding:0}
body.layout-canvas .cl-more .size-lock[aria-pressed=true]{background:var(--cl-accent-bg);border-color:var(--cl-accent);color:var(--cl-accent-ink)}
body.layout-canvas .cl-more .size-error{margin:0 0 0 76px;color:var(--cl-bad)}
body.layout-canvas .cl-more .size-error[hidden],body.layout-canvas .cl-more .size-warning[hidden]{display:none}
body.layout-canvas .cl-more .size-warning{margin-left:76px;font-size:12px;color:var(--cl-warn)}
body.layout-canvas .cl-more #inspector>.inspector-status{color:var(--cl-ink);padding:6px 10px;border-left:3px solid var(--cl-warn);background:var(--cl-canvas)}
body.layout-canvas .cl-more .inspector-routes .cl-count{font-weight:400;color:var(--cl-muted)}
body.layout-canvas .cl-more .inspector-routes[hidden]{display:none}
body.layout-canvas .cl-more .inspector-routes-slot:empty,body.layout-canvas .cl-more .inspector-editor-slot:empty{display:none}
body.layout-canvas .cl-more .route-style-controls{margin-top:8px}
/* Style, Suggested routes and Advanced read as one stack of disclosures. */
body.layout-canvas .cl-more #inspector>:is(.appearance-editor,.inspector-routes-slot,.inspector-advanced){margin:8px 0 0!important;padding:2px 0 0!important;border-top:1px solid var(--cl-line)!important}
body.layout-canvas .cl-more #inspector :is(.appearance-editor,.inspector-routes,.inspector-advanced)>summary{padding:0;margin:0}
body.layout-canvas .cl-more #inspector :is(.appearance-editor,.inspector-routes,.inspector-advanced)[open]>summary{margin-bottom:6px}
body.layout-canvas .cl-more #inspector>.property-error:empty{display:none}
/* Style: swatch rows for colour, presets plus a number for thickness. Every
   choice applies at once through the validated preview path. */
body.layout-canvas .cl-more .appearance-form{display:flex;flex-direction:column;gap:8px}
/* Each control's name sits above a full-width row, so eight swatches and the
   Custom swatch share one line at the inspector's width. The row is padded by
   the ring's width so a pressed or focused ring is never clipped. */
body.layout-canvas .cl-more .style-row{grid-template-columns:minmax(0,1fr);gap:2px;align-items:start}
body.layout-canvas .cl-more .style-row>:is(.style-swatches,.style-thickness){grid-column:1;min-width:0}
body.layout-canvas .cl-more .style-swatches{display:flex;flex-wrap:nowrap;align-items:center;gap:6px;padding:4px}
body.layout-canvas .cl-more .style-swatch{flex:none;position:relative;width:26px;height:26px;min-width:26px;min-height:26px;padding:0;border-radius:50%;
  border:1px solid var(--cl-field-line);background:var(--swatch,transparent);box-shadow:none;cursor:pointer}
body.layout-canvas .cl-more .style-swatch[data-colour=none]{background:linear-gradient(135deg,transparent calc(50% - 1px),var(--cl-bad) calc(50% - 1px),var(--cl-bad) calc(50% + 1px),transparent calc(50% + 1px)),var(--cl-canvas)}
body.layout-canvas .cl-more .style-swatch:hover{border-color:var(--cl-muted)}
/* The shared button hover tint must not repaint a colour swatch. */
body.layout-canvas .cl-more button.style-swatch:hover:not(:disabled){background:var(--swatch,transparent)}
body.layout-canvas .cl-more button.style-swatch[data-colour=none]:hover:not(:disabled){background:linear-gradient(135deg,transparent calc(50% - 1px),var(--cl-bad) calc(50% - 1px),var(--cl-bad) calc(50% + 1px),transparent calc(50% + 1px)),var(--cl-canvas)}
body.layout-canvas .cl-more .style-swatch[aria-pressed=true]{border-color:var(--cl-accent);box-shadow:0 0 0 2px var(--cl-chip),0 0 0 4px var(--cl-accent)}
body.layout-canvas .cl-more .style-swatch:focus-visible{outline:2px solid var(--cl-accent);outline-offset:2px}
body.layout-canvas .cl-more .style-swatch:disabled{opacity:.45;cursor:not-allowed}
/* Custom is a swatch too: a pipette that opens the picker and field below. */
body.layout-canvas .cl-more .style-custom,body.layout-canvas .cl-more button.style-custom:hover:not(:disabled){display:inline-grid;place-items:center;background:var(--cl-canvas);color:var(--cl-ink)}
body.layout-canvas .cl-more .style-custom svg{width:15px;height:15px}
body.layout-canvas .cl-more .style-custom[aria-pressed=true]{color:var(--cl-accent)}
body.layout-canvas .cl-more .style-custom-fields{display:flex;align-items:center;gap:6px;margin-left:4px;min-width:0}
body.layout-canvas .cl-more .style-custom-fields[hidden]{display:none}
body.layout-canvas .cl-more .appearance-editor .style-custom-fields input[type=color]{flex:none;width:34px;height:30px;padding:2px;border:1px solid var(--cl-field-line);border-radius:6px;background:var(--cl-canvas);cursor:pointer}
body.layout-canvas .cl-more .appearance-editor .style-custom-fields input[type=text]{flex:1 1 auto;width:auto;min-width:0;max-width:180px;padding:5px 8px}
body.layout-canvas .cl-more .appearance-editor input[aria-invalid=true]{border-color:var(--cl-bad);outline-color:var(--cl-bad)}
body.layout-canvas .cl-more .style-thickness{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;padding:0 4px}
body.layout-canvas .cl-more .style-number{display:inline-flex;align-items:center;gap:4px}
body.layout-canvas .cl-more .appearance-editor .style-number input{width:72px;padding:5px 6px}
body.layout-canvas .cl-more .style-unit,body.layout-canvas .cl-more .style-hint{font-size:12px;color:var(--cl-muted)}
body.layout-canvas .cl-more .style-hint{margin:0 0 0 4px}
body.layout-canvas .cl-more .style-error{margin:2px 0 0 4px;font-size:12px;color:var(--cl-bad)}
body.layout-canvas .cl-more .style-locked{margin:2px 0 0 4px;font-size:12px;line-height:1.45;color:var(--cl-muted)}
body.layout-canvas .cl-more .style-reveal{min-height:26px;padding:0 8px;font-size:12px;border-radius:6px}
body.layout-canvas .cl-more .style-error[hidden]{display:none}
body.layout-canvas .cl-more .style-warning{margin:2px 0 0 4px;font-size:12px;color:var(--cl-warn)}
body.layout-canvas .cl-more .style-warning[hidden]{display:none}
body.layout-canvas .cl-more .style-preview{display:inline-flex;align-items:center;gap:4px;margin-left:auto;font-weight:400;font-size:12px;color:var(--cl-muted)}
body.layout-canvas .cl-more .style-dot{width:14px;height:14px;border-radius:50%;border:1px solid var(--cl-line);background:var(--swatch,transparent)}
body.layout-canvas .cl-more .style-dot[data-colour=none]{background:linear-gradient(135deg,transparent 45%,var(--cl-bad) 45%,var(--cl-bad) 55%,transparent 55%),var(--cl-canvas)}
body.layout-canvas .cl-more .style-weight{margin-left:2px;font-variant-numeric:tabular-nums}
/* Text under Label: size, B / I / Mono and alignment, as in the text bar. */
body.layout-canvas .cl-more .text-style-group{display:flex;flex-direction:column;gap:6px}
body.layout-canvas .cl-more .text-style-line{grid-column:2/-1;display:flex;flex-wrap:wrap;align-items:center;gap:8px}
body.layout-canvas .cl-more .text-style-faces{display:inline-flex;gap:4px}
body.layout-canvas .cl-more .text-style-toggle{min-width:30px;min-height:30px;padding:0 8px;font-size:13px;border-radius:7px}
body.layout-canvas .cl-more .text-style-toggle[aria-pressed=true]{background:var(--cl-accent-bg);border-color:var(--cl-accent);color:var(--cl-accent-ink)}
body.layout-canvas .cl-more .cl-seg>button svg{width:16px;height:16px;vertical-align:middle;pointer-events:none}
body.layout-canvas .cl-more .text-style-group .style-hint{margin-left:76px}
/* Touch: every swatch and toggle is a 44 px target. Swatches draw a 30 px
   dot inside it and wrap into an even grid. */
@media (pointer:coarse){
  body.layout-canvas .cl-more .style-swatches{display:grid;grid-template-columns:repeat(5,44px);gap:4px}
  body.layout-canvas .cl-more .style-swatch,body.layout-canvas .cl-more button.style-swatch:hover:not(:disabled),
  body.layout-canvas .cl-more button.style-swatch[data-colour=none]:hover:not(:disabled){width:44px;height:44px;min-width:44px;min-height:44px;border:0;background:none;box-shadow:none}
  body.layout-canvas .cl-more .style-swatch::before{content:'';position:absolute;inset:7px;border-radius:50%;border:1px solid var(--cl-field-line);background:var(--swatch,transparent)}
  body.layout-canvas .cl-more .style-swatch[data-colour=none]::before{background:linear-gradient(135deg,transparent calc(50% - 1px),var(--cl-bad) calc(50% - 1px),var(--cl-bad) calc(50% + 1px),transparent calc(50% + 1px)),var(--cl-canvas)}
  body.layout-canvas .cl-more .style-custom::before{background:var(--cl-canvas)}
  body.layout-canvas .cl-more .style-custom svg{position:relative;width:18px;height:18px}
  body.layout-canvas .cl-more .style-swatch[aria-pressed=true]{box-shadow:none}
  body.layout-canvas .cl-more .style-swatch[aria-pressed=true]::before{border-color:var(--cl-accent);box-shadow:0 0 0 2px var(--cl-chip),0 0 0 4px var(--cl-accent)}
  body.layout-canvas .cl-more :is(.cl-seg>button,.text-style-toggle,.style-reveal){min-height:44px;min-width:44px}
  /* Every other inspector control is a 44 px target too. */
  body.layout-canvas .cl-more #inspector :is(button,select,input:not([type=checkbox]):not([type=radio])){min-height:44px;min-width:44px}
  body.layout-canvas .cl-more .appearance-editor .style-custom-fields input[type=color]{width:44px;height:44px}
}
@media (max-width:700px){
  body.layout-canvas .cl-more .text-style-group .style-hint{margin-left:0}
}

body.layout-canvas .cl-context .cl-endpoint-label{font-size:12px;padding:0 2px 0 6px}
body.layout-canvas .cl-context .cl-endpoint-label[hidden]{display:none}

/* Export menu: left-aligned rows */
body.layout-canvas .cl-export{padding:8px}
body.layout-canvas .cl-export>strong{font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--cl-muted);padding:4px 6px}
body.layout-canvas .cl-export button{justify-content:flex-start;border-color:transparent!important}

/* Shortcuts sheet */
body.layout-canvas .cl-help dt{font-family:inherit}
body.layout-canvas .cl-help dt kbd,body.layout-canvas .cl-help dt{font-size:11px}

/* Source drawer */
body.layout-canvas .cl-drawer{border-radius:10px;box-shadow:var(--cl-shadow);background:var(--cl-chip)}
body.layout-canvas .cl-drawer #source{background:var(--cl-canvas);color:var(--cl-ink);border:1px solid var(--cl-line);border-radius:7px;padding:10px;font:12px/1.6 ui-monospace,monospace}
body.layout-canvas .cl-drawer #source:focus-visible{outline:2px solid var(--cl-accent);outline-offset:0}
body.layout-canvas .cl-drawer-head strong{font-size:14px}

/* Dialogs (example picker, edit label) */
body.layout-canvas dialog{background:var(--cl-chip);border:0;border-radius:12px;box-shadow:var(--cl-shadow),0 12px 40px rgba(0,0,0,.25);padding:16px;max-width:min(560px,calc(100vw - 24px));max-height:calc(100dvh - 48px);overflow:auto}
body.layout-canvas dialog::backdrop{background:rgba(1,4,9,.35)}
body.layout-canvas dialog :is(h2){font-size:16px;margin:0}
body.layout-canvas dialog p{color:var(--cl-muted);font-size:12px;margin:8px 0}
body.layout-canvas #example-picker .example-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}
body.layout-canvas #example-picker [data-list]{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:6px;margin:8px 0}
body.layout-canvas #example-picker [data-list] button{justify-content:flex-start}
body.layout-canvas #example-picker [data-list] button[aria-pressed=true],body.layout-canvas #example-picker [data-list] button[aria-selected=true]{background:var(--cl-accent-bg);border-color:var(--cl-accent);color:var(--cl-ink)}
body.layout-canvas #example-picker [data-preview]{background:var(--cl-canvas);border-radius:8px;border:0;min-height:160px}
body.layout-canvas #example-picker .example-actions{display:flex;justify-content:flex-end;gap:8px;align-items:center}
body.layout-canvas .label-dialog{width:min(420px,calc(100vw - 24px))}
body.layout-canvas .label-dialog textarea{width:100%;min-height:72px}
body.layout-canvas .label-dialog :is(.actions,.dialog-actions,div:last-child){display:flex;gap:8px;justify-content:flex-end}

/* Candidate chip and toast */
body.layout-canvas .cl-candidate #preview-accept{color:var(--cl-accent);font-weight:600}
body.layout-canvas .cl-note{border-radius:8px}

@media (max-width:700px){
  /* A bottom sheet with its own scroll: the head stays put while the choices
     scroll under it, and nothing touches the screen edges. */
  /* The inspector is a bottom sheet: full width, rounded top, a grab handle, 45% tall
     and draggable up to 90% (the height is --cl-sheet, set by canvas-layout.js). */
  body.layout-canvas .cl-more{top:auto;bottom:0;left:0;right:0;width:auto;height:var(--cl-sheet,45dvh);max-height:none;box-sizing:border-box;padding:0 14px max(14px,env(safe-area-inset-bottom));
    border-radius:16px 16px 0 0;overscroll-behavior:contain;transition:height .18s ease}
  body.layout-canvas .cl-more.cl-dragging{transition:none}
  /* Undo and zoom ride above the open sheet so they stay reachable. */
  body.layout-canvas:has(.cl-more:not([hidden])) .cl-history{bottom:calc(var(--cl-sheet,45dvh) + 8px)}
  body.layout-canvas:has(.cl-more:not([hidden])) .cl-zoom{bottom:calc(var(--cl-sheet,45dvh) + 8px + var(--cl-zoom-lift,0px))}
  /* A sheet taller than 60% leaves no room for them; they come back when it shrinks or closes. */
  body.layout-canvas.cl-sheet-tall:has(.cl-more:not([hidden])) :is(.cl-history,.cl-zoom){visibility:hidden}
  body.layout-canvas .cl-more .cl-popover-head{top:0;margin:0 -14px 8px;padding:0 6px 8px 14px;flex-wrap:wrap}
  body.layout-canvas .cl-more .cl-grab{display:flex;order:-1;flex:0 0 100%;height:24px;margin:0 8px 0 -14px;padding:0;border:0;background:transparent;align-items:center;justify-content:center;touch-action:none;cursor:grab}
  body.layout-canvas .cl-more .cl-grab::before{content:"";width:40px;height:5px;border-radius:3px;background:var(--cl-line)}
  body.layout-canvas .cl-more .cl-close{min-width:36px;min-height:36px}
  body.layout-canvas .cl-route-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  body.layout-canvas .cl-route-option{min-height:56px!important;font-size:12px!important}
  body.layout-canvas .cl-menu{max-height:calc(100dvh - 190px)}
  body.layout-canvas dialog{padding:12px}
  body.layout-canvas #example-picker [data-list]{grid-template-columns:1fr 1fr}
}
/* Small laptop windows: keep the grid readable without shrinking the labels. */
@media (min-width:701px) and (max-width:860px){
  body.layout-canvas .cl-route-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
}
body.layout-canvas .cl-more .canvas-context-dock{height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important}
body.layout-canvas .cl-more .canvas-context-dock input[type=checkbox]{width:16px}
body.layout-canvas .cl-popover .cl-more .canvas-context-dock input:not([type]),body.layout-canvas .cl-more .canvas-context-dock input:is([type=number],[type=text]){width:72px}
body.layout-canvas #example-picker [data-list] button{white-space:normal;text-align:left;min-width:0}
body.layout-canvas dialog{outline:none}
body.layout-canvas .cl-line-handles .cl-end-handle{pointer-events:all;cursor:move}
body.layout-canvas .cl-line-handles .cl-end-handle:hover{fill:var(--cl-accent)}
.cl-marquee{position:absolute;pointer-events:none;border:1px solid var(--accent,#0969da);background:color-mix(in srgb,var(--accent,#0969da) 12%,transparent);border-radius:2px;z-index:5}

/* On-canvas text editor: sits exactly over the label it edits. */
.cl-inline-text{position:fixed;z-index:40;margin:0;padding:2px 4px;border:1px dashed var(--cl-accent);border-radius:4px;background:transparent;color:var(--cl-ink);text-align:center;resize:none;overflow:hidden;outline:none;box-sizing:border-box;caret-color:var(--cl-accent)}
body.layout-canvas .cl-inline-text:focus-visible{outline:none}
.cl-inline-error{position:fixed;z-index:40;margin:0;padding:6px 8px;box-sizing:border-box;max-width:calc(100vw - 16px);border-radius:6px;background:var(--cl-chip);color:var(--cl-bad);border:1px solid var(--cl-bad);box-shadow:var(--cl-shadow);font-size:13px;line-height:1.35}
/* Text style bar under the selection toolbar. */
body.layout-canvas .cl-textbar{position:fixed;z-index:30;display:flex;align-items:center;gap:2px;padding:4px}
body.layout-canvas .cl-textbar[hidden]{display:none}
body.layout-canvas .cl-textbar .cl-tb{min-width:30px;height:30px;padding:0 6px;border:0;border-radius:6px;background:transparent;color:var(--cl-ink);font:13px/1 system-ui,sans-serif;cursor:pointer}
body.layout-canvas .cl-textbar .cl-tb:hover{background:var(--cl-accent-bg)}
body.layout-canvas .cl-textbar .cl-tb svg{width:18px;height:18px;vertical-align:middle;pointer-events:none}
body.layout-canvas .cl-textbar .cl-tb[aria-pressed=true]{background:var(--cl-accent-bg);color:var(--cl-accent-ink)}
body.layout-canvas .cl-textbar .cl-tb.cl-swatch{flex:0 0 22px;min-width:22px;min-height:22px;max-height:22px;width:22px;height:22px;margin:0 2px;padding:0;border-radius:50%;border:2px solid var(--cl-line)}
body.layout-canvas .cl-textbar .cl-tb.cl-swatch[aria-pressed=true]{border-color:var(--cl-accent);box-shadow:0 0 0 2px var(--cl-accent-bg)}
body.layout-canvas .cl-textbar .cl-tb.cl-swatch:not([data-colour=default]){background:var(--swatch,var(--cl-ink))}
body.layout-canvas .cl-textbar .cl-tb.cl-swatch[data-colour=default]{background:linear-gradient(135deg,var(--cl-ink) 50%,var(--cl-canvas) 50%)}
@media (max-width:700px){body.layout-canvas .cl-textbar{flex-wrap:wrap;max-width:calc(100vw - 16px)}}
/* Touch: every text-bar control is a 44px target; a swatch keeps its 22px
   circle, drawn inside the larger button. */
@media (pointer:coarse){
  body.layout-canvas .cl-textbar{justify-content:center}
  body.layout-canvas .cl-textbar .cl-tb{min-width:44px;height:44px}
  body.layout-canvas .cl-textbar .cl-tb.cl-swatch,body.layout-canvas .cl-textbar .cl-tb.cl-swatch:not([data-colour=default]),body.layout-canvas .cl-textbar .cl-tb.cl-swatch[data-colour=default]{flex:0 0 44px;width:44px;height:44px;min-height:44px;max-height:44px;margin:0;border:0;border-radius:6px;background:transparent;box-shadow:none;position:relative}
  body.layout-canvas .cl-textbar .cl-tb.cl-swatch::before{content:'';position:absolute;inset:11px;border-radius:50%;border:2px solid var(--cl-line);box-sizing:border-box;background:var(--swatch,var(--cl-ink))}
  body.layout-canvas .cl-textbar .cl-tb.cl-swatch[data-colour=default]::before{background:linear-gradient(135deg,var(--cl-ink) 50%,var(--cl-canvas) 50%)}
  body.layout-canvas .cl-textbar .cl-tb.cl-swatch[aria-pressed=true]::before{border-color:var(--cl-accent);box-shadow:0 0 0 2px var(--cl-accent-bg)}
}
/* Selected shapes stay highlighted in the live drag preview. */
body.layout-canvas #diagram .live-drag .cl-live-selected :is(path,polygon,polyline,circle,ellipse,rect,line):not([stroke=transparent]):not([fill=transparent]){stroke:var(--cl-accent)!important}
/* About section in the document menu */
body.layout-canvas .cl-about{margin:4px 0;font-size:12px;color:var(--cl-muted);line-height:1.45}

/* ---- Menu v2: Document, Preferences, Advanced, footer; Changes and Adding popovers ---- */
body.layout-canvas .cl-menu .cl-recent{display:flex;flex-direction:column;gap:2px;max-height:200px;overflow:auto}
body.layout-canvas .cl-menu .cl-recent button{width:100%;justify-content:space-between;gap:12px;border-color:transparent;min-height:30px;font-size:13px}
body.layout-canvas .cl-menu .cl-recent button[aria-current=true]{background:var(--cl-accent-bg);color:var(--cl-accent-ink);border-color:transparent}
body.layout-canvas .cl-recent-name{overflow:hidden;text-overflow:ellipsis;min-width:0}
body.layout-canvas .cl-recent .cl-muted{flex:none}
body.layout-canvas .cl-save-state:not([data-state=error]){display:none}
body.layout-canvas .cl-save-state[data-state=error]{color:var(--cl-bad)}
body.layout-canvas .cl-footer{gap:2px}
body.layout-canvas .cl-footer-links{display:flex;flex-wrap:wrap;gap:2px 4px}
body.layout-canvas .cl-menu .cl-footer-links :is(a,button){border:0;padding:0 6px;min-height:28px;color:var(--cl-accent)}
body.layout-canvas .cl-footer .cl-about{margin:0;font-size:11px}
body.layout-canvas .cl-about a{color:var(--cl-accent);text-decoration:underline}
body.layout-canvas .cl-menu .cl-advanced .cl-row{gap:6px;margin-top:8px}
body.layout-canvas .cl-changes{top:60px;right:12px;width:min(380px,calc(100vw - 24px));max-height:calc(100dvh - 130px)}
body.layout-canvas .cl-changes #queue-list{margin:0;padding-left:18px;font-size:12px}
body.layout-canvas .cl-changes #queue-list:empty,body.layout-canvas .cl-changes #suggestions{display:none}
body.layout-canvas .cl-changes .queue-panel .cl-field-name:has(+ #diff:empty){display:none}
body.layout-canvas .cl-popover #accept:disabled{background:transparent}
body.layout-canvas .cl-adding{top:64px;left:50%;transform:translateX(-50%);width:min(340px,calc(100vw - 24px));max-height:calc(100dvh - 140px);display:flex;flex-direction:column;gap:8px}
body.layout-canvas .cl-adding[hidden]{display:none}
body.layout-canvas .cl-adding .cl-row label{display:flex;gap:6px;align-items:center}
body.layout-canvas .cl-palette .cl-chevron{min-width:22px;padding:2px 0}
body.layout-canvas .cl-palette .cl-chevron svg{width:14px;height:14px}
body.layout-canvas .cl-palette #multi-select{display:none}
@media (pointer:coarse){body.layout-canvas .cl-palette #multi-select{display:inline-flex}}
/* The summary is a button only while there is something to review. */
body.layout-canvas .cl-status button.cl-summary{padding:2px 6px;border-radius:6px;color:var(--cl-ink);text-decoration:underline dotted;text-underline-offset:3px}
body.layout-canvas .cl-status button.cl-summary:disabled{color:var(--cl-muted);text-decoration:none;cursor:default;opacity:1}
body.layout-canvas .cl-zoom .cl-sep{height:18px}
body.layout-canvas .cl-help h3{margin:10px 0 6px}
body.layout-canvas .cl-help dl{margin:0 0 6px}
body.layout-canvas .cl-help dt{white-space:nowrap}
/* Components dialog: same shell as the example picker. */
#components-dialog{width:min(520px,calc(100vw - 24px));max-height:calc(100dvh - 32px);padding:16px;border:1px solid var(--border-strong);overflow:auto;color:inherit;background:var(--bg)}
#components-dialog::backdrop{background:rgb(0 0 0 / .35)}
#components-dialog .example-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}
#components-dialog .cl-components{display:flex!important;flex-direction:column;gap:12px;border:0;padding:0}
#components-dialog .cl-components>summary{display:none}
#components-dialog .cl-component-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:end}
#components-dialog .cl-component-row .cl-field{margin:0}
#components-dialog :is(input,select){width:100%;min-height:32px;box-sizing:border-box;font:inherit}
body.layout-canvas .cl-popover.cl-export button{justify-content:flex-start}
body.layout-canvas .cl-adding{align-items:stretch}
body.layout-canvas .cl-adding .cl-row{justify-content:flex-start}
body.layout-canvas .cl-menu .cl-about .cl-link{display:inline;border:0;padding:0;min-height:0;color:var(--cl-accent);text-decoration:underline}
body.layout-canvas.cl-palette-bottom .cl-adding{top:auto;bottom:var(--cl-chips-bottom,70px);max-height:calc(100dvh - 190px)}
@media (max-width:700px){
  body.layout-canvas .cl-changes{top:110px;max-height:calc(100dvh - 240px)}
}
body.layout-canvas .cl-candidate .cl-check svg{width:16px;height:16px;vertical-align:-3px}
/* Document rename, delete, and the always-present Advanced disclosure. */
body.layout-canvas .cl-doc button.cl-title{font:inherit;font-weight:600;cursor:text;min-height:0;height:auto}
body.layout-canvas .cl-title-input{font:inherit;font-weight:600;width:180px;max-width:200px;padding:2px 6px;margin:0 4px}
body.layout-canvas .cl-menu .cl-recent-row{display:flex;gap:2px;align-items:center}
body.layout-canvas .cl-menu .cl-recent .cl-recent-row>button[data-id]{flex:1;width:auto;min-width:0}
body.layout-canvas .cl-menu .cl-recent .cl-recent-row>button.cl-recent-delete{flex:none;width:30px;min-height:30px;padding:0;justify-content:center;color:var(--cl-muted);border-color:transparent}
body.layout-canvas .cl-menu .cl-recent .cl-recent-delete:hover:not(:disabled){color:var(--cl-bad)}
body.layout-canvas .cl-menu .cl-recent .cl-recent-confirm button{width:auto;justify-content:center;border-color:var(--cl-line)}
body.layout-canvas .cl-menu .cl-recent-confirm{display:flex;flex-direction:column;gap:6px;padding:6px 8px;border:1px solid var(--cl-line);border-radius:8px}
body.layout-canvas .cl-menu .cl-recent-confirm p{margin:0;font-size:12px;line-height:1.4}
body.layout-canvas .cl-menu .cl-recent .cl-recent-confirm button.cl-danger{color:var(--cl-bad)}
body.layout-canvas .cl-export .cl-export-note{margin:0;font-size:12px}
body.layout-canvas .cl-export .cl-export-note[hidden]{display:none}
body.layout-canvas .cl-export button:disabled{opacity:.5}

/* Touch: every chrome control is at least a 44 px target. Undo and zoom
   tighten up on phones so both chips share one row; shortcuts stay in ☰. */
@media (pointer:coarse){
  body.layout-canvas :is(.cl-doc,.cl-palette,.cl-history,.cl-zoom,.cl-status,.cl-context,.cl-candidate,.cl-multi-pill) button,
  body.layout-canvas .cl-palette .cl-chevron{min-width:44px;min-height:44px}
  body.layout-canvas .cl-doc button.cl-title,body.layout-canvas .cl-menu .cl-recent .cl-recent-row>button.cl-recent-delete{min-width:44px;min-height:44px}
  body.layout-canvas :is(.cl-context,.cl-candidate) button{height:auto}
  body.layout-canvas #preview-actions.cl-candidate button{min-height:44px}
}
@media (pointer:coarse) and (max-width:700px){
  body.layout-canvas :is(.cl-history,.cl-zoom){gap:0;padding:2px}
  body.layout-canvas .cl-zoom :is(.cl-sep,[aria-label=Shortcuts]){display:none}
  body.layout-canvas .cl-status{top:72px}
}
/* Theme switcher in the menu's Preferences. */
body.layout-canvas .cl-theme-row{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;min-height:32px}
body.layout-canvas .cl-menu .cl-theme{display:inline-flex}
body.layout-canvas .cl-menu .cl-theme>button{display:inline-flex;align-items:center;gap:5px;width:auto;min-height:30px;padding:0 9px;border-radius:0;margin-left:-1px;font-size:12px;justify-content:center}
body.layout-canvas .cl-menu .cl-theme>button svg{width:15px;height:15px;flex:none}
body.layout-canvas .cl-menu .cl-theme>button:first-child{margin-left:0;border-radius:7px 0 0 7px}
body.layout-canvas .cl-menu .cl-theme>button:last-child{border-radius:0 7px 7px 0}
body.layout-canvas .cl-menu .cl-theme>button[aria-pressed=true]{position:relative;z-index:1;background:var(--cl-accent-bg);border-color:var(--cl-accent);color:var(--cl-accent-ink);font-weight:600}
@media (pointer:coarse){body.layout-canvas .cl-menu .cl-theme>button{min-height:44px}}
