/* ══════════════════════════════════════════════════════════════════
   FORMS — Workspace "Forms" tab + form builder modal
   ──────────────────────────────────────────────────────────────────
   Shared pill-colour palette (7 swatches) lives at the bottom of this
   file and is used both by the builder's colour-cycling dots and by
   the Abstract Screen answer pills/buttons (abstract-screen.css),
   so a colour picked here renders identically wherever the form is
   actually answered.
══════════════════════════════════════════════════════════════════ */

/* ── Forms tab: list ─────────────────────────────────────────────── */
.ws-forms-list {
  padding: 12px 18px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.ws-forms-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 38px 20px;
  color: var(--ink-muted);
}
.ws-forms-empty i { font-size: 2rem; opacity: 0.3; margin-bottom: 4px; }
.ws-forms-empty h4 { font-size: 0.86rem; font-weight: 700; color: var(--ink); margin: 0; }
.ws-forms-empty p { font-size: 0.72rem; max-width: 360px; line-height: 1.5; margin: 0 0 6px; }

/* ── Forms tab — stage sections (Abstract Screen / Full Text Screen) ──
   Each section is itself a nested grid using the same card sizing as the
   old flat list, so grouping by stage doesn't change how the cards lay
   out — it just adds a labelled seam between the two groups. */
.ws-forms-section {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.ws-forms-section + .ws-forms-section {
  margin-top: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.ws-forms-section-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ws-forms-section-head h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.ws-stage-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ws-stage-dot--abstract { background: var(--teal, #0da79a); }
.ws-stage-dot--fulltext { background: var(--purple, #7c3aed); }
.ws-forms-empty--section {
  grid-column: 1 / -1;
  align-items: flex-start;
  text-align: left;
  padding: 16px 4px;
}
.ws-forms-empty--section p { max-width: none; margin: 0; }

.ws-form-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--r-card, 10px);
  background: var(--bg-page, #f7f4f1);
  border: 1px solid var(--border, #e8e3df);
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.ws-form-card:hover {
  background: var(--bg-hover, #f0ece8);
  border-color: var(--border-hover);
  box-shadow: 0 2px 10px rgba(43,24,23,0.06);
}

.ws-form-card-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.ws-form-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.ws-form-card-body { min-width: 0; flex: 1; }
.ws-form-card-name {
  font-size: var(--text-sm, 0.76rem);
  font-weight: var(--fw-semi, 600);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-form-card-desc {
  font-size: 0.68rem;
  color: var(--ink-soft);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-form-card-meta {
  font-size: 0.64rem;
  color: var(--ink-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ws-form-card-dot { opacity: 0.5; }

.ws-form-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── "Assign to projects" panel — expands under a form card ─────────── */
.ws-form-card-wrap { display: flex; flex-direction: column; }

.ws-form-assign-panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  padding: 8px;
  border-radius: var(--r-card, 10px);
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #e8e3df);
  box-shadow: 0 4px 16px rgba(43,24,23,0.05);
  max-height: 260px;
  overflow-y: auto;
}
.ws-form-assign-panel::-webkit-scrollbar { width: 5px; }
.ws-form-assign-panel::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

.ws-form-assign-empty {
  padding: 10px 6px;
  font-size: 0.7rem;
  color: var(--ink-muted);
  text-align: center;
}

.ws-form-assign-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 7px;
  transition: background 0.12s ease;
}
.ws-form-assign-row:hover { background: var(--bg-page, #f7f4f1); }

.ws-form-assign-name {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-form-assign-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill, 20px);
  border: 1px solid var(--border);
  background: var(--bg-page, #f7f4f1);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.ws-form-assign-toggle:hover { border-color: var(--border-focus); color: var(--ink); }
.ws-form-assign-toggle.active {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}

/* ── Form builder modal — workflow layout ─────────────────────────────
   Rebuilt as a two-pane workflow, matching the Harvey-style canvas +
   inspector pattern: a left "flow" of step cards (question text, output
   type, option count — read-only at a glance) connected by a vertical
   track, and a right-hand inspector where the selected step's full
   detail is edited (label, output type, required, options, "show only
   if", delete). Only one step is ever open for editing at a time, so
   the old per-card popovers (.fb-settings-menu / .fb-showif-menu and
   their trigger buttons) are retired — every field for the selected
   step is visible at once in #fbInspector instead. ── */
#formBuilderModal .modal {
  width: 94vw;
  max-width: 980px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* only the panes below scroll internally */
}

/* Top meta fields (Applies To / Name / Description) — fixed above the
   flow, never scrolls itself. */
.fb-body {
  flex-shrink: 0;
  padding: 6px 2px;
}

.fb-workflow {
  display: flex;
  flex: 1;
  min-height: 0; /* required so the panes below can scroll instead of overflowing the modal */
  gap: 0;
  justify-content: center;
  background-image: radial-gradient(circle, var(--border-hover, rgba(43,24,23,0.16)) 1px, transparent 1px);
  background-size: 18px 18px;
  background-position: 10px 10px;
}

/* ── Left pane: the step-by-step flow ──────────────────────────────── */
.fb-flow-pane {
  flex: 0 1 560px;
  max-width: 560px;
  min-width: 256px;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-right: 0;
  transition: flex-basis 0.22s ease, max-width 0.22s ease, padding-right 0.22s ease;
}

.fb-workflow.fb-inspector-open {
  justify-content: flex-start;
}

.fb-workflow.fb-inspector-open .fb-flow-pane {
  flex: 0 0 40%;
  max-width: 380px;
  padding-right: 14px;
}

.fb-flow-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 8px 8px 2px;
}
.fb-flow-scroll::-webkit-scrollbar { width: 5px; }
.fb-flow-scroll::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

.fb-flow-list { /* plain block now — sizing/scrolling live on .fb-flow-scroll above */ }

.fb-flow-card {
  display: block;
  padding: 12px 13px 13px;
  border-radius: var(--r-card, 10px);
  border: 1px solid var(--border, #e8e3df);
  background: var(--bg-surface, #fff);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}
.fb-flow-card:hover { border-color: var(--border-hover); background: var(--bg-page); }
.fb-flow-card.selected {
  border-color: var(--teal);
  background: var(--bg-surface);
}
.fb-flow-card--locked.selected {
  border-color: var(--purple, #7c3aed);
}

.fb-flow-card--dragging { opacity: 0.4; }
.fb-flow-card--drag-over { box-shadow: 0 -3px 0 0 var(--teal, #0da79a); }

.fb-flow-card-top {
  display: flex;
  align-items: center;
  gap: 7px;
}

.fb-flow-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: var(--teal-soft);
  color: var(--teal);
}
.fb-flow-card-icon--locked { background: rgba(124, 58, 237, 0.12); color: var(--purple, #7c3aed); }

.fb-flow-card-kicker {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: var(--fw-black, 800);
  color: var(--ink);
}

.fb-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 5px;
  color: var(--ink-muted);
  cursor: grab;
  transition: background 0.14s ease, color 0.14s ease;
}
.fb-drag-handle:hover { background: var(--bg-surface); color: var(--ink-soft); }
.fb-drag-handle:active { cursor: grabbing; }
.fb-drag-handle i { font-size: 1rem; }

.fb-flow-card-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0 11px;
}

.fb-flow-card-label {
  font-size: 0.7rem;
  font-weight: var(--fw-semi, 700);
  color: var(--ink-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fb-flow-card-label.empty { color: var(--ink-muted); font-weight: 500; font-style: italic; }

.fb-flow-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
}

.fb-flow-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 2px 7px 2px 6px;
  border-radius: var(--r-pill, 20px);
  line-height: 1.5;
}
.fb-flow-chip i { font-size: 0.72rem; }

.fb-flow-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  height: 26px;
}
.fb-flow-connector-line {
  width: 1.5px;
  flex: 1;
  min-height: 8px;
  background: var(--border-hover);
}
.fb-flow-connector i {
  font-size: 0.85rem;
  line-height: 1;
  color: var(--border-hover);
  margin-top: -3px;
}

.fb-add-question {
  position: relative;
  display: flex;
  /* Narrower than a full-width card — this is a secondary "add" affordance,
     not another step, so it doesn't need to claim the full row. Centred
     in the space below the last card via margin-inline: auto. */
  width: 10%;
  min-width: 120px;
  margin-inline: auto;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 5px;
  border-radius: var(--r-card, 10px);
  border: 1px dashed var(--border-hover, rgba(43,24,23,0.2));
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
  flex-shrink: 0;
  margin-top: 26px;
}

.fb-add-question:hover { border-color: var(--ink-muted); background: var(--bg-hover); }
.fb-add-question i { font-size: 0.95rem; }

/* Connecting line down into "Add step" — no dot and no arrowhead here:
   just the plain line dropping straight out of the last card, since this
   is a static "add" affordance rather than a step-to-step link. Always
   the same muted tone as the real connectors, never tinted on hover. */
.fb-add-question::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -26px;
  width: 1.5px;
  height: 18px;
  transform: translateX(-50%);
  background: var(--border-hover);
}

/* ── "Add Step" type-picker popover ──────────────────────────────────
   Rendered by forms.js (_formsToggleAddStepMenu) as a detached element
   appended straight to <body> and positioned with inline top/left, so
   it isn't clipped by any of this modal's own overflow/scroll panes.
   z-index sits above .modal-overlay (3000, see literature-review.css)
   since it needs to float above the open form-builder modal itself. */
.fb-addstep-menu {
  z-index: 3100;
  min-width: 240px;
  max-width: 300px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--r-card, 10px);
  box-shadow: 0 8px 28px rgba(43,24,23,0.16);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fb-addstep-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}
.fb-addstep-option:hover,
.fb-addstep-option:focus-visible { background: var(--bg-hover, var(--bg-page)); outline: none; }

.fb-addstep-option-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: var(--teal-soft);
  color: var(--teal);
}
.fb-addstep-option-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.fb-addstep-option-title {
  font-size: 0.8rem;
  font-weight: var(--fw-semi, 700);
  color: var(--ink);
}
.fb-addstep-option-desc {
  font-size: 0.68rem;
  color: var(--ink-muted);
  line-height: 1.35;
  white-space: normal;
}

/* ── Right pane: the inspector — full editor for whichever step is
   selected on the left ──────────────────────────────────────────────── */
.fb-inspector-pane {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 2px 0 24px;
  border-left: 0 solid var(--border);
  opacity: 0;
  transition: flex-basis 0.22s ease, opacity 0.16s ease, padding 0.22s ease, border-color 0.22s ease;
}
.fb-inspector-pane::-webkit-scrollbar { width: 5px; }
.fb-inspector-pane::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

.fb-workflow.fb-inspector-open .fb-inspector-pane {
  flex: 1;
  width: auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px 24px 16px;
  border-left: 1px solid var(--border);
  opacity: 1;
  background: var(--bg-surface);
}

.fb-inspector-empty {
  height: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: var(--ink-muted);
}
.fb-inspector-empty i { font-size: 1.9rem; opacity: 0.32; }
.fb-inspector-empty p { font-size: 0.76rem; margin: 0; max-width: 220px; line-height: 1.5; }

.fb-inspector-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 13px;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
}
/* Header delete action — replaces the old full-width "Delete this
   question" button that lived at the bottom of the panel. Sits opposite
   the icon/title, revealed on hover of the header so it doesn't compete
   visually with the question identity every time the panel opens. Kept
   visible (not hover-gated) while disabled/focused so keyboard users and
   touch devices — neither of which get a hover state — can still reach
   and understand it. */
.fb-inspector-head-delete {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--red);
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.fb-inspector-head:hover .fb-inspector-head-delete,
.fb-inspector-head-delete:focus-visible,
.fb-inspector-head-delete:disabled {
  opacity: 1;
}
.fb-inspector-head-delete:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red-soft); }
.fb-inspector-head-delete:disabled { color: var(--ink-muted); cursor: default; opacity: 0.5; }
.fb-inspector-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.02rem;
  background: var(--teal-soft);
  color: var(--teal);
}
.fb-inspector-icon--locked { background: rgba(124, 58, 237, 0.12); color: var(--purple, #7c3aed); }

.fb-inspector-kicker {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-top: 2px;
}
.fb-inspector-head h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: var(--fw-black, 800);
  color: var(--ink);
  letter-spacing: -0.01em;
}

.fb-inspector-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 11px;
  margin-bottom: 15px;
  border-radius: var(--r-card, 10px);
  background: rgba(124, 58, 237, 0.06);
  border: 1px solid rgba(124, 58, 237, 0.18);
  color: var(--ink-soft);
  font-size: 0.7rem;
  line-height: 1.5;
}
.fb-inspector-note i { flex-shrink: 0; margin-top: 1px; font-size: 0.95rem; color: var(--purple, #7c3aed); }

.fb-inspector-section { margin-bottom: 16px; }
.fb-inspector-section:last-child { margin-bottom: 0; }

/* Section labels — sentence case throughout the panel now rather than
   tracked-out all-caps micro-copy; a touch bigger and a shade darker
   than before so they still read clearly as labels without needing the
   uppercase treatment to do that work. */
.fb-inspector-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.fb-inspector-label-count {
  margin-left: auto;
  font-weight: 700;
  font-size: 0.66rem;
  color: var(--ink-soft);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--r-pill, 20px);
  padding: 1px 7px;
}
/* Small purple "sent to AI" marker on the AI context field's label — same
   pill treatment as .fb-inspector-lock-tag (the Device Data Matrix
   prompt-context section) so both read as "this isn't a normal editable
   field, it feeds something outside this screen" at a glance, without
   the two looking identical (this one isn't locked, it's an ordinary
   editable textarea — just one whose only audience is the model). */
.fb-inspector-ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  padding: 1px 7px 1px 6px;
  border-radius: var(--r-pill, 20px);
  background: rgba(124, 58, 237, 0.1);
  color: var(--purple, #7c3aed);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.fb-inspector-ai-tag i { font-size: 0.78rem; }

.fb-inspector-field-hint {
  margin: 6px 2px 0;
  font-size: 0.66rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* Settings disclosure — collapsed by default (no "open" attribute in the
   markup) so the less-frequently-touched controls stay out of the way
   until an author actually wants them. The label doubles as the
   <summary> toggle; default marker triangles are suppressed in favor of
   a single chevron icon that rotates on open. */
.fb-inspector-details > summary.fb-inspector-label {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.fb-inspector-details > summary.fb-inspector-label::-webkit-details-marker { display: none; }
.fb-inspector-details-chevron {
  margin-left: auto;
  font-size: 0.95rem;
  color: var(--ink-muted);
  transition: transform 0.14s ease;
}
.fb-inspector-details[open] > summary .fb-inspector-details-chevron { transform: rotate(180deg); }
.fb-inspector-details > summary + .fb-inspector-settings { margin-top: 7px; }

.fb-inspector-textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 54px;
  border: 1px solid var(--border);
  border-radius: var(--r-card, 10px);
  background: var(--bg-page);
  padding: 9px 11px;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.45;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  color: var(--ink-soft);
}
.fb-inspector-textarea:focus {
  outline: none;
  background: var(--bg-surface);
}
.fb-inspector-textarea::placeholder { color: var(--ink-muted); font-weight: 500; }

.fb-inspector-readonly {
  padding: 9px 11px;
  border-radius: var(--r-card, 10px);
  background: var(--bg-page);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.45;
}

.fb-inspector-settings {
  border-radius: var(--r-card, 10px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.fb-settings-row {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 13px;
  border: none;
  background: transparent;
  font-family: inherit;
  text-align: left;
}
.fb-settings-row + .fb-settings-row { border-top: 1px solid var(--border); }
.fb-settings-row-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 9px;
}
.fb-settings-row-label i { font-size: 0.85rem; color: var(--ink-muted); }

/* Output type — a two-way segmented control (single vs. multiple choice),
   sat on a lighter "elevated" surface so it stands proud of the settings
   card's tinted background rather than blending into it. */
.fb-inspector-segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: var(--bg-page);
  border: 1px solid var(--border);
}
.fb-inspector-segmented button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}
.fb-inspector-segmented button i { font-size: 0.88rem; }
.fb-inspector-segmented button:hover { color: var(--ink-soft); }
.fb-inspector-segmented button.active {
  background: var(--bg-surface);
  color: var(--ink-soft);
}

/* Required-to-submit lives as a plain toggle row inside the same card —
   no border/background of its own any more (the card supplies both),
   just a hover tint like any other clickable list row. */
.fb-settings-row--toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 0;
  cursor: pointer;
  transition: background 0.14s ease;
}
.fb-settings-row--toggle:hover { background: var(--bg-hover); }
.fb-settings-row--toggle .fb-settings-row-label { margin-bottom: 0; }

.fb-inspector-showif {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--bg-page);
  border: 1px solid var(--border);
}
/* The condition groups/options/clear button render straight into
   .fb-inspector-showif now rather than into a floating .fb-showif-menu —
   drop the top margin/border the first group used to need to separate
   itself from a popover header. */
.fb-inspector-showif .fb-showif-group:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.fb-inspector-danger {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Prompt context — read-only preview of the summarisation prompt the
   Full Text locked block's answers drive (the only place this section
   still appears — see forms.js's _formsPromptContextHtml). Sits in a
   code-like surface, deliberately distinct from the editable
   .fb-inspector-textarea, so it reads as "shown, not editable" at a
   glance without needing to rely on a disabled/greyed-out affordance
   that can look like a bug. */
.fb-inspector-lock-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  padding: 1px 7px 1px 6px;
  border-radius: var(--r-pill, 20px);
  background: rgba(124, 58, 237, 0.1);
  color: var(--purple, #7c3aed);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.fb-inspector-lock-tag i { font-size: 0.78rem; }

.fb-prompt-context {
  border-radius: var(--r-card, 10px);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 11px;
}
.fb-prompt-context-hint {
  margin: 0 0 9px;
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--ink-muted);
}
.fb-prompt-context-box {
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 11px;
  border-radius: 8px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-family: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.66rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  user-select: text;
}
.fb-prompt-context-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 9px;
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-page);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.fb-prompt-context-copy i { font-size: 0.82rem; }
.fb-prompt-context-copy:hover { background: var(--bg-hover); border-color: var(--border-hover, var(--border)); }
.fb-prompt-context-copy.copied { color: var(--teal, #0da79a); border-color: var(--teal-border, var(--border)); background: var(--teal-soft); }

.fb-answers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.fb-answers--locked { margin-top: 0; }

.fb-answers-empty {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px dashed var(--border-hover, rgba(43,24,23,0.2));
  background: var(--bg-surface);
  color: var(--ink-muted);
  font-size: 0.7rem;
  font-style: italic;
  margin-bottom: 2px;
}

.fb-answer-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 3px;
  border-radius: var(--r-pill, 20px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: border-color 0.14s ease;
  flex: 0 0 auto;
  max-width: 100%;
}
.fb-answer-pill:focus-within { border-color: var(--border-teal); }
.fb-answer-pill--locked { background: var(--bg-surface); border-color: var(--border); }

.fb-answer-input {
  /* Width is driven natively via the `size` attribute (kept in sync with
     the value by forms.js, on render + oninput), so the box always tracks
     the actual text: short answers collapse the pill down, long answers
     stay fully visible instead of being clipped at a fixed max-width. */
  field-sizing: content;
  min-width: 22px;
  max-width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  padding: 2px 4px;
  flex: 0 1 auto;
}
.fb-answer-input:focus { outline: none; }
.fb-answer-input::placeholder { color: var(--ink-muted); font-weight: 500; }
.fb-answer-input--locked { color: var(--ink-soft); font-weight: 600; cursor: default; }

.fb-decision-badge {
  flex-shrink: 0;
  border: none;
  border-radius: var(--r-pill, 20px);
  padding: 3px 8px;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg-page, #f7f4f1);
  color: var(--ink-muted);
  transition: all 0.14s;
}
.fb-decision-badge:hover { background: var(--bg-elevated); }
.fb-decision-badge.fb-decision-include { background: var(--green-soft); color: var(--green); }
.fb-decision-badge.fb-decision-exclude { background: var(--red-soft); color: var(--red); }

.fb-answer-remove {
  width: 16px;
  height: 16px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.12s ease;
}
.fb-answer-remove:hover { background: var(--red-soft); color: var(--red); }

.fb-add-answer {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: var(--r-pill, 20px);
  border: 1px dashed var(--border-hover, rgba(43,24,23,0.2));
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.fb-add-answer:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }

/* Small pill-shaped on/off switch, reused by .fb-inspector-switch-row. */
.fb-settings-switch {
  flex-shrink: 0;
  position: relative;
  width: 30px;
  height: 17px;
  border-radius: 20px;
  background: var(--border-hover, rgba(43,24,23,0.18));
  transition: background 0.16s ease;
}
.fb-settings-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--bg-surface, #fff);
  box-shadow: 0 1px 3px rgba(43,24,23,0.25);
  transition: transform 0.16s ease;
}
.fb-settings-switch.on { background: var(--teal); }
.fb-settings-switch.on::after { transform: translateX(13px); }

/* Danger "delete" button — used both as the question's delete action in
   the inspector's footer, and previously inside the settings popover. */
.fb-settings-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--r-card, 10px);
  padding: 9px 6px;
  color: var(--red);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.fb-settings-delete:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red-soft); }
.fb-settings-delete:disabled { color: var(--ink-muted); cursor: default; opacity: 0.6; }

/* "Show only if" condition list — rendered inline inside
   .fb-inspector-showif now rather than behind a popover; the group/
   option/decision-tag/clear-button styling itself is unchanged. */
.fb-showif-hint {
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--ink-soft);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.fb-showif-group + .fb-showif-group { margin-top: 2px; padding-top: 8px; border-top: 1px solid var(--border); }

.fb-showif-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fb-showif-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.fb-showif-option:hover { background: var(--bg-surface); }
.fb-showif-option input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: var(--teal);
  flex-shrink: 0;
  cursor: pointer;
}
.fb-showif-option-label {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fb-showif-decision {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-pill, 30px);
}
.fb-showif-decision--include { background: var(--green-soft); color: var(--green); }
.fb-showif-decision--exclude { background: var(--red-soft); color: var(--red); }

.fb-showif-empty {
  padding: 8px 2px;
  font-size: 0.68rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

.fb-showif-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 2px;
  padding: 8px 6px 2px;
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--red);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease;
}
.fb-showif-clear:hover { background: var(--red-soft); }

/* ── Stage toggle (Abstract Screen / Full Text Screen) — top of the Form
   Builder modal. Two-way segmented control, same visual language as
   .fb-inspector-segmented, but this one is horizontal across the full
   meta width since both options need to stay visible/comparable. ── */
.fb-stage-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--r-card, 10px);
  background: var(--bg-page);
  border: 1px solid var(--border);
}
.fb-stage-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.fb-stage-btn:hover { color: var(--ink); }
.fb-stage-btn.active { background: var(--bg-elevated, #fff); color: var(--ink) }

/* Read-only stand-in for the stage toggle above, shown instead of it once
   a form already exists (see openBuilder, forms.js) — "Applies to" is a
   one-time, up-front choice for a brand-new form only; an existing form
   still needs its stage visible, just not editable inline here. */
.fb-stage-static {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: var(--r-card, 10px);
  background: var(--bg-page);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
}
.fb-stage-static i { font-size: 0.85rem; color: var(--ink-muted); }
.fb-stage-static strong { color: var(--ink); font-weight: var(--fw-black, 800); }

/* ── Narrow viewports: stack the flow above the inspector instead of
   running them side by side ──────────────────────────────────────────── */
@media (max-width: 760px) {
  #formBuilderModal .modal { width: 96vw; max-height: 94vh; }
  .fb-workflow { flex-direction: column; overflow-y: auto; }
  .fb-flow-pane, .fb-workflow.fb-inspector-open .fb-flow-pane {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    max-height: 240px;
    padding-right: 0;
  }
  /* Collapsed: no border/margin so an empty inspector doesn't leave a
     stray line under the flow list (mirrors the desktop zero-width
     collapse, just stacked instead of side-by-side). */
  .fb-inspector-pane {
    flex: 0 0 0;
    width: 100%;
    height: 0;
    border-left: none;
    border-top: 0 solid var(--border);
    padding: 0 2px;
    margin-top: 0;
    overflow: hidden;
  }
  .fb-workflow.fb-inspector-open .fb-inspector-pane {
    flex: 1 1 auto;
    height: auto;
    border-top: 1px solid var(--border);
    padding: 14px 2px 4px;
    margin-top: 12px;
    overflow-y: auto;
  }
}