/* ============================================================
   NICO — Salestools campaign builder / viewer (cadence pane)
   Live artifact: campaign list, real step chain, stats rail,
   build_agent composer, confirm overlays. Design-token only —
   works in all three themes (dark / light / sierra).
   ============================================================ */

#pane-salestools { background: var(--surface-1); }

/* ---- header ---- */
.cadx-top { gap: 8px; flex-wrap: wrap; row-gap: 6px; }
.cadx-tt { min-width: 0; flex: 0 1 auto; overflow: hidden; }
.cadx-tt .dtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cadx-tt .dmeta {
  display: flex; align-items: center; gap: 6px; margin-top: 2px;
  white-space: nowrap; overflow: hidden;
}
.cadx-tt .dmeta .cadx-status { flex: none; }
.cadx-back { flex: none; }
.cadx-actions { display: inline-flex; gap: 6px; flex: none; }
.cadx-act.primary, .pillbtn.primary {
  color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-dim);
}
.cadx-act.ok { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-dim); }
.cadx-act.warn { color: var(--run); border-color: var(--line-bright); }
.cadx-act:disabled { opacity: 0.5; cursor: not-allowed; }

/* provenance chip + freshness */
.cadx-prov {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  border: 0.5px solid var(--line); border-radius: 20px; padding: 3px 9px;
  background: var(--surface-2);
}
.cadx-prov i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 6px oklch(0.805 0.15 150 / 0.5);
}
.cadx-asof { font-family: var(--mono); font-size: 10px; color: var(--text-4); flex: none; }

/* ---- body / scroll ---- */
.cadx-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.cadx-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 32px; overscroll-behavior: contain; }

/* ---- status pill ---- */
.cadx-status {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-family: var(--mono); font-size: 10px; color: var(--text-2);
  border: 0.5px solid var(--line); border-radius: 20px; padding: 2px 8px;
  background: var(--surface-2); text-transform: lowercase;
}
.cadx-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); }
.cadx-status.st-active i { background: var(--ok); box-shadow: 0 0 6px oklch(0.805 0.15 150 / 0.5); }
.cadx-status.st-paused i { background: var(--run); }
.cadx-status.st-draft i { background: var(--text-4); }
.cadx-status.st-completed i { background: var(--accent); }
.cadx-status.st-stopped i, .cadx-status.st-failed i { background: var(--err); }

/* ---- status dot inside a step's status chip ---- */
.cadx-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); display: inline-block; margin-right: 5px; flex: none; }
.cadx-dot.sd-completed { background: var(--ok); }
.cadx-dot.sd-running { background: var(--run); box-shadow: 0 0 0 3px var(--run-dim); animation: cadxPulse 1.6s infinite; }
.cadx-dot.sd-failed { background: var(--err); }
.cadx-dot.sd-pending { background: var(--text-4); }
@keyframes cadxPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---- loading skeleton ---- */
.cadx-skel { display: flex; flex-direction: column; gap: 9px; }
.cadx-skelrow {
  border: 0.5px solid var(--line-soft); border-radius: var(--r-md);
  background: var(--surface-2); padding: 13px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.cadx-skelrow .sk-a, .cadx-skelrow .sk-b {
  display: block; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--hover) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: cadxShimmer 1.3s infinite linear;
}
.cadx-skelrow .sk-a { width: 42%; }
.cadx-skelrow .sk-b { width: 68%; opacity: 0.7; }
@keyframes cadxShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---- empty / error states ---- */
.cadx-state {
  max-width: 380px; margin: 40px auto; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.cadx-state .cs-ic {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); border: 0.5px solid var(--line); color: var(--text-4);
  font-size: 16px; margin-bottom: 4px;
}
.cadx-error .cs-ic { color: var(--err); }
.cadx-state .cs-t { font-size: 13px; font-weight: 600; color: var(--text); }
.cadx-state .cs-m { font-size: 12px; line-height: 1.6; color: var(--text-3); }
.cadx-state .cadx-btn { margin-top: 8px; }

/* ---- campaign list rows (the switcher) ---- */
.cadx-arow {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  border: 0.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-1); transition: all 0.12s;
}
.cadx-arow:hover { border-color: var(--line-bright); background: var(--surface-2); }
.cadx-arow .ar-main { flex: 1; min-width: 0; }
.cadx-arow .ar-name { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.cadx-arow .ar-meta {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-4); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cadx-arow .ar-go { font-family: var(--mono); font-size: 10.5px; color: var(--accent-text); flex: none; }

/* ============================================================
   VIEWER — steps column + summary rail
   ============================================================ */
.cad-grid {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) 216px;
  grid-template-rows: minmax(0, 1fr);
}
.cad-main {
  min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 16px 36px;               /* deep bottom inset — the last card (and its
                                            expanded shadow) fully clears the pane edge */
  display: flex; flex-direction: column; gap: 9px;
}
.cad-main > * { flex: 0 0 auto; }

/* ---- step icon ---- */
.cad-ic {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 10.5px; color: #fff;
}
.cad-ic.li  { background: #0A66C2; }                        /* LinkedIn brand */
.cad-ic.em  { background: oklch(0.30 0.012 264); }
.cad-ic.wa  { background: #25D366; }                        /* WhatsApp brand */
.cad-ic.call{ background: oklch(0.52 0.13 38); }
.cad-ic.research { background: #7C5CFF; }
.cad-ic.data { background: var(--c-salestools); }
.cad-ic.ctrl { background: oklch(0.46 0.12 300); }
.cad-ic.wait { background: var(--surface-3); color: var(--text-3); border: 0.5px solid var(--line); }
.cad-ic.wait svg path, .cad-ic.wait svg circle { stroke: currentColor; }
.cad-ic.start { background: var(--surface-3); color: var(--text-3); border: 0.5px solid var(--line); }
.cad-ic.start svg path { fill: currentColor; }
.cad-ic.cond { background: oklch(0.50 0.10 220); }
.cad-ic svg { display: block; }

/* ---- step card ---- */
.cad-step {
  border: 0.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-1); overflow: hidden;
}
.cad-step.is-wait { background: var(--surface-2); border-style: dashed; }
.cad-step.expanded {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 1px var(--accent-line), 0 10px 30px oklch(0 0 0 / 0.18);
}
.cad-step-head {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; cursor: pointer;
}
.cad-num {
  font-family: var(--mono); font-size: 11px; color: var(--text-4);
  width: 18px; flex: none; text-align: center;
}
.cad-caret {
  width: 12px; flex: none; display: grid; place-items: center;
  color: var(--text-4); transition: transform 0.15s ease;
}
.cad-caret svg { width: 10px; height: 10px; }
.cad-step:not(.expanded) .cad-caret { transform: rotate(-90deg); }
.cad-step-head:hover .cad-caret { color: var(--accent-text); }
.cad-titles { min-width: 0; flex: 1; }
.cad-titles .t1 {
  font-size: 13px; color: var(--text); font-weight: 600; letter-spacing: -0.01em;
  white-space: normal; overflow-wrap: break-word; line-height: 1.3;
}
.cad-titles .t1 .kind { color: var(--text-4); font-weight: 400; font-size: 11px; }
.cad-titles .trow {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 4px;
}
.cad-titles .t2 {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-3); line-height: 1.4;
  min-width: 0; flex: 1 1 130px; white-space: normal; overflow-wrap: break-word;
}
.cad-timing {
  flex: none; display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 10px; color: var(--text-2);
  background: var(--surface-2); border: 0.5px solid var(--line);
  border-radius: 6px; padding: 3px 8px; white-space: nowrap;
}

/* expanded body */
.cad-step-body { border-top: 0.5px solid var(--line-soft); padding: 12px 14px; }
.cad-step:not(.expanded) .cad-step-body { display: none; }

/* structural steps collapse into one quiet "Automation setup" summary — the editable
   surface is just the outreach message steps below it */
.cad-setup { border: 0.5px dashed var(--line); border-radius: var(--r-md); background: var(--surface-2); margin-bottom: 4px; overflow: hidden; }
.cad-setup-head { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 12px; cursor: pointer; background: none; border: 0; text-align: left; color: inherit; font: inherit; }
.cad-setup .cad-caret { width: 12px; flex: none; display: grid; place-items: center; color: var(--text-4); transition: transform 0.15s ease; }
.cad-setup:not(.open) .cad-caret { transform: rotate(-90deg); }
.cad-setup-head:hover .cad-caret { color: var(--accent-text); }
.cad-setup .cad-ic.ctrl { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 13px; flex: none; }
.cad-setup .t1 { font-size: 12.5px; font-weight: 600; color: var(--text); }
.cad-setup .t2 { font-family: var(--mono); font-size: 10px; color: var(--text-4); margin-top: 2px; display: block; }
.cad-setup-body { border-top: 0.5px solid var(--line-soft); padding: 11px 13px; }
.cad-setup:not(.open) .cad-setup-body { display: none; }
.cad-flowchain { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 4px; margin-top: 8px; }
.cad-flowstep {
  display: inline-flex; align-items: center; font-family: var(--mono); font-size: 10.5px;
  color: var(--text-2); background: var(--surface-1); border: 0.5px solid var(--line-soft);
  border-radius: 20px; padding: 3px 9px;
}
.cad-flowstep.msg { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-dim); font-weight: 600; }
.cad-flowarrow { color: var(--text-4); font-size: 10px; }

/* ---- key/value rows (step detail, confirms) ---- */
.cadx-kvs { display: flex; flex-direction: column; gap: 6px; }
.cadx-kv { display: flex; gap: 12px; align-items: baseline; }
.cadx-kv .k {
  font-family: var(--mono); font-size: 10px; color: var(--text-4);
  flex: none; width: 128px; text-transform: lowercase;
}
.cadx-kv .v { flex: 1; min-width: 0; font-size: 12px; color: var(--text); overflow-wrap: break-word; }

/* ============================================================
   RIGHT RAIL — progress / prospects / meta / personas
   ============================================================ */
.cad-rail {
  border-left: 0.5px solid var(--line); background: var(--surface-1);
  min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 28px;
  display: flex; flex-direction: column; gap: 18px;
}
/* tight artifact panel (body.canvas-narrow set by nico.js) — the rail stops
   eating a third of the width: single column, rail flows ABOVE the steps as a
   horizontal card row so "hard to see all" never happens in a squeezed panel */
body.canvas-narrow .cad-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
body.canvas-narrow .cad-rail {
  order: -1; border-left: none; border-bottom: 0.5px solid var(--line);
  flex-direction: row; flex-wrap: wrap; gap: 12px; overflow-y: visible;
  max-height: 42vh; overflow: auto; padding: 12px 16px;
}
/* squeezed panel: the cadx header wraps cleanly — title takes the row,
   actions drop to their own line instead of crushing the name */
body.canvas-narrow .cadx-top { row-gap: 8px; }
body.canvas-narrow .cadx-top .cadx-tt { flex: 1 1 160px; }
body.canvas-narrow .cadx-top .cadx-actions { flex-wrap: wrap; row-gap: 6px; }
body.canvas-narrow .cad-rail > * { flex: 1 1 200px; min-width: 180px; }
.cad-rail-label {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-4);
  margin-bottom: 8px;
}
.cad-sum {
  border: 0.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); padding: 13px 13px 8px;
}
.cad-sum .big { font-family: var(--mono); font-size: 25px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.cad-sum .small { font-family: var(--mono); font-size: 10.5px; color: var(--text-4); margin-top: 3px; line-height: 1.5; }
.cad-sum hr { border: none; border-top: 0.5px solid var(--line-soft); margin: 11px 0; }
.cad-srow { display: flex; gap: 10px; padding: 0 0 10px; align-items: baseline; }
.cad-srow .sk {
  font-family: var(--mono); font-size: 10px; color: var(--text-4);
  flex: none; width: 68px;
}
.cad-srow .sv { flex: 1; min-width: 0; font-size: 12px; color: var(--text); text-align: right; }
.cad-srow .sv.wrap { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.cad-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; color: var(--text-2);
  background: var(--surface-1); border: 0.5px solid var(--line);
  border-radius: 20px; padding: 3px 8px;
}

/* progress bar */
.cadx-bar {
  height: 5px; border-radius: 4px; background: var(--surface-3);
  border: 0.5px solid var(--line-soft); overflow: hidden; margin: 11px 0 8px;
}
.cadx-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s ease; }

/* footnote / provenance in the rail */
.cadx-footnote { font-family: var(--mono); font-size: 10px; line-height: 1.7; color: var(--text-4); }
.cadx-footnote .cadx-prov { margin-right: 6px; }

/* ---- persona profiles (real, read-only) ---- */
.cadx-personas .small { font-family: var(--mono); font-size: 10.5px; color: var(--text-4); line-height: 1.5; margin: 4px 0 8px; }
.cadx-chiprow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cad-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 12px; line-height: 1; color: var(--text-2);
  background: var(--surface-2); border: 0.5px solid var(--line);
  border-radius: 20px; padding: 6px 11px; cursor: pointer;
}
.cad-chip .ring { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line-bright); flex: none; }
.cad-chip.on { color: var(--text); border-color: var(--accent-line); background: var(--accent-dim); }
.cad-chip.on .ring { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }
.cadx-jts { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.cadx-jt {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 9px; border: 0.5px solid var(--line-soft); border-radius: 8px;
  background: var(--surface-1);
}
.cadx-jt .jt-t { font-size: 12px; color: var(--text); min-width: 0; overflow-wrap: break-word; }
.cadx-role {
  flex: none; font-family: var(--mono); font-size: 9.5px; color: var(--text-3);
  border: 0.5px solid var(--line); border-radius: 20px; padding: 2px 7px;
  background: var(--surface-2); white-space: nowrap;
}
.cadx-role.r-decision-maker { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-dim); }
.cadx-role.r-champion { color: var(--ok); }
.cadx-role.r-influencer { color: var(--run); }

/* ============================================================
   BUTTONS
   ============================================================ */
.cadx-btn {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  background: var(--surface-2); border: 0.5px solid var(--line);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; transition: all 0.12s;
}
.cadx-btn:hover { border-color: var(--line-bright); color: var(--text); }
.cadx-btn.primary { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-dim); }
.cadx-btn.primary:hover { background: var(--accent); color: var(--on-accent); }
.cadx-btn.warn { color: var(--run); border-color: var(--line-bright); }
.cadx-btn.ghost { background: transparent; }
.cadx-btn.mini { padding: 3px 9px; font-size: 10px; border-radius: 6px; }
.cadx-btn.wide { width: 100%; margin-top: 4px; }
.cadx-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* text tones */
.cadx-dim { color: var(--text-4); }
.cadx-red { color: var(--err); }
.cadx-red-soft { color: var(--err); opacity: 0.85; }
.cadx-ok { color: var(--ok); }
.mono { font-family: var(--mono); font-size: 0.95em; }

/* ============================================================
   OVERLAY — confirms / add-prospects sheet
   ============================================================ */
.cadx-overlay {
  position: absolute; inset: 0; z-index: 40;
  background: oklch(0 0 0 / 0.45);
  display: flex; align-items: center; justify-content: center; padding: 22px;
}
.cadx-modal {
  width: min(440px, 100%); max-width: 100%; max-height: 100%;
  margin: auto;                          /* stays centered, never touches the panel edges */
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-1); border: 0.5px solid var(--line-bright);
  border-radius: var(--r-lg); padding: 18px;
  box-shadow: 0 24px 70px oklch(0 0 0 / 0.4);
  animation: cadxModalIn 0.14s ease;
}
.cadx-modal.wide { width: min(560px, 100%); }
@keyframes cadxModalIn { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: none; } }
.cadx-mtitle { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; margin-bottom: 8px; }
.cadx-mintro { font-size: 12px; line-height: 1.6; color: var(--text-3); margin-bottom: 14px; }
.cadx-mlabel {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-4); margin: 14px 0 7px;
}
.cadx-ol { margin: 0 0 4px 18px; padding: 0; }
.cadx-ol li { font-size: 12px; color: var(--text-2); line-height: 1.7; }
.cadx-merr {
  margin-top: 12px; padding: 9px 11px; border-radius: 8px;
  border: 0.5px solid var(--err); color: var(--err);
  font-family: var(--mono); font-size: 11px; line-height: 1.5;
  background: oklch(0.690 0.190 25 / 0.08);
}
.cadx-mbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* add-prospects internals */
.cadx-parsehint { font-family: var(--mono); font-size: 10.5px; color: var(--text-4); margin-top: 6px; }
.cadx-leads { display: flex; flex-direction: column; gap: 5px; max-height: 190px; overflow-y: auto; overscroll-behavior: contain; }
.cadx-leadrow {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 7px 9px; border: 0.5px solid var(--line-soft); border-radius: 8px;
  background: var(--surface-2);
}
.cadx-leadrow.off { opacity: 0.55; cursor: not-allowed; }
.cadx-leadrow input { flex: none; accent-color: var(--accent); }
.cadx-leadrow .lr-n { font-size: 12px; font-weight: 500; color: var(--text); flex: none; }
.cadx-leadrow .lr-m { font-size: 11px; color: var(--text-4); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cadx-leadrow .lr-e { font-size: 10px; color: var(--text-3); flex: none; }
.cadx-leadrow .lr-g {
  flex: none; font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--text-2);
  border: 0.5px solid var(--line); border-radius: 5px; padding: 1px 6px; background: var(--surface-1);
}

/* ============================================================
   CREATE FORM
   ============================================================ */
.cadx-form { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.cadx-card {
  border: 0.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-1); padding: 14px;
}
.cadx-clabel {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-4);
  margin: 0 0 9px;
}
.cadx-card .cadx-clabel + .cadx-clabel { margin-top: 14px; }
.cadx-chiprow + .cadx-clabel, .cadx-hinttext + .cadx-clabel, .cad-levels + .cadx-clabel { margin-top: 14px; }
.cadx-field { margin-bottom: 12px; }
.cadx-field:last-child { margin-bottom: 0; }
.cadx-field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.cadx-field label .req { font-family: var(--mono); font-size: 9.5px; color: var(--run); margin-left: 4px; }
.cadx-input, .cadx-textarea {
  width: 100%; box-sizing: border-box;
  border: 0.5px solid var(--line-bright); border-radius: 9px;
  background: var(--surface-2); color: var(--text);
  font-family: var(--sans); font-size: 13px; line-height: 1.5;
  padding: 9px 11px; outline: none; resize: vertical;
}
.cadx-input:focus, .cadx-textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-dim); }
.cadx-hinttext { font-size: 11.5px; line-height: 1.55; color: var(--text-4); margin-top: 4px; }
.cadx-profiles { margin-top: 12px; padding-top: 12px; border-top: 0.5px solid var(--line-soft); }

/* research-depth level group (shared look) */
.cad-levels {
  display: inline-flex; gap: 0; border: 0.5px solid var(--line-bright);
  border-radius: 9px; overflow: hidden; background: var(--surface-2);
}
.cad-levels .cad-level {
  font-family: var(--mono); font-size: 11px; padding: 6px 14px; border: none; background: transparent;
  color: var(--text-3); cursor: pointer; border-right: 0.5px solid var(--line);
}
.cad-levels .cad-level:last-child { border-right: none; }
.cad-levels .cad-level:hover { color: var(--text); }
.cad-levels .cad-level.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* daily-limit steppers */
.cadx-limrow { display: flex; gap: 10px; flex-wrap: wrap; }
.cadx-stepper {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0.5px solid var(--line); border-radius: 9px;
  background: var(--surface-2); padding: 6px 9px;
}
.cadx-stepper .st-l { font-family: var(--mono); font-size: 10px; color: var(--text-4); }
.cadx-stepper .st-v { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); min-width: 30px; text-align: center; }
.cadx-stepper button {
  width: 22px; height: 22px; border-radius: 6px; border: 0.5px solid var(--line);
  background: var(--surface-1); color: var(--text-3); cursor: pointer;
  display: grid; place-items: center; font-size: 12px; line-height: 1;
}
.cadx-stepper button:hover { color: var(--text); border-color: var(--line-bright); }

/* audience — attached people chips */
.cadx-audchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.cadx-audchip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0.5px solid var(--line); border-radius: 999px;
  background: var(--surface-2); padding: 4px 6px 4px 10px;
  font-size: 12px; color: var(--text-2); max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cadx-audchip.cadx-dim { color: var(--text-4); }
.cadx-audx {
  border: 0; background: transparent; color: var(--text-4); cursor: pointer;
  width: 16px; height: 16px; border-radius: 50%; line-height: 1; font-size: 11px;
  display: grid; place-items: center; flex: 0 0 auto;
}
.cadx-audx:hover { color: var(--text); background: var(--surface-1); }

/* workflow composer */
.cadx-wfchain { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.cadx-wfrow {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border: 0.5px solid var(--line); border-radius: 10px;
  background: var(--surface-2);
}
.cadx-wfrow .wf-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 500; color: var(--text); }
.cadx-wfrow .wf-ctrl { display: inline-flex; gap: 4px; flex: none; }
.cadx-wfrow .wf-ctrl button {
  width: 22px; height: 22px; border-radius: 6px; border: 0.5px solid var(--line);
  background: var(--surface-1); color: var(--text-4); cursor: pointer;
  font-size: 9px; line-height: 1; display: grid; place-items: center;
}
.cadx-wfrow .wf-ctrl button:hover { color: var(--text); border-color: var(--line-bright); }
.cadx-wfrow .wf-ctrl button:disabled { opacity: 0.35; cursor: not-allowed; }
.cadx-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.cadx-palbtn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 12px; color: var(--text-2);
  border: 1px dashed var(--line-bright); border-radius: 9px;
  background: transparent; padding: 6px 10px 6px 6px; cursor: pointer; transition: all 0.12s;
}
.cadx-palbtn:hover { border-style: solid; color: var(--text); background: var(--surface-2); }
.cadx-palbtn .cad-ic { width: 20px; height: 20px; border-radius: 6px; font-size: 8.5px; }
.cadx-palbtn .cad-ic svg { width: 11px; height: 11px; }

.cadx-createfoot { display: flex; align-items: center; gap: 14px; }
.cadx-createfoot .cadx-hinttext { flex: 1; margin: 0; }
.cadx-createfoot .cadx-btn { flex: none; }

/* ============================================================
   STEP PROMPTS — pill editor / slash menu / variable bar /
   prompt library / dry-run preview (all design-token themed)
   ============================================================ */
.cadv-step {
  border: 0.5px solid var(--line); border-radius: 10px;
  background: var(--surface-2); margin-bottom: 8px; overflow: hidden;
}
.cadv-step.open { border-color: var(--accent-line); }
.cadv-head {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 11px; cursor: pointer; border: none; background: transparent;
  color: var(--text);
}
.cadv-head:hover .cad-caret { color: var(--accent-text); }
.cadv-step:not(.open) .cadv-head .cad-caret { transform: rotate(-90deg); }
.cadv-hname { font-size: 12.5px; font-weight: 600; color: var(--text); flex: none; }
.cadv-htype {
  flex: none; font-size: 9.5px; color: var(--text-3);
  border: 0.5px solid var(--line); border-radius: 20px; padding: 2px 7px;
  background: var(--surface-1); white-space: nowrap;
}
.cadv-hmeta {
  flex: 1; min-width: 0; font-size: 10px; color: var(--text-4); text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cadv-body { padding: 0 11px 11px; }
.cadv-roles { margin: 2px 0 10px; }
.cadv-roles .cad-chip { padding: 4px 9px; font-size: 11px; }
.cadv-hasdot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  display: inline-block; flex: none;
}
.cadv-tabs { margin-bottom: 10px; }
.cadv-tabs .cad-level { padding: 4px 12px; font-size: 10px; }

/* the contenteditable pill editor */
.cadv-editor {
  min-height: 84px; max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
  border: 0.5px solid var(--line-bright); border-radius: 9px;
  background: var(--surface-1); color: var(--text);
  font-family: var(--sans); font-size: 13px; line-height: 1.7;
  padding: 10px 12px; outline: none; white-space: pre-wrap; word-break: break-word;
}
.cadv-editor:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-dim); }
.cadv-editor:empty::before {
  content: attr(data-placeholder); color: var(--text-4); pointer-events: none;
}

/* variable pills — {{token}} chips (accent; unknown = warn tone) */
.cadv-pill {
  display: inline-flex; align-items: center; vertical-align: baseline;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; line-height: 1;
  color: var(--accent-text); background: var(--accent-dim);
  border: 0.5px solid var(--accent-line); border-radius: 6px;
  padding: 2.5px 6px; margin: 0 1px; white-space: nowrap;
  transition: transform 0.1s ease; cursor: default; user-select: none;
}
.cadv-editor .cadv-pill:hover { transform: scale(1.05); }
.cadv-pill.unk {
  color: var(--run); background: transparent;
  border-color: var(--line-bright); border-style: dashed;
}
.cadv-pill.ro { font-size: 9.5px; padding: 1.5px 5px; margin: 0 1px; }
.cadv-pill.mini { font-size: 9.5px; padding: 2px 5px; margin: 0; }

/* read-only prompt block (viewer + confirm) */
.cadv-ro {
  border: 0.5px solid var(--line-soft); border-radius: 8px;
  background: var(--surface-2); padding: 8px 10px;
  font-size: 12px; line-height: 1.7; color: var(--text-2);
  max-height: 150px; overflow-y: auto; overscroll-behavior: contain;
  white-space: pre-wrap; word-break: break-word;
}
.cadv-mark { font-family: var(--mono); font-size: 9.5px; color: var(--accent-text); }

/* toolbar under the editor */
.cadv-tools { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.cadv-toolhint { font-family: var(--mono); font-size: 9.5px; color: var(--text-4); margin-left: auto; }

/* click-to-insert variable bar */
.cadv-varlabel {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-4); margin: 12px 0 6px;
}
.cadv-varbar { display: flex; flex-wrap: wrap; gap: 4px; }
.cadv-varchip {
  font-family: var(--mono); font-size: 10px; line-height: 1; color: var(--text-3);
  border: 0.5px solid var(--line); border-radius: 6px; padding: 4px 7px;
  background: var(--surface-1); cursor: pointer; transition: all 0.1s;
}
.cadv-varchip:hover { color: var(--text); border-color: var(--line-bright); }
.cadv-varchip.used {
  color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-dim);
}
.cadv-varfoot { font-size: 9.5px; color: var(--text-4); margin-top: 7px; line-height: 1.6; word-break: break-word; }

/* slash menu (portal-ish: absolutely positioned inside the pane) */
.cadv-menu {
  position: absolute; z-index: 60; width: 280px;
  background: var(--surface-1); border: 0.5px solid var(--line-bright);
  border-radius: 10px; box-shadow: 0 16px 48px oklch(0 0 0 / 0.35);
  padding: 7px; animation: cadxModalIn 0.12s ease;
}
.cadv-msearch {
  width: 100%; box-sizing: border-box; margin-bottom: 6px;
  border: 0.5px solid var(--line); border-radius: 7px;
  background: var(--surface-2); color: var(--text);
  font-family: var(--sans); font-size: 12px; padding: 6px 9px; outline: none;
}
.cadv-msearch:focus { border-color: var(--accent-line); }
.cadv-mlist { max-height: 210px; overflow-y: auto; overscroll-behavior: contain; }
.cadv-msec {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-4); padding: 6px 5px 4px; position: sticky; top: 0;
  background: var(--surface-1);
}
.cadv-mitem {
  display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  border: none; background: transparent; border-radius: 7px;
  padding: 5px 6px; cursor: pointer; color: var(--text-2);
}
.cadv-mitem:hover, .cadv-mitem.sel { background: var(--hover); }
.cadv-mitem.sel { outline: 1px solid var(--accent-line); }
.cadv-mtok { margin-left: auto; font-size: 9.5px; color: var(--text-4); flex: none; }
.cadv-mbook { flex: none; font-size: 11px; color: var(--text-3); }
.cadv-mpn { font-size: 12px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cadv-mempty { font-size: 11px; color: var(--text-4); padding: 5px 6px 8px; line-height: 1.5; }

/* library drawer */
.cadv-lib {
  border: 0.5px solid var(--line-soft); border-radius: 9px;
  background: var(--surface-1); padding: 9px 10px; margin-top: 8px;
}
.cadv-librows { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; overscroll-behavior: contain; }
.cadv-librow {
  display: flex; align-items: center; gap: 9px;
  border: 0.5px solid var(--line-soft); border-radius: 8px;
  background: var(--surface-2); padding: 7px 9px;
}
.cadv-librow .lp-main { flex: 1; min-width: 0; }
.cadv-librow .lp-n { font-size: 12px; font-weight: 500; color: var(--text); }
.cadv-librow .lp-m { font-size: 9.5px; color: var(--text-4); margin-top: 1px; }
.cadv-librow .lp-p { font-size: 10.5px; color: var(--text-3); margin-top: 3px; line-height: 1.45; overflow-wrap: break-word; }
.cadv-librow .cadx-btn { flex: none; }

/* dry-run preview */
.cadv-preview { display: flex; flex-direction: column; gap: 9px; }
.cadv-prevsrc {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-3); line-height: 1.5;
}
.cadv-prevsrc b { color: var(--text); font-weight: 600; }
.cadv-prevout {
  border: 0.5px solid var(--line); border-radius: 9px;
  background: var(--surface-1); padding: 11px 13px;
  font-size: 13px; line-height: 1.75; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
}
/* generated-message preview: reads like the outbound copy, not a template */
.cadv-msg { background: var(--surface-2, var(--surface-1)); border-left: 2px solid var(--accent-line); }
.cadv-genlabel { font-size: 9.5px; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.cadv-val {
  color: var(--accent-text); background: var(--accent-dim);
  border-radius: 4px; padding: 0.5px 4px;
  border-bottom: 1px solid var(--accent-line);
}
.cadv-miss {
  font-family: var(--mono); font-size: 0.9em; color: var(--run);
  background: transparent; border: 0.5px dashed var(--line-bright);
  border-radius: 4px; padding: 0.5px 4px;
}

/* ---- AI Assistant tab: describe → Nico writes the persona prompt ---- */
.cadv-assist { display: flex; flex-direction: column; gap: 10px; }
.cadv-assistrow { display: flex; gap: 8px; align-items: center; }
.cadv-assistin {
  flex: 1; min-width: 0; height: 34px; padding: 0 11px; border-radius: 9px;
  font: inherit; font-size: 12.5px; color: var(--text);
  background: var(--surface-1); border: 0.5px solid var(--line); outline: none;
}
.cadv-assistin:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-dim); }
.cadv-assistout {
  border: 0.5px dashed var(--line); border-radius: 9px;
  background: var(--surface-1); padding: 11px 13px;
  max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
}

/* viewer-mode inline step editing (same editor as the composer) */
.cadv-viewedit { margin-top: 12px; border-top: 0.5px solid var(--line); padding-top: 10px; }

/* ---- auto-designed prompts: provenance, grounding strip, risk chips ---- */
.cadv-origin {
  display: flex; align-items: center; gap: 8px; margin: 2px 0 8px;
  padding: 6px 10px; border: 0.5px solid var(--accent-line); border-radius: 8px;
  background: var(--accent-dim);
}
.cadv-origin-t { font-family: var(--mono); font-size: 10.5px; color: var(--accent-text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cadv-ctxstrip { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; font-size: 10px; }
.cadv-ctxchip {
  padding: 2px 8px; border-radius: 999px; border: 0.5px solid var(--line);
  color: var(--text-4); background: var(--surface-1); white-space: nowrap;
}
.cadv-ctxchip.on { color: var(--text-2); border-color: var(--accent-line); background: var(--accent-dim); }
/* catalog variables Salestools' sanitizer deletes on save — visibly at-risk until the whitelist ships */
.cadv-varchip.risk { border-style: dashed; opacity: 0.55; text-decoration: line-through; text-decoration-thickness: 1px; }
.cadv-varchip.risk:hover { opacity: 0.8; }

/* ---- research-provenance chips: which research ACTUALLY grounds this outreach.
   Real-state only (live tool feed); an honest "no research yet" degrade otherwise.
   Blue accent for confirmed research, dashed/muted for pending/absent. ---- */
.cadv-provrow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.cadv-provlabel { font-family: var(--mono); font-size: 10px; color: var(--text-4); }
.cadv-provchip {
  font-family: var(--mono); font-size: 10px; padding: 2px 9px; border-radius: 999px;
  border: 0.5px solid var(--line); color: var(--text-4); background: var(--surface-1);
}
.cadv-provchip.on { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-dim); }
.cadv-provchip.pending { border-style: dashed; color: var(--text-4); background: transparent; }
