/* ===========================================================
   Site editor (sites.html) — the on-canvas website editor.
   js/builder-shell.js (canvas, selection, inline editing, toolbars,
   sections, undo, save) + js/builder-shell-panels.js (the one side
   panel, the add-section gallery, dialogs).

   Only sites.html loads this file. The CV / Quote / Invoice shells keep
   using css/builder-shell.css as before; everything here is scoped to
   .bsx (the site editor root) or uses bsx- class names, so nothing
   leaks into those pages. Logical properties throughout (RTL + LTR).
   =========================================================== */

.bsx {
  --bsx-accent: #14B8A6;
  --bsx-accent-dark: #0F766E;
  --bsx-accent-soft: #CCFBF1;
  --bsx-ink: #0F172A;
  --bsx-text: #1F2937;
  --bsx-muted: #64748B;
  --bsx-line: #E2E8F0;
  --bsx-line-strong: #CBD5E1;
  --bsx-surface: #FFFFFF;
  --bsx-stage: #EEF2F6;
  --bsx-danger: #DC2626;
  --bsx-radius: 12px;
  --bsx-shadow: 0 10px 30px -8px rgba(15, 23, 42, .22), 0 2px 6px rgba(15, 23, 42, .06);
  --bsx-top-h: 56px;
  --bsx-panel-w: 340px;
  --bsx-ease: cubic-bezier(.2, .7, .2, 1);
  font-family: 'Heebo', Arial, sans-serif;
  color: var(--bsx-text);
}
.bsx.active { background: var(--bsx-stage); }
.bsx *, .bsx *::before, .bsx *::after { box-sizing: border-box; }
.bsx svg { width: 18px; height: 18px; flex: none; display: block; }
.bsx [hidden] { display: none !important; }
.bsx button { font-family: inherit; }
.bsx :focus-visible { outline: 2px solid var(--bsx-accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.bsx-icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--bsx-text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  transition: background .15s var(--bsx-ease), color .15s var(--bsx-ease), border-color .15s var(--bsx-ease);
}
.bsx-icon-btn:hover:not(:disabled) { background: #F1F5F9; }
.bsx-icon-btn:disabled { opacity: .35; cursor: default; }
.bsx-icon-btn.is-on { background: var(--bsx-accent-soft); color: var(--bsx-accent-dark); }
.bsx-icon-btn-sm { width: 30px; height: 30px; border-radius: 8px; }
.bsx-icon-btn-sm svg { width: 16px; height: 16px; }
.bsx-btn {
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--bsx-line); background: var(--bsx-surface);
  color: var(--bsx-text); font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .15s var(--bsx-ease), border-color .15s var(--bsx-ease), color .15s var(--bsx-ease), box-shadow .15s var(--bsx-ease);
}
.bsx-btn:hover:not(:disabled) { border-color: var(--bsx-line-strong); background: #F8FAFC; }
.bsx-btn:disabled { opacity: .5; cursor: default; }
.bsx-btn-ghost { border-color: transparent; background: transparent; }
.bsx-btn-ghost:hover:not(:disabled) { background: #F1F5F9; border-color: transparent; }
.bsx-btn-ghost.is-on { background: var(--bsx-accent-soft); color: var(--bsx-accent-dark); }
.bsx-btn-primary { background: var(--bsx-accent); border-color: var(--bsx-accent); color: #fff; font-weight: 700; }
.bsx-btn-primary:hover:not(:disabled) { background: var(--bsx-accent-dark); border-color: var(--bsx-accent-dark); }
.bsx-btn-danger { color: var(--bsx-danger); }
.bsx-btn-danger.bsx-btn-solid { background: var(--bsx-danger); border-color: var(--bsx-danger); color: #fff; }
.bsx-btn-block { width: 100%; justify-content: center; }
.bsx-btn svg { width: 16px; height: 16px; }

/* ---------- top bar ---------- */
.bsx-top {
  height: var(--bsx-top-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--bsx-surface); border-bottom: 1px solid var(--bsx-line); position: relative; z-index: 40;
}
.bsx-top-start, .bsx-top-end { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bsx-top-start { flex: 1 1 0; }
.bsx-top-end { flex: 1 1 0; justify-content: flex-end; }
.bsx-top-center { display: flex; align-items: center; gap: 10px; flex: none; }
.bsx-group { display: flex; gap: 2px; }
.bsx-back {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 8px; border-radius: 10px;
  color: var(--bsx-muted); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.bsx-back:hover { background: #F1F5F9; color: var(--bsx-text); }
.bsx-top-sep { width: 1px; height: 22px; background: var(--bsx-line); flex: none; }
.bsx-name { font-weight: 700; font-size: 14.5px; color: var(--bsx-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 220px; }
.bsx-status { display: flex; align-items: center; gap: 4px; min-width: 0; }
.bsx .bshell-top-status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--bsx-muted);
  white-space: nowrap; padding: 3px 9px 3px 8px; border-radius: 999px;
}
.bsx .bshell-top-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; flex: none; }
.bsx .bshell-top-status:empty { display: none; }
.bsx .bshell-top-status.saved { color: #15803D; background: #F0FDF4; }
.bsx .bshell-top-status.saving { color: #B45309; background: #FFFBEB; }
.bsx .bshell-top-status.failed { color: var(--bsx-danger); background: #FEF2F2; }
.bsx-status-retry { border: none; background: none; color: var(--bsx-danger); font-weight: 700; font-size: 12.5px; text-decoration: underline; cursor: pointer; padding: 0 4px; }
.bsx-devices { display: flex; gap: 2px; background: #F1F5F9; border-radius: 10px; padding: 3px; }
.bsx .bshell-device-btn {
  width: 34px; height: 30px; border-radius: 8px; border: none; background: transparent; color: var(--bsx-muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.bsx .bshell-device-btn.active { background: var(--bsx-surface); color: var(--bsx-accent-dark); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.bsx .bshell-device-btn svg { width: 17px; height: 17px; }
.bsx-menu-wrap { position: relative; }
html[dir="ltr"] .bsx [data-flip] svg, html[dir="ltr"] .bsx-back svg { transform: scaleX(-1); }

/* dropdown menu (top bar "more", toolbar popovers) */
.bsx-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 230px; background: var(--bsx-surface);
  border: 1px solid var(--bsx-line); border-radius: 12px; box-shadow: var(--bsx-shadow); padding: 6px; z-index: 60;
  animation: bsx-pop .14s var(--bsx-ease);
}
.bsx-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; text-align: start; cursor: pointer;
  padding: 9px 10px; border-radius: 8px; font-size: 13.5px; color: var(--bsx-text); font-weight: 500; text-decoration: none;
}
.bsx-menu-item:hover, .bsx-menu-item:focus-visible { background: #F1F5F9; outline: none; }
.bsx-menu-item svg { width: 17px; height: 17px; color: var(--bsx-muted); }
.bsx-menu-sep { height: 1px; background: var(--bsx-line); margin: 5px 4px; }

/* AI helper + help popovers */
.bsx .bsx-ai-panel {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; inset-inline-start: auto; width: 320px; margin: 0;
  background: var(--bsx-surface); border: 1px solid var(--bsx-line); border-radius: 14px; padding: 14px; box-shadow: var(--bsx-shadow); z-index: 61;
}
.bsx-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.bsx .bsx-ai-panel input[type="text"] { width: 100%; padding: 10px 12px; border: 1px solid var(--bsx-line); border-radius: 10px; font: inherit; font-size: 14px; margin-bottom: 6px; }
.bsx-help {
  position: fixed; z-index: 62; width: 300px; max-width: calc(100vw - 24px); background: var(--bsx-surface); border: 1px solid var(--bsx-line);
  border-radius: 14px; box-shadow: var(--bsx-shadow); padding: 16px 16px 12px; animation: bsx-pop .14s var(--bsx-ease);
}
.bsx-help h3 { margin: 0 0 10px; font-size: 15px; color: var(--bsx-ink); }
.bsx-help ol { margin: 0; padding-inline-start: 18px; display: grid; gap: 7px; font-size: 13px; line-height: 1.5; color: var(--bsx-text); }
.bsx-help kbd { font-family: inherit; font-size: 11.5px; background: #F1F5F9; border: 1px solid var(--bsx-line); border-radius: 5px; padding: 0 5px; }

/* ---------- body: stage + panel ---------- */
.bsx-body { flex: 1; display: flex; min-height: 0; position: relative; }
.bsx-stage { flex: 1; min-width: 0; position: relative; overflow: hidden; background: var(--bsx-stage); }
.bsx-canvas-area { position: absolute; inset: 0; display: flex; justify-content: center; padding: 20px 24px 84px; }
.bsx .bsx-holder { width: 100%; max-width: 1440px; height: 100%; transition: max-width .25s var(--bsx-ease); }
.bsx .bsx-holder.device-tablet { max-width: 768px; }
.bsx .bsx-holder.device-mobile { max-width: 390px; }
.bsx .bsx-frame { position: relative; height: 100%; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 12px 32px -10px rgba(15,23,42,.18); }
.bsx .bshell-canvas-iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.bsx .bshell-canvas-iframe.bshell-canvas-buffer { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.bsx-preview-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }

/* The single side panel (inline-end). The stage shrinks next to it, so
   it never covers the site. */
.bsx-panel {
  width: var(--bsx-panel-w); flex: none; background: var(--bsx-surface); border-inline-start: 1px solid var(--bsx-line);
  display: flex; flex-direction: column; min-height: 0; animation: bsx-slide-in .2s var(--bsx-ease); z-index: 30;
}
.bsx-panel-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--bsx-line); }
.bsx-panel-title { flex: 1; margin: 0; font-size: 15px; font-weight: 700; color: var(--bsx-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bsx-panel-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 16px; }
.bsx-pgroup { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--bsx-line); }
.bsx-pgroup:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.bsx-pgroup-title { font-size: 12px; font-weight: 700; color: var(--bsx-muted); letter-spacing: .02em; margin: 0 0 12px; }
.bsx-field { margin-bottom: 14px; }
.bsx-field:last-child { margin-bottom: 0; }
.bsx-label { display: block; font-size: 12.5px; font-weight: 600; color: #475569; margin-bottom: 6px; }
.bsx-hint { font-size: 12px; color: var(--bsx-muted); line-height: 1.5; margin: 6px 0 0; }
.bsx-note-global { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--bsx-accent-dark); background: #F0FDFA; border: 1px solid #CCFBF1; border-radius: 8px; padding: 6px 9px; margin: 0 0 12px; }
.bsx-note-global svg { width: 14px; height: 14px; }
.bsx-input, .bsx-panel-body input[type="text"], .bsx-panel-body input[type="url"], .bsx-panel-body input[type="number"], .bsx-panel-body textarea, .bsx-panel-body select {
  width: 100%; height: 38px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--bsx-line-strong); background: #fff;
  font: inherit; font-size: 14px; color: var(--bsx-ink); transition: border-color .15s var(--bsx-ease), box-shadow .15s var(--bsx-ease);
}
.bsx-panel-body textarea { height: auto; min-height: 96px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
.bsx-input:focus, .bsx-panel-body input:focus, .bsx-panel-body textarea:focus, .bsx-panel-body select:focus { outline: none; border-color: var(--bsx-accent); box-shadow: 0 0 0 3px rgba(20,184,166,.18); }
.bsx-panel-body input[type="color"] { width: 44px; height: 38px; padding: 3px; border-radius: 9px; border: 1px solid var(--bsx-line-strong); background: #fff; cursor: pointer; }
.bsx-row { display: flex; align-items: center; gap: 8px; }
.bsx-row > .bsx-grow { flex: 1; min-width: 0; }
.bsx-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; cursor: pointer; font-size: 13.5px; font-weight: 500; }
.bsx-toggle input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--bsx-line-strong); position: relative; cursor: pointer; flex: none; transition: background .15s var(--bsx-ease); margin: 0; }
.bsx-toggle input::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: inset-inline-start .15s var(--bsx-ease); }
.bsx-toggle input:checked { background: var(--bsx-accent); }
.bsx-toggle input:checked::after { inset-inline-start: 18px; }
.bsx-seg { display: flex; background: #F1F5F9; border-radius: 9px; padding: 3px; gap: 2px; }
.bsx-seg button { flex: 1; border: none; background: transparent; height: 32px; border-radius: 7px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: #475569; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 6px; }
.bsx-seg button.is-on { background: #fff; color: var(--bsx-accent-dark); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.bsx-seg button svg { width: 16px; height: 16px; }
.bsx-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.bsx-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--bsx-line-strong); cursor: pointer; padding: 0; }
.bsx-swatch.is-on { box-shadow: 0 0 0 2px var(--bsx-accent-dark); }
.bsx-palette-strip { display: flex; border-radius: 10px; overflow: hidden; height: 34px; border: 1px solid var(--bsx-line); }
.bsx-palette-strip span { flex: 1; }
.bsx-list { display: grid; gap: 6px; }
.bsx-list-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--bsx-line); border-radius: 10px; background: #fff;
  font-size: 13.5px; min-height: 44px; transition: border-color .15s var(--bsx-ease), background .15s var(--bsx-ease), transform .15s var(--bsx-ease);
}
.bsx-list-row.is-selected { border-color: var(--bsx-accent); background: #F0FDFA; }
.bsx-list-row.is-hidden .bsx-list-name { color: var(--bsx-muted); text-decoration: line-through; text-decoration-color: rgba(100,116,139,.5); }
.bsx-list-row.is-fixed { background: #F8FAFC; }
.bsx-list-row.is-dragging { opacity: .45; }
.bsx-list-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; cursor: pointer; border: none; background: none; text-align: start; padding: 0; color: inherit; font: inherit; font-weight: 600; }
.bsx-grip { cursor: grab; color: #94A3B8; display: inline-flex; touch-action: none; border: none; background: none; padding: 2px; border-radius: 6px; }
.bsx-grip:active { cursor: grabbing; }
.bsx-tag { font-size: 11px; font-weight: 700; color: var(--bsx-muted); background: #F1F5F9; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.bsx-list-drop { height: 3px; border-radius: 3px; background: var(--bsx-accent); margin: -1px 0; }
.bsx-thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bsx-thumb { position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden; border: 2px solid transparent; background: #F1F5F9; padding: 0; cursor: pointer; }
.bsx-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bsx-thumb.is-on { border-color: var(--bsx-accent); }
.bsx-thumb-x { position: absolute; top: 4px; inset-inline-end: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(15,23,42,.7); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.bsx-thumb-x svg { width: 12px; height: 12px; }
.bsx-focal { display: grid; grid-template-columns: repeat(3, 1fr); width: 120px; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; border: 1px solid var(--bsx-line-strong); background-size: cover; background-position: center; }
.bsx-focal button { border: none; background: rgba(255,255,255,.08); cursor: pointer; position: relative; padding: 0; }
.bsx-focal button::after { content: ""; position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: rgba(255,255,255,.75); box-shadow: 0 0 0 1px rgba(15,23,42,.35); }
.bsx-focal button.is-on::after { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: var(--bsx-accent); box-shadow: 0 0 0 2px #fff; }
.bsx-empty { text-align: center; color: var(--bsx-muted); font-size: 13px; padding: 18px 8px; line-height: 1.6; }
.bsx-panel-body .bshell-mood-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* ---------- overlays on the canvas ---------- */
.bsx-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.bsx-ov { position: absolute; pointer-events: none; }
.bsx-box { border-radius: 4px; }
.bsx-box.is-hover { box-shadow: 0 0 0 1.5px rgba(20,184,166,.75); }
.bsx-box.is-sel { box-shadow: 0 0 0 2px var(--bsx-accent), 0 0 0 5px rgba(20,184,166,.16); }
.bsx-box.is-editing { box-shadow: 0 0 0 2px var(--bsx-accent-dark), 0 0 0 5px rgba(15,118,110,.14); }
.bsx-box.is-sec { box-shadow: inset 0 0 0 1.5px rgba(15,118,110,.55); border-radius: 0; }
.bsx-box.is-sec.is-sel { box-shadow: inset 0 0 0 2px var(--bsx-accent-dark); }
.bsx-chip {
  position: absolute; pointer-events: none; font-size: 11px; font-weight: 700; line-height: 1; color: #fff; background: var(--bsx-accent);
  padding: 4px 7px; border-radius: 6px; white-space: nowrap; transform: translateY(-100%); margin-top: -4px; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.bsx-chip.is-sec { background: var(--bsx-accent-dark); transform: none; margin-top: 0; border-radius: 0 0 8px 0; }
.bsx-chip.is-global { background: #0F172A; }
html[dir="rtl"] .bsx-chip.is-sec { border-radius: 0 0 0 8px; }
.bsx-tools {
  position: absolute; pointer-events: auto; display: flex; align-items: center; gap: 2px; padding: 4px; background: #fff;
  border: 1px solid var(--bsx-line); border-radius: 12px; box-shadow: var(--bsx-shadow); z-index: 25; flex-wrap: wrap; max-width: calc(100% - 16px);
  animation: bsx-pop .12s var(--bsx-ease);
}
.bsx-tools .bsx-icon-btn { width: 32px; height: 32px; border-radius: 8px; }
.bsx-tools .bsx-icon-btn svg { width: 17px; height: 17px; }
.bsx-tools-sep { width: 1px; height: 20px; background: var(--bsx-line); margin: 0 3px; flex: none; }
.bsx-tool-txt { height: 32px; border: none; background: transparent; border-radius: 8px; padding: 0 8px; font-size: 12.5px; font-weight: 600; color: var(--bsx-text); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; max-width: 150px; }
.bsx-tool-txt:hover { background: #F1F5F9; }
.bsx-tool-txt span { overflow: hidden; text-overflow: ellipsis; }
.bsx-tool-txt .bsx-caret { width: 12px; height: 12px; opacity: .6; }
.bsx-tool-color { width: 32px; height: 32px; border: none; background: transparent; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.bsx-tool-color:hover { background: #F1F5F9; }
.bsx-tool-color i { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(15,23,42,.18); display: block; }
.bsx-tools .bsx-danger:hover { color: var(--bsx-danger); background: #FEF2F2; }
.bsx-tools-field { display: flex; align-items: center; gap: 6px; padding: 2px 4px; }
.bsx-tools-field input { height: 32px; width: 210px; max-width: 46vw; border: 1px solid var(--bsx-line-strong); border-radius: 8px; padding: 0 9px; font: inherit; font-size: 13.5px; }
.bsx-tools-field input:focus { outline: none; border-color: var(--bsx-accent); box-shadow: 0 0 0 3px rgba(20,184,166,.18); }
.bsx-tools-note { flex-basis: 100%; display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--bsx-accent-dark); padding: 2px 6px 3px; }
.bsx-tools-note svg { width: 13px; height: 13px; }
/* the section toolbar: dark teal, small */
.bsx-sectools { background: var(--bsx-accent-dark); border-color: var(--bsx-accent-dark); border-radius: 10px; padding: 3px; gap: 1px; flex-wrap: nowrap; }
.bsx-sectools .bsx-icon-btn { color: #fff; width: 30px; height: 30px; }
.bsx-sectools .bsx-icon-btn:hover:not(:disabled) { background: rgba(255,255,255,.16); }
.bsx-sectools .bsx-icon-btn svg { width: 16px; height: 16px; }
.bsx-sectools .bsx-grip { color: #fff; width: 30px; height: 30px; align-items: center; justify-content: center; }
.bsx-sectools .bsx-tool-txt { color: #fff; height: 30px; }
.bsx-sectools .bsx-tool-txt:hover { background: rgba(255,255,255,.16); }
.bsx-sectools .bsx-tools-sep { background: rgba(255,255,255,.25); }
/* "+" insert between sections */
.bsx-insert {
  position: absolute; pointer-events: auto; transform: translate(-50%, -50%); z-index: 24; height: 28px; padding: 0 12px 0 8px;
  border-radius: 999px; border: 2px solid #fff; background: var(--bsx-accent); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; box-shadow: 0 4px 14px rgba(15,118,110,.35); white-space: nowrap;
  animation: bsx-fade .15s var(--bsx-ease);
}
.bsx-insert:hover { background: var(--bsx-accent-dark); }
.bsx-insert svg { width: 15px; height: 15px; }
.bsx-insert-line { position: absolute; height: 0; border-top: 2px dashed rgba(20,184,166,.65); pointer-events: none; }
.bsx-drop-line { position: absolute; height: 4px; border-radius: 4px; background: var(--bsx-accent); box-shadow: 0 0 0 3px rgba(20,184,166,.22); pointer-events: none; z-index: 26; }
.bsx-drag-ghost { position: absolute; pointer-events: none; z-index: 27; background: var(--bsx-accent-dark); color: #fff; font-size: 12.5px; font-weight: 700; padding: 7px 12px; border-radius: 10px; box-shadow: var(--bsx-shadow); white-space: nowrap; }
.bsx-shield { position: absolute; inset: 0; z-index: 26; cursor: grabbing; pointer-events: auto; touch-action: none; }

/* popovers inside toolbars */
.bsx-pop {
  position: fixed; z-index: 70; background: #fff; border: 1px solid var(--bsx-line); border-radius: 12px; box-shadow: var(--bsx-shadow);
  padding: 6px; max-height: min(60vh, 380px); overflow-y: auto; min-width: 180px; animation: bsx-pop .12s var(--bsx-ease);
}
.bsx-pop-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; border: none; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: start; font-size: 14px; color: var(--bsx-text); }
.bsx-pop-item:hover, .bsx-pop-item:focus-visible { background: #F1F5F9; outline: none; }
.bsx-pop-item.is-on { background: #F0FDFA; color: var(--bsx-accent-dark); font-weight: 700; }
.bsx-pop-item small { color: var(--bsx-muted); font-size: 11.5px; }
.bsx-pop-sep { height: 1px; background: var(--bsx-line); margin: 5px 2px; }
.bsx-pop-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; }
.bsx-pop-row input[type="number"], .bsx-pop-row input[type="text"] { width: 90px; height: 32px; border: 1px solid var(--bsx-line-strong); border-radius: 8px; padding: 0 8px; font: inherit; font-size: 13px; }
.bsx-pop-colors { display: grid; grid-template-columns: repeat(6, 26px); gap: 7px; padding: 6px 6px 4px; }
.bsx-pop-colors button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--bsx-line-strong); cursor: pointer; padding: 0; }
.bsx-pop-colors button.is-on { box-shadow: 0 0 0 2px var(--bsx-accent-dark); }

/* ---------- quick-actions dock ---------- */
.bsx-dock {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 28; display: flex; align-items: stretch; gap: 2px;
  background: #fff; border: 1px solid var(--bsx-line); border-radius: 16px; box-shadow: var(--bsx-shadow); padding: 5px; max-width: calc(100% - 24px);
  overflow-x: auto; scrollbar-width: none;
}
.bsx-dock::-webkit-scrollbar { display: none; }
.bsx-dock-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 62px; height: 52px; padding: 0 6px;
  border: none; background: transparent; border-radius: 11px; cursor: pointer; color: var(--bsx-text); font-size: 11px; font-weight: 600; white-space: nowrap; flex: none;
  transition: background .15s var(--bsx-ease), color .15s var(--bsx-ease);
}
.bsx-dock-btn:hover { background: #F1F5F9; }
.bsx-dock-btn svg { width: 19px; height: 19px; }
.bsx-dock-btn.is-primary { background: var(--bsx-accent); color: #fff; min-width: 74px; }
.bsx-dock-btn.is-primary:hover { background: var(--bsx-accent-dark); }
.bsx-dock-btn.is-on { background: var(--bsx-accent-soft); color: var(--bsx-accent-dark); }
.bsx-dock-sep { width: 1px; background: var(--bsx-line); margin: 8px 3px; flex: none; }

/* ---------- toasts ---------- */
.bsx-toasts { position: absolute; bottom: 86px; left: 50%; transform: translateX(-50%); z-index: 45; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100% - 24px); }
.bsx-toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--bsx-ink); color: #fff; font-size: 13.5px; font-weight: 500;
  padding: 10px 12px 10px 16px; border-radius: 12px; box-shadow: var(--bsx-shadow); animation: bsx-rise .2s var(--bsx-ease); max-width: 100%;
}
.bsx-toast button { border: none; background: rgba(255,255,255,.14); color: #5EEAD4; font-weight: 700; font-size: 13px; padding: 6px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.bsx-toast button:hover { background: rgba(255,255,255,.22); }
.bsx-toast.is-error { background: #7F1D1D; }

/* ---------- modals (add section, change design, confirm) ---------- */
.bsx-modal-back { position: fixed; inset: 0; z-index: 6000; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 20px; animation: bsx-fade .15s var(--bsx-ease); }
.bsx-modal { background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(15,23,42,.35); width: 100%; max-width: 980px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; overflow: hidden; animation: bsx-rise .2s var(--bsx-ease); font-family: 'Heebo', Arial, sans-serif; color: var(--bsx-text, #1F2937); }
.bsx-modal *, .bsx-modal *::before, .bsx-modal *::after { box-sizing: border-box; }
.bsx-modal svg { width: 18px; height: 18px; display: block; flex: none; }
.bsx-modal-sm { max-width: 420px; }
.bsx-modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid #E2E8F0; }
.bsx-modal-head h2 { flex: 1; margin: 0; font-size: 17px; color: #0F172A; }
.bsx-modal-head p { margin: 2px 0 0; font-size: 13px; color: #64748B; }
.bsx-modal-x { width: 34px; height: 34px; border-radius: 9px; border: none; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #334155; }
.bsx-modal-x:hover { background: #F1F5F9; }
.bsx-modal-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.bsx-modal-text { padding: 18px; font-size: 14.5px; line-height: 1.6; color: #334155; }
.bsx-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.bsx-modal-foot button { height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid #E2E8F0; background: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; color: #1F2937; }
.bsx-modal-foot button.is-primary { background: #14B8A6; border-color: #14B8A6; color: #fff; }
.bsx-modal-foot button.is-danger { background: #DC2626; border-color: #DC2626; color: #fff; }
.bsx-cats { width: 190px; flex: none; border-inline-end: 1px solid #E2E8F0; padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.bsx-cat { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: none; background: none; text-align: start; padding: 9px 11px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; color: #334155; }
.bsx-cat:hover { background: #F1F5F9; }
.bsx-cat.is-on { background: #F0FDFA; color: #0F766E; }
.bsx-cat small { font-size: 11.5px; color: #94A3B8; font-weight: 600; }
.bsx-cards { flex: 1; min-width: 0; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; align-content: start; }
.bsx-card { border: 1px solid #E2E8F0; border-radius: 14px; background: #fff; overflow: hidden; cursor: pointer; text-align: start; padding: 0; font: inherit; color: inherit; display: flex; flex-direction: column; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.bsx-card:hover, .bsx-card:focus-visible { border-color: #14B8A6; box-shadow: 0 10px 24px -10px rgba(15,118,110,.45); outline: none; transform: translateY(-1px); }
.bsx-card.is-current { border-color: #0F766E; box-shadow: 0 0 0 2px #0F766E inset; }
.bsx-card-prev { position: relative; height: 170px; overflow: hidden; background: #F8FAFC; border-bottom: 1px solid #EEF2F6; }
.bsx-card-prev iframe { position: absolute; top: 0; inset-inline-start: 0; width: 1200px; height: 800px; border: 0; transform-origin: 0 0; pointer-events: none; background: #fff; }
html[dir="rtl"] .bsx-card-prev iframe { transform-origin: 100% 0; }
.bsx-card-body { padding: 10px 12px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bsx-card-name { font-weight: 700; font-size: 14px; color: #0F172A; }
.bsx-card-sub { font-size: 12px; color: #64748B; }
.bsx-card-badge { font-size: 11px; font-weight: 700; color: #0F766E; background: #CCFBF1; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

/* ---------- canvas-in-preview mode ---------- */
.bsx.is-previewing .bsx-overlay, .bsx.is-previewing .bsx-dock, .bsx.is-previewing .bsx-panel { display: none !important; }
.bsx-preview-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; gap: 8px; align-items: center; background: var(--bsx-ink); color: #fff; padding: 6px 6px 6px 14px; border-radius: 12px; box-shadow: var(--bsx-shadow); font-size: 13px; font-weight: 600; white-space: nowrap; }
.bsx-preview-bar button { height: 30px; border: none; border-radius: 8px; padding: 0 12px; background: rgba(255,255,255,.14); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.bsx-preview-bar button.is-primary { background: var(--bsx-accent); }

@keyframes bsx-pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes bsx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bsx-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes bsx-slide-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
html[dir="rtl"] .bsx-panel { animation-name: bsx-slide-in-rtl; }
@keyframes bsx-slide-in-rtl { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .bsx *, .bsx *::before, .bsx *::after, .bsx-modal, .bsx-modal-back, .bsx-pop { animation: none !important; transition: none !important; }
}

/* ---------- narrower screens ---------- */
@media (max-width: 1100px) {
  .bsx-hide-sm { display: none !important; }
  .bsx-back-label { display: none; }
  .bsx-name { max-width: 140px; }
}
@media (max-width: 900px) {
  .bsx { --bsx-top-h: auto; }
  .bsx-top { flex-wrap: wrap; row-gap: 6px; padding: 8px 10px; min-height: 56px; }
  .bsx-top-start { flex: 1 1 auto; order: 1; }
  .bsx-top-end { flex: 0 0 auto; order: 2; }
  .bsx-top-center { order: 3; flex: 1 0 100%; justify-content: center; }
  .bsx-canvas-area { padding: 10px 10px 82px; }
  /* The panel becomes a bottom sheet over the canvas. */
  .bsx-panel {
    position: absolute; inset-inline: 0; bottom: 0; width: auto; max-height: 62%; border-inline-start: none;
    border-top: 1px solid var(--bsx-line); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(15,23,42,.22); z-index: 50;
    animation: bsx-sheet .22s var(--bsx-ease);
  }
  html[dir="rtl"] .bsx-panel { animation-name: bsx-sheet; }
  .bsx-panel-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--bsx-line-strong); }
  .bsx-panel-head { position: relative; padding-top: 16px; }
  .bsx.has-panel .bsx-dock { display: none; }
  .bsx-cats { width: auto; border-inline-end: none; border-bottom: 1px solid #E2E8F0; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 8px 10px; flex: none; }
  .bsx-cat { white-space: nowrap; flex: none; }
  .bsx-modal-body { flex-direction: column; }
  .bsx-modal-back { padding: 10px; }
}
@keyframes bsx-sheet { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 520px) {
  .bsx-hide-xs { display: none !important; }
  .bsx-top-sep { display: none; }
  .bsx-name { max-width: 96px; font-size: 13.5px; }
  .bsx .bshell-top-status { padding: 3px 6px; font-size: 0; gap: 0; }
  .bsx .bshell-top-status::before { width: 9px; height: 9px; opacity: 1; }
  .bsx .bshell-top-status.failed { font-size: 12px; gap: 5px; }
  .bsx-btn { padding: 0 11px; }
  .bsx-dock { bottom: 8px; border-radius: 14px; }
  .bsx-dock-btn { min-width: 56px; height: 48px; font-size: 10.5px; }
  .bsx-toasts { bottom: 72px; }
  .bsx-cards { grid-template-columns: 1fr; padding: 12px; }
  .bsx-card-prev { height: 150px; }
  .bsx .bsx-ai-panel { position: fixed; top: 64px; inset-inline: 10px; width: auto; }
}

/* undo/redo point "back" in the UI's own direction */
html[dir="rtl"] .bsx #bshell-undo-btn svg, html[dir="rtl"] .bsx #bshell-redo-btn svg { transform: scaleX(-1); }
.bsx-bsd-glyph { display: inline-flex; align-items: center; justify-content: center; height: 19px; font-size: 11.5px; font-weight: 800; letter-spacing: -.02em; line-height: 1; padding: 0 3px; border: 1.5px solid currentColor; border-radius: 5px; }
.bsx-cards { grid-auto-rows: max-content; }
.bsx-card-prev, .bsx-card-body { flex: none; }
.bsx-pop-item svg { width: 16px; height: 16px; }
@media (max-width: 520px) {
  .bsx-devices { display: none !important; }
  .bsx-top { flex-wrap: nowrap; padding: 8px; gap: 4px; }
  .bsx-top-center { order: 2; flex: none; }
  .bsx-top-end { order: 3; }
  .bsx-top-center .bsx-icon-btn { width: 32px; }
  .bsx-tools .bsx-icon-btn { width: 30px; }
  .bsx-tool-txt { padding: 0 6px; }
}

/* the page under the full-screen editor never scrolls */
html:has(.bsx.active), body:has(.bsx.active) { overflow: hidden !important; scrollbar-gutter: auto !important; }

/* logo & tab icon (d.logo / d.favicon) */
.bsx-logo-thumb { width: 100%; min-height: 72px; max-width: 220px; border-radius: 10px; border: 1px solid var(--bsx-line, #E2E8F0); display: flex; align-items: center; justify-content: center; padding: 10px;
  background-color: #fff; background-image: linear-gradient(45deg, #F1F5F9 25%, transparent 25%, transparent 75%, #F1F5F9 75%), linear-gradient(45deg, #F1F5F9 25%, transparent 25%, transparent 75%, #F1F5F9 75%);
  background-size: 14px 14px; background-position: 0 0, 7px 7px; box-sizing: border-box; flex: none; }
.bsx-row .bsx-logo-thumb { width: 96px; min-height: 64px; padding: 6px; }
.bsx-logo-thumb img { max-width: 100%; max-height: 56px; object-fit: contain; display: block; }
.bsx-logo-thumb span { font-size: 12px; color: #94A3B8; }
.bsx-fav-thumb { width: 48px; height: 48px; border-radius: 10px; border: 1px solid var(--bsx-line, #E2E8F0); background: #F8FAFC; display: flex; align-items: center; justify-content: center; flex: none; }
.bsx-fav-thumb img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; display: block; }
.bshell-serp-fav.has-img { background: #fff; border: 1px solid #ECEDEF; overflow: hidden; }
.bshell-serp-fav.has-img img { width: 18px; height: 18px; object-fit: contain; display: block; }

/* one-click publish (js/site-wizard-router.js) + the site address in settings */
.dk-publish-error { margin: -6px 0 14px; padding: 10px 12px; border-radius: 10px; background: #FEF3F2; border: 1px solid #FECDCA; color: #B42318; font-size: 13.5px; line-height: 1.6; }
.dk-publish-error a { color: inherit; }
#dk-checklist-confirm.is-loading { opacity: .85; cursor: progress; }
#dk-checklist-confirm.is-loading::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-inline-end: 8px; vertical-align: -2px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: dk-pub-spin .8s linear infinite; }
@keyframes dk-pub-spin { to { transform: rotate(360deg); } }
.dk-publish-modal .dk-publish-result { background: var(--surface, #fff); border: 1px solid var(--border, #E2E8F0); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.dk-publish-modal #dk-publish-extra > * + * { margin-top: 14px; }
.dk-publish-modal .publish-url-text, .bsx-site-address .publish-url-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; color: var(--primary-dark, #0F766E); text-align: left; }
.bsx-site-address .publish-url-box { display: flex; align-items: center; gap: 8px; background: #F8FAFC; border: 1px solid var(--bsx-line, #E2E8F0); border-radius: 10px; padding: 6px 6px 6px 10px; }
.bsx-site-address .publish-copy-btn { background: #fff; color: #0F172A; border: 1px solid var(--bsx-line, #E2E8F0); border-radius: 8px; padding: 6px 10px; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.bsx-site-address .btn-teal { background: #14B8A6; color: #fff; border-radius: 10px; padding: 10px 14px; font-weight: 700; text-decoration: none; }
.bsx-site-address .btn-teal:hover { background: #0F766E; }
.bsx-site-address .host-info-box { background: #F8FAFC; border: 1px solid var(--bsx-line, #E2E8F0); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.6; color: #475569; }
.bsx-site-address .btn-mini { background: #fff; border: 1px solid var(--bsx-line, #E2E8F0); border-radius: 8px; padding: 4px 8px; font-family: inherit; font-size: 12px; cursor: pointer; }

/* ---------- phones & tablets (touch) ----------
   Responsive audit (tests/responsive/audit.py), 360-1024px:
   - DeskKit's help-chat button is hidden here on phones (css/style.css):
     it sat on the canvas and over the bottom sheet's fields. Help stays
     one tap away in the top bar's "⋯" menu.
   - the dock, the bottom sheet and the preview bar clear the home
     indicator on notched phones (env() is 0 everywhere else);
   - the preview bar sat over the site's own header on a phone: it moves
     into the strip under the canvas that the (hidden) dock leaves free;
   - touch: every toolbar button / "+" is at least 40px to the finger
     (the "+" keeps its look, its hit area grows), and taps never wait for
     a double-tap zoom (pinch-zoom still works). */
@media (max-width: 900px) {
  .bsx-dock { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .bsx-canvas-area { padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
  .bsx-panel { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .bsx-toasts { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  .bsx-preview-bar { top: auto; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 16px); padding-inline-start: 10px; }
  .bsx-preview-bar span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .bsx-preview-bar button { height: 40px; flex: none; }
}
@media (max-width: 520px) {
  .bsx-dock { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .bsx-toasts { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .bsx-preview-bar span { display: none; }
}
@media (pointer: coarse) {
  .bsx, .bsx-modal-back { touch-action: manipulation; }
  .bsx-icon-btn, .bsx-icon-btn-sm { width: 40px; height: 40px; }
  .bsx-btn { height: 40px; }
  .bsx-tools .bsx-icon-btn, .bsx-tool-color { width: 40px; height: 40px; }
  .bsx-tool-txt { height: 40px; }
  .bsx-sectools .bsx-icon-btn, .bsx-sectools .bsx-grip { width: 40px; height: 40px; }
  .bsx-sectools .bsx-tool-txt { height: 40px; }
  .bsx-insert { height: 32px; }
  .bsx-insert::before { content: ""; position: absolute; inset: -6px -4px; }
  .bsx-menu-item { min-height: 44px; }
  .bsx-modal-x { width: 40px; height: 40px; }
  .bsx-cat { min-height: 40px; }
  .bsx .bshell-device-btn { width: 40px; height: 36px; }
  .bsx-swatch { width: 36px; height: 36px; }
  .bsx-list-name { min-height: 40px; }
  .bsx-site-address .publish-copy-btn, .bshell-serp-toggle button { min-height: 36px; }
  .bsx-back { height: 40px; }
  .bsx-list-row .bsx-grip { min-width: 32px; min-height: 40px; justify-content: center; align-items: center; }
  /* the phone / e-mail fields had no field style at all (a bare 24px box) */
  .bsx-panel-body input[type="tel"], .bsx-panel-body input[type="email"] {
    width: 100%; height: 40px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--bsx-line-strong); background: #fff; font: inherit; color: var(--bsx-ink);
  }
}
@media (pointer: coarse) and (max-width: 520px) {
  .bsx-top { gap: 2px; }
  .bsx-top-center .bsx-icon-btn, .bsx-tools .bsx-icon-btn { width: 40px; }
}

/* ---------- Safe areas (installed app under the iOS status bar, landscape) ----------
   The editor covers the whole screen: its top bar takes the status-bar
   strip (--dk-safe-top, css/style.css), the sides clear the notch. */
.bsx.active { padding-left: var(--dk-safe-left); padding-right: var(--dk-safe-right); }
.bsx-top { height: calc(var(--bsx-top-h) + var(--dk-safe-top)); padding-top: var(--dk-safe-top); }
@media (max-width: 900px) {
  .bsx-top { height: auto; min-height: calc(56px + var(--dk-safe-top)); padding-top: calc(8px + var(--dk-safe-top)); }
}
@media (max-width: 520px) { .bsx .bsx-ai-panel { top: calc(64px + var(--dk-safe-top)); } }
