:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --text: #14231f;
  --muted: #5b6b66;
  --border: #dbe4e1;
  --primary: #0f8a6b;
  --primary-ink: #ffffff;
  --primary-soft: #e1f4ee;
  --danger: #b3261e;
  --danger-soft: #fdeceb;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --bubble-in: #ffffff;
  --bubble-out: #d8f4e6;
  --chart: #0f8a6b;
  --c-buttons: #3a6fd8;
  --c-text: #b7791f;
  --c-handoff: #b3261e;
  --c-end: #6b7a75;
  --radius: 12px;
  --nav-w: 220px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1514;
    --surface: #172220;
    --surface-2: #1c2926;
    --text: #e6efec;
    --muted: #94a7a1;
    --border: #2a3a36;
    --primary: #3cc9a0;
    --primary-ink: #04221a;
    --primary-soft: #1b3a31;
    --danger: #ff8a80;
    --danger-soft: #3a1f1d;
    --warn: #f2c26b;
    --warn-soft: #3a2f16;
    --bubble-in: #1f2d2a;
    --bubble-out: #1c4a3b;
    --chart: #3cc9a0;
    --c-buttons: #7aa2f7;
    --c-text: #f2c26b;
    --c-handoff: #ff8a80;
    --c-end: #94a7a1;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- butang & borang ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: 0 1rem; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { min-height: 32px; padding: 0 .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field > span, .field > label { font-size: .85rem; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=time], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 40px; padding: .5rem .7rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); 
}
textarea { resize: vertical; min-height: 84px; }
.check { display: flex; align-items: center; gap: .5rem; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > select { width: auto; min-width: 150px; }
.grow { flex: 1; min-width: 0; }

/* ---------- kad, lencana ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.card + .card { margin-top: 1rem; }
.card > h2 { margin-bottom: .75rem; }
.chip {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--primary-soft); color: var(--primary); white-space: nowrap;
}
.chip.s-baru { background: var(--warn-soft); color: var(--warn); }
.chip.s-tak_berminat { background: var(--danger-soft); color: var(--danger); }
.chip.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: .72rem; font-weight: 700;
}
.notice { padding: .7rem .9rem; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--primary-soft); color: var(--primary); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

/* ---------- rangka aplikasi ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); height: 100dvh; }
.nav {
  display: flex; flex-direction: column; gap: .25rem; padding: 1rem .75rem;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; padding: .25rem .6rem 1rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; stroke: var(--primary-ink); fill: none; stroke-width: 2; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .badge { margin-left: auto; }
.mode { margin-top: auto; padding: .6rem .7rem; font-size: .8rem; }
.view { overflow: auto; padding: 1.25rem; min-width: 0; }
.view.flush { padding: 0; overflow: hidden; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page { max-width: 1000px; margin: 0 auto; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .v { font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.kpi a { text-decoration: none; color: inherit; display: block; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.two > .card + .card { margin-top: 0; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--chart); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart text.val { fill: var(--text); font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.statbars { display: grid; gap: .55rem; }
.statbar { display: grid; grid-template-columns: 110px 1fr 36px; gap: .6rem; align-items: center; font-size: .9rem; }
.statbar svg { width: 100%; height: 12px; display: block; }
.statbar .track { fill: var(--surface-2); }
.statbar .fill { fill: var(--chart); }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; }
.inbox.has-info { grid-template-columns: 340px minmax(0, 1fr) 320px; }
.inbox-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--surface); }
.list-head { padding: .75rem; display: grid; gap: .6rem; border-bottom: 1px solid var(--border); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; min-height: 34px; border: 0; background: transparent; cursor: pointer; font-size: .85rem; }
.seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
#clist { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.citem {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: .65rem; align-items: center;
  padding: .7rem .75rem; border-bottom: 1px solid var(--border); cursor: pointer; width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left;
}
.citem:hover { background: var(--surface-2); }
.citem[aria-current="true"] { background: var(--primary-soft); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }
.citem .t { display: flex; gap: .4rem; align-items: baseline; justify-content: space-between; }
.citem .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem .mid { display: block; min-width: 0; }
.citem .pv { display: block; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem .when { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.citem .side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.citem.unread .name, .citem.unread .pv { color: var(--text); font-weight: 700; }

.inbox-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 1rem; }
.chat-head { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-head .who { min-width: 0; flex: 1; }
.chat-head .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#back-btn { display: none; }
.msgs { flex: 1; overflow: auto; padding: 1rem .75rem; display: flex; flex-direction: column; gap: .35rem; }
.day-sep { align-self: center; font-size: .75rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .7rem; margin: .5rem 0; }
.msg { max-width: min(78%, 560px); padding: .5rem .7rem .35rem; border-radius: 12px; border: 1px solid var(--border); overflow-wrap: anywhere; }
.msg .text { white-space: pre-wrap; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 4px; }
.msg .meta { display: flex; justify-content: flex-end; gap: .5rem; font-size: .7rem; color: var(--muted); margin-top: .15rem; white-space: normal; }
.msg .who-tag { font-weight: 600; }
.msg.failed { border-color: var(--danger); }
.msg .err { color: var(--danger); }
.chat-banner { padding: .5rem .75rem; }
.composer { display: flex; gap: .5rem; padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 140px; resize: none; }

.info { display: none; overflow: auto; background: var(--surface); border-left: 1px solid var(--border); padding: 1rem; }
.inbox.has-info .info { display: block; }
.info-top { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.info h3 { margin: 1rem 0 .5rem; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.tag { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .2rem .1rem .6rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .8rem; font-weight: 600; }
.tag button { border: 0; background: none; cursor: pointer; color: inherit; width: 22px; height: 22px; border-radius: 50%; }
.src { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .7rem; font-size: .85rem; margin-bottom: .5rem; background: var(--surface-2); overflow-wrap: anywhere; }

/* ---------- peraturan ---------- */
.rule { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.rule:last-child { border-bottom: 0; }
.rule .body { flex: 1; min-width: 0; }
.rule .reply { color: var(--muted); font-size: .88rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 4.4em; overflow: hidden; }
.kw { display: inline-block; font-size: .78rem; padding: 0 .45rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); margin: 0 .25rem .25rem 0; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; width: 100%; height: 100%; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--primary); outline-offset: 2px; }
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { padding: 1.1rem; max-height: 88dvh; overflow: auto; }
dialog .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
dialog .actions .left { margin-right: auto; }

/* ---------- tetapan ---------- */
.hours-row { display: grid; grid-template-columns: 90px 1fr 1fr; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.hours-row .check { grid-column: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.copy-row { display: flex; gap: .5rem; align-items: center; }
.copy-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: .45rem .6rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.status-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .4rem; }
.status-list li { display: flex; gap: .5rem; align-items: baseline; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex: none; align-self: center; }
.dot.ok { background: var(--primary); }
.dot.bad { background: var(--danger); }

/* ---------- log masuk ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; }
.login .brand { padding: 0 0 1rem; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: .4rem; z-index: 50; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: .65rem .9rem; border-radius: 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); font-size: .9rem; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- responsif ---------- */
@media (max-width: 1180px) {
  .inbox.has-info { grid-template-columns: 320px minmax(0, 1fr); }
  .inbox.has-info .info { position: fixed; inset: 0 0 0 auto; width: min(360px, 100vw); z-index: 20; box-shadow: -8px 0 30px rgba(0, 0, 0, .25); }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .app.chat-open { grid-template-rows: minmax(0, 1fr); }
  .app.chat-open .nav { display: none; }
  .nav {
    order: 2; flex-direction: row; justify-content: space-around; padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
  }
  .brand, .mode { display: none; }
  .nav a { flex-direction: column; gap: .1rem; font-size: .66rem; white-space: nowrap; min-width: 0; padding: .35rem .5rem; position: relative; flex: 1; align-items: center; }
  .nav .badge { position: absolute; top: 0; left: 55%; margin: 0; }
  .view { padding: 1rem; }
  .view.flush { padding: 0; }
  .inbox, .inbox.has-info { grid-template-columns: 1fr; position: relative; }
  .inbox .inbox-chat { display: none; }
  .inbox.show-chat .inbox-chat { display: flex; }
  .inbox.show-chat .inbox-list { display: none; }
  #back-btn { display: grid; }
  .inbox.has-info .info { width: 100vw; }
  .two { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .msg { max-width: 88%; }
  #toast { bottom: calc(70px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- broadcast & templat ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.chip.b-sending, .chip.t-APPROVED { background: var(--primary-soft); color: var(--primary); }
.chip.b-scheduled, .chip.t-PENDING, .chip.b-paused, .chip.t-PAUSED { background: var(--warn-soft); color: var(--warn); }
.chip.t-REJECTED, .chip.t-DISABLED { background: var(--danger-soft); color: var(--danger); }
.chip.b-draft, .chip.t-DRAFT, .chip.b-cancelled { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip.b-completed { background: var(--text); color: var(--bg); }
.progress { width: 100%; height: 10px; display: block; }
.progress .track { fill: var(--surface-2); stroke: var(--border); stroke-width: .3; }
.progress .fill { fill: var(--chart); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin: 1rem 0; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; }
.stat .v { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .l { font-size: .8rem; color: var(--muted); }
.stat.bad .v { color: var(--danger); }
.bubble { background: var(--bubble-out); border: 1px solid var(--border); border-radius: 12px; border-top-right-radius: 4px; padding: .6rem .8rem; max-width: 420px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.bubble .h { font-weight: 700; margin-bottom: .2rem; }
.bubble .f { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.bubble-btns { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; max-width: 420px; }
.bubble-btns span { flex: 1; min-width: 90px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .3rem .5rem; color: var(--primary); font-weight: 600; font-size: .85rem; }
.tpl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: start; }
.tpl-meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.tpl-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.audience { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem; margin: .5rem 0 1rem; }
.audience b { font-variant-numeric: tabular-nums; }
.var-row { display: grid; grid-template-columns: 48px 1.2fr 1.4fr 1.4fr; gap: .5rem; align-items: end; margin-bottom: .4rem; }
.var-row .tag-n { font-weight: 700; padding-bottom: .5rem; }
.pill-list { display: flex; flex-wrap: wrap; gap: .3rem; }

/* ---------- flow chatbot ---------- */
.flow-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.flow-grid > *, .flow-side > * { min-width: 0; }
.flow-side { position: sticky; top: 0; display: grid; gap: 1rem; }
.page.wide { max-width: 1320px; }
.node-card > .row { margin-bottom: .6rem; }
.node-card > .row select { width: auto; min-width: 0; max-width: 200px; }
.flow-side .card + .card { margin-top: 0; }
.node-card.flash { outline: 3px solid var(--primary); outline-offset: 2px; }
.opt-box { border: 1px solid var(--border); border-radius: 10px; padding: .6rem; margin-bottom: .5rem; background: var(--surface-2); }
.opt-row { display: grid; grid-template-columns: 1.1fr 1.1fr 1.1fr auto; gap: .4rem; align-items: center; }
.act-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .5rem; }
.act-row label { display: flex; flex-direction: column; gap: .2rem; color: var(--muted); font-size: .78rem; }
.node-card details { margin-top: .6rem; }
.node-card summary { cursor: pointer; }
.diagram-wrap { overflow: auto; max-height: 440px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.diagram { display: block; }
.diagram .dn { cursor: pointer; }
.diagram .dn rect { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
.diagram .dn.message rect { stroke: var(--primary); }
.diagram .dn.buttons rect { stroke: var(--c-buttons); }
.diagram .dn.text rect { stroke: var(--c-text); }
.diagram .dn.handoff rect { stroke: var(--c-handoff); }
.diagram .dn.end rect { stroke: var(--c-end); }
.diagram .dn.start rect { stroke-width: 3.5; }
.diagram .dn:focus-visible rect, .diagram .dn:hover rect { fill: var(--primary-soft); }
.diagram text { font-family: inherit; }
.diagram .dn-id { font-size: 10px; font-weight: 700; fill: var(--muted); }
.diagram .dn-tx { font-size: 11px; fill: var(--text); }
.diagram .dn-st { font-size: 9px; fill: var(--muted); }
.diagram .edge { fill: none; stroke: var(--muted); stroke-width: 1.4; }
.diagram .edge.dashed { stroke-dasharray: 4 3; }
.diagram .arrow { fill: var(--muted); }
.diagram .elabel { font-size: 9px; fill: var(--muted); paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; }
.tester { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: .6rem; height: 290px; overflow: auto; display: flex; flex-direction: column; gap: .35rem; margin: .6rem 0; }
.tmsg { max-width: 88%; padding: .4rem .65rem; border-radius: 10px; border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
.tmsg.bot { align-self: flex-start; background: var(--bubble-in); }
.tmsg.user { align-self: flex-end; background: var(--bubble-out); }
.tchips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.tchip { border: 1px solid var(--primary); color: var(--primary); background: var(--surface); border-radius: 999px; padding: .25rem .75rem; cursor: pointer; font-size: .85rem; }
.tchip:hover { background: var(--primary-soft); }
.tend { align-self: center; color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.notice ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------- backup ---------- */
.bk-list { margin: .5rem 0 1rem; }
.bk-item { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.bk-item:last-child { border-bottom: 0; }
.bk-info { min-width: 0; }

/* lajur perbualan memenuhi ketinggian supaya mesej boleh tatal dan kotak tulis kekal di bawah */
.chat-col { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* Peraturan responsif untuk komponen yang ditakrifkan selepas blok @media di atas (Broadcast, Flow, Templat). */
@media (max-width: 800px) {
  .filter-grid, .flow-grid { grid-template-columns: 1fr; }
  .flow-side { position: static; }
  .opt-row, .act-row { grid-template-columns: 1fr; }
  .tpl { grid-template-columns: 1fr; }
  .var-row { grid-template-columns: 1fr; }
  .var-row .tag-n { padding-bottom: 0; }
}
