/* Kumii v2 — the form builder shell. Typeform's light aesthetic, light ONLY.
 *
 * NO HEX CODES. Every colour is a token from tokens.css, and builder.html hard-sets
 * data-theme="light" so the light block of the console tokens is the only one in play. There is
 * deliberately no dark mode here: Typeform's and Formflow's builders are light-only, the
 * likeness Rob asked for is mostly a light aesthetic, and the dark console identity stays with
 * v1's dashboard. The likeness comes from layout, surface, radius and spacing - NOT from new
 * hues: the chromatic palette of this chrome is still --dash-accent plus --dash-warn (validated,
 * DE 28.8 apart), with the primary action worn as near-black INK, which is monochrome and is
 * also Typeform's own move.
 *
 * THE CONTAINMENT RULE, unchanged from revision 1 and not taste: no brand hue and no band hue in
 * the chrome - --dash-warn sits DE 3.5 from --series-keune under deuteranopia and the Draft chip
 * wears it near the brand switch, so the words Keune and miiki carry the identity. The ONE
 * exception is .frame, the centre card: it shows what the CUSTOMER sees, wears the brand fully,
 * and is boxed and captioned so the boundary between internal tool and customer surface stays
 * visible.
 */

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` attribute is only display:none in the UA stylesheet, so any later
 * `display: grid` on the same element beats it and hidden controls stay on screen AND in the
 * tab order. Same fix as v1's admin.css, and load-bearing here for the two views. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--dash-bg);
  color: var(--dash-ink);
  font-family: var(--dash-font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* Visible focus everywhere, never removed. A builder is a keyboard tool for anyone who uses it
 * more than once. */
:focus-visible {
  outline: 2px solid var(--dash-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ shell */

.builder {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--dash-panel);
  border-bottom: 1px solid var(--dash-line);
}

/* min-width:0 lets these columns actually shrink inside the 1fr tracks. Without it a flex item
 * refuses to go below its content width, the right group grows past its column, and it lands on
 * top of the centred tabs - which is exactly what happened in revision 1. flex-wrap is the
 * second guard, for a language whose labels run wider than English's. */
.top-l, .top-r { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.top-r { justify-content: flex-end; }

/* ------------------------------------------------------------------ controls */

.bbtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--dash-line);
  border-radius: 8px;
  background: var(--dash-panel);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  color: var(--dash-ink);
  text-decoration: none;
}
.bbtn:hover { background: var(--dash-panel-2); }
.bbtn:disabled { opacity: .4; cursor: default; }
.bbtn:disabled:hover { background: var(--dash-panel); }

/* Near-black, as Typeform's own primary is. Ink is monochrome, so this stays inside the
 * containment rule without spending either status hue on a button. */
.bbtn--primary {
  background: var(--dash-ink);
  color: var(--dash-panel);
  border-color: var(--dash-ink);
  font-weight: 600;
}
.bbtn--primary:hover { background: var(--dash-ink); opacity: .85; }
.bbtn--icon { padding: 7px 10px; }
.bbtn--ghost { background: transparent; border-color: transparent; color: var(--dash-ink-2); }
.bbtn--ghost:hover { color: var(--dash-ink); background: var(--dash-panel-2); }

.bseg {
  display: inline-flex;
  border: 1px solid var(--dash-line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--dash-panel);
}
.bseg button {
  padding: 6px 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--dash-ink-2);
  border-right: 1px solid var(--dash-line);
  font-weight: 500;
}
.bseg button:last-child { border-right: 0; }
.bseg button[aria-pressed="true"] { background: var(--dash-ink); color: var(--dash-panel); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid var(--dash-line);
  color: var(--dash-ink-2);
  background: var(--dash-panel);
}
.chip--draft { border-color: var(--dash-warn); color: var(--dash-warn); text-transform: uppercase; }
.chip--nw { border-color: var(--dash-warn); color: var(--dash-warn); cursor: pointer; }

/* ------------------------------------------------------------------ tabs — Typeform's centred pair */

.tabs { display: inline-flex; gap: 4px; }
.tab {
  padding: 8px 18px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--dash-ink-2);
  cursor: pointer;
  font-weight: 500;
  font-size: 15px;
}
.tab:hover { color: var(--dash-ink); }
.tab[aria-selected="true"] { background: var(--dash-panel-2); color: var(--dash-ink); font-weight: 600; }

/* ------------------------------------------------------------------ notice */

.notice {
  padding: 8px 20px;
  border-bottom: 1px solid var(--dash-line);
  background: var(--dash-panel);
  font-size: 13px;
}
.notice--warn { border-left: 4px solid var(--dash-warn); }
.notice--ok   { border-left: 4px solid var(--dash-accent); }

/* ------------------------------------------------------------------ views */

/* Rows are PINNED, not implicit. The notice and the inactive view are display:none, and grid
 * auto-placement ignores hidden children - so without explicit rows the visible view slides up
 * into the auto second row and renders at content height instead of filling the 1fr third. */
.top { grid-row: 1; }
.notice { grid-row: 2; }
.view { grid-row: 3; min-height: 0; overflow: hidden; }

.view--content {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
}

.pane { overflow: auto; min-height: 0; padding: 16px; background: var(--dash-panel); }
.pane--rail { border-right: 1px solid var(--dash-line); }
.pane--insp { border-left: 1px solid var(--dash-line); }
/* The centre is the canvas: the one grey surface, so the white card and the white side panels
 * read as layers above it - Typeform's exact arrangement. */
.pane--canvas { background: var(--dash-bg); padding: 28px 32px; }

/* ------------------------------------------------------------------ left rail */

.rail-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 0 8px;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dash-ink-3);
  font-weight: 600;
}
.rail-head:first-child { margin-top: 0; }

.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.qrow {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.qrow:hover { background: var(--dash-panel-2); }
.qrow[aria-current="true"] { background: var(--dash-panel-2); border-color: var(--dash-accent); }
.qrow.is-dragging { opacity: .4; }
.qrow.is-over-before { box-shadow: 0 -2px 0 var(--dash-accent); }
.qrow.is-over-after  { box-shadow: 0  2px 0 var(--dash-accent); }

.qnum {
  display: grid; place-items: center;
  width: 26px; height: 22px;
  border-radius: 6px;
  background: var(--dash-panel-2);
  border: 1px solid var(--dash-line);
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--dash-ink-2);
}
.qrow[aria-current="true"] .qnum { background: var(--dash-ink); color: var(--dash-panel); border-color: var(--dash-ink); }
.qtitle { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qtitle--empty { color: var(--dash-ink-3); font-style: italic; }
.qmeta { display: flex; gap: 4px; align-items: center; }

/* A question with missing wording, and a question asked by both questionnaires. Dots rather
 * than words: the rail is scanned, not read - the sentences are in the inspector. */
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot--missing { background: var(--dash-warn); }
.dot--shared  { background: var(--dash-ink-3); }
/* A step that carries branching rules - Typeform marks these "1 rule set" in its block list. */
.dot--rules { background: var(--dash-accent); }

.rail-hint { margin: 6px 0 8px; font-size: 12px; color: var(--dash-ink-3); }
.railbtn-add { width: 100%; justify-content: center; margin-top: 8px; }

/* ------------------------------------------------------------------ centre stage */

.frame-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 720px; margin: 0 auto 6px;
  font-size: 12px; color: var(--dash-ink-3);
}
.frame-switches { display: flex; gap: 8px; }
.frame-hint { max-width: 720px; margin: 0 auto 12px; font-size: 12px; color: var(--dash-ink-3); }

/* The brand frame: the one place on this page that wears a brand, boxed so the boundary shows. */
.frame {
  max-width: 720px;
  margin: 0 auto;
  border: 1px solid var(--dash-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--dash-shadow);
  background: var(--bg);
}
.frame-in { padding: 32px 28px 36px; }

/* The card comes from css/survey.css unchanged; only the bits that assume a full-page
 * questionnaire are neutralised, so the preview stays honest about what it shows. */
.frame .card { max-width: none; margin: 0; }
.frame .nav, .frame .counter, .frame .fineprint { display: none; }

[contenteditable] { outline: none; border-radius: 4px; }
[contenteditable]:hover { box-shadow: inset 0 -1px 0 currentColor; }
[contenteditable]:focus-visible { outline: 2px solid var(--dash-accent); outline-offset: 3px; }
[contenteditable][data-empty="true"]::before {
  content: attr(data-placeholder);
  opacity: .4;
  pointer-events: none;
}

.frame-empty {
  max-width: 720px; margin: 0 auto; padding: 56px 24px; text-align: center;
  color: var(--dash-ink-3);
  border: 1px dashed var(--dash-line);
  border-radius: 16px;
}

/* The AI box, labelled Not wired - same rule as the dashboard's invented funnel figures. */
.aibox {
  max-width: 720px; margin: 20px auto 0;
  display: flex; gap: 8px; align-items: center;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--dash-line);
  border-radius: 14px;
  background: var(--dash-panel);
  box-shadow: var(--dash-shadow);
}
.aibox input { flex: 1; min-width: 0; padding: 8px 0; border: 0; background: transparent; }
.aibox input::placeholder { color: var(--dash-ink-3); }

/* ------------------------------------------------------------------ inspector */

.insp-sec { padding: 14px 0; border-bottom: 1px solid var(--dash-line); }
.insp-sec:last-child { border-bottom: 0; }
.insp-h {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dash-ink-3); margin-bottom: 8px; font-weight: 600;
}
.insp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
            padding: 6px 0; }
.insp-hint { font-size: 12px; color: var(--dash-ink-3); margin-top: 4px; }
.insp-note {
  margin-top: 10px; padding: 9px 11px;
  border-left: 3px solid var(--dash-warn);
  background: var(--dash-panel-2);
  border-radius: 0 8px 8px 0;
  font-size: 12px;
}

select.ctl, input.ctl {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--dash-line);
  border-radius: 8px;
  background: var(--dash-panel);
}

.mono { font-family: var(--dash-mono, ui-monospace, Consolas, monospace); font-size: 12px;
        color: var(--dash-ink-2); }

.tog { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* Typeform's toggle switch, built ON the real checkbox rather than beside it: the input stays an
 * input, so keyboard, forms and screen readers are untouched and only the paint changes. On is
 * ink, not a hue - the same monochrome move as the primary button. */
.insp-row input[type="checkbox"] {
  appearance: none;
  width: 36px; height: 21px;
  border-radius: 999px;
  background: var(--dash-line);
  position: relative;
  cursor: pointer;
  transition: background .15s;
  flex: none;
}
.insp-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--dash-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: left .15s;
}
.insp-row input[type="checkbox"]:checked { background: var(--dash-ink); }
.insp-row input[type="checkbox"]:checked::after { left: 17px; }

.optrow { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center;
          margin-bottom: 6px; }

/* A branching rule, summarised in the panel: "instagram -> Ending" */
.rulerow {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--dash-line);
  border-radius: 8px;
  background: var(--dash-panel-2);
  font-size: 12px;
}
.rulerow .mono { color: var(--dash-accent); }

/* ------------------------------------------------------------------ workflow canvas */

/* A pannable VIEWPORT with one WORLD moved by a single transform (js/graph.js). One explicit
 * 1fr row: with the default auto row the pane collapses to the world's own height and the zoom
 * bar - anchored to the view's bottom - floats mid-screen. */
.view--workflow { position: relative; display: grid; grid-template-rows: 1fr; overflow: hidden; }
.graph-viewport {
  position: relative; overflow: hidden; min-height: 0;
  background: var(--dash-bg);
  cursor: grab; touch-action: none; user-select: none;
}
.graph-viewport.is-panning { cursor: grabbing; }
.graph { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }

/* Edges are ONE svg layer underneath; nodes, chips and the popover are HTML on top - Typeform's
 * own construction, which is what lets edges be real curves while nodes stay focusable HTML. */
/* The DIRECT child only: chips, ports and the toolbar carry inline glyphs of their own, and a
 * descendant selector here pinned every one of them to the card's corner. */
.graph > svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.edge { fill: none; stroke: var(--dash-ink-2); stroke-width: 1.25; }
.edge--pending { stroke-width: 2; stroke-dasharray: 5 5; }

/* The card. Typeform's, measured: white, radius 12, no border at rest, a whisper of shadow
 * that deepens on hover; the accent border marks the selected step as the rail does. */
.node {
  position: absolute;
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--dash-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  text-align: left;
  cursor: grab;
  touch-action: none;      /* or the browser pans the page instead of moving the node */
  user-select: none;
  font-family: var(--dash-font);
}
.node:active { cursor: grabbing; }
.node:hover { box-shadow: var(--dash-shadow); }
/* pointer-events:none while moving, so elementFromPoint sees the card UNDER the one being
 * dragged - that is how a drop on another card becomes a reorder (js/graph.js hitCard). */
.node.is-moving { box-shadow: 0 8px 24px rgba(0, 0, 0, .14); z-index: 3; pointer-events: none; opacity: .92; }
.node[aria-current="true"] { border-color: var(--dash-accent); }
.node.is-droptarget { border-color: var(--dash-accent); box-shadow: 0 0 0 3px var(--dash-panel-2); }
/* The insertion bar: a dragged card will land before (left) or after (right) this one. */
.node.is-insert-before::before, .node.is-insert-after::after {
  content: ''; position: absolute; top: 6px; bottom: 6px; width: 3px;
  border-radius: 2px; background: var(--dash-accent);
}
.node.is-insert-before::before { left: -14px; }
.node.is-insert-after::after { right: -14px; }

/* The type chip: icon + number. Ink on grey, not Typeform's per-type tint - the icon alone
 * carries the type, and the chrome stays inside its two-hue palette (file header). */
.nchip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 7px 0 5px;
  border-radius: 6px;
  background: var(--dash-panel-2);
  color: var(--dash-ink);
  font-size: 12px; font-weight: 500; line-height: 1;
  width: max-content;
}
.nchip svg { display: block; }

/* The graph lays nodes out with FIXED maths (NODE_W and the heights in js/graph.js) so edges
 * can be computed without measuring the DOM. That only stays true if a node cannot grow: the
 * label is clamped to three lines and the preview is bounded. Remove the clamp and every edge
 * below a long question attaches to empty space. */
.node-label {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 16px;
  color: var(--dash-ink-2);
}
.npre { display: grid; gap: 1px; font-size: 12px; line-height: 15px; color: var(--dash-ink-2); }
.npre-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.npre--scale { display: flex; flex-wrap: wrap; gap: 2px; }
.npre--scale i {
  font-style: normal; font-size: 9px;
  width: 13px; height: 13px;
  display: grid; place-items: center;
  border-radius: 3px;
  background: var(--dash-panel-2);
}

/* The start card: what the invitation link carries. Dashed, like Typeform's "Pull data in". */
.node--start { border: 1px dashed var(--dash-line); background: transparent; box-shadow: none; }
.node--start:hover { box-shadow: none; }
.node-start-icon { color: var(--dash-ink); }
.node-title { font-size: 14px; color: var(--dash-ink); }
.node-hint { font-size: 12px; line-height: 15px; color: var(--dash-ink-3); }
.node-params { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.nparam {
  font-family: var(--dash-mono, ui-monospace, Consolas, monospace); font-size: 11px;
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--dash-line);
  color: var(--dash-ink-2); background: var(--dash-panel);
}
.node--end .node-label { color: var(--dash-ink); }

/* The connector: Typeform's black circle on the arrow's origin at the card's right edge, 40 px
 * from the top, with a soft halo that lifts it off the line it sits on. Ink, not a hue. While a
 * rule is being dragged out of it, it collapses to a plain dot - the glyph would only sit under
 * the dashed line. */
.port {
  position: absolute; right: -12px; top: 28px;
  width: 24px; height: 24px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--dash-ink); color: var(--dash-panel);
  box-shadow: 0 0 0 3px var(--dash-panel-2);
  cursor: pointer; touch-action: none; z-index: 2;
}
.port svg { display: block; }
.port:hover { box-shadow: 0 0 0 3px var(--dash-line); }
/* A free-text card cannot carry rules, but its badge stays visible and clickable: grey says
 * "different here", and the click opens the modal whose one sentence says why. Absence was
 * tried first and read as the feature missing. */
.port--off { background: var(--dash-ink-3); }
.port.is-dragging { width: 14px; height: 14px; right: -7px; top: 33px; }
.port.is-dragging svg { display: none; }

/* The hover toolbar under a card: Typeform's four logic types by name. :focus-within shows it
 * to a keyboard user, who otherwise would never learn it exists. */
/* The outer span starts FLUSH with the card and pads the gap, so the pointer travelling down
 * to the pill never leaves the card's hover area; the pill is the inner span. Hiding waits a
 * beat (the visibility delay) so a pointer that strays off for a moment does not lose it. */
.ntools {
  position: absolute; left: 0; top: 100%;
  padding-top: 8px;
  opacity: 0; visibility: hidden;
  transition: opacity .12s, visibility 0s linear .3s;
  z-index: 4;
}
.ntools-in {
  display: flex; gap: 2px; padding: 4px;
  border-radius: 12px;
  background: var(--dash-panel); border: 1px solid var(--dash-line);
  box-shadow: var(--dash-shadow);
}
.node:hover .ntools, .node:focus-within .ntools, .node.is-droptarget .ntools {
  opacity: 1; visibility: visible; transition-delay: 0s;
}
.node.is-moving .ntools { visibility: hidden; opacity: 0; }
.ntool {
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 8px;
  display: grid; place-items: center;
  background: transparent; color: var(--dash-ink-2);
  cursor: pointer;
}
.ntool:hover { background: var(--dash-panel-2); color: var(--dash-ink); }

/* A rule chip: Typeform's 24 px "sliders" square in a 32 px halo the colour of the ground, so
 * it masks the edge it sits on. A button, so Tab reaches it and Enter opens the editor. */
.rchip {
  position: absolute; width: 32px; height: 32px; padding: 4px;
  border: 0; border-radius: 10px;
  background: var(--dash-bg);
  cursor: pointer; z-index: 2;
}
.rchip > span {
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 8px;
  background: var(--dash-panel); color: var(--dash-ink);
  border: 1px solid var(--dash-line);
}
.rchip:hover > span, .rchip:focus-visible > span { border-color: var(--dash-ink-3); }

/* The rule popover: If ... / then go to ... / Delete, Edit. Opens on hover and on focus. */
.rpop {
  position: absolute; z-index: 5; width: 300px;
  padding: 14px 16px 12px;
  border-radius: 12px;
  background: var(--dash-panel); border: 1px solid var(--dash-line);
  box-shadow: var(--dash-shadow);
  font-size: 13px; color: var(--dash-ink-2);
  cursor: default;
}
.rpop-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rpop-row--op b { color: var(--dash-ink); font-weight: 500; }
.rpop-k { color: var(--dash-ink); font-weight: 500; min-width: 30px; }
.rpop-k--soft { color: var(--dash-ink-2); font-weight: 400; min-width: 48px; }
.rpop-q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dash-ink); }
.rpop-join { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
             color: var(--dash-ink-3); margin: 2px 0 8px 38px; }
.rpop-then { border-top: 1px solid var(--dash-line); margin: 4px 0 10px; padding-top: 10px; }
.rpop-f { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.rpop-del { color: var(--dash-warn); }
.rpop-del svg { vertical-align: -2px; }

/* The zoom bar, bottom-left like Typeform's: out, in, fit | tidy, ?. */
.graph-ctl {
  position: absolute; left: 16px; bottom: 16px;
  display: flex; align-items: center; gap: 2px;
  padding: 4px;
  border: 1px solid var(--dash-line);
  border-radius: 12px;
  background: var(--dash-panel);
  box-shadow: var(--dash-shadow);
}
.graph-ctl .bbtn--icon { padding: 6px; border-color: transparent; }
.graph-ctl .bbtn--icon svg { display: block; }
.graph-ctl-sep { width: 1px; height: 18px; background: var(--dash-line); margin: 0 3px; }

/* Typeform's "Chat to create" bar: floating, bottom-centre, rounded. Ours says what it is -
 * the Not wired chip sits inside the box and cannot come off it. */
.graph-ai {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: min(520px, calc(100% - 340px));
  display: flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 8px; margin: 0;
  border: 1px solid var(--dash-line);
  border-radius: 16px;
  background: var(--dash-panel);
  box-shadow: 0 0 0 4px var(--dash-panel-2), var(--dash-shadow);
}
.graph-ai input {
  flex: 1; min-width: 0; padding: 8px 4px;
  border: 0; background: transparent;
  font-family: var(--dash-font); font-size: 14px; color: var(--dash-ink);
}
.graph-ai input::placeholder { color: var(--dash-ink-3); }
.graph-ai .ntool--send { background: var(--dash-ink); color: var(--dash-panel); }
.graph-ai .ntool--send:hover { background: var(--dash-ink); opacity: .85; }

/* ------------------------------------------------------------------ modals */

.modal-host {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .4);
}
.modal {
  width: min(880px, 100%);
  max-height: 86vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: 16px;
  background: var(--dash-panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
  overflow: hidden;
}
.modal--narrow { width: min(600px, 100%); }
.modal-h { padding: 20px 24px 14px; border-bottom: 1px solid var(--dash-line); }
.modal-h h2 { margin: 0 0 4px; font-size: 17px; }
.modal-lead { margin: 0; font-size: 12px; color: var(--dash-ink-2); max-width: 62ch; }
.modal-b { padding: 22px 24px; overflow: auto; }
.modal-f { padding: 14px 24px; border-top: 1px solid var(--dash-line);
           display: flex; justify-content: flex-end; gap: 8px; }

.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.bcard {
  display: grid; gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--dash-line);
  border-radius: 12px;
  background: var(--dash-panel);
  cursor: pointer;
  text-align: left;
}
.bcard:hover { border-color: var(--dash-accent); background: var(--dash-panel-2); }
.bcard b { font-weight: 600; }
.bcard span { font-size: 12px; color: var(--dash-ink-2); }

/* The two types measurement rule 5 lives or dies on. Named, not merely listed. */
.bcard--nps span { color: var(--dash-accent); }
.bcard--faces span { color: var(--dash-warn); }

.tgrid { width: 100%; border-collapse: collapse; font-size: 13px; }
.tgrid th, .tgrid td { padding: 9px 10px; border-bottom: 1px solid var(--dash-line);
                       text-align: left; vertical-align: top; }
.tgrid th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
            color: var(--dash-ink-3); font-weight: 600; }
.tgrid td.is-missing { color: var(--dash-warn); font-style: italic; }

/* ------------------------------------------------------------------ the Logic modal */

/* Typeform's two-pane Logic dialog (js/logic.js): the question list on the left, the selected
 * question's sections on the right, Delete all rules / Cancel / Save across the foot. */
.modal--logic { width: min(1120px, 100%); height: min(86vh, 760px); }
.modal-h { position: relative; }
.modal-x { position: absolute; right: 14px; top: 14px; }
.lbody { display: grid; grid-template-columns: 300px 1fr; padding: 0; overflow: hidden; }
.llist {
  overflow: auto; padding: 14px 12px;
  border-right: 1px solid var(--dash-line);
  background: var(--dash-bg);
}
.lq {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center;
  width: 100%; padding: 10px 12px; margin-bottom: 4px;
  border: 0; border-radius: 10px;
  background: transparent; text-align: left; cursor: pointer;
  font-family: var(--dash-font); color: var(--dash-ink);
}
.lq:hover, .lq.is-selected { background: var(--dash-panel-2); }
.lq--start { cursor: default; color: var(--dash-ink-2); }
.lq--start:hover { background: transparent; }
.lq-text { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lq-hint { grid-column: 2; font-size: 11px; color: var(--dash-ink-3); white-space: normal; }
.lq-count {
  grid-column: 2; width: max-content;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--dash-line); background: var(--dash-panel); color: var(--dash-ink-2);
}
.lpane { overflow: auto; padding: 24px 28px; background: var(--dash-panel); }
.lpane-h { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: 14px; }
.lpane-q { color: var(--dash-ink); }

/* One section: header with icon, title, an (i), the rule count, the not-wired chip where the
 * section is shown only, and a chevron; the body beneath. */
.lsec { border: 1px solid var(--dash-line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.lsec-h {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 14px 16px;
  border: 0; background: var(--dash-panel);
  cursor: pointer; text-align: left;
  font-family: var(--dash-font); font-size: 14px; font-weight: 600; color: var(--dash-ink);
}
.lsec.is-open .lsec-h { background: var(--dash-panel-2); }
.lsec-i { color: var(--dash-ink-3); display: inline-flex; }
.lsec-h .lq-count { grid-column: auto; }
.lsec-h .chip--nw { font-size: 11px; padding: 2px 8px; }
.lsec-chev { margin-left: auto; color: var(--dash-ink-3); display: inline-flex; transition: transform .12s; }
.lsec.is-open .lsec-chev { transform: rotate(180deg); }
.lsec-b { padding: 16px 16px 18px; }
.lsec-empty { display: flex; align-items: center; gap: 6px; margin: 0 0 12px; font-size: 13px; color: var(--dash-ink-2); }
.lsec-empty svg { display: inline-block; }
.lsec-nw {
  margin: 0 0 12px; padding: 10px 12px;
  border-left: 3px solid var(--dash-warn);
  background: var(--dash-panel-2);
  font-size: 12px; color: var(--dash-ink-2);
}
.modal-f--split { justify-content: space-between; align-items: center; }
.lfoot-r { display: flex; align-items: center; gap: 8px; }
.lerr { font-size: 12px; color: var(--dash-warn); max-width: 46ch; }
.ldel { color: var(--dash-warn); }
.ldel svg, .brule-del svg, .rpop-del svg { vertical-align: -2px; }

/* One branching rule, Typeform's order: Go to [target] / When [q] [op] [value] / + Add
 * condition (and|or) / Delete rule. */
.brule {
  padding: 14px 16px; margin-bottom: 12px;
  border: 1px solid var(--dash-line); border-radius: 12px;
  background: var(--dash-panel);
}
.crow {
  display: grid; grid-template-columns: 76px 1.7fr 1.1fr .9fr 34px;
  gap: 8px; align-items: center; margin-bottom: 8px;
}
.crow--goto { grid-template-columns: 76px 1fr; padding-bottom: 12px; margin-bottom: 12px;
              border-bottom: 1px solid var(--dash-line); }
.crow--acts { display: flex; justify-content: space-between; margin: 4px 0 0; }
.crow-k { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--dash-ink); }
.crow-k svg { display: inline-block; }
.ctl--join { width: max-content; }
.brule-del { color: var(--dash-warn); }
.branch-default {
  display: flex; gap: 8px; align-items: baseline;
  padding: 12px 14px; margin: 4px 0 12px;
  border: 1px dashed var(--dash-line); border-radius: 10px;
  color: var(--dash-ink-2); font-size: 13px;
}

/* ------------------------------------------------------------------ narrow */

/* Below 900px the three panes stack and there is nothing beside anything. THE BREAKPOINT IS
 * ALSO IN js/builder.js - if the two drift, a pane stacks while the code still believes it is
 * beside another one. */
@media (max-width: 900px) {
  .builder { height: auto; min-height: 100vh; }
  .view--content { grid-template-columns: 1fr; }
  .pane--rail { border-right: 0; border-bottom: 1px solid var(--dash-line); }
  .pane--insp { border-left: 0; border-top: 1px solid var(--dash-line); }
  .top { grid-template-columns: 1fr; gap: 8px; }
  .graph-ctl { position: static; margin: 12px 16px 0; }
  .graph-ai { position: static; transform: none; width: auto; margin: 12px 16px; }
  .lbody { grid-template-columns: 1fr; }
  .llist { max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--dash-line); }
  .crow { grid-template-columns: 1fr 1fr; }
  .crow--goto { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
