/* ============================================================================
   Contour · builders, designers and the record modal
   Owned by [builders]. Every rule is scoped under .builder, .designer,
   .record-modal or the surface machinery those three share (.bx-*).
   Colour, size, radius, shadow and duration come from css/tokens.css only.
   ========================================================================== */

/* ---------------------------------------------------------------- layer -- */
/* Only used when the module runs without the shell; the shell's own #layer
   already supplies these rules. */
.builder-layer { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-modal); }
.builder-layer > * { pointer-events: auto; }
.builder-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* -------------------------------------------------------------- surfaces - */

.bx-wrap { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; }
.bx-wrap.no-scrim { pointer-events: none; }
.bx-wrap.no-scrim > .bx-panel { pointer-events: auto; }

.bx-scrim { position: absolute; inset: 0; background: var(--scrim); animation: bxfade var(--dur-panel) var(--ease); }
@keyframes bxfade { from { opacity: 0; } to { opacity: 1; } }

.bx-panel {
  position: relative;
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--raised); color: var(--text);
  border: var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-base); line-height: var(--lh-base);
}

/* modal — centred */
.bx-modal { align-items: flex-start; justify-content: center; padding: 8vh var(--sp-4) var(--sp-4); }
.bx-modal > .bx-panel { width: min(640px, 100%); max-height: 84vh; animation: bxin var(--dur-panel) var(--ease); }
.bx-modal > .bx-panel.narrow { width: min(460px, 100%); }
@keyframes bxin { from { opacity: 0; transform: translateY(-8px) scale(.99); } to { opacity: 1; transform: none; } }

/* drawer — docked right */
.bx-drawer { justify-content: flex-end; }
.bx-drawer > .bx-panel {
  width: min(720px, 100%); height: 100%;
  border-radius: 0; border-right: 0; border-top: 0; border-bottom: 0;
  animation: bxslide var(--dur-panel) var(--ease);
}
@keyframes bxslide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* rail — docked right when there is no Configure rail to mount inside */
.bx-rail { justify-content: flex-end; pointer-events: none; }
.bx-rail > .bx-panel {
  pointer-events: auto; width: min(var(--config-w), 100%); height: 100%;
  border-radius: 0; border-top: 0; border-right: 0; border-bottom: 0;
}

/* rail — covers the Configure rail it is mounted inside.
   An ordinary flex child, never an absolute overlay: app.css moves
   .configrail between static and fixed at 1200px, and an absolutely
   positioned cover would escape to the viewport the moment it did.
   [data-builder-rail] is set by openSurface() on the host for exactly as long
   as one of our surfaces is up; the shell's own rail content is hidden, not
   removed, and comes back untouched when we close. */
[data-builder-rail] > *:not(.bx-railcover) { display: none; }
.bx-railcover { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; }
.bx-railcover > .bx-panel {
  flex: 1 1 auto; min-height: 0; min-width: 0; width: 100%;
  border: 0; border-radius: 0; box-shadow: none;
  background: var(--surface);
}

/* inline — the caller gave us a mount of its own */
.builder-inline { display: flex; height: 100%; min-height: 0; }
.builder-inline > .bx-panel { flex: 1 1 auto; border: 0; border-radius: 0; box-shadow: none; background: transparent; }

.bx-head {
  display: flex; align-items: flex-start; gap: var(--sp-2); flex: none;
  padding: var(--sp-3) var(--sp-3) var(--sp-2) var(--sp-4);
  border-bottom: var(--border-soft);
}
.bx-headtext { min-width: 0; flex: 1 1 auto; }
.bx-crumb {
  font-size: var(--fs-sm); color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bx-title {
  font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bx-close { flex: none; }

.bx-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-6);
}
.bx-foot {
  flex: none; display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: var(--border-soft); background: var(--canvas);
}
.bx-foot .spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------- menus ----- */

.bx-menu-wrap { position: fixed; inset: 0; z-index: var(--z-menu); }
.bx-menu-back { position: absolute; inset: 0; }
.bx-menu {
  position: fixed; min-width: 220px; max-width: 340px; max-height: min(60vh, 480px);
  overflow-y: auto; padding: var(--sp-1);
  display: flex; flex-direction: column;
  background: var(--raised); border: var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ------------------------------------------------------- shared elements - */

.builder .bx-section, .designer .bx-section, .record-modal .bx-section {
  display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0;
}
.bx-sectitle {
  font-size: var(--fs-xs); letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--text-3); font-weight: var(--fw-semibold);
  margin: 0;
}
.bx-field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; flex: 1 1 0; }
.bx-hint { font-size: var(--fs-sm); color: var(--text-2); }
.bx-hint.bad, .bx-sample .bad, .bx-uselist li.bad { color: var(--danger); }
.bx-lead { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--text-2); margin: 0; }
.bx-stack { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.bx-row { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.bx-row .grow, .bx-field .grow { min-width: 0; }

.bx-card {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3); border: var(--border-soft); border-radius: var(--radius-lg);
  background: var(--canvas);
}
.bx-empty {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3); border: var(--border-w) dashed var(--line); border-radius: var(--radius-lg);
  color: var(--text-2); font-size: var(--fs-sm);
}
.bx-checkrow { display: flex; flex-direction: column; gap: var(--sp-1); }
.bx-consequences { margin: 0; padding-left: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-1); }
.bx-consequences li { color: var(--text); }
.bx-uselist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--sp-1); }
.bx-uselist li { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.bx-uselist li .icon { color: var(--text-3); flex: none; }

.bx-stats { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.bx-stats b { font-size: var(--fs-lg); }

.bx-typebtn { width: 100%; justify-content: flex-start; }
.bx-typebtn .grow { text-align: left; min-width: 0; }

.bx-colordot {
  flex: none; width: 20px; height: 20px; border-radius: var(--radius-pill);
  border: var(--border-w) solid var(--line); background: var(--c, var(--accent)); cursor: pointer;
}
.bx-optprev, .bx-tokens { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.bx-archived { opacity: .55; }
.bx-formula { font-family: var(--font-mono); font-size: var(--fs-sm); }

.bx-preview {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text); font-size: var(--fs-sm);
  border: var(--border-w) solid var(--accent-line);
}
.bx-preview .icon { color: var(--accent); flex: none; margin-top: 1px; }
.bx-preview.bad { background: var(--danger-soft); border-color: var(--danger-line); }
.bx-preview.bad .icon { color: var(--danger); }

.bx-ratingprev { font-size: var(--fs-lg); color: var(--obj-amber); letter-spacing: 2px; }

.bx-sample {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: var(--sp-1) var(--sp-2);
  font-size: var(--fs-sm); align-items: center;
}
.bx-sample.bx-sample-3 { grid-template-columns: 1.3fr 1fr 1fr; }
.bx-samplekey { color: var(--text-2); }
.bx-samplenow { color: var(--text-2); }
.bx-samplenext { color: var(--text); font-weight: var(--fw-medium); }

.bx-accessrow {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-1) 0; border-bottom: var(--border-soft);
}
.bx-accessrow:last-child { border-bottom: 0; }
.bx-accessrow .check span { font-size: var(--fs-sm); color: var(--text-2); }

.bx-dangerbox { display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-start; }
.bx-copylist { display: flex; flex-direction: column; gap: var(--sp-1); }

.builder .btn.primary.danger-solid,
.record-modal .btn.primary.danger-solid { background: var(--danger); border-color: transparent; color: var(--text-inverse); }

/* ------------------------------------------------------- icon picker ----- */

.bx-iconpick { display: flex; flex-direction: column; gap: var(--sp-2); }
.bx-icongrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: var(--sp-1); max-height: 132px; overflow-y: auto;
  padding: var(--sp-1); border: var(--border-soft); border-radius: var(--radius);
}
.bx-iconbtn {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; border: var(--border-w) solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text-2); cursor: pointer;
}
.bx-iconbtn:hover { background: var(--hover); color: var(--text); }
.bx-iconbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* ===================================================== OBJECT BUILDER ==== */

.bx-modal > .bx-panel.builder-object { width: min(900px, 100%); }
.builder-object .bx-body { padding: 0; gap: 0; overflow: hidden; }
.ob-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; height: 100%; }
.ob-preview {
  min-width: 0; padding: var(--sp-4); background: var(--canvas);
  border-right: var(--border-soft); overflow: auto;
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.ob-rail { min-width: 0; padding: var(--sp-4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-6); }
.ob-prevhead { display: flex; align-items: center; gap: var(--sp-2); }
.ob-ask h2 { font-size: var(--fs-xl); line-height: var(--lh-xl); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-1); }

.ob-grid {
  display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(110px, 1fr));
  border: var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.ob-gh {
  display: flex; align-items: center; gap: var(--sp-1);
  height: var(--col-header-h); padding: 0 var(--sp-2);
  background: var(--sunken); border-bottom: var(--border);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2);
}
.ob-gh .icon { color: var(--text-3); }
.ob-gc {
  height: var(--row-short); display: flex; align-items: center;
  padding: 0 var(--sp-2); border-bottom: var(--border-soft); font-size: var(--fs-base);
}
.ob-gc.ob-blank::after { content: ""; display: block; height: 6px; width: 60%; border-radius: var(--radius-pill); background: var(--sunken); }
.ob-srow { align-items: flex-start; padding: var(--sp-1); }
.ob-srow .grow { display: flex; flex-direction: column; gap: var(--sp-1); }



/* ====================================================== VOCABULARY ======= */

.bx-voclist { display: flex; flex-direction: column; gap: var(--sp-1); }
.bx-vocrow {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1); border-radius: var(--radius);
}
.bx-vocrow:hover { background: var(--hover); }
.bx-vocorder {
  flex: none; width: 20px; text-align: right;
  font-size: var(--fs-sm); color: var(--text-3);
}

/* ======================================================= RELATION ======== */

.rel-cards { display: flex; align-items: flex-end; gap: var(--sp-2); }
.rel-card { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.rel-arrow { color: var(--text-3); margin-bottom: var(--sp-2); flex: none; }
.rel-diagram { padding: var(--sp-2); background: var(--canvas); border: var(--border-soft); border-radius: var(--radius-lg); }
.rel-svg { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto; }
.rel-node { fill: color-mix(in srgb, var(--c, var(--accent)) var(--tint-chip), var(--surface)); stroke: var(--c, var(--accent)); stroke-width: 1.5; }
.rel-label { fill: var(--text); font-size: 15px; font-weight: 600; text-anchor: middle; font-family: var(--font-sans); }
.rel-sub { fill: var(--text-2); font-size: 10px; text-anchor: middle; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.rel-edge { stroke: var(--line); stroke-width: 2; fill: none; }
.rel-edgechip { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; }
.rel-edgechip.dim { fill: var(--canvas); }
.rel-edgelabel { fill: var(--text); font-size: 12px; text-anchor: middle; font-family: var(--font-sans); }
.rel-edgelabel.dim { fill: var(--text-2); }
.rel-sentence { display: flex; flex-direction: column; gap: var(--sp-1); }
.rel-sentence p { margin: 0; font-size: var(--fs-md); }



/* ==================================================== IMPACT / MIGRATION = */

.bx-modal > .bx-panel.builder-impact { width: min(760px, 100%); }
.bx-change { display: flex; align-items: center; gap: var(--sp-4); }
.bx-changeside { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.bx-changearrow { color: var(--text-3); flex: none; }
.bx-impactcounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.bx-countcard {
  display: flex; flex-direction: column; gap: 2px; padding: var(--sp-3);
  border: var(--border-soft); border-radius: var(--radius-lg); background: var(--canvas);
  font-size: var(--fs-sm); color: var(--text-2);
}
.bx-countcard b { font-size: var(--fs-xl); line-height: var(--lh-xl); color: var(--text); }
.bx-countcard.success b { color: var(--success); }
.bx-countcard.warn b { color: var(--warning); }

.bx-unres { display: flex; flex-direction: column; gap: var(--sp-2); }
.bx-unresrow {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto;
  gap: var(--sp-2); align-items: center;
  padding: var(--sp-2); border: var(--border-soft); border-radius: var(--radius); background: var(--canvas);
}
.bx-blocknote { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }



/* ======================================================= RECORD MODAL ==== */

.record-modal .bx-body { padding: 0; gap: 0; }
.rec-stage-host { display: flex; flex-direction: column; min-width: 0; }

.rec-titlebar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); background: var(--raised);
  border-bottom: var(--border-soft);
}
.rec-titlerow { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.rec-titleinput {
  flex: 1 1 auto; min-width: 0; border: var(--border-w) solid transparent; background: transparent;
  color: var(--text); font-size: var(--fs-xl); line-height: var(--lh-xl); font-weight: var(--fw-semibold);
  padding: 0 var(--sp-1); border-radius: var(--radius);
}
.rec-titleinput:hover { border-color: var(--line-2); }
.rec-titleinput:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.rec-titletext { font-size: var(--fs-xl); line-height: var(--lh-xl); font-weight: var(--fw-semibold); margin: 0; }
.rec-actions { display: flex; align-items: center; gap: var(--sp-2); }
.rec-actions .spacer { flex: 1 1 auto; }

/* pipeline strips */
.rec-pipes { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--canvas); border-bottom: var(--border-soft); }
.rec-pipe { display: flex; flex-direction: column; gap: var(--sp-1); }
.rec-pipehead { display: flex; align-items: baseline; gap: var(--sp-2); }
.rec-pipehead .caps { font-size: var(--fs-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-3); }
.rec-stages { display: flex; gap: 2px; flex-wrap: wrap; }
.rec-stage {
  flex: 1 1 auto; min-width: 72px; height: 28px; padding: 0 var(--sp-2);
  border: var(--border-w) solid var(--line-2); background: var(--surface); color: var(--text-2);
  font-size: var(--fs-sm); cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%);
}
.rec-stage:first-child { clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%); }
.rec-stage:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 8px 50%); }
.rec-stage:hover:not([disabled]) { background: var(--hover); color: var(--text); }
.rec-stage.done { background: color-mix(in srgb, var(--c) var(--tint-weak), var(--surface)); color: var(--text-2); }
.rec-stage.on {
  background: color-mix(in srgb, var(--c) var(--tint-strong), var(--surface));
  border-color: var(--c); color: var(--text); font-weight: var(--fw-semibold);
}
.rec-stage[disabled] { cursor: not-allowed; opacity: .6; }

/* tabs */
.rec-tabs { display: flex; gap: var(--sp-1); padding: 0 var(--sp-4); border-bottom: var(--border-soft); }
.rec-tab {
  height: 34px; padding: 0 var(--sp-3); border: 0; background: transparent;
  color: var(--text-2); font-size: var(--fs-base); font-weight: var(--fw-medium);
  cursor: pointer; border-bottom: 2px solid transparent;
}
.rec-tab:hover { color: var(--text); }
.rec-tab.on { color: var(--text); border-bottom-color: var(--accent); }

/* page */
.rec-layouthost { min-width: 0; }
.rec-page {
  display: flex; flex-direction: column; gap: var(--sp-6);
  padding: var(--sp-4); max-width: var(--content-max);
}
.rec-section { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; border-radius: var(--radius-lg); }
.rec-sectitle { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold); margin: 0; }
.rec-secgrid { display: grid; gap: var(--sp-4) var(--sp-4); grid-template-columns: 1fr; min-width: 0; }
.rec-section.cols-2 .rec-secgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rec-section.cols-3 .rec-secgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rec-item.span-all { grid-column: 1 / -1; }
.rec-empty { color: var(--text-3); font-size: var(--fs-sm); padding: var(--sp-2) 0; }

.rec-field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.rec-label {
  display: flex; align-items: center; gap: var(--sp-1);
  font-size: var(--fs-sm); color: var(--text-2); min-width: 0;
}
.rec-label .truncate { min-width: 0; }
.rec-req { color: var(--danger); }
.rec-help { color: var(--text-3); display: inline-flex; cursor: help; }
.rec-fieldmenu { margin-left: auto; opacity: 0; }
.rec-field:hover .rec-fieldmenu, .rec-fieldmenu:focus-visible { opacity: 1; }

.rec-control { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.rec-readonly {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h);
  padding: 0 var(--sp-2); border: var(--border-w) dashed var(--line-2); border-radius: var(--radius);
  color: var(--text); background: var(--canvas);
}
.rec-readonly .icon { color: var(--text-3); flex: none; }
.rec-restricted {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h);
  padding: 0 var(--sp-2); border-radius: var(--radius);
  background: var(--sunken); color: var(--text-3); font-style: italic;
}
.rec-err { color: var(--danger); font-size: var(--fs-sm); }
.rec-err:empty { display: none; }
.rec-check { min-height: var(--control-h); }
.rec-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.rec-tag { cursor: pointer; border: var(--border-w) solid transparent; }
.rec-tag[aria-pressed="false"] { background: var(--sunken); color: var(--text-3); }
.rec-tag[aria-pressed="true"] { border-color: color-mix(in srgb, var(--c, var(--accent)) 50%, transparent); }

.rec-rating { display: flex; gap: 2px; }
.rec-star { border: 0; background: transparent; color: var(--line); font-size: var(--fs-lg); cursor: pointer; padding: 0 1px; }
.rec-star.on { color: var(--obj-amber); }

.rec-links { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; }
.rec-linkchip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  border: var(--border); border-radius: var(--radius-pill); padding-left: var(--sp-2);
  background: var(--surface);
}
.rec-linkopen {
  border: 0; background: transparent; color: var(--accent); cursor: pointer;
  font-size: var(--fs-sm); padding: 4px 0; max-width: 200px;
}
.rec-linkopen:hover { text-decoration: underline; }

.rec-files { display: flex; flex-direction: column; gap: var(--sp-1); }
.rec-file { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.rec-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: var(--radius-sm); border: var(--border-soft); }
.rec-sign { display: flex; align-items: center; gap: var(--sp-2); }
.rec-ai { display: flex; flex-direction: column; gap: var(--sp-1); }
.rec-aisug {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2); border-radius: var(--radius);
  background: var(--warning-soft); border: var(--border-w) solid var(--warning-line);
  font-size: var(--fs-sm);
}
.rec-aisug .icon { color: var(--warning); }

.rec-broken {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--radius);
  background: var(--warning-soft); border: var(--border-w) solid var(--warning-line);
  font-size: var(--fs-sm);
}
.rec-broken .icon { color: var(--warning); flex: none; }

/* related + activity */
.rec-related, .rec-activity {
  display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0;
  border: var(--border-soft); border-radius: var(--radius-lg); padding: var(--sp-3); background: var(--canvas);
}
.rec-relhead { display: flex; align-items: center; gap: var(--sp-2); }
.rec-relhead .caps { font-size: var(--fs-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-3); }
.rec-reltable {
  display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(calc(var(--cols) - 1), minmax(0, 1fr));
  gap: 0; border: var(--border-soft); border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.rec-relcell {
  min-height: var(--row-short); display: flex; align-items: center;
  padding: 0 var(--sp-2); border-bottom: var(--border-soft); font-size: var(--fs-sm);
}
.rec-reltitle {
  border: 0; background: transparent; color: var(--accent); cursor: pointer;
  text-align: left; font-weight: var(--fw-medium);
}
.rec-reltitle:hover { text-decoration: underline; }
.rec-reltitle[disabled] { color: var(--text); cursor: default; }
.rec-relcell.restricted { color: var(--text-3); font-style: italic; }

.rec-composer { display: flex; gap: var(--sp-2); align-items: center; }
.rec-composer .input { flex: 1 1 auto; }
.rec-pinned { display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-2); border-radius: var(--radius); background: var(--accent-soft); }
.rec-pinned .caps { font-size: var(--fs-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--accent); }

.rec-stream { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rec-act { display: flex; gap: var(--sp-2); padding: var(--sp-2) 0; border-bottom: var(--border-soft); }
.rec-act:last-child { border-bottom: 0; }
.rec-actmark { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: var(--radius-pill); background: var(--c, var(--line)); }
.rec-actbody { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.rec-actline { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.rec-actline .grow { min-width: 0; }
.rec-actline .icon { color: var(--text-3); flex: none; }
.rec-acttitle { border: 0; background: transparent; color: var(--text); font-weight: var(--fw-medium); cursor: pointer; padding: 0; text-align: left; min-width: 0; }
.rec-acttitle:hover { color: var(--accent); }
.rec-acttitle[disabled] { cursor: default; }
.rec-actnote { margin: 0; font-size: var(--fs-sm); color: var(--text-2); }

.rec-history { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }

/* record picker */
.rec-picker .bx-body { padding: var(--sp-4); gap: var(--sp-3); }
.rec-pickresults { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.rec-pickrow {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  min-height: var(--control-h); padding: 0 var(--sp-2);
  border: var(--border-w) solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text); cursor: pointer; text-align: left;
}
.rec-pickrow:hover { background: var(--hover); }
.rec-pickrow.on { background: var(--accent-soft); border-color: var(--accent-line); }
.rec-pickrow .icon { color: var(--accent); }

/* stage completion */
.rec-gate .bx-body { padding: var(--sp-4); gap: var(--sp-3); }
.rec-gatehead { display: flex; align-items: center; gap: var(--sp-2); }
.rec-gateitem {
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-3); border: var(--border-w) solid var(--warning-line);
  border-radius: var(--radius-lg); background: var(--warning-soft);
}
.rec-gatelabel { display: flex; align-items: center; gap: var(--sp-2); }
.rec-gatelabel .icon { color: var(--warning); }



/* ========================================================== DESIGNERS ==== */

.designer .dz-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; }
.dz-tab {
  height: var(--control-h-sm); padding: 0 var(--sp-2);
  border: var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text-2); font-size: var(--fs-sm); cursor: pointer;
}
.dz-tab.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: var(--fw-medium); }

.dz-outline { display: flex; flex-direction: column; gap: 1px; max-height: 260px; overflow-y: auto; }
.dz-row {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  min-height: var(--control-h-sm); padding: 0 var(--sp-2);
  border: var(--border-w) solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text); font-size: var(--fs-sm);
  cursor: pointer; text-align: left;
}
.dz-row:hover { background: var(--hover); }
.dz-row.on { background: var(--accent-soft); border-color: var(--accent-line); }
.dz-row .icon { color: var(--text-3); flex: none; }
.dz-sec { font-weight: var(--fw-semibold); }
.dz-item { padding-left: var(--sp-6); }

.dz-palette { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.dz-chip {
  display: inline-flex; align-items: center; gap: var(--sp-1); max-width: 100%;
  height: var(--control-h-sm); padding: 0 var(--sp-2);
  border: var(--border); border-radius: var(--radius-pill); background: var(--surface);
  color: var(--text); font-size: var(--fs-sm); cursor: grab;
}
.dz-chip:hover { background: var(--hover); border-color: var(--accent-line); }
.dz-chip .icon { color: var(--text-3); }
.dz-chip .truncate { max-width: 140px; }
.dz-checks { display: flex; flex-direction: column; gap: var(--sp-1); max-height: 180px; overflow-y: auto; }

.dz-gatepick { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; }
.dz-gatechip { max-width: 100%; height: auto; padding: 2px var(--sp-1) 2px var(--sp-2); background: var(--sunken); color: var(--text); }
.dz-gatechip .truncate { max-width: 180px; }

/* A staged move onto another field. It reads as pending work, not as a done
   thing: the same warning tint the preview dock uses for the same fact, so the
   rail and the canvas cannot tell the operator two different stories. */
.dz-pending {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3); border-radius: var(--radius-lg);
  background: var(--warning-soft); border: var(--border-w) solid var(--warning-line);
}
.dz-pending > .bx-row > .icon { color: var(--warning); flex: none; }
.dz-pending .bx-hint { color: var(--text-2); }
.dz-pending .row { flex-wrap: wrap; gap: var(--sp-2); }

/* Stage entry conditions.
   The rows ARE the view filter builder's: same grammar, same .fb* classes, so
   one gate and one filter cannot drift into two different looks. What is local
   is the fold — that builder lives in a full-width toolbar panel, this one in a
   320px rail, where a 62px join column plus three 90px minimums cannot sit on
   one line. Only the wrapping is redeclared; nothing here restyles a control. */
.dz-fb { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.designer .fb-line { flex-wrap: wrap; row-gap: var(--sp-1); }
.designer .fb-join, .designer .fb-join-static { width: 52px; }
/* Basis 0 with no minimum: the two selects SHARE what the join word and the
   remove button leave, so the row cannot push its own remove button onto a
   second line. Measured in a 287px rail: 52 + 4 + 105 + 4 + 92 + 4 + 26 = 287,
   one visual row, at 780px and at 390px alike. */
.designer .fb-field { flex: 1.15 1 0; min-width: 0; }
.designer .fb-cmp { flex: 1 1 0; min-width: 0; }
/* The value takes the next line whole: a date, a number or a list of options
   needs the width, and a fixed place for it beats three cells fighting over
   one 287px row. What is left — join, field, comparison, remove — fits above. */
.designer .fb-val { flex: 1 1 100%; min-width: 0; }
.designer .fb-actions { flex-wrap: wrap; }
.designer .fb-group:not(.root) { flex: 1 1 100%; }

/* preview dock */

/* The drawer keeps clear of the Configure rail by RESERVING the rail's own
   token, not by measuring the rail. js/designers.js decides only WHETHER the
   rail holds the right edge; how wide it is stays here, where CSS resolves it
   in the same layout pass that sizes the rail itself.
   This is the fix for the 2026-09-11 defect: the shell opens the rail in the
   same task that opens the designer, `.workarea` transitions its
   grid-template-columns, and a script reading the rail's box mid-flight got
   1px — so the drawer reserved 1px and covered 100 % of the controls. A token
   cannot be caught mid-transition, so a changed duration or easing, an
   interrupted transition, reduced motion or a resize cannot bring it back.
   At <=1200px .configrail is fixed and --config-w wide instead of a grid
   column that is --config-w wide; either way it is flush right at that width,
   so one reserve is correct at every viewport. */
.bx-wrap.designer-dock.beside-rail { padding-right: var(--config-w); }

.designer-preview .bx-body { padding: var(--sp-4); gap: var(--sp-4); background: var(--canvas); }
/* flex: none, because the layout being designed must never be compressed to
   whatever is left of the drawer. As a shrinkable flex item with overflow
   clipping, its automatic minimum size is 0, so it was squashed from its
   2085px content into an 879px box and silently clipped 58 % of the record —
   with no scroller anywhere to reach the rest. At its natural height .bx-body
   above it is the one scroller and the whole layout is reachable. */
.designer-preview .rec-layouthost {
  flex: none;
  background: var(--surface); border: var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.designer-preview .rec-layouthost.narrow { max-width: 680px; }
.designer-preview .rec-layouthost.narrow .rec-section .rec-secgrid { grid-template-columns: 1fr; }

.designer-preview .rec-item { position: relative; border: var(--border-w) dashed transparent; border-radius: var(--radius); cursor: grab; }
.designer-preview .rec-item:hover { border-color: var(--accent-line); }
.designer-preview .rec-item.selected { border-color: var(--accent); background: var(--selected); }
.designer-preview .rec-section { padding: var(--sp-2); border: var(--border-w) dashed transparent; }
.designer-preview .rec-section:hover { border-color: var(--line); }
.designer-preview .rec-section.selected { border-color: var(--accent); }
.designer-preview .rec-section.drop-on { border-color: var(--accent); background: var(--accent-soft); }

/* pipeline canvas */
.dz-stagecanvas { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-2); align-items: flex-start; }
.dz-stagecol {
  flex: 0 0 var(--board-col-w); min-width: 0;
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3); border-radius: var(--radius-lg);
  border: var(--border-w) solid var(--line-2);
  background: color-mix(in srgb, var(--c) var(--tint-weak), var(--surface));
  cursor: grab;
}
.dz-stagecol.on { border-color: var(--c); box-shadow: var(--shadow-sm); }
.dz-stagecol.drop-on { border-color: var(--accent); background: var(--accent-soft); }
.dz-stagehead { display: flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-semibold); }
.dz-stagemeta { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; font-size: var(--fs-sm); color: var(--text-2); }
.dz-gatelist { margin: 0; padding-left: var(--sp-4); font-size: var(--fs-sm); color: var(--text-2); }
.dz-exceptions {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--radius);
  background: var(--warning-soft); border: var(--border-w) solid var(--warning-line);
  font-size: var(--fs-sm);
}
.dz-exceptions .icon { color: var(--warning); flex: none; margin-top: 1px; }



/* WCAG target size: the shell's .check is a 14px box, and a bare label around
   it is under 24px tall. Ours get a proper row. */
.builder .check, .designer .check, .record-modal .check { min-height: 24px; }
.rec-tag { min-height: 24px; }

/* The shell supplies .visually-hidden; repeat it here so a surface opened
   without the shell never shows a raw file input. */
.builder .visually-hidden, .designer .visually-hidden, .record-modal .visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.rec-gateitem.ok { border-color: var(--line-2); background: var(--canvas); }
.rec-gateitem.ok .rec-gatelabel .icon { color: var(--success); }

/* ------------------------------------------------------- reduced motion -- */
@media (prefers-reduced-motion: reduce) {
  .bx-modal > .bx-panel, .bx-drawer > .bx-panel, .bx-scrim { animation: none; }
  .designer-preview .rec-item, .dz-stagecol { cursor: pointer; }
}
