:root {
  --bg: #f4f5f8; --panel: #ffffff; --line: #e3e6ec; --line2: #eef0f4; --text: #1d2330; --muted: #6b7385; --faint: #9aa1b0;
  --accent: #2a8cf0; --accent-soft: #e6f1fe; --msg: #2a8cf0; --input: #17a673; --cond: #e0920e; --danger: #e5484d;
  --grid: #dfe3ea; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 16px rgba(20,30,50,.06);
  --tg-bg: #c9dcc0; --tg-bubble: #ffffff; --tg-btn: rgba(80,110,90,.35); --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1a1e26; --line: #2a303b; --line2: #222731; --text: #e6e9ef; --muted: #98a0b0; --faint: #6b7385;
    --accent: #4aa3ff; --accent-soft: #1d2a3b; --grid: #232833; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    --tg-bg: #0e1621; --tg-bubble: #182533; --tg-btn: rgba(80,120,160,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 60px; }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 5px; text-transform: none; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--line2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.wide { width: 100%; padding: 10px; }
.btn.toggle.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; background: var(--line2); font-size: 12px; margin: 1px 2px 1px 0; }
.chip b { font-weight: 600; }

/* login */
.login { position: fixed; inset: 0; display: grid; place-items: center; }
.login-card { width: 320px; background: var(--panel); padding: 32px; border-radius: 16px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: 10px 0 2px; font-size: 22px; }
.login-card input { margin: 20px 0 10px; }
.logo-big { width: 56px; height: 56px; margin: auto; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 28px; }

/* shell */
.app { display: flex; height: 100vh; }
.side { width: 200px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); user-select: none; }
.nav i { font-style: normal; width: 20px; text-align: center; }
.nav:hover { background: var(--line2); color: var(--text); }
.nav.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 6px; font-weight: 700; }
.bot-status { font-size: 12px; padding: 10px; border-radius: 10px; background: var(--line2); cursor: pointer; }
.bot-status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--faint); }
.bot-status.on .dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.bot-status.error .dot { background: var(--danger); }
main { flex: 1; min-width: 0; position: relative; }
.view { display: none; height: 100%; overflow: auto; }
.view.active { display: block; }
#view-flow { position: relative; overflow: hidden; }

/* toolbar */
.toolbar { position: absolute; z-index: 5; top: 12px; left: 12px; right: 12px; display: flex; gap: 10px; flex-wrap: wrap; pointer-events: none; }
.tb-group { display: flex; gap: 4px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: var(--shadow); pointer-events: auto; position: relative; }
.tb-group .btn { border-color: transparent; }
.add-msg { color: var(--msg); } .add-input { color: var(--input); } .add-cond { color: var(--cond); }
.search { width: 220px; border: none; padding: 5px 8px; }
.search:focus { box-shadow: none; }
.search-results { position: absolute; top: 100%; left: 0; margin-top: 6px; width: 320px; max-height: 360px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; }
.search-results div { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.search-results div:hover, .search-results div.sel { background: var(--accent-soft); }
.zoom { font-size: 12px; color: var(--muted); width: 42px; text-align: center; }

/* canvas */
.canvas { position: absolute; inset: 0; overflow: hidden; cursor: grab;
  background-color: var(--bg); background-image: radial-gradient(var(--grid) 1.2px, transparent 1.2px); background-size: 22px 22px; }
.canvas.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.edges path { fill: none; stroke-width: 2; opacity: .55; }
.edges path.back { opacity: .13; stroke-dasharray: 4 4; }
.edges path.hl { stroke-width: 3; opacity: 1; }
.edges path.drag { stroke-dasharray: 6 4; opacity: 1; }
.hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--faint); background: var(--panel); padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); pointer-events: none; white-space: nowrap; }

.node { position: absolute; width: 250px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); cursor: default; user-select: none; --c: var(--msg); }
.node.input { --c: var(--input); } .node.condition { --c: var(--cond); }
.node:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.node.sel { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent), var(--shadow); }
.node.sim-here { box-shadow: 0 0 0 5px color-mix(in srgb, #22c55e 40%, transparent), var(--shadow); border-color: #22c55e; }
.node.drop { border-color: var(--c); border-style: dashed; }
.node.dim { opacity: .25; }
.n-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 6px; cursor: move; border-radius: 12px 12px 0 0; }
.n-type { width: 20px; height: 20px; border-radius: 6px; background: var(--c); color: #fff; display: grid; place-items: center; font-size: 11px; flex: none; }
.n-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.n-start { font-size: 10px; font-weight: 700; color: #fff; background: #22c55e; border-radius: 5px; padding: 1px 6px; }
.n-cmd { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; }
.n-in { position: absolute; left: -7px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--panel); border: 2px solid var(--c); }
.n-body { padding: 0 10px 8px; color: var(--muted); font-size: 12px; cursor: move; }
.n-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.n-text.empty { color: var(--faint); font-style: italic; }
.n-media { font-size: 11px; margin-top: 4px; color: var(--faint); }
.n-outs { border-top: 1px solid var(--line2); padding: 4px 0; }
.n-out { position: relative; display: flex; align-items: center; gap: 6px; padding: 3px 18px 3px 10px; font-size: 12px; min-height: 24px; }
.n-out .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--line2); border-radius: 6px; padding: 2px 8px; }
.n-out .lbl.url { color: var(--accent); }
.n-out .lbl.cond { font-family: ui-monospace, monospace; font-size: 11px; }
.n-out .lbl.flow { background: none; color: var(--muted); padding-left: 0; }
.n-out .save { font-size: 10px; color: var(--input); }
.port { position: absolute; right: -7px; top: 50%; margin-top: -6px; width: 12px; height: 12px; border-radius: 50%; background: var(--panel); border: 2px solid var(--c); cursor: crosshair; z-index: 2; }
.port.linked { background: var(--c); }
.port:hover { transform: scale(1.35); }
.n-more { font-size: 11px; color: var(--faint); padding: 2px 10px; }
.heat { position: absolute; top: -10px; right: 10px; background: #111827; color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 8px; display: none; }
.show-heat .heat { display: block; }

/* drawer */
.drawer { position: absolute; z-index: 6; top: 0; right: 0; bottom: 0; width: 440px; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(20,30,50,.08); overflow: auto; padding: 0 18px 40px; }
.d-head { position: sticky; top: 0; background: var(--panel); z-index: 2; display: flex; align-items: center; gap: 8px; padding: 14px 0 10px; border-bottom: 1px solid var(--line2); }
.d-head .n-type { width: 26px; height: 26px; font-size: 13px; border-radius: 8px; }
.d-title { font-size: 16px; font-weight: 700; border-color: transparent; padding: 4px 6px; }
.d-title:hover { border-color: var(--line); }
.saved { font-size: 11px; color: var(--faint); white-space: nowrap; }
.sect { margin-top: 18px; }
.sect h4 { margin: 0 0 6px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.sect h4 .muted { font-weight: 400; font-size: 12px; }
.fmt-bar { display: flex; gap: 2px; padding: 4px; border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0; background: var(--line2); flex-wrap: wrap; }
.fmt-bar button { border: none; background: none; padding: 3px 8px; border-radius: 5px; cursor: pointer; min-width: 28px; }
.fmt-bar button:hover { background: var(--panel); }
.fmt-bar select { width: auto; padding: 2px 6px; font-size: 12px; margin-left: auto; }
.textarea-fmt { border-radius: 0 0 8px 8px; min-height: 140px; font-size: 13px; }
.counter { font-size: 11px; color: var(--faint); text-align: right; margin-top: 3px; }
.counter.over { color: var(--danger); }
.btn-row { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; background: var(--bg); }
.btn-row .row + .row { margin-top: 6px; }
.btn-row .idx { color: var(--faint); font-size: 12px; width: 16px; text-align: center; flex: none; }
.btn-row .act { width: 128px; flex: none; }
.btn-row .ico { white-space: nowrap; flex: none; border: none; background: none; cursor: pointer; color: var(--faint); padding: 2px 4px; border-radius: 4px; }
.btn-row .ico:hover { color: var(--text); background: var(--line2); }
.btn-row .ico.on { color: var(--input); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--panel); padding: 5px 12px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--accent); color: #fff; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-top: 10px; font-size: 13px; }
.switch input { display: none; }
.switch .tg { width: 34px; height: 20px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch .tg::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .tg { background: var(--accent); }
.switch input:checked + .tg::after { left: 16px; }
.media-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.media-item { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--line2); display: grid; place-items: center; font-size: 11px; text-align: center; padding: 4px; word-break: break-all; }
.media-item img, .media-item video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-item .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; border: none; cursor: pointer; z-index: 2; font-size: 12px; line-height: 1; }
.dropzone { width: 84px; height: 84px; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--faint); cursor: pointer; font-size: 12px; text-align: center; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--accent); }
.deeplink { font-family: ui-monospace, monospace; font-size: 12px; background: var(--line2); padding: 6px 8px; border-radius: 6px; cursor: pointer; word-break: break-all; }
.rule-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.rule-row .eq { color: var(--faint); flex: none; }
.helptext { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* telegram phone preview */
.tg-screen { background: var(--tg-bg); border-radius: 12px; padding: 12px 10px; background-image: radial-gradient(rgba(255,255,255,.18) 1px, transparent 1px); background-size: 14px 14px; }
.tg-msg { max-width: 92%; }
.tg-bubble { background: var(--tg-bubble); border-radius: 12px 12px 12px 4px; padding: 7px 10px 8px; box-shadow: 0 1px 1px rgba(0,0,0,.12); word-wrap: break-word; white-space: pre-wrap; font-size: 13.5px; line-height: 1.4; }
.tg-bubble a { color: #2a8cf0; }
.tg-bubble code { font-family: ui-monospace, monospace; font-size: 12.5px; background: rgba(0,0,0,.06); padding: 0 3px; border-radius: 3px; }
.tg-bubble .spoiler { background: #999; color: transparent; border-radius: 3px; }
.tg-bubble blockquote { margin: 2px 0; padding-left: 8px; border-left: 3px solid #2a8cf0; }
.tg-bubble .var { background: rgba(42,140,240,.15); color: #2a8cf0; border-radius: 4px; padding: 0 3px; }
.tg-media { border-radius: 10px 10px 0 0; overflow: hidden; display: grid; gap: 2px; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); background: var(--tg-bubble); }
.tg-media img, .tg-media video { width: 100%; max-height: 240px; object-fit: cover; display: block; }
.tg-media .doc { padding: 10px; font-size: 12px; display: flex; gap: 8px; align-items: center; }
.tg-media + .tg-bubble { border-radius: 0 0 12px 4px; }
.tg-kb { display: grid; gap: 4px; margin-top: 4px; }
.tg-kb .r { display: flex; gap: 4px; }
.tg-kb button { flex: 1; min-width: 0; background: var(--tg-btn); color: #fff; border: none; border-radius: 8px; padding: 7px 6px; font-size: 13px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; backdrop-filter: blur(4px); }
.tg-kb button:hover { filter: brightness(1.15); }
.tg-kb button .u { font-size: 10px; opacity: .8; }
.tg-user { margin-left: auto; background: #effdde; border-radius: 12px 12px 4px 12px; padding: 6px 10px; max-width: 80%; width: fit-content; font-size: 13.5px; box-shadow: 0 1px 1px rgba(0,0,0,.12); color: #1d2330; }
.tg-sys { text-align: center; font-size: 11px; color: #fff; background: rgba(0,0,0,.25); border-radius: 99px; padding: 2px 10px; width: fit-content; margin: 6px auto; }

/* simulator */
.sim { position: absolute; z-index: 7; left: 16px; bottom: 16px; width: 360px; height: min(640px, calc(100% - 90px)); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(20,30,50,.25); display: flex; flex-direction: column; overflow: hidden; }
.sim-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sim-head b { flex: 1; }
.sim-body { flex: 1; overflow: auto; border-radius: 0; display: flex; flex-direction: column; gap: 8px; }
.sim-vars { padding: 6px 10px; border-top: 1px solid var(--line); font-size: 12px; max-height: 70px; overflow: auto; }
.sim-input { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }

/* pages */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 28px 60px; }
.page h2 { margin: 0 0 4px; font-size: 22px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } .side { width: 60px; } .side span, .brand-name, .bot-status { display: none; } }
.kpi .v { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.kpi .l { color: var(--muted); font-size: 13px; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.t td { padding: 9px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.t tr.click:hover td { background: var(--line2); cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; }
.split { display: grid; grid-template-columns: 340px 1fr; height: 100%; }
.split > div { overflow: auto; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line2); }
.list-item:hover { background: var(--line2); }
.list-item.active { background: var(--accent-soft); }
.list-item .meta { flex: 1; min-width: 0; }
.list-item .meta div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat { display: flex; flex-direction: column; gap: 6px; padding: 16px; }
.chat .m { max-width: 70%; padding: 7px 11px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.chat .m.in { background: var(--panel); border: 1px solid var(--line); align-self: flex-start; }
.chat .m.out { background: var(--accent); color: #fff; align-self: flex-end; }
.chat .m .ts { font-size: 10px; opacity: .6; margin-top: 2px; }
.user-panel { position: fixed; z-index: 20; top: 0; right: 0; bottom: 0; width: 520px; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(20,30,50,.12); display: flex; flex-direction: column; }
.user-panel .up-body { flex: 1; overflow: auto; padding: 0 18px 18px; }
.timeline { font-size: 12px; }
.timeline div { padding: 3px 0 3px 14px; border-left: 2px solid var(--line); position: relative; }
.timeline div::before { content: ""; position: absolute; left: -5px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars div:hover { opacity: 1; }
.bars div:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; margin-bottom: 4px; }
.hbar { display: flex; align-items: center; gap: 10px; margin: 5px 0; font-size: 13px; }
.hbar .name { width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { flex: 1; background: var(--line2); border-radius: 4px; height: 10px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.hbar .num { width: 40px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: 99px; background: var(--line2); overflow: hidden; margin-top: 6px; }
.progress div { height: 100%; background: var(--accent); }
.empty { text-align: center; color: var(--faint); padding: 40px 10px; }
.warn { background: #fff4e0; color: #8a5300; border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
@media (prefers-color-scheme: dark) { .warn { background: #3a2a10; color: #ffcf8a; } }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 9px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); }
kbd { font-family: ui-monospace, monospace; font-size: 11px; background: var(--line2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
a.btn { text-decoration: none; display: inline-block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
#convChat { height: 100%; }
.row > .btn { flex: none; }

/* ===== простой режим «Экраны» ===== */
.seg-mode .btn.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sv { display: none; position: absolute; inset: 0; background: var(--bg); }
.simple-mode .sv { display: flex; }
.simple-mode .toolbar, .simple-mode #canvas, .simple-mode .drawer, .simple-mode #sim { display: none !important; }
.sv-list { width: 280px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.sv-list-head { padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.sv-items { flex: 1; overflow: auto; padding: 4px 8px 12px; }
.sv-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.sv-item:hover { background: var(--line2); }
.sv-item.sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sv-item.here { box-shadow: inset 3px 0 0 #22c55e; background: color-mix(in srgb, #22c55e 12%, transparent); }
.sv-item .ic { width: 20px; text-align: center; flex: none; }
.sv-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-item .flag { font-size: 10px; font-weight: 700; color: #fff; background: #22c55e; border-radius: 5px; padding: 1px 6px; flex: none; }
.dot-warn { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
.sv-sub { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; padding: 14px 10px 4px; }
.sv-toflow { border: none; border-top: 1px solid var(--line); background: none; padding: 12px; color: var(--muted); cursor: pointer; font-size: 13px; }
.sv-toflow:hover { color: var(--accent); }
.sv-stage { flex: 1; min-width: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; padding: 20px 24px 40px; }
.sv-top { width: 100%; max-width: 640px; display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.sv-kind { font-size: 20px; }
.sv-title { flex: 1; font-size: 20px; font-weight: 700; border-color: transparent; background: transparent; padding: 4px 8px; }
.sv-title:hover { border-color: var(--line); background: var(--panel); }
.sv-seg button { padding: 6px 12px; }
.phone { width: 400px; max-width: 100%; border-radius: 28px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(20,30,50,.12); overflow: hidden; display: flex; flex-direction: column; flex: none; }
.phone-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.bot-ava { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.phone-chat { min-height: 460px; max-height: calc(100vh - 230px); overflow: auto; border-radius: 0; padding: 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.phone-chat.drop { outline: 3px dashed var(--accent); outline-offset: -8px; }
.phone-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.sv-hint { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; max-width: 420px; }
.sv-empty { margin-top: 14vh; text-align: center; max-width: 420px; color: var(--muted); }
.sv-empty .big { font-size: 48px; }
.sv-empty b { display: block; font-size: 18px; color: var(--text); margin: 8px 0; }
.ed-msg { display: flex; flex-direction: column; gap: 6px; max-width: 92%; }
.ed-media { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-m { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: var(--tg-bubble); display: grid; place-items: center; font-size: 11px; padding: 4px; text-align: center; word-break: break-all; }
.ed-m img, .ed-m video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ed-m .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; z-index: 1; }
.ed-add-media, .ed-addbtn { border: 1.5px dashed #6f9463; color: #3d5a36; background: rgba(255,255,255,.35); border-radius: 10px; padding: 8px 12px; font-size: 13px; cursor: pointer; }
.ed-add-media:hover, .ed-addbtn:hover { background: rgba(255,255,255,.6); }
@media (prefers-color-scheme: dark) { .ed-add-media, .ed-addbtn { color: #cfe0ff; border-color: #5a7aa8; background: rgba(255,255,255,.04); } }
.ed-bubble { position: relative; background: var(--tg-bubble); border-radius: 14px 14px 14px 4px; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.ed-fmt { display: none; position: absolute; bottom: 100%; left: 0; margin-bottom: 6px; background: #1f2633; border-radius: 8px; padding: 3px; gap: 2px; z-index: 3; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.ed-bubble:focus-within .ed-fmt { display: flex; }
.ed-fmt button { border: none; background: none; color: #fff; padding: 4px 9px; border-radius: 5px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.ed-fmt button:hover { background: rgba(255,255,255,.15); }
.ed-text { padding: 9px 12px 10px; min-height: 40px; outline: none; white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; line-height: 1.45; border-radius: inherit; cursor: text; }
.ed-text:hover { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 40%, transparent); }
.ed-text:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.ed-text:empty::before { content: attr(data-ph); color: var(--faint); }
.ed-text a { color: #2a8cf0; }
.ed-text .spoiler { background: #bbb; }
.ed-reply { align-self: flex-end; background: #effdde; color: #3b5b2a; border: 1.5px dashed #9cc47f; border-radius: 14px 14px 4px 14px; padding: 8px 12px; font-size: 13px; cursor: pointer; max-width: 90%; margin: 4px 0; }
.ed-reply small { display: block; opacity: .75; margin-top: 2px; }
.ed-reply:hover { border-style: solid; }
.ed-kb { margin-top: 0; }
.ed-kb:empty { display: none; }
.ed-kb button { position: relative; }
.ed-kb button:hover { outline: 2px solid rgba(255,255,255,.9); }
.ed-kb button.bad::after { content: ""; position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: #ff5a5f; }
.ed-next { font-size: 12px; color: #fff; background: rgba(0,0,0,.25); border-radius: 99px; padding: 3px 10px; width: fit-content; cursor: pointer; }
.ed-cond { background: var(--panel); border-radius: 14px; padding: 14px; font-size: 13px; }
.ed-cond-h { font-weight: 600; margin-bottom: 4px; }
.ed-rule { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.ed-rule input { width: 110px; flex: none; }
.ed-rule .ico { border: none; background: none; cursor: pointer; color: var(--faint); }
.pop { position: fixed; z-index: 50; width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 48px rgba(20,30,50,.22); padding: 14px 16px; }
.pop-h { font-weight: 700; font-size: 15px; }
.pop-go { display: inline-block; margin-top: 8px; font-size: 13px; }
.pop details { margin-top: 12px; font-size: 13px; }
.pop summary { cursor: pointer; color: var(--muted); }
.pop-foot { display: flex; align-items: center; gap: 6px; margin-top: 14px; }
.choice { display: flex; gap: 6px; margin-bottom: 8px; }
.choice label { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 13px; }
.choice label.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.choice input, .type-card input { display: none; }
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(15,20,30,.35); display: grid; place-items: center; padding: 16px; }
.modal { width: 480px; max-width: 100%; max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border-radius: 16px; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-h { display: flex; align-items: center; justify-content: space-between; font-size: 16px; margin-bottom: 4px; }
.modal .switch { margin-top: 14px; }
.m-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 13px; }
.types { display: grid; gap: 8px; }
.type-card { display: grid; grid-template-columns: 34px 1fr; column-gap: 8px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.type-card .ic { grid-row: span 2; font-size: 24px; align-self: center; }
.type-card .muted { font-size: 12px; }
.type-card.on { border-color: var(--accent); background: var(--accent-soft); }
.view-switch { display: flex; background: var(--line2); border-radius: 10px; padding: 3px; gap: 3px; }
.view-switch button { flex: 1; border: none; background: none; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.view-switch button:hover { color: var(--text); }
.view-switch button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(20,30,50,.12); cursor: default; }
.seg-mode .btn { font-weight: 600; }
.search { width: 170px; }
