:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1c2230; --muted: #667085; --line: #e3e6eb;
  --accent: #2f5bd3; --accent-text: #ffffff; --ok-bg: #e8f5ec; --ok: #1d6b3a; --bad-bg: #fdecec; --bad: #a12626;
  --bubble-in: #eef1f5; --bubble-out: #e3ebff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --surface: #1b1f27; --text: #e6e8ec; --muted: #9aa3b2; --line: #2b313c;
    --accent: #7c9cff; --accent-text: #0e1220; --ok-bg: #16301f; --ok: #8fd6a6; --bad-bg: #3a1a1a; --bad: #f1a0a0;
    --bubble-in: #232934; --bubble-out: #23305a; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; } h2 { font-size: 1rem; margin: 0 0 .6rem; } h3 { font-size: .9rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: .7rem 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.page { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 3rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.card.attention { border-left: 4px solid var(--bad); }
.narrow { max-width: 420px; margin: 2rem auto; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; } .between { justify-content: space-between; } .block { color: inherit; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.list { list-style: none; padding: 0; margin: 0; }
.muted { color: var(--muted); font-weight: normal; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 99px; border: 1px solid var(--line); font-size: .8rem; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.flash { padding: .6rem .8rem; border-radius: 8px; } .flash.ok { background: var(--ok-bg); color: var(--ok); } .flash.bad { background: var(--bad-bg); color: var(--bad); }
.btn, input[type=submit] { font: inherit; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.small { padding: .2rem .6rem; font-size: .85rem; } .btn:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
form.button_to { display: inline; }
label { display: block; margin-bottom: .7rem; font-weight: 500; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .5rem; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
textarea.code { font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.transcript { display: flex; flex-direction: column; gap: .5rem; max-height: 60vh; overflow-y: auto; margin-bottom: .8rem; }
.bubble { max-width: 85%; padding: .5rem .75rem; border-radius: 12px; } .bubble p { margin: 0 0 .3rem; }
.bubble.in { background: var(--bubble-in); align-self: flex-start; } .bubble.out { background: var(--bubble-out); align-self: flex-end; }
.composer { display: flex; gap: .5rem; margin-top: .5rem; } .composer input[type=text] { margin: 0; }
.stages { margin: 0; padding-left: 1.2rem; } .stages li.done { color: var(--muted); text-decoration: line-through; } .stages li.current { font-weight: 700; color: var(--accent); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; margin: 0; } .facts dt { color: var(--muted); } .facts dd { margin: 0; overflow-wrap: anywhere; }
.fact { margin-bottom: .6rem; }
pre { font-size: 12px; overflow-x: auto; background: var(--bg); padding: .5rem; border-radius: 6px; }
.history { padding-left: 1rem; font-size: .85rem; } code { font-size: .85em; overflow-wrap: anywhere; }
details { margin-bottom: .3rem; } summary { cursor: pointer; font-size: .9rem; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
@media (max-width: 860px) { .week { grid-template-columns: 1fr; } }
.day.today { border-color: var(--accent); }
.slot { display: block; padding: .4rem .5rem; border-radius: 8px; margin-bottom: .4rem; background: var(--bubble-out); color: inherit; }
.slot.requested { background: var(--bg); border: 1px dashed var(--line); }
.slot small { display: block; }
.quick-replies { margin-top: .4rem; }
/* --- flow builder --- */
.builder { display: grid; grid-template-columns: 290px minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .builder { grid-template-columns: 1fr; } }
.pane { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .8rem; }
.outline, .inspector { position: sticky; top: .5rem; max-height: calc(100vh - 1rem); overflow-y: auto; }
.o-stages, .o-bricks { list-style: none; margin: 0; padding: 0; }
.o-stage { margin-bottom: .6rem; } .o-stage.depth-1 { margin-left: 1rem; } .o-stage.depth-2 { margin-left: 2rem; } .o-stage.depth-3 { margin-left: 3rem; }
.o-bricks li { margin-left: .8rem; } .o-bricks li.depth-1 { margin-left: 1.8rem; }
.o-item { color: inherit; display: block; }
.o-row { display: flex; flex-wrap: wrap; gap: .3rem; align-items: baseline; padding: .3rem .45rem; border-radius: 6px; font-size: .9rem; }
.o-row:hover { background: var(--bg); } .o-row.selected { background: var(--bubble-out); outline: 1px solid var(--accent); }
.o-add { display: flex; gap: .4rem; margin-top: .6rem; } .o-add input[type=text] { margin: 0; }
.o-listeners { border-top: 1px solid var(--line); margin-top: .8rem; padding-top: .5rem; }
.tabs { display: flex; gap: .3rem; margin-bottom: .7rem; }
.tab { padding: .35rem .8rem; border-radius: 99px; border: 1px solid var(--line); color: var(--text); font-size: .9rem; }
.tab.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.funnel-frame { width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.small { font-size: .85rem; }
.i-section { border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .6rem; }
.i-section summary { font-weight: 600; }
.inspector label { font-size: .9rem; } .inspector input, .inspector select, .inspector textarea { font-size: .9rem; padding: .35rem .5rem; }
label.inline { display: flex; gap: .4rem; align-items: center; } label.inline input { width: auto; display: inline; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; margin: 0 0 .6rem; }
.cond-picker select, .cond-picker input { width: auto; flex: 1 1 6rem; }
label.color { display: grid; grid-template-columns: 6rem 1.4rem 1fr; gap: .4rem; align-items: center; } label.color input { margin: 0; }
.swatch { width: 1.4rem; height: 1.4rem; border-radius: 4px; border: 1px solid var(--line); }
.phone { max-width: 380px; margin: 0 auto; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); background: #efe7dd; }
.phone-head { background: #075e54; color: #fff; padding: .6rem .9rem; display: flex; flex-direction: column; }
.phone-body { padding: .8rem; display: flex; flex-direction: column; gap: .45rem; min-height: 50vh; }
.wa { max-width: 85%; padding: .45rem .65rem; border-radius: 10px; font-size: .9rem; color: #111; }
.wa.out { background: #fff; align-self: flex-start; } .wa.in { background: #d9fdd3; align-self: flex-end; color: #333; }
.wa.selected { outline: 2px solid #25d366; }
.wa-buttons { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; } .wa-buttons span { border-top: 1px solid #ddd; color: #027eb5; padding: .2rem .5rem; font-weight: 600; }
.sys { align-self: center; background: #fff3c4; color: #5c4a00; font-size: .78rem; padding: .15rem .6rem; border-radius: 8px; margin: .2rem 0; }
.wide { max-width: 720px; }

/* New flow */
.new-flow { max-width: 560px; }
.stack { display: flex; flex-direction: column; gap: .6rem; border: 0; padding: 0; margin: 0 0 1rem; }
.new-flow input[type=text] { font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; }
.starter { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.starter:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.starter input { margin-top: .25rem; }
