/* ============================================================
   Flows tab — "the tool is quiet, the conversation is alive"
   SaaS chrome in cool slate; message content as true WhatsApp
   bubbles on the chat wallpaper. Signature: the ladder timeline.
   ============================================================ */

:root {
  --fl-bg: #f6f7f9;
  --fl-surface: #ffffff;
  --fl-ink: #1f2937;
  --fl-muted: #64748b;
  --fl-faint: #94a3b8;
  --fl-line: #e5e9ef;
  --fl-accent: #0b8064;
  --fl-accent-soft: #e6f4f0;
  --wa-wall: #efe7dd;
  --fl-amber: #b98115;
  --fl-monday: #1f76c2;
  --wa-bubble: #d9fdd3;
  --wa-bubble-ink: #111b21;
  --wa-meta: #667781;
  --ok-bg: #d9f5e9;  --ok-ink: #0b7a4b;
  --wait-bg: #fdf3d7; --wait-ink: #8a6d1a;
  --bad-bg: #fde2e0;  --bad-ink: #a4271c;
  --fl-radius: 14px;
  --fl-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);
}

#flows-view { background: var(--fl-bg); }
.flows-layout {
  font-family: 'Rubik', -apple-system, 'Segoe UI', sans-serif; color: var(--fl-ink);
  display: grid; grid-template-columns: 240px 1fr;
  height: calc(100vh - 56px); background: var(--fl-bg);
}
.flows-sidebar {
  border-left: 1px solid var(--fl-line); background: var(--fl-surface);
  display: flex; flex-direction: column; overflow: hidden;
}

/* the editor fills the rest of the screen; the canvas takes every free pixel */
.flows-editor { padding: 12px 16px; overflow: hidden; display: flex; flex-direction: column; }
#flows-editor-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------- header toolbar ---------- */
.flows-header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--fl-surface); border: 1px solid var(--fl-line);
  border-radius: var(--fl-radius); box-shadow: var(--fl-shadow);
  padding: 12px 16px; margin-bottom: 14px;
}
.flows-header .prompt-name-input {
  font-family: inherit; font-size: 17px; font-weight: 600; color: var(--fl-ink);
  border: none; background: transparent; min-width: 180px;
}
.flows-header .prompt-name-input:focus { outline: none; border-bottom: 2px solid var(--fl-accent); }
.flow-trigger { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--fl-muted); }
.flow-trigger input {
  width: 90px; padding: 6px 10px; border: 1px solid var(--fl-line); border-radius: 8px;
  font-family: inherit; font-size: 12.5px; background: var(--fl-bg);
}
.flow-enabled { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fl-muted); cursor: pointer; }
.flow-enabled input { accent-color: var(--fl-accent); width: 15px; height: 15px; }
.flow-versions-wrap { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fl-muted); margin-inline-start: auto; }
.flow-versions-wrap select {
  max-width: 230px; padding: 6px 8px; border: 1px solid var(--fl-line); border-radius: 8px;
  font-family: inherit; font-size: 12px; background: var(--fl-surface); color: var(--fl-ink);
}

/* ============================================================
   THE LADDER — outbound-touch chain, drawn on the canvas
   (amber, dashed: frozen Meta content on a timed rail)
   ============================================================ */
.lnode { border: 2px dashed #e6c98c; }
.lnode.selected { border-color: var(--fl-amber); border-style: solid; box-shadow: 0 4px 18px rgba(185,129,21,.28); }
.lnode .fnode-head { background: #fdf6e3; color: #8a6d1a; border-bottom-color: #f3e6c8; }
.fnode-dot.ladder { background: var(--fl-amber); }
.lnode-time {
  text-align: center; font-size: 11px; color: #8a6d1a; background: var(--wait-bg);
  padding: 3px 0; border-bottom: 1px solid #f3e6c8;
}
.lnode-note { font-size: 11.5px; color: var(--fl-muted); text-align: center; padding: 2px 0; line-height: 1.5; }
.lnode-start { width: 210px; }
.lnode-collapse {
  margin-inline-start: auto; border: none; background: none; color: #8a6d1a;
  cursor: pointer; font-size: 10px; padding: 2px 5px; border-radius: 5px;
}
.lnode-collapse:hover { background: #f3e6c8; }
.lnode.off { opacity: .55; }
.lnode-ghost {
  width: 130px; padding: 13px 0; text-align: center; color: #8a6d1a; font-size: 13px;
  background: #fdf6e3; border: 2px dashed #e6c98c; border-radius: 13px; cursor: pointer;
  box-shadow: none;
}
.lnode-ghost:hover { background: #fbeecb; border-color: var(--fl-amber); }
.lnode-ghost .fport-in { top: 50%; }
/* chain runs downward: out-port at the bottom, in-port at the top */
.fport-chain {
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--fl-amber);
}
.fport-in.chain {
  background: var(--fl-amber);
  top: -7px; right: 50%; transform: translateX(50%);
}
.lnode-ghost .fport-in { top: -7px; }

/* ============================================================
   MONDAY TRIGGERS — board events that start flows
   (blue, dashed: outside events entering the canvas)
   ============================================================ */
.tnode { border: 2px dashed #9ec9ef; }
.tnode.selected { border-color: var(--fl-monday); border-style: solid; box-shadow: 0 4px 18px rgba(31,118,194,.28); }
.tnode .fnode-head { background: #e9f2fb; color: #1a5da0; border-bottom-color: #d6e7f8; }
.fnode-dot.monday { background: var(--fl-monday); }
.tnode .lnode-collapse { color: #1a5da0; }
.tnode .lnode-collapse:hover { background: #d6e7f8; }
.tnode.off { opacity: .55; }
.tnode-ghost {
  width: 150px; padding: 13px 0; text-align: center; color: #1a5da0; font-size: 13px;
  background: #e9f2fb; border: 2px dashed #9ec9ef; border-radius: 13px; cursor: pointer;
  box-shadow: none;
}
.tnode-ghost:hover { background: #dcebf9; border-color: var(--fl-monday); }
.trigger-event-chip {
  padding: 6px 10px; background: #e9f2fb; color: #1a5da0;
  border-radius: 8px; font-size: 12px; text-align: center;
}
.fport-chain.monday { border-color: var(--fl-monday); }

/* meeting-sequence slot cards: blue rail under a meeting_seq trigger */
.mslot-time { color: #1a5da0; background: #eef5fc; border-bottom: 1px solid #d6e7f8; }
.fport-in.chain.mchain { background: var(--fl-monday); }
.tnode-ghost .fport-in.chain { top: -7px; }

/* journey roots drag; clones just select */
.fnode-root { cursor: move; }
.fnode-clone { cursor: move; box-shadow: 0 1px 6px rgba(15,23,42,.09); }
.fnode-shared {
  font-size: 9.5px; background: var(--fl-accent-soft); color: var(--fl-accent);
  border-radius: 999px; padding: 1.5px 7px; white-space: nowrap;
}
.fnode-cycle {
  width: auto; max-width: 230px; padding: 9px 14px; font-size: 11.5px;
  color: var(--fl-muted); background: var(--fl-bg); cursor: pointer;
  border: 1.5px dashed var(--fl-line); border-radius: 10px; box-shadow: none;
}

/* ladder editing rows in the side panel */
.fpanel-note { font-size: 11.5px; color: var(--fl-muted); background: var(--fl-bg); border-radius: 8px; padding: 9px 11px; line-height: 1.6; }
.fpanel-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fl-muted); }
.fpanel-row label { flex: 0 0 auto; }
.fpanel-row input[type="text"] {
  flex: 1; min-width: 0; padding: 6px 9px; border: 1px solid var(--fl-line); border-radius: 8px;
  font-family: inherit; font-size: 12.5px; background: var(--fl-surface); color: var(--fl-ink);
}
.fpanel-row input[type="number"] {
  width: 54px; padding: 6px 6px; border: 1px solid var(--fl-line); border-radius: 8px;
  font-family: inherit; font-size: 12.5px; text-align: center; background: var(--fl-surface); color: var(--fl-ink);
}
.fpanel-row select {
  padding: 6px 6px; border: 1px solid var(--fl-line); border-radius: 8px;
  font-family: inherit; font-size: 12px; background: var(--fl-surface); color: var(--fl-ink);
}
.fpanel-row input:focus, .fpanel-row select:focus { outline: none; border-color: var(--fl-accent); }
.fpanel-actions { display: flex; gap: 8px; }
.fpanel-actions .flow-btn-add { flex: 1; }
.flow-panel > .flow-btn-add, .fpanel-actions .flow-btn-add {
  border: 1.5px dashed var(--fl-line); background: var(--fl-surface); color: var(--fl-muted); padding: 8px;
}
.flow-panel > .flow-btn-add:hover, .fpanel-actions .flow-btn-add:hover { border-color: var(--fl-accent); color: var(--fl-accent); }
.fpanel-del {
  border: 1px solid var(--fl-line); background: var(--fl-surface); color: var(--bad-ink);
  border-radius: 8px; padding: 7px 12px; font-family: inherit; font-size: 12px; cursor: pointer;
}
.fpanel-del:hover { background: var(--bad-bg); }

/* ============================================================
   WhatsApp preview language (shared: timeline + tree)
   ============================================================ */
.wa-preview {
  background: var(--wa-wall);
  background-image: radial-gradient(rgba(0,0,0,.025) 1px, transparent 1.2px);
  background-size: 14px 14px;
  border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.wa-bubble {
  background: var(--wa-bubble); color: var(--wa-bubble-ink);
  border-radius: 10px; border-start-end-radius: 2px;
  padding: 7px 10px 8px; font-size: 12.8px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
  max-width: 100%; align-self: stretch; position: relative;
}
.wa-bubble.frozen { user-select: text; }
.wa-clamp { max-height: 128px; overflow: hidden; position: relative; }
.wa-clamp.open { max-height: none; }
.wa-clamp:not(.open)::after {
  content: ''; position: absolute; bottom: 0; right: 0; left: 0; height: 34px;
  background: linear-gradient(transparent, var(--wa-bubble));
}
.wa-more {
  border: none; background: none; color: var(--fl-accent); font-family: inherit;
  font-size: 11.5px; cursor: pointer; align-self: center; padding: 1px 6px;
}
.wa-replies { display: flex; flex-direction: column; gap: 4px; }
.wa-reply {
  background: #fff; color: #0a80f5; text-align: center; font-size: 12.3px;
  border-radius: 8px; padding: 6px 8px; box-shadow: 0 1px 1px rgba(0,0,0,.08);
}

/* editable bubble (tree editor) */
.wa-bubble textarea, textarea.wa-edit {
  width: 100%; border: none; background: transparent; resize: none;
  font-family: inherit; font-size: 12.8px; line-height: 1.5; color: var(--wa-bubble-ink);
  padding: 0; display: block; overflow: hidden;
}
.wa-bubble textarea:focus { outline: none; }
.wa-bubble:focus-within { box-shadow: 0 0 0 2px var(--fl-accent); }

/* ---------- status chips ---------- */
.tpl-chip { font-size: 11px; padding: 2.5px 9px; border-radius: 999px; white-space: nowrap; font-weight: 500; }
.tpl-approved { background: var(--ok-bg); color: var(--ok-ink); }
.tpl-pending { background: var(--wait-bg); color: var(--wait-ink); }
.tpl-rejected, .tpl-missing { background: var(--bad-bg); color: var(--bad-ink); }

/* ---------- template picker + button mapping ---------- */
.tpl-head { display: flex; align-items: center; gap: 8px; }
.tpl-name {
  flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--fl-line); border-radius: 8px;
  font-family: inherit; font-size: 12px; background: var(--fl-surface); color: var(--fl-ink);
}
.tpl-btn-rows { display: flex; flex-direction: column; gap: 5px; }
.tpl-btn-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--fl-faint); }
.tpl-btn-row .arrow { flex: 0 0 auto; }
.tpl-btn-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--fl-muted); font-size: 11.5px;
}
.tpl-btn-row select {
  flex: 1; min-width: 90px; padding: 4px 6px; border: 1px solid var(--fl-line); border-radius: 7px;
  font-family: inherit; font-size: 11.5px; background: var(--fl-surface); color: var(--fl-ink);
}
.tpl-btn-row .flow-btn-open {
  border: none; background: var(--fl-accent-soft); color: var(--fl-accent);
  border-radius: 7px; padding: 4px 8px; font-family: inherit; font-size: 11px; cursor: pointer; white-space: nowrap;
}
.tpl-btn-row .flow-btn-open:hover { background: var(--fl-accent); color: #fff; }

/* ============================================================
   THE CANVAS — the flow as a node map (n8n-style, WhatsApp skin)
   ============================================================ */
.flow-canvas-wrap {
  display: flex; gap: 0;
  flex: 1; min-height: 300px;
  background: var(--fl-surface); border: 1px solid var(--fl-line);
  border-radius: var(--fl-radius); box-shadow: var(--fl-shadow); overflow: hidden;
}
.flow-canvas-wrap.fullscreen {
  position: fixed; inset: 0; z-index: 500;
  border-radius: 0; border: none; min-height: 0;
}
/* floating save — the header save button is hidden behind fullscreen, so mirror it */
.flow-fs-save { display: none; }
.flow-canvas-wrap.fullscreen .flow-fs-save {
  display: block; position: absolute; top: 14px; inset-inline-start: 14px; z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
#flow-media-modal { z-index: 600; }
.flow-save-hint { font-size: 13px; color: #667781; margin-bottom: 4px; }
.flow-canvas {
  flex: 1; position: relative; overflow: hidden; cursor: grab;
  background-color: var(--wa-wall);
  background-image: radial-gradient(rgba(0,0,0,.06) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
.flow-canvas.panning { cursor: grabbing; }
.flow-world { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.flow-wires { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
#flow-nodes { position: absolute; top: 0; left: 0; }

.flow-zoomctl {
  position: absolute; bottom: 14px; left: 14px; z-index: 5;
  display: flex; flex-direction: column; gap: 5px;
}
.flow-zoomctl button {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--fl-line);
  background: var(--fl-surface); color: var(--fl-muted); font-size: 15px; cursor: pointer;
  box-shadow: 0 1px 4px rgba(15,23,42,.10);
}
.flow-zoomctl button:hover { color: var(--fl-accent); border-color: var(--fl-accent); }

/* -- node card -- */
.fnode {
  position: absolute; width: 260px; background: var(--fl-surface);
  border-radius: 13px; border: 2px solid transparent;
  box-shadow: 0 2px 10px rgba(15,23,42,.12); user-select: none; cursor: move;
}
.fnode.selected { border-color: var(--fl-accent); box-shadow: 0 4px 18px rgba(11,128,100,.28); }
.fnode-head {
  display: flex; align-items: center; gap: 7px; padding: 8px 12px;
  border-bottom: 1px solid var(--fl-line); background: var(--fl-bg);
  border-radius: 11px 11px 0 0; font-size: 12.5px; font-weight: 600; color: var(--fl-muted);
}
.fnode-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fnode-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fl-accent); flex: 0 0 auto; }
.fnode-dot.start { background: #f0a52a; }
.fnode-action { margin-inline-start: auto; font-size: 10.5px; color: var(--fl-faint); white-space: nowrap; }
.fnode .flow-trigger-chip { margin: 8px 10px 0; }
.fnode-body {
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
  background:
    linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,.5)),
    var(--wa-wall);
  border-radius: 0 0 11px 11px;
}
.fnode-bubble { font-size: 12px; max-height: 110px; overflow: hidden; }
.fnode-bubble.frozen { color: var(--fl-muted); }
.fnode-delay {
  align-self: center; font-size: 10px; color: var(--fl-accent);
  background: rgba(255,255,255,.8); border-radius: 999px; padding: 1px 9px;
}
.fnode-media { background: var(--wa-bubble); padding: 4px; border-radius: 10px; border-start-end-radius: 2px; overflow: hidden; }
.fnode-media img, .fnode-media video { width: 100%; max-height: 110px; object-fit: cover; border-radius: 7px; display: block; }
.fnode-pill {
  position: relative; background: #fff; color: #0a80f5; text-align: center;
  font-size: 11.8px; border-radius: 8px; padding: 5px 8px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.fnode-ai-mark { position: absolute; left: 7px; top: 50%; transform: translateY(-50%); font-size: 11px; }
.fnode-empty { color: var(--wa-meta); font-size: 12px; text-align: center; padding: 12px 0; }
.fnode-tail { font-size: 10.5px; color: var(--fl-accent); text-align: center; padding-top: 2px; }

/* connection ports */
.fport {
  position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--fl-accent);
}
.fport-in {
  position: absolute; right: -7px; top: 24px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--fl-accent); border: 2.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

/* -- side panel (edit the selected node); sits on the right, canvas to its left -- */
.flow-panel {
  flex: 0 0 340px; border-inline-end: 1px solid var(--fl-line);
  background: var(--fl-surface); overflow-y: auto; padding: 14px 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
/* the panel scrolls — its children must never get crushed to fit */
.flow-panel > * { flex-shrink: 0; }
.fpanel-empty { color: var(--fl-faint); font-size: 13px; text-align: center; margin-top: 60px; line-height: 1.8; }
.fpanel-head { display: flex; align-items: center; gap: 8px; }
.fpanel-title { font-size: 14.5px; font-weight: 600; color: var(--fl-ink); }
.fpanel-action { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--fl-faint); }
.fpanel-action select {
  padding: 3px 6px; border: 1px solid var(--fl-line); border-radius: 7px;
  font-family: inherit; font-size: 11px; background: var(--fl-surface); color: var(--fl-muted);
}
.fpanel-messages {
  background: var(--wa-wall);
  background-image: radial-gradient(rgba(0,0,0,.025) 1px, transparent 1.2px);
  background-size: 14px 14px;
  border-radius: 10px;
  padding: 12px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 70px;
}
.flow-trigger-chip {
  padding: 6px 10px; background: var(--fl-accent-soft); color: var(--fl-accent);
  border-radius: 8px; font-size: 12px;
}
.flow-empty-node { color: var(--wa-meta); font-size: 12px; text-align: center; padding: 14px 0; }

.flow-card { position: relative; display: flex; flex-direction: column; gap: 6px; }
.flow-card-ctl {
  position: absolute; top: -7px; left: 2px; z-index: 2; display: none; gap: 2px;
}
.flow-card:hover .flow-card-ctl { display: flex; }
.flow-card-ctl button {
  border: 1px solid var(--fl-line); background: var(--fl-surface); color: var(--fl-muted);
  width: 21px; height: 21px; border-radius: 6px; cursor: pointer; font-size: 10.5px;
  line-height: 1; padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.flow-card-ctl button:hover:not(:disabled) { color: var(--fl-ink); }
.flow-card-ctl button:disabled { opacity: .35; cursor: default; }

/* delay chip between bubbles */
.flow-delay-row {
  align-self: center; display: flex; align-items: center; gap: 4px;
  font-size: 10.5px; color: var(--wa-meta);
  background: rgba(255,255,255,.75); border-radius: 999px; padding: 2px 10px;
}
.flow-delay-row.active { color: var(--fl-accent); font-weight: 500; }
.flow-delay-row input {
  width: 40px; border: none; background: transparent; font-family: inherit;
  font-size: 11px; text-align: center; color: inherit; font-weight: 600;
}
.flow-delay-row input:focus { outline: none; }

/* media bubble */
.flow-card-media .flow-media-thumb {
  background: var(--wa-bubble); padding: 4px; border-radius: 10px; border-start-end-radius: 2px;
  cursor: pointer; box-shadow: 0 1px 1px rgba(0,0,0,.08); overflow: hidden;
}
.flow-media-thumb img, .flow-media-thumb video { width: 100%; border-radius: 7px; display: block; }
/* inside the side panel, cap media height so a tall image doesn't swallow the panel */
.fpanel-messages .flow-media-thumb img, .fpanel-messages .flow-media-thumb video {
  max-height: 160px; object-fit: cover;
}
.flow-media-doc { text-align: center; font-size: 12px; padding: 12px 6px; color: var(--wa-bubble-ink); }
.flow-media-missing { text-align: center; font-size: 11.5px; color: var(--bad-ink); padding: 10px; }
.flow-media-desc { font-size: 10.5px; color: var(--wa-meta); text-align: center; }

/* buttons bubble: quick replies with editable titles */
.flow-btn-rows { display: flex; flex-direction: column; gap: 4px; }
.flow-btn-row {
  display: flex; align-items: center; gap: 5px;
  background: #fff; border-radius: 8px; padding: 3px 6px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.flow-btn-row.selected { box-shadow: 0 0 0 2px var(--fl-accent); }
.flow-btn-row input {
  flex: 1; min-width: 0; border: none; background: transparent; text-align: center;
  font-family: inherit; font-size: 12.3px; color: #0a80f5; padding: 3px 0;
}
.flow-btn-row input:focus { outline: none; }
.flow-btn-count { font-size: 9.5px; color: var(--fl-faint); }
.flow-btn-count.max { color: var(--bad-ink); font-weight: 600; }
.flow-btn-open {
  border: none; background: var(--fl-accent-soft); color: var(--fl-accent);
  border-radius: 6px; padding: 3px 8px; font-family: inherit; font-size: 10.5px; cursor: pointer; white-space: nowrap;
}
.flow-btn-open:hover { background: var(--fl-accent); color: #fff; }
.flow-btn-del { border: none; background: none; color: var(--fl-faint); cursor: pointer; font-size: 11px; padding: 0 2px; }
.flow-btn-del:hover { color: var(--bad-ink); }
.flow-btn-add {
  border: 1.5px dashed rgba(255,255,255,.9); background: rgba(255,255,255,.4); color: var(--wa-meta);
  border-radius: 8px; padding: 5px; font-family: inherit; font-size: 11.5px; cursor: pointer;
}
.flow-btn-add:hover:not(:disabled) { background: #fff; }
.flow-btn-add:disabled { opacity: .5; cursor: default; }

/* template box inside a tree column */
.flow-card-template .tpl-box {
  background: var(--fl-surface); border: 1px dashed var(--fl-faint); border-radius: 10px;
  padding: 8px 9px; display: flex; flex-direction: column; gap: 7px;
}
.tpl-box .wa-preview { padding: 8px; }

/* column tail + add row */
.flow-tail { padding: 9px 14px; font-size: 11.5px; color: var(--fl-muted); line-height: 1.5; }
.flow-tail small { color: var(--fl-faint); }
.flow-tail-ai { color: var(--fl-accent); }
.flow-add { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.flow-add button {
  flex: 1 1 40%; padding: 7px 4px; border: 1px solid var(--fl-line); background: var(--fl-surface);
  border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 11.5px; color: var(--fl-muted);
}
.flow-add button:hover:not(:disabled) { border-color: var(--fl-accent); color: var(--fl-accent); }
.flow-add button:disabled { opacity: .45; cursor: default; }

/* ---------- sidebar + empty state ---------- */
.flows-empty { color: var(--fl-faint); text-align: center; padding: 60px 0; font-size: 14px; }

/* ---------- media picker modal (unchanged behavior) ---------- */
.flow-media-modal-content { width: 720px; max-width: 95vw; }
.flow-media-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  max-height: 60vh; overflow-y: auto; margin: 10px 0;
}
.flow-media-pick { cursor: pointer; border: 2px solid transparent; border-radius: 10px; padding: 4px; }
.flow-media-pick:hover { border-color: var(--fl-accent); }
.flow-media-pick .flow-media-thumb { cursor: pointer; background: var(--fl-bg); }

@media (prefers-reduced-motion: no-preference) {
  .tl-card, .flow-column { transition: box-shadow .15s ease; }
  .tl-card:hover { box-shadow: var(--fl-shadow); }
}

/* Inline template editor inside a wa-preview (flows side panel) */
.tpl-edit { display: flex; flex-direction: column; gap: 6px; }
.tpl-edit textarea { width: 100%; min-height: 90px; resize: vertical; box-sizing: border-box; }
.tpl-edit-label { font-size: 12px; color: #8895a0; }
.tpl-edit-btns { display: flex; flex-direction: column; gap: 6px; }
/* each editable button looks like the WhatsApp quick-reply pill it becomes */
.tpl-edit-btnrow { display: flex; align-items: center; gap: 6px; }
.tpl-edit-btnrow input {
  flex: 1; box-sizing: border-box; text-align: center;
  background: #fff; color: #0a80f5; font-weight: 600; font-size: 12.5px;
  border: 1px solid #d9dee3; border-radius: 8px; padding: 7px 10px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.tpl-edit-btnrow input:focus { outline: none; border-color: #0a80f5; }
.te-count {
  font-size: 11px; color: #8895a0; min-width: 38px; text-align: left;
  font-variant-numeric: tabular-nums; direction: ltr;
}
.te-count.full { color: #e74c3c; font-weight: 700; }
