/* Kumii v3 — 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;
  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 track. 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 left one - in v2 it landed on 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; }

/* ------------------------------------------------------------------ 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); }

/* ------------------------------------------------------------------ the one page */

/* Rows are PINNED, not implicit. The notice is display:none until something happens, and grid
 * auto-placement ignores hidden children - so without explicit rows the 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; }

/* Rail | workflow | drawer. The drawer is a grid column that exists only while the drawer does:
 * [hidden] removes the item, not the track, so the track is toggled by class (js/builder.js
 * render). minmax(0, 1fr) lets the workflow column shrink below its content - the zoom bar and
 * the AI bar inside it are wide, and 1fr alone would refuse to go under them. */
.view--one {
  display: grid; position: relative;
  --rail-w: 300px; --panel-w: 520px;       /* written by js/splitters.js; these are the defaults */
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
}
.view--one.has-panel { grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--panel-w); }

.pane { overflow: auto; min-height: 0; padding: 16px; background: var(--dash-panel); }
/* Columns are PINNED, like the rows above. A collapsed rail is display:none, and auto-placement
 * would slide the workflow into its empty 0px track and the page would show nothing. */
.pane--rail { grid-column: 1; border-right: 1px solid var(--dash-line); }
.flow { grid-column: 2; }
.pane--qpanel { grid-column: 3; }

/* The workflow column: positioned, because the zoom bar and the AI bar anchor to it (in v2 they
 * anchored to the Workflow tab's panel). One explicit 1fr row: with the default auto row the
 * viewport collapses to the world's own height and the zoom bar floats mid-screen. */
.flow {
  position: relative; display: grid; grid-template-rows: 1fr; overflow: hidden; min-width: 0;
  container: flow / inline-size;    /* the AI bar below asks how wide THIS column is, not the window */
}

/* The drawer: a header with the close button, the grey ground holding the white card, then the
 * settings. 520px so the card inside is about 446px wide - a phone - and the container query
 * under .frame below makes the card show the phone arrangement rather than a squeezed desktop
 * one. */
.pane--qpanel {
  border-left: 1px solid var(--dash-line); padding: 0;
  display: grid; grid-template-rows: auto auto 1fr; align-content: start;
}
.qpanel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--dash-line);
  font-weight: 600;
}
/* The grey ground under the white card, as v2's centre pane was: the card is a layer above it. */
.qpanel-card { background: var(--dash-bg); padding: 16px; }
.qpanel-card .frame-in { padding: 24px 20px 28px; }
.qpanel-insp { padding: 4px 16px 16px; }

/* ------------------------------------------------------------------ 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;
  flex-wrap: wrap;      /* two switches and a caption in a 488px drawer, in German too */
  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;
}

/* Inside the drawer the frame is about 446px wide, which is a phone. The customer's own
 * stylesheet only knows viewports, so its phone rules are restated here against the frame's
 * width - the card must look like what a phone shows, not like a desktop card squeezed.
 * Keep in step with css/survey.css @media (max-width: 560px). */
.frame { container-type: inline-size; }
@container (max-width: 560px) {
  .frame .q { font-size: 26px; }
  .frame .scale--nps { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .frame .opt--nps { font-size: 16px; }
  .frame .scale--faces { gap: 2px; }
  .frame .opt--face .opt-num { font-size: 11px; }
}

/* ------------------------------------------------------------------ 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). The 1fr row that
 * gives it its height is on .flow, in the page section above. */
.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;
  align-content: start;    /* fixed heights (js/graph.js NODE_H): rows from the top, slack at the bottom */
  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 NODE_H 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, the preview is bounded, and the card's height is set, not a
 * minimum - the vertical flow hangs its connector on the bottom edge. 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; }
/* The start card's three soft spots, pinned so its height can be a constant at all (js/graph.js
 * NODE_H.start): the inline svg would add a text strut, the hint is the one unclamped sentence
 * on the canvas, and the four link parameters wrapped differently under every monospace fallback.
 * Six lines hold both languages of graph.startHint at 142px; a longer translation is cut, not
 * overflowed - the edge maths stays true and the sentence loses its tail. */
.node-start-icon { color: var(--dash-ink); }
.node-start-icon svg { display: block; }
.node-title { font-size: 14px; color: var(--dash-ink); }
.node-hint {
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 12px; line-height: 15px; color: var(--dash-ink-3);
}
.node-params { display: grid; justify-items: start; gap: 4px; margin-top: 2px; }   /* one chip per row: two per row truncated brand=keune */
.nparam {
  font-family: var(--dash-mono, ui-monospace, Consolas, monospace); font-size: 11px;
  line-height: 16px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  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; }

/* ------------------------------------------------------------------ splitters */

/* The two boundaries the user can drag (js/splitters.js): rail | workflow and workflow | drawer.
 * The widths are the two custom properties on .view--one, so the grid does the layout and the
 * script only writes numbers. The handles sit on the boundary, 8px wide, with a 2px line that
 * shows on hover, focus and while dragging - the line IS the focus ring here; a 2px outline
 * around an 8px strip reads as a bug. Separators in the tab order, so the keyboard has the
 * same route. Absolutely positioned: a grid child out of flow takes no track. */
.split {
  position: absolute; top: 0; bottom: 0; width: 8px; z-index: 6;
  cursor: col-resize; touch-action: none; user-select: none;
}
.split::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px;
  background: var(--dash-accent); opacity: 0; transition: opacity .12s;
}
.split:hover::before, .split:focus-visible::before, .split.is-dragging::before { opacity: 1; }
.split:focus-visible { outline: none; }
.split--l { left: calc(var(--rail-w) - 4px); }
.split--r { right: calc(var(--panel-w) - 4px); }
.view--one:not(.has-panel) .split--r { display: none; }
/* While a boundary moves, nothing on the page may select and the cursor stays the resize one
 * even over the canvas, or a fast drag reads as the canvas grabbing the pointer. */
.view--one.is-splitting { user-select: none; cursor: col-resize; }
.view--one.is-splitting .graph-viewport { cursor: col-resize; }

/* The collapsed rail: the pane goes and its track with it, and the handle becomes a 14px strip
 * at the edge with a chevron - the way back in, by click, drag or Enter. */
.view--one.rail-collapsed { --rail-w: 0px; }
.view--one.rail-collapsed .pane--rail { display: none; }
.view--one.rail-collapsed .split--l {
  left: 0; width: 14px;
  background: var(--dash-panel); border-right: 1px solid var(--dash-line);
}
.view--one.rail-collapsed .split--l::before { display: none; }
.split-tab {
  display: none; position: absolute; top: 50%; left: 1px;
  transform: translateY(-50%) rotate(-90deg);
  color: var(--dash-ink-2);
}
.split-tab svg { display: block; }
.view--one.rail-collapsed .split-tab { display: block; }
.view--one.rail-collapsed .split--l:hover .split-tab,
.view--one.rail-collapsed .split--l:focus-visible .split-tab { color: var(--dash-ink); }

/* ------------------------------------------------------------------ vertical flow */

/* js/graph.js puts .is-vertical on the world when the flow runs top-to-bottom. Same cards, same
 * table shape; only the sides change. The connector moves from the right edge to the bottom
 * edge, the insertion bars from the sides to the top and bottom, and the hover toolbar from
 * below the card to beside it, as a column - below is where the connector now lives, and a
 * toolbar sliding over the port would catch the pointer on its way to draw a rule. */
.graph.is-vertical .port { right: auto; top: auto; left: calc(50% - 12px); bottom: -12px; }
.graph.is-vertical .port.is-dragging { left: calc(50% - 7px); bottom: -7px; }
.graph.is-vertical .ntools { left: 100%; top: 0; padding: 0 0 0 8px; }
.graph.is-vertical .ntools-in { flex-direction: column; }
/* Both axes reset explicitly: the horizontal rule sets top/bottom/width, and a partial override
 * would leave a 3px-wide bar that is also 3px tall. */
.graph.is-vertical .node.is-insert-before::before,
.graph.is-vertical .node.is-insert-after::after {
  left: 6px; right: 6px; width: auto; height: 3px;
}
.graph.is-vertical .node.is-insert-before::before { top: -14px; bottom: auto; }
.graph.is-vertical .node.is-insert-after::after  { top: auto; bottom: -14px; }

/* The zoom bar, bottom-left like Typeform's: out, in, fit | tidy, orientation, ?. */
.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; }
/* The orientation pair reads as a two-state control: the pressed one sits on the panel's
 * second grey, ink on it - the same monochrome move as everything else on this bar. */
.graph-ctl .bbtn--icon[aria-pressed="true"] { background: var(--dash-panel-2); color: var(--dash-ink); }

/* 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; bottom: 20px;
  /* Centred when there is room, otherwise pushed right of the zoom bar (about 250px wide with
   * the orientation pair, plus its 16px margin) so the two never overlap in a narrow column. */
  left: max(calc(50% - 260px), 280px);
  width: min(520px, calc(100% - 296px));
  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);
}
/* With the drawer open on a 1280px screen the workflow column is about 460px, and beside the
 * zoom bar the AI bar would be 165px with its chip wrapped. Below 640px of column it moves up
 * a row instead, above the zoom bar, full width. Column width, not window width: the same
 * column is 980px with the drawer closed. */
@container flow (max-width: 640px) {
  .graph-ai { left: 16px; right: 16px; width: auto; bottom: 72px; }
}
.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 lives
 * here only: v2 also exported a NARROW constant from js/builder.js that nothing read. */
@media (max-width: 900px) {
  .builder { height: auto; min-height: 100vh; }
  .view--one, .view--one.has-panel { grid-template-columns: 1fr; }
  .pane--rail { border-right: 0; border-bottom: 1px solid var(--dash-line); }
  /* The canvas keeps a height of its own when stacked - without it the 1fr row has nothing to
   * fill and the viewport is 0px tall; the two bars become rows under it instead of floating. */
  .flow { min-height: 60vh; grid-template-rows: 1fr auto auto; }
  .pane--qpanel { border-left: 0; border-top: 1px solid var(--dash-line); }
  /* Stacked, there is no boundary to drag, and a rail collapsed on a wide screen shows again. */
  .split { display: none; }
  .view--one.rail-collapsed .pane--rail { display: block; }
  .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; }
}
