:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #737373;
  --line: #e5e5e5;
  --bg: #fafafa;
  --white: #fff;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.card {
  width: min(100%, 24rem);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}
.kicker { margin: 0; color: var(--muted); font-size: 14px; }
h1 { margin: 4px 0 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.hint { margin: 8px 0 0; color: #525252; font-size: 14px; }
.stack { display: grid; gap: 10px; }
form.stack { margin-top: 20px; }
label { display: grid; gap: 4px; font-size: 14px; }
.field, textarea, select.field {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
textarea.field { min-height: 88px; resize: vertical; }
.field:focus, textarea.field:focus { border-color: #a3a3a3; }
.primary, .ghost {
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
}
.primary { background: #171717; color: white; }
.ghost { background: white; border-color: var(--line); }
.primary:disabled { opacity: 0.6; }
.err { color: #b91c1c; font-size: 14px; min-height: 1.2em; margin: 0; }

.shell { height: 100dvh; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.topbar-start { flex: 1; min-width: 0; }
.topbar-actions { flex: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-start.row { flex-wrap: nowrap; }
.flow-select-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; min-width: 0; }
.flow-select { width: min(210px, 22vw); padding: 7px 10px; border-radius: 9px; }
.topbar-nav { display: flex; gap: 6px; align-items: center; flex: none; }
.topbar-nav-btn { padding: 7px 10px; font-size: 13px; white-space: nowrap; border-radius: 9px; }
.topbar-nav-btn.on { background: #f4f4f5; border-color: #a3a3a3; }
.account-brand { margin: 0; font-size: 15px; font-weight: 600; }
.account-email { margin: 0; color: var(--muted); font-size: 13px; word-break: break-all; }
.workspace { position: relative; min-height: 0; min-width: 0; display: grid; grid-template-columns: 1fr; overflow: hidden; }
.drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: min(340px, 92vw);
  background: white;
  z-index: 4;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.12);
  transition: transform .22s ease, visibility .22s ease;
  visibility: hidden;
  pointer-events: none;
}
.drawer.left { left: 0; width: min(420px, 96vw); border-right: 1px solid var(--line); transform: translateX(-105%); padding: 10px 12px 12px; overflow: hidden; overscroll-behavior: contain; gap: 0; }
.drawer.right { right: 0; width: min(520px, 94vw); border-left: 1px solid var(--line); transform: translateX(105%); overflow: hidden; }
.media-source-panel { display: grid; gap: 8px; }
.media-source-panel[hidden] { display: none !important; }
.media-source-panel .row .hint { margin: 0; flex: 1; min-width: 0; word-break: break-all; }
.preview { display: grid; gap: 6px; font-size: 12px; color: #525252; }
.preview img, .preview video { width: 100%; max-width: 100%; border-radius: 12px; background: #171717; display: block; height: auto; }
.preview img { max-height: 180px; object-fit: contain; background: #f4f4f5; }
.preview video { max-height: 160px; background: #171717; }
.preview audio { display: block; width: 100%; max-width: 280px; height: 40px; }
.drawer.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}
.drawer-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.drawer-tab {
  flex: 1 0 auto;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 6px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 0;
  white-space: nowrap;
}
.drawer-tab.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.drawer-close { flex: none; margin-left: 4px; }
/* Only the active drawer panel is shown — display:flex/grid must not override [hidden]. */
.drawer.left > .drawer-panel {
  display: none !important;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  flex: 1 1 auto;
  align-content: start;
}
.drawer.left > .drawer-panel.is-on {
  display: grid !important;
}
.drawer.left > .drawer-panel.grow.is-on {
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
}
.thread-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0 8px;
  border-bottom: 1px solid var(--line);
  min-height: 40px;
}
.thread-head .thread-back {
  flex: none;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 18px;
  border-radius: 10px;
}
.thread-who {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
}
.thread-who strong {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-sub[hidden] { display: none; }
.drawer-panel .hint { margin: 0; }
.drawer-panel.grow.is-on #people,
.drawer-panel.grow.is-on #event-log { flex: 1 1 auto; min-height: 0; overflow: auto; }
.drawer-panel.grow #people-toolbar[hidden],
.drawer-panel.grow #people[hidden],
.drawer-panel.grow #thread[hidden],
.drawer-panel.grow #thread-head[hidden],
.drawer-panel.grow #jump[hidden] { display: none; }
.drawer-panel.grow.is-on #thread { flex: 1 1 auto; min-height: 0; }
.drawer-panel.grow.is-on #thread-head,
.drawer-panel.grow.is-on #people-toolbar,
.drawer-panel.grow.is-on #jump { flex: none; }
.section-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.people-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 0 6px;
}
.people-toolbar-label { font-size: 11px; color: var(--muted); }
.people-sort {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #f4f4f5;
}
.people-sort-btn {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  font-size: 11px;
  color: #737373;
}
.people-sort-btn.on {
  background: #171717;
  color: #fff;
}
.people, .event-log { display: grid; gap: 6px; min-height: 0; overflow: auto; align-content: start; }
.people-group {
  display: grid;
  gap: 6px;
}
.people-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.people-group-head .flow-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}
.people-group-head .people-group-count {
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
}
.thread, .event-log.wa-feed { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto; align-content: stretch; background: #efeae2; border-radius: 12px; padding: 10px 8px; border: 1px solid var(--line); }
.thread { flex: 1 1 auto; }
.person {
  display: grid;
  gap: 2px;
  text-align: left;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 8px 10px;
  border-left: 3px solid var(--flow-color, var(--line));
}
.person.on { border-color: #171717; border-left-color: var(--flow-color, #171717); }
.person-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}
.person-main {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0;
  display: grid;
  gap: 2px;
}
.person-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.person-name-row b {
  display: block;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.flow-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 110px;
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--flow-color, #171717);
  background: color-mix(in srgb, var(--flow-color, #171717) 14%, white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-pill[hidden] { display: none; }
.thread-who .flow-pill { max-width: 160px; margin-top: 2px; }
.person b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person span { color: #737373; font-size: 12px; }
.person .person-status { color: #1f7a4d; font-size: 11px; }
.person .person-status.is-paused { color: #9a5b24; }
.person-acts {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  margin-top: -2px;
  margin-right: -4px;
}
.person-act {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #737373;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.person-act:hover { background: #f0f0ee; color: #171717; }
.person-act:disabled { opacity: .35; cursor: default; }
.person-act:disabled:hover { background: transparent; color: #737373; }
.person-act.is-paused { color: #9a5b24; background: #fff3e8; }
.person-act.is-paused:hover { background: #ffe8d4; }
.jump { display: grid; gap: 6px; padding-top: 4px; }
.jump[hidden] { display: none; }
.jump-open { width: 100%; justify-self: stretch; }
.jump-dialog { width: min(440px, calc(100% - 24px)); max-height: min(86dvh, 720px); padding: 16px; display: none; }
.jump-dialog[open] { display: grid; gap: 10px; grid-template-rows: auto auto auto 1fr auto; }
.jump-dialog-title { margin: 2px 0 0; font-size: 18px; }
.jump-dialog-actions { margin-top: 2px; }
.jump-flow-label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.jump-flow { width: 100%; }
.jump-list { display: grid; gap: 8px; min-height: 0; overflow: auto; padding: 2px; }
.jump-card {
  text-align: left;
  border: 1px solid var(--line);
  background: #f7f7f5;
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  display: grid;
  gap: 8px;
}
.jump-card.on { border-color: #171717; background: #fff; box-shadow: 0 0 0 1px #171717; }
.jump-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.jump-card-head b { font-size: 13px; font-weight: 600; }
.jump-card-type { font-size: 10px; color: #737373; text-transform: uppercase; letter-spacing: .04em; }
.jump-wa {
  display: grid;
  gap: 5px;
  background: #efeae2;
  border-radius: 10px;
  padding: 8px;
}
.jump-wa-bubble {
  justify-self: start;
  max-width: 94%;
  background: #d9fdd3;
  border-radius: 8px 8px 8px 2px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  color: #111;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.jump-wa-bubble b { font-weight: 700; }
.jump-wa-bubble i { font-style: italic; }
.jump-wa-bubble s { text-decoration: line-through; }
.jump-wa-bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.jump-wa-media {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 94%;
  background: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  color: #3f3f46;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.jump-wa-ico { font-size: 14px; }
.jump-wa-pause, .jump-wa-wait, .jump-wa-note {
  justify-self: center;
  font-size: 10px;
  color: #737373;
  background: rgba(255,255,255,.65);
  border-radius: 999px;
  padding: 2px 8px;
}
.jump-wa-wait { color: #9a5b24; background: #fff3e8; }
.flow-section.is-compact { gap: 10px; }
.flow-section.is-compact #flows { gap: 12px; }
.flow-section.is-compact .flow-btn { padding: 8px 10px; gap: 2px; border-radius: 10px; }
.flow-section.is-compact .flow-btn strong { font-size: 13px; }
.flow-section.is-compact .flow-btn span { font-size: 10px; }
.flow-section.is-compact .trigger { padding: 5px 8px; font-size: 11px; }
.flow-section.is-compact .make-default { font-size: 11px; padding: 3px 6px; }
.flow-section.is-compact #new,
.flow-section.is-compact #flow-io-btn { padding: 6px 10px; font-size: 13px; }
.flow-section.is-compact .badge { font-size: 10px; padding: 3px 6px; }
.flow-section.is-compact .flow-act { width: auto; min-width: 0; height: auto; padding: 4px 8px; font-size: 11px; }
.flow-section.is-compact .flow-item { padding: 10px; gap: 8px; }
.float-unwire { position: absolute; z-index: 6; left: 50%; bottom: 18px; transform: translateX(-50%); }
.float-unwire[hidden] { display: none; }
.place-menu { position: fixed; z-index: 8; display: grid; gap: 4px; min-width: 180px; padding: 8px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.12); }
.place-menu[hidden] { display: none; }
.place-menu button { text-align: left; border: 0; background: #fafafa; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.pill { font-size: 12px; background: #fff6d8; color: #6b4e00; border-radius: 999px; padding: 6px 10px; }
.icon { min-width: 40px; }
.steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.steps li { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; line-height: 1.35; background: rgba(255,255,255,.72); border-radius: 8px; padding: 4px 6px; color: #262626; }
.step-icon { width: 16px; flex: none; text-align: center; }
.wires { pointer-events: none; }
.wires path { pointer-events: stroke; cursor: pointer; }
.wires path.on { stroke-dasharray: 7 5; animation: dash .5s linear infinite; stroke-width: 2.5; }
@keyframes dash { to { stroke-dashoffset: -24; } }
.node { width: 260px; padding: 0; overflow: hidden; transition: outline-color .15s ease, transform .15s ease; }
.node header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: white; border-radius: 15px 15px 0 0; cursor: grab; }
.node .body { cursor: grab; }
.node header h3 { color: white; }
.node header span { font-size: 14px; }
.node .body { padding: 8px 12px 12px; }
.node.start header { background: #1f7a4d; }
.node.message header { background: #2f6fed; }
.node.wait_response header { background: #e07a2f; }
.node.schedule header { background: #7c3aed; }
.toolbar button[draggable="true"] { cursor: grab; }
.node.on { outline: 2px solid #171717; transform: translateY(-1px); }
.node.multi { outline: 2px solid #525252; outline-offset: 1px; }
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #fafafa; overflow: hidden; }
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.drag-blocks { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.drag-block { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; min-width: 145px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: white; cursor: grab; user-select: none; -webkit-user-select: none; }
.drag-block > span { grid-row: 1 / span 2; align-self: center; font-size: 18px; }
.drag-block b { font-size: 12px; }
.drag-block small { color: var(--muted); font-size: 10px; }
.drag-block.start { border-color: #1f7a4d; background: #e8f7ee; }
.drag-block.message { border-color: #2f6fed; background: #e7f0fc; }
.drag-block.wait { border-color: #e07a2f; background: #fff3e8; }
.drag-block.schedule { border-color: #7c3aed; background: #f3eefc; }
.canvas { position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: default; touch-action: none; background-image: radial-gradient(#e5e5e5 1px, transparent 1px); background-size: 18px 18px; }
.canvas.dragging { cursor: grabbing; }
.world { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.wires { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.node {
  position: absolute;
  width: 260px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  overflow: visible;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  cursor: default;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.node.start { background: #e8f7ee; border-color: #1f7a4d; }
.node.message { background: #e7f0fc; border-color: #2f6fed; }
.node.wait_response { background: #fff3e8; border-color: #e07a2f; }
.node.schedule { background: #f3eefc; border-color: #7c3aed; }
.node.on { outline: 2px solid #171717; }
.node.on.multi { outline-color: #171717; }
.node.sim { outline: 2px solid #7c3aed; }
dialog.sim { width: min(420px, calc(100% - 24px)); }
dialog.sim[open] { display: grid; gap: 10px; }
.sim-chat { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-height: 420px; min-height: 170px; overflow: auto; background: #f5f5f5; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.sim-bubble { max-width: min(260px, 92%); padding: 8px 10px; border-radius: 12px; background: white; border: 1px solid var(--line); color: var(--ink); font-size: 14px; }
.sim-bubble.client { align-self: flex-end; background: #3b0764; color: #f5f5f5; }
.sim-bubble.note { align-self: center; background: transparent; border: 0; color: #a3a3a3; font-size: 12px; padding: 0; max-width: 94%; }
.sim-bubble .wa-media { min-width: 0; width: 100%; }
.sim-bubble .wa-media img,
.sim-bubble .wa-media video {
  max-width: 100%;
  width: 100%;
  max-height: 140px;
  border-radius: 8px;
  object-fit: cover;
  background: #111;
  cursor: pointer;
}
.sim-bubble .wa-media audio,
.sim-bubble .wa-audio {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 220px;
  height: 36px;
  margin: 0;
}
.sim-bubble .wa-media-chip { font-size: 10px; padding: 2px 7px; }
.sim-bubble .wa-body { font-size: 12px; }
.sim-reply { display: grid; gap: 8px; }
.node h3 { margin: 0; font-size: 14px; font-weight: 600; }
.node p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.port {
  position: absolute;
  right: -8px;
  z-index: 3;
  width: 16px;
  height: 16px;
  border-radius: 99px;
  border: 2px solid white;
  background: #171717;
  cursor: crosshair;
  touch-action: none;
}
.port.in { left: -8px; right: auto; top: 50%; margin-top: -8px; background: white; border: 2px solid #171717; }
.port.timeout { right: -8px; top: auto; bottom: 14px; background: #e07a2f; }
.port.always { right: -8px; top: 18px; }
.port.fail { right: -8px; top: 50%; margin-top: -8px; background: #c2410c; }
.node.wait_response .port.always { top: 48px; }
.node.wait_response .port.fail { top: 88px; margin-top: 0; }
.node.wait_response .port.timeout { bottom: 14px; }
.wait-fork { display: grid; gap: 6px; }
.wait-fork p { margin: 0; background: rgba(255,255,255,.72); border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.wait-fork .or, .wait-fork .muted { background: transparent; text-align: center; color: #9a5b24; padding: 0; }
.wait-fork .after { font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.log { font-size: 12px; color: #262626; display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.wa-bubble {
  max-width: 88%;
  padding: 6px 8px 4px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
  display: grid;
  gap: 4px;
  word-break: break-word;
}
.wa-bubble.in { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.wa-bubble.out { align-self: flex-end; background: #d9fdd3; border-top-right-radius: 2px; }
.wa-bubble.error { align-self: center; background: #fde8e8; color: #7f1d1d; max-width: 94%; text-align: center; font-size: 12px; }
.wa-bubble.status, .wa-bubble.log { align-self: center; background: transparent; box-shadow: none; color: #737373; font-size: 11px; text-align: center; max-width: 94%; padding: 2px 6px; }
.wa-bubble .wa-meta { display: flex; justify-content: flex-end; align-items: baseline; gap: 6px; margin-top: 2px; }
.wa-bubble .wa-time { font-size: 10px; color: #667781; white-space: nowrap; }
.wa-bubble .wa-who { font-size: 11px; font-weight: 600; color: #1f7a4d; }
.wa-bubble.out .wa-who { color: #1f5c3a; }
.wa-bubble .wa-body { white-space: pre-wrap; color: var(--ink); }
.wa-bubble .wa-media { display: grid; gap: 6px; min-width: 180px; }
.wa-bubble .wa-media-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #3f3f46;
  background: rgba(0,0,0,.04);
  border-radius: 999px;
  padding: 3px 8px;
  width: fit-content;
}
.wa-bubble .wa-media-ico { font-size: 12px; line-height: 1; }
.wa-bubble .wa-media img,
.wa-bubble .wa-media video {
  display: block;
  max-width: 100%;
  width: 100%;
  max-height: 240px;
  border-radius: 8px;
  background: #111;
  cursor: pointer;
  object-fit: cover;
}
.wa-bubble .wa-audio,
.wa-bubble .wa-media audio {
  display: block;
  width: 100%;
  min-width: 200px;
  max-width: 280px;
  height: 40px;
  margin: 0;
}
.wa-bubble .wa-file-link { font-size: 12px; color: #1f5c3a; text-decoration: underline; }
.wa-bubble .wa-media-missing {
  font-size: 12px;
  color: #525252;
  background: rgba(0,0,0,.04);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-word;
}
.wa-live {
  align-self: flex-start;
  font-size: 12px;
  color: #667781;
  padding: 4px 10px;
  background: rgba(255,255,255,.72);
  border-radius: 999px;
  animation: wa-pulse 1.2s ease-in-out infinite;
}
.wa-live.out-side { align-self: flex-end; }
@keyframes wa-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.wa-status-row { display: flex; align-items: center; gap: 8px; }
.wa-status-row .hint { margin: 0; }
.wa-dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  flex: none;
  background: #a3a3a3;
}
.wa-dot[data-state="open"] {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .55);
  animation: wa-blink 1.1s ease-out infinite;
}
.wa-dot[data-state="close"],
.wa-dot[data-state="missing"] { background: #ef4444; }
@keyframes wa-blink {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.wa-qr-box { display: grid; gap: 8px; justify-items: start; }
.wa-qr-box[hidden] { display: none; }
#flows { display: grid; gap: 12px; }
.side .ghost, .side .primary { width: 100%; }
.block { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.meta-row { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 8px; align-items: end; }
.meta-row label { display: grid; gap: 4px; font-size: 12px; min-width: 0; }
.inspect-head, .action-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.x { width: 28px; height: 28px; border: 0; border-radius: 8px; background: #f4f4f5; color: #171717; font-size: 18px; line-height: 1; cursor: pointer; }
.action .x { background: #fde8e8; color: #c24141; }
.remove-block { color: #c24141; border-color: #f0c9c9; }
.action-list { display: grid; gap: 8px; min-height: 8px; }
.action.text { background: #e7f0fc; border-color: #2f6fed; }
.action.pause { background: #fff6d8; border-color: #d4a017; }
.action.file { background: #f3e8ff; border-color: #7c3aed; }
.action.wait { background: #fff3e8; border-color: #e07a2f; }
.drawer.right .action-list { flex: 1 1 auto; min-height: 0; overflow: auto; align-content: start; grid-auto-rows: max-content; }
.action { position: relative; height: auto; min-height: max-content; overflow: visible; }
.action textarea.field { min-height: 88px; }
.add-box { display: grid; gap: 6px; margin-top: auto; padding: 8px 0 0; border-top: 1px solid var(--line); background: white; position: sticky; bottom: 0; z-index: 2; }
.add-box .kicker { font-size: 11px; }
.add-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.add-chip { display: flex; align-items: center; justify-content: center; gap: 4px; border: 0; border-radius: 8px; padding: 4px 6px; color: white; font-size: 11px; font-weight: 600; cursor: grab; }
.remove-block { width: fit-content; font-size: 11px; padding: 3px 8px; }
.add-chip.text { background: #2f6fed; }
.add-chip.pause { background: #d4a017; }
.add-chip.file { background: #7c3aed; }
.add-chip.wait { background: #e07a2f; }
.flow-btn {
  width: 100%;
  text-align: left;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px 10px 10px;
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--flow-color, var(--line));
}
.flow-btn.on { border-color: #171717; background: white; border-left-color: var(--flow-color, #171717); }
.flow-btn strong {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.flow-btn .flow-swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--flow-color, #171717);
  flex: 0 0 auto;
}
.flow-btn span { color: var(--muted); font-size: 11px; }
.flow-btn.is-renaming {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  box-sizing: border-box;
  padding: 8px 10px 8px 10px;
  border: 1px solid #171717;
  border-radius: 10px;
  border-left: 3px solid var(--flow-color, #171717);
  background: white;
}
.flow-btn.is-renaming .flow-swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--flow-color, #171717);
  flex: 0 0 auto;
}
.flow-btn-rename {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  color: inherit;
  outline: none;
}
.flow-btn-rename:focus {
  border-color: #171717;
}
.flow-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.trigger { padding: 4px 8px; font-size: 12px; }
.flow-row { display: flex; align-items: center; gap: 6px; }
.flow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
.flow-act { width: auto; min-width: 0; height: auto; padding: 5px 9px; line-height: 1.2; font-size: 12px; white-space: nowrap; }
.flow-act.danger { color: #c24141; border-color: #f0c9c9; }
.flow-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.flow-toolbar #new { flex: 1 1 auto; }
.flow-io { position: relative; flex: 1 1 auto; }
.flow-io > .ghost { width: 100%; }
.flow-io-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: grid;
  gap: 2px;
  min-width: 180px;
  padding: 6px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.1);
}
.flow-io-menu[hidden] { display: none; }
.flow-io-menu button {
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
.flow-io-menu button:hover { background: #f4f4f5; }
.flow-info { position: relative; flex: none; }
.flow-info > summary {
  list-style: none;
  box-sizing: border-box;
  width: 40px;
  min-width: 40px;
  padding: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  cursor: pointer;
}
.flow-info > summary::-webkit-details-marker { display: none; }
.flow-info[open] > summary { background: #f4f4f5; }
.flow-info > p {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  right: 0;
  width: min(260px, 70vw);
  margin: 0;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.1);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.badge { font-size: 11px; font-weight: 600; color: #1f7a4d; background: #e8f7ee; border-radius: 999px; padding: 4px 8px; }
.make-default { font-size: 12px; padding: 4px 8px; }
.flow-row .flow-btn { min-width: 0; flex: 1; }
.settings-section { gap: 10px; align-content: start; }
.settings-group { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fafafa; }
.settings-group + .settings-group { margin-top: 2px; }
.settings-group .row { gap: 6px; }
.settings-group .ghost { padding: 8px 10px; }
.settings-group .section-help { margin: 0; }
.run-actions { display: grid; gap: 6px; }
.run-actions .ghost { justify-self: start; }
.qr { width: 180px; height: 180px; border-radius: 12px; border: 1px solid var(--line); }
.dialog {
  width: min(640px, calc(100% - 24px));
  border: 0;
  border-radius: 16px;
  padding: 20px;
}
.dialog::backdrop { background: rgba(0,0,0,.35); }
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .side, .inspector { border: 0; border-bottom: 1px solid var(--line); }
  .drawer.left, .drawer.right { width: min(100%, 100vw); max-width: 100%; }
}
@media (max-width: 720px) {
  .topbar {
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .topbar-start {
    flex: 1;
    min-width: 0;
    width: auto;
    gap: 6px;
  }
  .topbar-actions { flex: none; gap: 6px; margin-left: 0; }
  .topbar-actions .icon { min-width: 36px; padding: 8px; }
  .topbar-actions .primary { padding: 8px 12px; }
  .flow-select-label { flex: 1 1 auto; min-width: 0; max-width: none; }
  .flow-select { width: 100%; max-width: none; min-width: 0; font-size: 13px; }
  .topbar-nav { gap: 4px; }
  .topbar-nav-btn { padding: 7px 8px; font-size: 12px; }
  .pill { display: none; }
  .toolbar {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
  }
  .drag-blocks {
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    padding-bottom: 2px;
  }
  .drag-block {
    flex: 0 0 auto;
    min-width: 118px;
    max-width: 150px;
    cursor: pointer;
    touch-action: pan-x;
  }
  .drag-block small { display: none; }
  .stage { min-height: 0; min-width: 0; overflow: hidden; }
  .canvas { min-height: 0; }
  .node { width: 220px; }
  .drawer.left, .drawer.right {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }
  .drawer.right { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .float-unwire { bottom: max(18px, env(safe-area-inset-bottom)); width: calc(100% - 32px); max-width: 280px; }
  .place-menu { min-width: min(220px, calc(100vw - 24px)); }
  .meta-row { grid-template-columns: 1fr; }
  .add-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .topbar { gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .topbar-nav-btn { padding: 7px 7px; }
  .icon { min-width: 36px; padding: 8px; }
  .topbar-actions #undo,
  .topbar-actions #redo { display: none; }
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.page { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }

.sched-interval-tag {
  margin: 0 0 6px;
  font-size: 11px;
  color: #5b21b6;
  font-weight: 600;
}
.sched-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f3eefc;
  color: #5b21b6;
  font-size: 11px;
  font-weight: 700;
}
.person-act.has-sched { color: #5b21b6; background: #f3eefc; }
.person-act.danger:hover { color: #b91c1c; background: #fef2f2; }
.primary.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.primary.danger:hover { background: #991b1b; border-color: #991b1b; }
.delete-chat-dialog[open] { grid-template-rows: auto auto auto; }
.sched-active-box { display: grid; gap: 8px; margin-bottom: 8px; }
.sched-run-card {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #faf8ff;
}
.sched-run-card b { display: block; font-size: 14px; }
.sched-run-card span { color: var(--muted); font-size: 12px; }
.jump-item {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
}
.jump-item b { font-size: 14px; }
.jump-item span { color: var(--muted); font-size: 12px; }
.jump-item.on { border-color: #171717; background: #f4f4f2; }

.sales-panel {
  background:
    radial-gradient(circle at top left, rgba(194, 65, 12, .12), transparent 240px),
    linear-gradient(180deg, #fffaf5 0, #fff 220px);
}
.sales-toolbar, .sales-detail, .sales-create { display: grid; gap: 12px; min-height: 0; }
.sales-toolbar[hidden], .sales-detail[hidden], .sales-create[hidden] { display: none !important; }
.sales-hero {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(194, 65, 12, .18);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 23, 23, .06);
}
.sales-hero h2 {
  margin: 4px 0 6px;
  font-size: clamp(22px, 7vw, 30px);
  line-height: 1.04;
  letter-spacing: -.04em;
}
.sales-new-btn { width: 100%; border-radius: 999px; }
.sales-provider-card {
  padding: 10px 12px;
  border: 1px solid #fed7aa;
  border-radius: 14px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
  font-weight: 700;
}
.sales-list { display: grid; gap: 10px; overflow: auto; min-height: 0; align-content: start; padding: 2px; }
.drawer-panel.grow.is-on #sales-list { flex: 1 1 auto; }
.sales-empty {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px dashed #fdba74;
  border-radius: 18px;
  background: rgba(255, 247, 237, .7);
}
.sales-empty b { font-size: 15px; }
.sales-card {
  display: grid;
  gap: 12px;
  text-align: left;
  width: 100%;
  border: 1px solid rgba(23,23,23,.1);
  border-radius: 18px;
  background: #fff;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(23,23,23,.03);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.sales-card:hover {
  transform: translateY(-1px);
  border-color: rgba(194, 65, 12, .5);
  box-shadow: 0 10px 24px rgba(23,23,23,.08);
}
.sales-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.sales-card-top b { font-size: 15px; line-height: 1.2; letter-spacing: -.01em; }
.sales-card-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.sales-metric {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 8px;
  border-radius: 12px;
  background: #fafafa;
}
.sales-metric strong { font-size: 13px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sales-metric span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sales-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  background: #f4f4f5;
  color: #525252;
  white-space: nowrap;
}
.sales-badge.ok { background: #ecfdf5; color: #047857; }
.sales-badge.draft { background: #fff7ed; color: #c2410c; }
.sales-detail-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sales-detail-head strong {
  display: block;
  font-size: 18px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sales-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.sales-actions .primary, .sales-actions .ghost, .sales-actions a.primary, .sales-actions a.ghost {
  justify-content: center;
  min-height: 40px;
  padding: 9px 10px;
  font-size: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
}
.sales-actions a[aria-disabled="true"] {
  opacity: .55;
  pointer-events: none;
}
.sales-live-url {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafafa;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.danger-text { color: #b91c1c !important; }
.sales-funnel, .sales-orders {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(23,23,23,.08);
  border-radius: 18px;
  background: #fff;
}
.sales-funnel-bars { display: grid; gap: 8px; }
.sales-funnel-row {
  display: grid;
  grid-template-columns: minmax(5rem, 7.5rem) 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.sales-funnel-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sales-funnel-bar { height: 9px; background: #f4f4f5; border-radius: 999px; overflow: hidden; }
.sales-funnel-bar i { display: block; height: 100%; background: linear-gradient(90deg, #fb923c, #c2410c); border-radius: 999px; }
.sales-funnel-n { text-align: right; font-weight: 700; min-width: 2ch; }
.sales-order {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
  font-size: 13px;
}
.sales-order span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.sales-create-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(23,23,23,.1);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 23, 23, .05);
}
.sales-create label { display: grid; gap: 5px; font-size: 13px; }
.sales-create .field { border-radius: 14px; }
.sales-create textarea.field { min-height: 116px; }
.sales-form-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 10px; }
@media (max-width: 720px) {
  #nav-sales { max-width: 7.5rem; overflow: hidden; text-overflow: ellipsis; }
  .sales-panel { padding: 10px; }
  .sales-hero { padding: 14px; border-radius: 18px; }
  .sales-hero h2 { font-size: clamp(26px, 10vw, 40px); }
  .sales-new-btn { min-height: 52px; }
  .sales-actions { grid-template-columns: 1fr; }
  .sales-card-meta { grid-template-columns: 1fr; }
  .sales-form-grid { grid-template-columns: 1fr; }
  .sales-funnel-row { grid-template-columns: 5.8rem 1fr auto; }
}
