/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * Copyright © 2026 Marcel Rymenhout and IniqDash contributors */
/* ==========================================================================
   Widget Studio (POC) — the editor host only (components/studio/studio.js). Everything is scoped to .wst: nothing here reaches a widget
   outside the Studio, and the widget it shows carries none of it (the selection layer is a sibling of the widget, never inside it).
   ========================================================================== */
.wst { width: min(1400px, 96vw); height: min(900px, 92vh); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 18px;
  background: var(--surface-secondary, #17181c); color: var(--text-primary); font-family: var(--font); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8); overflow: hidden; }
.wst::backdrop { background: rgba(0, 0, 0, .6); }
.wst[open] { display: flex; flex-direction: column; }
.wst__head { display: flex; align-items: center; gap: 6px; min-height: 56px; padding: 8px 12px; border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, .08)); flex-wrap: nowrap; overflow: hidden; }
.wst__title { display: flex; align-items: center; gap: 8px; margin: 0 6px 0 2px; font-size: 15px; font-weight: 700; white-space: nowrap; }
.wst__logo { width: 22px; height: 22px; color: var(--accent, #ff7a1a); }
.wst__tgrp { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-left: 1px solid var(--border-subtle, rgba(255, 255, 255, .08)); min-width: 0; }
.wst__tgrp--doc { flex: 0 1 auto; }
.wst__tgrp--end { margin-left: auto; border-left: 0; gap: 6px; }
.wst__ic { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; }
.wst__ic svg, .wst .iqsg__ic svg, .wst .iqsg__bic svg, .wst .iqsg__pvic svg, .wst .iqsg__tic svg, .wst__sic svg { width: 100%; height: 100%; fill: currentColor; }
.wst__tb { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 9px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text-secondary); font: 600 13px var(--font); cursor: pointer; white-space: nowrap; }
.wst__tb:hover:not(:disabled) { background: var(--surface-tertiary, #26272c); color: var(--text-primary); }
.wst__tb:focus-visible { outline: 2px solid var(--accent, #ff7a1a); outline-offset: 1px; }
.wst__tb:disabled { opacity: .35; cursor: default; }
.wst__tb[aria-pressed="true"] { color: var(--text-primary); background: color-mix(in srgb, var(--accent, #ff7a1a) 18%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #ff7a1a) 55%, transparent) inset; }
.wst__tb--add { color: var(--text-primary); background: color-mix(in srgb, var(--accent, #ff7a1a) 16%, var(--surface-tertiary, #26272c)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #ff7a1a) 45%, transparent) inset; padding: 0 12px 0 10px; }
.wst__tb--add .wst__ic { color: var(--accent, #ff7a1a); }
.wst__tb--sm { height: 30px; min-width: 30px; padding: 0 6px; }
.wst__save { display: inline-flex; align-items: center; gap: 6px; }
.wst__save .wst__ic { width: 17px; height: 17px; }
.wst__name { width: clamp(120px, 16vw, 230px); min-height: 36px; box-sizing: border-box; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-primary);
  padding: 0 10px; font: 600 14px var(--font); text-overflow: ellipsis; }
.wst__name:hover { border-color: var(--border-subtle, rgba(255, 255, 255, .12)); }
.wst__name:focus { outline: none; border-color: var(--accent, #ff7a1a); background: var(--control-well, #0d0d0f); }
.wst__status { flex: 1 1 auto; min-width: 0; margin-left: 8px; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.wst__body { position: relative; flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.wst__col { min-height: 0; min-width: 0; overflow: auto; padding: 12px; }
.wst__col--r { border-left: 1px solid var(--border-subtle, rgba(255, 255, 255, .08)); overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; }
.wst__col--c { position: relative; padding: 0; overflow: hidden; }
.wst__h { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
/* the CANVAS toolbar: arrange (left) · grid and snapping (right) · zoom */
.wst__tools { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 10px; border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, .08));
  background: var(--surface-secondary, #17181c); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.wst__arrange, .wst__aids { display: flex; align-items: center; gap: 2px; flex: none; }
.wst__grow { flex: 1 1 auto; }
.wst__sep { flex: none; width: 1px; height: 20px; margin: 0 4px; background: var(--border-subtle, rgba(255, 255, 255, .1)); }
.wst__tg { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; min-width: 30px; justify-content: center; padding: 0 8px; border-radius: 8px; border: 0; background: transparent;
  color: var(--text-secondary); font: 600 12px var(--font); cursor: pointer; white-space: nowrap; }
.wst__tg .wst__ic { width: 17px; height: 17px; }
.wst__tg:hover:not(:disabled) { background: var(--surface-tertiary, #26272c); color: var(--text-primary); }
.wst__tg[aria-pressed="true"] { color: var(--text-primary); background: color-mix(in srgb, var(--accent, #ff7a1a) 18%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #ff7a1a) 50%, transparent) inset; }
.wst__tg:focus-visible { outline: 2px solid var(--accent, #ff7a1a); outline-offset: 1px; }
.wst__tg--n { min-width: 28px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.wst__seg { display: inline-flex; gap: 1px; padding: 2px; border-radius: 10px; background: var(--control-well, #0d0d0f); }
.wst__seg .wst__tg { min-height: 26px; }
.wst__help { display: inline-grid; place-items: center; width: 28px; height: 28px; color: var(--text-muted); border-radius: 8px; cursor: help; }
.wst__help:focus-visible { outline: 2px solid var(--accent, #ff7a1a); }
.wst__zoom { flex: none; min-width: 48px; text-align: right; font: 600 11.5px var(--font-mono, ui-monospace, monospace); color: var(--text-muted); }
.wst__viewport { position: absolute; inset: 44px 0 0 0; display: grid; place-items: center; overflow: hidden;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--text-primary, #fff) 6%, transparent) 1px, transparent 1px); background-size: 16px 16px; }
.wst__board { position: relative; transform-origin: center; flex: none; }
.wst__board > .stw { position: absolute; inset: 0; }
.wst__layer { position: absolute; inset: 0; z-index: 2; cursor: default; touch-action: none; }
.wst__sel { position: absolute; box-sizing: border-box; outline: calc(1.5px / var(--wst-z, 1)) solid var(--accent, #ff7a1a); outline-offset: 0; cursor: move; }
.wst__tag { position: absolute; left: 0; bottom: 100%; padding: calc(1px / var(--wst-z, 1)) calc(6px / var(--wst-z, 1)); border-radius: calc(6px / var(--wst-z, 1)) calc(6px / var(--wst-z, 1)) 0 0; background: var(--accent, #ff7a1a); color: #000; font-size: calc(11px / var(--wst-z, 1)); font-weight: 700; white-space: nowrap; pointer-events: none; }
.wst__grip { position: absolute; right: calc(-6px / var(--wst-z, 1)); bottom: calc(-6px / var(--wst-z, 1)); width: calc(12px / var(--wst-z, 1)); height: calc(12px / var(--wst-z, 1)); margin: 0; border-radius: 3px; background: var(--accent, #ff7a1a); box-shadow: 0 0 0 calc(2px / var(--wst-z, 1)) #000; cursor: nwse-resize; }
.wst__empty { display: grid; justify-items: center; gap: 12px; color: var(--text-secondary); }
.wst__hint { color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.wst__ptitle { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-width: 0; }
.wst__ptic { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; color: var(--accent, #ff7a1a); background: color-mix(in srgb, var(--accent, #ff7a1a) 14%, transparent); }
.wst__ptt { display: grid; min-width: 0; flex: 1; }
.wst__ptitle code { font-size: 11px; color: var(--text-secondary); }
.wst__ptitle b { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; }
.wst__pname { font-size: 15px; font-weight: 600; color: var(--text-primary); font-family: var(--font-mono, ui-monospace, monospace); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst__box { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.wst__box--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wst__field { display: grid; gap: 4px; min-width: 0; font-size: 11.5px; color: var(--text-secondary); }
.wst__num, .wst__in, .wst__csname, .wst__csfind { width: 100%; min-width: 0; min-height: 34px; box-sizing: border-box; border-radius: 9px; border: 0; background: var(--control-well, #0d0d0f); box-shadow: var(--control-well-shadow);
  color: var(--text-primary); padding: 0 9px; font: 500 13px var(--font); font-variant-numeric: tabular-nums; }
.wst__num:focus-visible, .wst__in:focus-visible, .wst__csname:focus-visible, .wst__csfind:focus-visible { outline: 2px solid var(--accent, #ff7a1a); outline-offset: 1px; }
.wst__acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.wst__acts--end { justify-content: flex-end; margin: 0; }
@media (max-width: 1100px) { .wst__body { grid-template-columns: minmax(0, 1fr) 320px; } .wst__tb--text > span:last-child, .wst__title > span { display: none; } .wst__tb--add > span:last-child { display: inline; } }
@media (max-width: 760px) { .wst__body { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1fr) minmax(200px, 40%); } .wst__col--r { border-left: 0; border-top: 1px solid var(--border-subtle); } .wst__tgrp--doc .wst__name { width: 110px; } }
/* the editing aids (on the selection layer — never inside the widget): the grid (a background in logical px), the smart guides */
.wst__layer[data-grid="on"] { background-image: radial-gradient(circle, color-mix(in srgb, var(--text-primary, #fff) 34%, transparent) calc(.75px / var(--wst-z, 1)), transparent calc(1.05px / var(--wst-z, 1)));
  background-size: var(--wst-grid, 8px) var(--wst-grid, 8px); background-position: calc(var(--wst-grid, 8px) / -2) calc(var(--wst-grid, 8px) / -2); }
.wst__selhost, .wst__guides { position: absolute; inset: 0; pointer-events: none; }
.wst__selhost > * { pointer-events: auto; }
.wst__guide { position: absolute; background: var(--info, #4dabff); pointer-events: none; }
.wst__guide--x { top: 0; bottom: 0; width: calc(1px / var(--wst-z, 1)); transform: translateX(-50%); }
.wst__guide--y { left: 0; right: 0; height: calc(1px / var(--wst-z, 1)); transform: translateY(-50%); }
/* the widget's library metadata · save messages */
.wst__coll { display: grid; gap: 6px; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--text-primary, #fff) 4%, transparent); font-size: 13px; }
.wst__clabel { font-weight: 600; }
.wst__crow, .wst__cnew { display: flex; gap: 6px; align-items: center; }
.wst__cnew[hidden] { display: none; }
.wst__csel, .wst__cname { flex: 1 1 auto; min-width: 0; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-subtle); background: var(--surface-secondary); color: var(--text-primary); font: inherit; }
.wst__cerr { color: var(--danger); min-height: 0; }
.wst__cerr:empty { display: none; }
.wst__chelp { color: var(--text-muted); font-size: 12px; }
.wst__msgs { padding: 6px 16px; border-bottom: 1px solid var(--border-subtle); }
.wst__msgs[hidden] { display: none; }
.wst__msg { margin: 2px 0; font-size: 13px; }
.wst__msg--err { color: var(--danger); }
.wst__msg--warn { color: var(--warning); }
/* the PROPERTY SHEET (a compact inspector): collapsible sections, the box in one row, no card-in-card */
.wst__props .ef-group--acc { margin: 0 0 6px; }
.wst__props .ef-group--acc > .ef-field, .wst__props .ef-group--acc > .wst__box, .wst__props .ef-group--acc > .wst__acts, .wst__props .ef-group--acc > .wst__dprops { margin-top: 8px; }
.wst__props .ef-field input[data-k=wst-cname] { font-family: var(--font-mono, ui-monospace, monospace); }
/* the widget's DATA PROPERTIES: one compact row each */
.wst__dprops { display: grid; gap: 8px; font-size: 13px; }
.wst__prop { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border-subtle); }
.wst__prow { display: flex; gap: 6px; align-items: center; }
.wst__prow > .wst__pf { flex: 1; min-width: 0; }
.wst__pn { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst__pmeta, .wst__pcur { font-size: 12px; color: var(--text-secondary); }
.wst__pcur[data-status="ready"] { color: var(--text-primary); }
.wst__users { font-size: 11px; color: var(--text-secondary); }
.wst__users.is-unused { color: var(--text-muted); font-style: italic; }
.wst__confirm { display: grid; gap: 6px; margin-top: 6px; padding: 8px; border-radius: 8px; background: rgba(255, 90, 90, .08); font-size: 12px; }
.wst__confirm[hidden] { display: none; }
.wst__confirm p { margin: 0; }
.wst__phelp { font-size: 11px; color: var(--text-muted); margin: 0; }
/* the PROPERTY EDITOR (create · edit) */
.wst__peditor { display: grid; gap: 8px; margin: 8px 0; padding: 10px; border-radius: 10px; border: 1px solid var(--accent, #ff7a1a); background: color-mix(in srgb, var(--text-primary, #fff) 3%, transparent); font-size: 13px; }
.wst__ctitle { font-size: 13px; }
.wst__psec { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-top: 2px; }
.wst__pf { display: grid; gap: 3px; }
.wst__pf[hidden] { display: none; }
.wst__pf > span { font-size: 12px; color: var(--text-secondary); }
.wst__peditor input, .wst__peditor select { min-width: 0; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border-subtle); background: var(--surface-secondary); color: var(--text-primary); font: inherit; }
/* the current preview value: design information, not a field */
.wst__pcurrent { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--text-primary, #fff) 5%, transparent); }
.wst__pcl { font-size: 11px; color: var(--text-muted); }
.wst__pcurrent b { font-size: 15px; font-variant-numeric: tabular-nums; }
.wst__pcurrent:not([data-status="ready"]) b { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.wst__pwarn { margin: 0; font-size: 12px; color: var(--warning); }
.wst__pedit { justify-self: start; margin-top: 4px; }
.wst__truth { margin: 6px 0 0; font-size: 12px; color: var(--text-secondary); }
.wst__truth[data-bound="false"] { color: var(--text-muted); font-style: italic; }
/* the LAYERS panel (floating over the canvas) and the ARRANGE tools */
.wst__h--layers { margin-top: 18px; }
.wst__layers { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.wst__lyr { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.wst__lyr.is-sel { background: color-mix(in srgb, var(--accent, #ff7a1a) 14%, transparent); }
.wst__lyr.is-primary { box-shadow: inset 0 0 0 1px var(--accent, #ff7a1a); }
.wst__lyr.is-hidden .wst__lyr-name { opacity: .5; }
.wst__lyr button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.wst__lyr-eye, .wst__lyr-lock { flex: none; width: 24px; height: 28px; border-radius: 6px; color: var(--text-secondary); font-size: 12px; }
.wst__lyr-eye:hover, .wst__lyr-lock:hover { background: var(--surface-tertiary); color: var(--text-primary); }
.wst__lyr-name { flex: 1; min-width: 0; display: grid; text-align: left; padding: 3px 6px; border-radius: 6px; }
.wst__lyr-name b { font-size: 12.5px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--font-mono, ui-monospace, monospace); }
.wst__lyr-name small { font-size: 10.5px; color: var(--text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wst__ar { min-width: 30px; padding: 0 6px; }
.wst__ar:disabled { opacity: .35; cursor: default; }
.wst__sel--also { position: absolute; box-sizing: border-box; outline: calc(1.5px / var(--wst-z, 1)) dashed var(--accent, #ff7a1a); pointer-events: none; }
.wst__sel.is-locked { outline-style: dotted; cursor: default; }
.wst__mlist { margin: 6px 0; padding-left: 18px; font-size: 13px; color: var(--text-secondary); }
.wst__mdi { display: inline-grid; place-items: center; width: 15px; height: 15px; }
.wst__mdi svg { width: 100%; height: 100%; fill: currentColor; }
/* designing only: a hidden element drawn faintly (still selectable) · a spacer's empty room outlined */
.wst__board .stw__c[data-hidden] { visibility: visible; opacity: .28; }
.wst__board .iqel-spacer { outline: 1px dashed color-mix(in srgb, var(--text-muted) 70%, transparent); outline-offset: -1px;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--text-muted) 12%, transparent) 0 6px, transparent 6px 12px); }
.wst__board .stw__c[data-absent] { display: flex; opacity: .28; }
/* the canvas grip: resize the widget's canvas by mouse (bottom-right corner of the board; keeps its screen size at any zoom) */
/* fully OUTSIDE the canvas corner: never over an element (an element's own resize handle at that corner stays reachable) */
.wst__cgrip { position: absolute; left: 100%; top: 100%; width: calc(14px / var(--wst-z, 1)); height: calc(14px / var(--wst-z, 1)); margin: calc(3px / var(--wst-z, 1)) 0 0 calc(3px / var(--wst-z, 1));
  border-radius: 3px; background: var(--ed-ui, #6ea8ff); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); cursor: nwse-resize; z-index: 1; touch-action: none; }

/* ================================================================ the LAYERS panel — floats over the canvas, opened from the toolbar */
.wst__lpanel { position: absolute; left: 10px; top: 54px; bottom: 10px; z-index: 4; width: 240px; display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 14px;
  background: color-mix(in srgb, var(--surface-secondary, #17181c) 94%, transparent); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .8), 0 0 0 1px var(--border-subtle, rgba(255, 255, 255, .08)) inset; backdrop-filter: blur(10px); }
.wst__lpanel[hidden] { display: none; }
.wst__lphead { display: flex; align-items: center; gap: 6px; padding: 0 2px 0 6px; font-size: 13px; }
.wst__lphead b { flex: 1; }
.wst__lpn { font-size: 11px; color: var(--text-muted); padding: 1px 7px; border-radius: 999px; background: var(--surface-tertiary, #26272c); }
.wst__lpanel .wst__layers { overflow: auto; min-height: 0; }
/* ================================================================ PREVIEW: the widget as the dashboard shows it */
.wst[data-preview="on"] .wst__layer { pointer-events: none; background-image: none !important; }
.wst[data-preview="on"] .wst__selhost, .wst[data-preview="on"] .wst__guides, .wst[data-preview="on"] .wst__cgrip { display: none; }
.wst[data-preview="on"] .wst__board .stw__c[data-hidden], .wst[data-preview="on"] .wst__board .stw__c[data-absent] { display: none; }
.wst[data-preview="on"] .wst__board .iqel-spacer { outline: 0; background: none; }
/* ================================================================ the RIGHT panel: nothing selected */
.wst__props { min-width: 0; }
.wst__props :is(input, .wst select, .wst textarea){ max-width: 100%; }
.wst__emptyp { display: grid; justify-items: center; gap: 10px; padding: 26px 8px 12px; text-align: center; }
.wst__emptyic { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; color: var(--accent, #ff7a1a); background: color-mix(in srgb, var(--accent, #ff7a1a) 12%, transparent); }
.wst__emptyic .wst__ic { width: 28px; height: 28px; }
.wst__emptyt { font-size: 15px; }
.wst__emptyp .wst__hint { margin: 0 0 4px; max-width: 280px; }
.wst__emptyacts { display: grid; gap: 8px; width: 100%; max-width: 260px; }
.wst__emptyacts .ed-btn { justify-content: center; gap: 8px; }
.wst__stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; margin-top: 8px; }
.wst__stat { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface-tertiary, #26272c); text-align: left; min-width: 0; }
.wst__stat small { font-size: 11px; color: var(--text-muted); }
.wst__stat b { font-size: 13px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst__link { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; border: 0; background: none; color: var(--accent, #ff7a1a); font: 600 13px var(--font); cursor: pointer; }
/* the ELEMENT ACTION bar: icons, tooltips, active states, a distinct Delete */
.wst__eacts { display: flex; align-items: center; gap: 2px; margin: 0 0 10px; padding: 4px; border-radius: 12px; background: var(--surface-tertiary, #26272c); }
.wst__eact { display: inline-grid; place-items: center; width: 34px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.wst__eact .wst__ic { width: 18px; height: 18px; }
.wst__eact:hover { background: var(--surface-secondary, #17181c); color: var(--text-primary); }
.wst__eact[aria-pressed="true"] { color: var(--accent, #ff7a1a); background: color-mix(in srgb, var(--accent, #ff7a1a) 16%, transparent); }
.wst__eact--danger { color: color-mix(in srgb, var(--danger, #ff5a5a) 85%, var(--text-secondary)); }
.wst__eact--danger:hover { color: var(--danger, #ff5a5a); background: color-mix(in srgb, var(--danger, #ff5a5a) 14%, transparent); }
.wst__eact:focus-visible { outline: 2px solid var(--accent, #ff7a1a); outline-offset: 1px; }
/* section headings: an icon and a count */
.wst__sic { display: inline-grid; width: 16px; height: 16px; margin-right: 6px; color: var(--text-muted); vertical-align: -3px; }
.wst__badge { margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--surface-tertiary, #26272c); text-transform: none; letter-spacing: 0; }
.wst__badge[data-on="true"] { color: #1b1406; background: color-mix(in srgb, var(--accent, #ff7a1a) 85%, #fff); }
/* a labelled row with a switch (visibility) · small labels */
.wst__frow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 4px; min-width: 0; }
.wst__frowt { display: grid; gap: 2px; min-width: 0; }
.wst__frowt b { font-size: 13px; font-weight: 600; }
.wst__frowt small { font-size: 11.5px; line-height: 1.35; color: var(--text-muted); }
.wst__frow .ef-switch { flex: none; }
.wst__flabel { display: block; margin: 12px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.wst__field--row { grid-template-columns: minmax(0, 1fr) 90px; align-items: center; gap: 10px; margin-top: 12px; }
.wst__field--row > span { display: grid; gap: 2px; }
.wst__field--row b { font-size: 13px; color: var(--text-primary); font-weight: 600; }
.wst__field--row small { font-size: 11.5px; color: var(--text-muted); line-height: 1.35; }
/* a segmented choice (Show: Always · With data · With a tab) */
.wst__segc { display: flex; gap: 2px; padding: 3px; margin: 4px 0 8px; border-radius: 12px; background: var(--control-well, #0d0d0f); box-shadow: var(--control-well-shadow); }
.wst__segb { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px; padding: 0 6px; border: 0; border-radius: 9px; background: transparent;
  color: var(--text-secondary); font: 600 12px var(--font); cursor: pointer; white-space: nowrap; overflow: hidden; }
.wst__segb .wst__ic { width: 16px; height: 16px; }
.wst__segb[aria-pressed="true"] { color: var(--text-primary); background: var(--surface-tertiary, #26272c); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #ff7a1a) 55%, transparent) inset; }
.wst__segb[aria-pressed="true"] .wst__ic { color: var(--accent, #ff7a1a); }
.wst__segb:disabled { opacity: .4; cursor: default; }
.wst__segb:focus-visible { outline: 2px solid var(--accent, #ff7a1a); outline-offset: 1px; }
.wst [data-k=wst-showwhen][hidden] { display: none; }
/* OPTION CARDS (On tap · dashboard sizing): a radio group of described choices */
.wst__choice { display: grid; gap: 6px; margin: 0 0 8px; }
.wst__choice--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wst__opt { display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 10px; border: 0; border-radius: 12px; background: var(--surface-tertiary, #26272c); color: var(--text-secondary); text-align: left; font: inherit; cursor: pointer;
  box-shadow: 0 0 0 1px var(--border-subtle, rgba(255, 255, 255, .08)) inset; }
.wst__opt > span:not(.wst__ic) { display: grid; gap: 2px; min-width: 0; }
.wst__opt b { font-size: 13px; color: var(--text-primary); }
.wst__opt small { font-size: 11.5px; line-height: 1.35; color: var(--text-muted); }
.wst__opt .wst__ic { margin-top: 1px; color: var(--text-muted); }
.wst__opt:hover:not(:disabled) { box-shadow: 0 0 0 1px color-mix(in srgb, var(--text-primary, #fff) 20%, transparent) inset; }
.wst__opt[aria-checked="true"] { box-shadow: 0 0 0 1.5px var(--accent, #ff7a1a) inset; background: color-mix(in srgb, var(--accent, #ff7a1a) 10%, var(--surface-tertiary, #26272c)); }
.wst__opt[aria-checked="true"] .wst__ic { color: var(--accent, #ff7a1a); }
.wst__opt:disabled { opacity: .45; cursor: default; }
.wst__opt:focus-visible { outline: 2px solid var(--accent, #ff7a1a); outline-offset: 1px; }
.wst__tapp { display: grid; gap: 4px; margin: 0 0 8px; }
.wst__tapp[hidden] { display: none; }
/* PINS: two labelled dropdowns side by side */
.wst__pins { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wst__pin { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 6px; min-width: 0; font-size: 11.5px; color: var(--text-secondary); }
.wst__pin .wst__ic { width: 15px; height: 15px; color: var(--text-muted); }
.wst__pin select { grid-column: 1 / -1; }
/* CUSTOMIZE EACH COPY */
.wst__csbody { display: grid; gap: 10px; margin-top: 8px; }
.wst__csg { display: grid; gap: 4px; }
.wst__csgh { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin: 2px 0; }
.wst__csg--on .wst__csgh { color: var(--accent, #ff7a1a); }
.wst__cs { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 8px; padding: 4px 4px 4px 10px; border-radius: 10px; background: var(--surface-tertiary, #26272c); }
.wst__cs.is-on { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #ff7a1a) 55%, transparent) inset; }
.wst__cst { display: grid; min-width: 0; }
.wst__cst b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst__cst small { font-size: 11px; color: var(--text-muted); }
.wst__cs .ef-switch { height: 34px; }
.wst__cs .ef-switch::before { top: 5px; bottom: 5px; }
.wst__cs .ef-switch__k { top: 9px; }
.wst__csn { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; padding: 0 6px 6px 0; font-size: 11.5px; color: var(--text-muted); }
.wst__csmore { border-radius: 10px; }
.wst__csmore > summary { cursor: pointer; padding: 6px 2px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); list-style: none; }
.wst__csmore > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--text-muted); }
.wst__csmore[open] > summary::before { content: "▾"; }
.wst__csmore > .wst__csfind { margin: 2px 0 8px; }
.wst__csmore .wst__csg { margin-bottom: 8px; }
/* WHEN rules: one card per rule, one line per step */
.wst__rule { display: grid; gap: 6px; margin: 8px 0; padding: 8px; border-radius: 12px; background: var(--surface-tertiary, #26272c); font-size: 12px; color: var(--text-secondary); }
.wst__rrow { display: flex; align-items: center; gap: 6px; min-width: 0; }
.wst__rrow > select, .wst__rrow > input { flex: 1 1 0; min-width: 0; }
.wst__rw { flex: none; width: 34px; font-weight: 600; color: var(--text-muted); }
.wst__when .ed-btn { gap: 6px; }
/* the property editor's controls in the design system */
.wst__peditor select { -webkit-appearance: none; appearance: none; padding-right: 30px;
  background: var(--control-well, #0d0d0f) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%239aa0ab' d='M7.4 8.6 12 13.2l4.6-4.6L18 10l-6 6-6-6z'/%3E%3C/svg%3E") no-repeat right 8px center / 16px 16px; border: 0; box-shadow: var(--control-well-shadow); }
.wst__peditor input { border: 0; background: var(--control-well, #0d0d0f); box-shadow: var(--control-well-shadow); }

/* ================================================================ WIDGET SETTINGS (a popup over the editor) */
.wst__wswrap { position: absolute; inset: 56px 0 0 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, .5); backdrop-filter: blur(2px); }
.wst__ws { width: min(920px, 100%); height: min(760px, 100%); display: flex; flex-direction: column; border-radius: 18px; background: var(--surface-secondary, #17181c); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .9), 0 0 0 1px var(--border-subtle, rgba(255, 255, 255, .08)) inset; overflow: hidden; }
.wst__wshead { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, .08)); }
.wst__wsic { width: 26px; height: 26px; color: var(--accent, #ff7a1a); }
.wst__wst { flex: 1; min-width: 0; display: grid; }
.wst__wst h3 { margin: 0; font-size: 16px; }
.wst__wstn { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst__wsmain { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px minmax(0, 1fr); }
.wst__wsnav { display: grid; align-content: start; gap: 2px; padding: 12px 8px; border-right: 1px solid var(--border-subtle, rgba(255, 255, 255, .08)); overflow: auto; }
.wst__wsnb { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text-secondary); font: 600 13px var(--font); text-align: left; cursor: pointer; }
.wst__wsnb:hover, .wst__wsnb[aria-current="true"] { background: var(--surface-tertiary, #26272c); color: var(--text-primary); }
.wst__wsnb .wst__ic { width: 17px; height: 17px; color: var(--text-muted); }
.wst__wsbody { overflow-y: auto; overflow-x: hidden; padding: 6px 20px 30px; scroll-padding-top: 8px; }
.wst__wss { padding: 14px 0 6px; border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, .06)); }
.wst__wss:last-child { border-bottom: 0; }
.wst__wssh { margin: 0 0 4px; font-size: 15px; }
.wst__wssi { margin: 0 0 10px; font-size: 12.5px; line-height: 1.45; color: var(--text-muted); max-width: 640px; }
.wst__wsbody .wst__wmeta { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.wst__wsbody .wst__coll { background: var(--surface-tertiary, #26272c); }
.wst__canvasset { display: grid; gap: 2px; max-width: 640px; }
.wst__canvasset .wst__choice { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wst__appear { display: grid; gap: 8px; max-width: 640px; }
.wst__bglist { display: grid; gap: 6px; }
.wst__bgrow { display: flex; align-items: center; justify-content: flex-start; width: 100%; gap: 10px; padding: 10px; border: 0; border-radius: 12px; background: var(--surface-tertiary, #26272c); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.wst__bgrow > span:not(.wst__ic) { flex: 1; display: grid; justify-items: start; min-width: 0; text-align: left; }
.wst__bgrow small { color: var(--text-muted); font-size: 11.5px; }
.wst__bgrow:hover { box-shadow: 0 0 0 1px var(--accent, #ff7a1a) inset; }
.wst__src { display: grid; gap: 6px; margin: 8px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-tertiary, #26272c); }
.wst__srch { display: flex; align-items: center; gap: 8px; }
.wst__srch .wst__ic { color: var(--accent, #ff7a1a); }
.wst__chip { padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--text-secondary); background: var(--surface-secondary, #17181c); }
.wst__srcdl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 12px; margin: 0; font-size: 12px; }
.wst__srcdl dt { color: var(--text-muted); }
.wst__srcdl dd { margin: 0; color: var(--text-secondary); overflow-wrap: anywhere; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px; }
.wst__srcopt { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wst__srcopt > span { display: grid; }
.wst__srcopt b { font-size: 13px; }
.wst__srcreq { font-size: 11.5px; color: var(--text-muted); }
@media (max-width: 760px) { .wst__wsmain { grid-template-columns: 1fr; } .wst__wsnav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border-subtle); padding: 6px; } .wst__wsnb { flex: none; } }
/* unsaved changes: Save · Discard · Cancel */
.wst__ask-wrap { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, .55); }
.wst__ask { width: min(440px, 92%); display: grid; gap: 10px; padding: 18px; border-radius: 16px; background: var(--surface-secondary, #17181c); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .9), 0 0 0 1px var(--border-subtle) inset; }
.wst__askh { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.wst__askh .wst__ic { color: var(--accent, #ff7a1a); }
.wst__ask p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }

/* ================================================================ THE GALLERY (components/studio/gallery.js): Add element · Open a widget */
.wst .iqsg-wrap{ position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 22px; background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.wst .iqsg-wrap.is-dragging{ opacity: 0; pointer-events: none; }
.wst .iqsg{ width: min(1040px, 100%); height: min(780px, 100%); display: flex; flex-direction: column; gap: 10px; padding: 16px 18px 0; border-radius: 18px; background: var(--surface-secondary, #17181c);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .9), 0 0 0 1px var(--border-subtle, rgba(255, 255, 255, .08)) inset; overflow: hidden; }
.wst .iqsg__head{ display: flex; align-items: flex-start; gap: 12px; }
.wst .iqsg__ttl{ flex: 1; min-width: 0; }
.wst .iqsg__ttl h3{ margin: 0; font-size: 18px; }
.wst .iqsg__ttl p{ margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.wst .iqsg__hacts{ display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.wst .iqsg__hacts .ed-btn{ display: inline-flex; align-items: center; gap: 6px; }
.wst .iqsg__bic{ display: inline-grid; width: 16px; height: 16px; }
.wst .iqsg__x{ display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.wst .iqsg__x:hover{ background: var(--surface-tertiary, #26272c); color: var(--text-primary); }
.wst .iqsg__x .wst__ic, .wst .iqsg__x .iqsg__ic{ width: 20px; height: 20px; }
.wst .iqsg__ic{ display: inline-grid; place-items: center; width: 18px; height: 18px; }
.wst .iqsg__tools{ display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wst .iqsg__search{ flex: 1 1 240px; min-width: 0; min-height: 40px; padding: 0 14px; border: 0; border-radius: 12px; font: 500 14px var(--font); color: var(--text-primary); background: var(--control-well, #0d0d0f); box-shadow: var(--control-well-shadow); }
.wst .iqsg__search:focus-visible{ outline: 2px solid var(--accent, #ff7a1a); outline-offset: 1px; }
.wst .iqsg__tools select.iqsg__sel{ width: auto; flex: 0 1 220px; max-width: 220px; min-height: 40px; }
.wst .iqsg__views{ display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--control-well, #0d0d0f); }
.wst .iqsg__vb{ display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.wst .iqsg__vb[aria-pressed="true"]{ background: var(--surface-tertiary, #26272c); color: var(--accent, #ff7a1a); }
.wst .iqsg__chips{ display: flex; flex-wrap: wrap; gap: 6px; }
.wst .iqsg__chip{ min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--surface-tertiary, #26272c); color: var(--text-secondary); font: 600 12.5px var(--font); cursor: pointer; }
.wst .iqsg__chip:hover{ color: var(--text-primary); }
.wst .iqsg__chip[aria-pressed="true"]{ color: #1b1406; background: color-mix(in srgb, var(--accent, #ff7a1a) 88%, #fff); }
.wst .iqsg__chip:focus-visible, .wst .iqsg__vb:focus-visible, .wst .iqsg__card:focus-visible{ outline: 2px solid var(--accent, #ff7a1a); outline-offset: 2px; }
.wst .iqsg__body{ flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 2px 18px; }
.wst .iqsg__grp{ margin: 6px 0 14px; }
.wst .iqsg__gh{ display: flex; align-items: baseline; gap: 8px; margin: 4px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.wst .iqsg__gh small{ font-weight: 600; color: var(--text-muted); opacity: .7; }
.wst .iqsg__grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.wst .iqsg__card{ position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 8px; border: 0; border-radius: 14px; background: var(--surface-tertiary, #26272c); color: inherit; text-align: left; font: inherit; cursor: pointer;
  box-shadow: 0 0 0 1px var(--border-subtle, rgba(255, 255, 255, .06)) inset; transition: box-shadow var(--dur-fast, .12s), transform var(--dur-fast, .12s); }
.wst .iqsg__card:hover{ box-shadow: 0 0 0 1.5px var(--accent, #ff7a1a) inset; transform: translateY(-1px); }
.wst .iqsg__card.is-current{ box-shadow: 0 0 0 2px var(--accent, #ff7a1a) inset; }
.wst .iqsg__pv{ position: relative; display: grid; place-items: center; height: 110px; border-radius: 10px; overflow: hidden; color: var(--text-muted);
  background: radial-gradient(circle, rgba(255, 255, 255, .05) 1px, transparent 1px) 0 0 / 12px 12px, var(--control-well, #0d0d0f); }
.wst .iqsg__pvic{ width: 34px; height: 34px; opacity: .6; }
.wst .iqsg__pv[data-drawn] .iqsg__pvic{ display: none; }
.wst .iqsg__pic{ pointer-events: none; }
.wst .iqsg__t{ display: grid; gap: 2px; min-width: 0; padding: 0 2px 2px; }
.wst .iqsg__nm{ display: flex; align-items: center; gap: 6px; min-width: 0; }
.wst .iqsg__nm b{ font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst .iqsg__tic{ flex: none; width: 16px; height: 16px; color: var(--accent, #ff7a1a); }
.wst .iqsg__sub{ font-size: 11.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wst .iqsg__desc{ font-size: 11.5px; line-height: 1.35; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wst .iqsg__badges{ display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.wst .iqsg__badge{ padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600; color: var(--text-muted); background: var(--surface-secondary, #17181c); }
.wst .iqsg__badge--cur{ color: #1b1406; background: color-mix(in srgb, var(--accent, #ff7a1a) 88%, #fff); }
.wst .iqsg__none{ padding: 30px; text-align: center; color: var(--text-muted); }
/* list view: a row per card */
.wst .iqsg__body[data-view="list"] .iqsg__grid{ grid-template-columns: 1fr; gap: 6px; }
.wst .iqsg__body[data-view="list"] .iqsg__card{ flex-direction: row; align-items: center; }
.wst .iqsg__body[data-view="list"] .iqsg__pv{ flex: none; width: 96px; height: 64px; }
.wst .iqsg__body[data-view="list"] .iqsg__t{ flex: 1; }
.wst .iqsg__body[data-view="list"] .iqsg__desc{ -webkit-line-clamp: 1; }
/* the Add element gallery: shorter previews of the elements' real look */
.wst [data-k=wst-gallery] .iqsg__grid{ grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.wst [data-k=wst-gallery] .iqsg__pv{ height: 92px; }
@media (max-width: 760px) { .wst .iqsg-wrap{ padding: 8px; } .wst .iqsg{ padding: 12px 12px 0; } .wst .iqsg__grid{ grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } .wst .iqsg__hacts .ed-btn span{ display: none; } }
.wst__crow > .ed-btn { flex: none; white-space: nowrap; }
.wst.has-layers .wst__viewport { left: 258px; }
/* Layers: drag a row to change the layer order (the list is drawn top first) */
.wst__lyr[draggable="true"] { cursor: grab; }
.wst__lyr.is-dragging { opacity: .45; }
.wst__lyr.is-drop-above { box-shadow: 0 -2px 0 0 var(--ed-ui, #6ea8ff); }
.wst__lyr.is-drop-below { box-shadow: 0 2px 0 0 var(--ed-ui, #6ea8ff); }
/* MODES (Widget settings → Entity bindings): name · watched property · default words · remove */
.wst__modes { display: grid; gap: 8px; margin-top: 12px; }
.wst__mode { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 6px; align-items: center; }
@media (max-width: 700px) { .wst__mode { grid-template-columns: 1fr 1fr; } }
