/* ChatFlow flow editor: the Edit Block panel (#panel, design A). Needs tokens.css,
   components.css (fields, check rows, segmented control, menu, chips, icon buttons) and
   flows-list.css (the switch, .flw-switch, and its word, .flw-live-word) first.

   The panel slides in from the right over the canvas: a header (title, the block's Start /
   Post-REG / Post-FTD marks, More, Close), then the block's fields, which scroll. Each action
   is a card with the soft card shadow: a 36px head (drag grip, the action's name, More) with
   no divider, then its fields. Short fields sit on one line with their label ("Duration [4]
   seconds", .fbp-inline); the others have their label above. Sub-cards hold the conditions of
   a Condition or AI Chatter block, one line each.

   Density (colour language rule 1, 2026-09-30): the panel keeps the old one's density, so
   every block that fit a 1440x900 screen before fits again, Reply and Connections included.
   Inputs are 32px here (44px on touch), gaps 8px inside a section and 16px between them.

   Colours come from tokens only, so night needs no rules here; the class names (fbp-*) keep
   the old night layer's .panel, .action-card, .tag-* and .toggle-* rules (deleted with this
   file) from ever reaching it again.

   The canvas and its toolbar are not styled here (the next phase). */

.panel {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: 100%;
  box-sizing: border-box;
  border-left: 1px solid var(--line);
  background: var(--pop);
  color: var(--ink);
  font-family: var(--font);
  color-scheme: var(--scheme);
  /* closed: off screen and out of the Tab order (visibility), after the slide */
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .2s ease, visibility 0s linear .2s;
  --field-h: 32px;
}
@media (pointer: coarse) {
  .panel { --field-h: 44px; }
}
.panel.open { transform: none; visibility: visible; transition: transform .2s ease, visibility 0s; }

/* ---------- Header ---------- */
.fbp-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 48px;
  box-sizing: border-box;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--line);
}
.fbp-title-line { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.fbp-title { margin: 0; font: var(--fw-semibold) var(--fs-section)/var(--lh-section) var(--font); color: var(--ink); white-space: nowrap; }
.fbp-flags { display: flex; gap: 4px; min-width: 0; overflow: hidden; }
.fbp-flags:empty { display: none; }

/* ---------- Body: the block's fields ---------- */
.fbp-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* the canvas toolbar floats over the bottom of the window (72px): the last field scrolls clear of it */
  padding: 12px 16px 96px;
}
.fbp-sec { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fbp-sec-title { margin: 0; font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); }
.fbp-body p { margin: 0; }
.fbp-body strong { font-weight: var(--fw-semibold); }
/* A form field inside a flex column takes the column's width, never more; a long choice in a
   select ends with an ellipsis */
.fbp-body .field { gap: 4px; }
.fbp-body select.input { text-overflow: ellipsis; }
.fbp-body .field, .fbp-body .input { min-width: 0; }
.fbp-body textarea.input { min-height: 64px; padding: 6px 10px; }
.fbp-body .check-row input[type="checkbox"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Action cards ---------- */
.fbp-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg);
  box-shadow: var(--shadow-card);
  transition: box-shadow .15s ease, opacity .15s ease;
}
.fbp-card.dragging { opacity: .4; }
.fbp-card.drag-over { box-shadow: 0 -3px 0 0 var(--reply), var(--shadow-card); }
.fbp-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  box-sizing: border-box;
  padding: 0 4px 0 12px;
}
.fbp-grip { flex: none; display: flex; margin-left: -4px; color: var(--ink-2); cursor: grab; }
.fbp-card:active .fbp-grip { cursor: grabbing; }
.fbp-card-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fbp-card-body { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 10px; min-width: 0; }
.fbp-add { align-self: flex-start; }

/* A group of fields with its own small heading (AI Chatter: Advance conditions) */
.fbp-group { display: flex; flex-direction: column; gap: 8px; }
.fbp-group-title { margin: 0; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }

/* Sub-cards: one condition of a Condition or AI Chatter block, a group named "Condition N".
   Its selects and Remove share one line; the value or description goes under them. */
.fbp-sub {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-control);
  background: var(--fill);
}
.fbp-sub .icon-btn:hover:not(:disabled) { background: var(--line); }
.fbp-sub .hint { padding: 0 4px 2px; }
.fbp-add-sub { align-self: flex-start; }
.fbp-cond-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px; }
.fbp-cond-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; align-items: center; gap: 6px; }
.fbp-cond-value { position: relative; }

/* ---------- Small layouts: a label beside its short field, a number with its unit ---------- */
.fbp-inline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fbp-inline > .field-label { flex: none; min-width: 64px; }
.fbp-inline > .input, .fbp-inline > .fbp-dur { flex: 1; min-width: 0; }
.fbp-dur { display: flex; align-items: center; gap: 8px; }
.fbp-num { flex: none; width: 72px; }
.fbp-unit { flex: none; width: 112px; }
.fbp-unit-text { flex: none; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.fbp-field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fbp-indent { padding-left: 24px; }
/* Send window: from, to, and its time zone on one line */
.fbp-window { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fbp-window > .input { flex: none; width: 88px; }
.fbp-window-tz { flex: 1; min-width: 0; font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }
.fbp-seg { display: grid; width: 100%; }
.fbp-seg > button { min-width: 0; }
/* The chosen offer's state (paused, stopped, not assigned), in its status colour */
.fbp-state { font-weight: var(--fw-semibold); }
.fbp-state.is-warn { color: var(--warn); }
.fbp-state.is-bad { color: var(--bad); }

/* Two-line check row: a title over its hint */
.fbp-check2 { align-items: flex-start; }
.fbp-check2 input { margin-top: 1px; }
.fbp-check-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fbp-check-title { font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }

/* Switch rows (the list's switch and its state word). A row that heads its section (Wait for
   a reply) has the section title's size. */
.fbp-switch-row { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.fbp-switch-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fbp-switch-title { font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); cursor: pointer; }
.fbp-switch-row.is-head .fbp-switch-title { font-size: var(--fs-body); line-height: var(--lh-body); }
.fbp-switch-row .flw-live-word { min-width: 44px; }
/* A switch whose words are a status (AI replies: Active or Muted) is green when on, like the
   list's Live switch; a setting's switch stays blue */
.fbp-switch-row.is-status .flw-switch input:checked + .flw-switch-track { background: var(--ok-solid); }

/* ---------- Notes, previews, files ---------- */
.fbp-note {
  padding: 8px 10px;
  border-radius: var(--radius-control);
  background: var(--fill);
  color: var(--ink);
  font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font);
}
.fbp-note.is-warn { background: var(--warn-tint); color: var(--warn); }
.fbp-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: var(--fw-semibold);
  text-decoration: underline;
  cursor: pointer;
}
.fbp-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.fbp-preview {
  max-height: 260px;
  overflow: auto;
  padding: 8px 10px;
  border-radius: var(--radius-control);
  background: var(--fill);
  color: var(--ink);
  font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.fbp-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-caption); }
.fbp-file { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }
.fbp-file-name { font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.fbp-file-meta { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fbp-bets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.fbp-bet { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--fill); }
.fbp-bet-one { aspect-ratio: auto; max-height: 220px; object-fit: contain; }

/* ---------- Upload zone: a one-line button that opens the file chooser and takes a drop ----------
   Done: a green check and "Uploaded" (colour language: good = green), the file, then Replace.
   Failed: red. */
.fbp-drop {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px dashed var(--edge-field);
  border-radius: var(--radius-control);
  background: var(--bg);
  color: var(--ink-2);
  font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font);
  text-align: left;
  cursor: pointer;
}
.fbp-drop:hover { background: var(--hover); }
.fbp-drop:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fbp-drop .ic { color: var(--ink-2); }
.fbp-drop-title { flex: none; max-width: 100%; font-weight: var(--fw-semibold); color: var(--ink); overflow-wrap: anywhere; }
.fbp-drop-meta { flex: 1; min-width: 0; font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fbp-drop-act { flex: none; margin-left: auto; font: var(--fw-semibold) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--reply); }
.fbp-drop.is-done { border-style: solid; border-color: var(--line); }
.fbp-drop.is-done .ic, .fbp-drop.is-done .fbp-drop-title { color: var(--ok); }
.fbp-drop.is-drag { border-style: solid; border-color: var(--reply); background: var(--reply-tint); }
.fbp-drop.is-busy { cursor: progress; }
.fbp-drop.is-error { border-style: solid; border-color: var(--bad); }
.fbp-drop.is-error .ic, .fbp-drop.is-error .fbp-drop-title { color: var(--bad); }

/* ---------- Link domain: zone, subdomain row, Save ---------- */
.fbp-domain { display: flex; flex-direction: column; gap: 8px; }
.fbp-sub-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fbp-subdomain { flex: none; width: 120px; }
.fbp-root { flex: 1; min-width: 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); overflow-wrap: anywhere; }
.fbp-sub-row > [hidden] { display: none; }

/* ---------- Tags: chips and a field in one box, suggestions under it ---------- */
.fbp-tags {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: var(--field-h);
  box-sizing: border-box;
  padding: 3px 6px;
  border: 1px solid var(--edge-field);
  border-radius: var(--radius-control);
  background: var(--bg);
  cursor: text;
}
.fbp-tags:focus-within { border-color: var(--reply); box-shadow: 0 0 0 1px var(--reply); }
.fbp-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: 28px;
  box-sizing: border-box;
  padding-left: 10px;
  border-radius: 6px;
  background: var(--fill);
  color: var(--ink);
  font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font);
}
.fbp-tag-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fbp-tag-x {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.fbp-tag-x:hover { background: var(--line); color: var(--ink); }
.fbp-tag-x:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.fbp-tag-input {
  flex: 1;
  min-width: 120px;
  height: 28px;
  padding: 0 4px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font);
}
.fbp-tag-input::placeholder { color: var(--ink-2); opacity: 1; }
/* Suggestions: the menu surface, under the field they complete */
.fbp-suggest {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: -1px;
  right: -1px;
  z-index: 20;
  max-height: 188px;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--pop);
  box-shadow: var(--shadow-pop);
}
.fbp-suggest.show { display: block; }
.fbp-suggest-item {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--ink);
  font: var(--fw-regular) var(--fs-label)/16px var(--font);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.fbp-suggest-item:hover { background: var(--fill); }
.fbp-suggest-note { margin: 0; padding: 6px 8px; font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }

/* ---------- Stickers: the picked one, then the library as toggle buttons ---------- */
.fbp-sticker-sel { display: flex; align-items: center; gap: 12px; }
.fbp-sticker-sel img { display: block; width: 72px; height: 72px; object-fit: contain; }
/* 4px of padding: the scrolling grid never clips a focused sticker's ring (2px at 2px) */
.fbp-sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}
.fbp-sticker-empty { grid-column: 1 / -1; }
.fbp-sticker-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 4px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--fill);
  cursor: pointer;
}
.fbp-sticker-btn img { display: block; width: 56px; height: 56px; object-fit: contain; }
.fbp-sticker-btn:hover { background-image: linear-gradient(var(--press-overlay), var(--press-overlay)); }
/* Picked: the blue tint and a check badge (not a ring, so it never looks like keyboard focus) */
.fbp-sticker-btn[aria-pressed="true"] { background: var(--reply-tint); }
.fbp-sticker-check { position: absolute; top: 3px; right: 3px; display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--reply); color: var(--on-reply); }
.fbp-sticker-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fbp-sticker-emoji { font-size: 32px; line-height: 1; }
.fbp-sticker-none { font: var(--fw-regular) var(--fs-badge)/var(--lh-badge) var(--font); color: var(--ink-2); }

/* ---------- Connections: where each output goes, with Remove ---------- */
.fbp-conns { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg); box-shadow: var(--shadow-card); }
.fbp-conn { display: flex; align-items: center; gap: 6px; min-height: 32px; box-sizing: border-box; padding: 2px 2px 2px 12px; }
.fbp-conn + .fbp-conn { border-top: 1px solid var(--line); }
/* The path's word is a chip in the colour of its path (green replied or match, the money colours
   for Registered and Deposited, amber objection, red timeout, neutral Continue or Next) */
.fbp-conn-port.chip { display: inline-block; flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.fbp-conn-arrow { flex: none; display: flex; color: var(--ink-2); }
.fbp-conn-to { flex: 1; min-width: 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Touch and phones ---------- */
@media (pointer: coarse) {
  .fbp-tag { height: 44px; }
  .fbp-tag-x, .fbp-tag-input { height: 44px; }
  .fbp-tag-x { width: 44px; }
  .fbp-suggest-item { height: 44px; }
  .fbp-conn { min-height: 52px; }
}
/* Review flows-1: on a 393pt phone the panel took 370 of 393px and left a 23px sliver of
   canvas. Under 768px it takes the whole width under the bar; Close is its way back. */
@media (max-width: 767px) {
  /* --fbp-top: set by the page when the editor bar wraps below the top bar (481 to 767px) */
  .panel { top: var(--fbp-top, 45px); width: 100%; border-left: 0; }
  .fbp-tag-input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .panel, .panel.open, .fbp-card { transition: none; }
}
