/* =========================================================
   Design tokens
   ========================================================= */
:root {
  --font: "IBM Plex Sans Arabic", "Inter", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --ig: linear-gradient(135deg, #feda75 0%, #fa7e1e 22%, #d62976 50%, #962fbf 75%, #4f5bd5 100%);
  --brand: #d62976;
  --brand-2: #8a3ab9;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f3f3f5;
  --surface-3: #ebebef;
  --border: #e7e7ec;
  --border-strong: #d6d6de;
  --text: #0f1117;
  --text-2: #4a4d5a;
  --muted: #8a8d9a;
  --brand-soft: #fdeef5;
  --ok: #12a150; --ok-soft: #e7f7ee;
  --warn: #b26b00; --warn-soft: #fff4e0;
  --err: #e5484d; --err-soft: #feecec;
  --info: #3e63dd; --info-soft: #edf2fe;
  --chart: #d62976;
  --shadow-sm: 0 1px 2px rgba(16, 17, 23, .05);
  --shadow: 0 1px 2px rgba(16, 17, 23, .04), 0 8px 24px -8px rgba(16, 17, 23, .1);
  --shadow-lg: 0 24px 64px -16px rgba(16, 17, 23, .25);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b0c10;
  --surface: #121318;
  --surface-2: #181a20;
  --surface-3: #20232b;
  --border: #23262e;
  --border-strong: #31353f;
  --text: #ececf1;
  --text-2: #b4b7c3;
  --muted: #7d8190;
  --brand-soft: #2a1320;
  --chart: #e0508f;
  --ok-soft: #0f2a1b; --warn-soft: #2b2010; --err-soft: #2e1415; --info-soft: #141c33;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -8px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* =========================================================
   Base
   ========================================================= */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.6;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.sm { font-size: .85rem; }
.xs { font-size: .76rem; }
.err-text { color: var(--err); font-size: .85rem; min-height: 1.2em; margin-top: .5rem; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
::selection { background: var(--brand-soft); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* =========================================================
   Controls
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 38px; padding: 0 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--text); color: var(--bg); border-color: transparent; }
.btn.primary:hover { opacity: .9; }
.btn.brand { background: var(--ig); color: #fff; border: none; box-shadow: 0 6px 18px -6px rgba(214, 41, 118, .55); }
.btn.brand:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--err); }
.btn.icon { width: 36px; height: 36px; padding: 0; }
.btn.sm { height: 32px; padding: 0 .75rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field > label, .label { font-weight: 500; font-size: .87rem; color: var(--text-2); }
.hint { font-size: .78rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.7; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); }

/* switch */
.switch { position: relative; display: inline-flex; width: 40px; height: 24px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3);
  border: 1px solid var(--border-strong); transition: background .2s var(--ease); }
.switch span::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .25s var(--ease); }
.switch input:checked + span { background: var(--ok); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(-16px); }
[dir=ltr] .switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; }
.seg button { border: none; background: none; color: var(--text-2); font: inherit; font-size: .87rem; font-weight: 500;
  padding: .38rem .85rem; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem;
  transition: background .15s, color .15s; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg.full { display: flex; } .seg.full button { flex: 1; justify-content: center; }

/* choice cards */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.choice { text-align: start; border: 1.5px solid var(--border); background: var(--surface); border-radius: 12px;
  padding: .8rem .9rem; cursor: pointer; font: inherit; color: var(--text); display: flex; gap: .65rem;
  align-items: flex-start; transition: border-color .15s, background .15s, box-shadow .15s; }
.choice:hover { border-color: var(--border-strong); }
.choice.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px var(--brand-soft); }
.choice b { display: block; font-weight: 600; font-size: .9rem; }
.choice small { color: var(--muted); font-size: .78rem; line-height: 1.45; display: block; }
.choice .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--text-2); }
.choice.on .ic { background: var(--brand); color: #fff; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; color: var(--text-2); white-space: nowrap; }
.chip.brand { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.chip button { border: none; background: none; padding: 0; color: inherit; cursor: pointer; display: grid; opacity: .6; }
.chip button:hover { opacity: 1; }
.chip svg.i { width: 13px; height: 13px; }
.chips-input { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; min-height: 44px; padding: .4rem .5rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: text; }
.chips-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.chips-input input { border: none; box-shadow: none !important; padding: .2rem .3rem; flex: 1; min-width: 120px; background: none; }
.chips-input .chip { font-size: .85rem; padding: .2rem .6rem; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .1rem .5rem;
  border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.dot.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(18,161,80,.5); } 70% { box-shadow: 0 0 0 7px rgba(18,161,80,0); } 100% { box-shadow: 0 0 0 0 rgba(18,161,80,0); } }

/* =========================================================
   Login
   ========================================================= */
.login { min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden; padding: 1rem; }
.mesh { position: absolute; inset: -20%; filter: blur(80px); opacity: .55;
  background:
    radial-gradient(40% 40% at 20% 30%, #fa7e1e 0, transparent 70%),
    radial-gradient(35% 35% at 80% 20%, #d62976 0, transparent 70%),
    radial-gradient(45% 45% at 60% 85%, #4f5bd5 0, transparent 70%); animation: drift 18s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate3d(3%, -4%, 0) rotate(8deg); } }
.login-card { position: relative; width: min(380px, 100%); background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border);
  border-radius: 22px; padding: 2.2rem 1.8rem; box-shadow: var(--shadow-lg); text-align: center; }
.login-card h1 { margin: 1rem 0 .3rem; font-size: 1.4rem; }
.login-card .muted { margin-bottom: 1.4rem; }

.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--ig); display: grid; place-items: center;
  box-shadow: 0 6px 16px -6px rgba(214, 41, 118, .6); flex: none; }
.logo span { width: 13px; height: 13px; border: 2.2px solid #fff; border-radius: 50%; position: relative; }
.logo span::after { content: ""; position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #fff;
  bottom: -5px; left: -5px; }
.logo.lg { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto; }
.logo.lg span { width: 24px; height: 24px; border-width: 3.5px; }
.logo.lg span::after { width: 10px; height: 10px; bottom: -9px; left: -9px; }

/* =========================================================
   Shell
   ========================================================= */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1rem;
  padding: 1.1rem .8rem; border-inline-end: 1px solid var(--border); background: var(--surface); }
.side-brand { display: flex; align-items: center; gap: .6rem; padding: .2rem .5rem .6rem; }
.side-brand b { font-size: 1.1rem; }
.side-brand small { color: var(--muted); font-size: .7rem; margin-inline-start: auto; border: 1px solid var(--border); border-radius: 6px; padding: 0 .35rem; }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-weight: 500; transition: background .15s, color .15s; position: relative; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.on { background: var(--surface-2); color: var(--text); }
.nav-item.on::before { content: ""; position: absolute; inset-inline-start: -.8rem; top: 8px; bottom: 8px; width: 3px;
  border-radius: 3px; background: var(--brand); }
.nav-item .count { margin-inline-start: auto; font-size: .72rem; color: var(--muted); background: var(--surface-3);
  border-radius: 6px; padding: 0 .4rem; }
.side-foot { margin-top: auto; }
.bot-pill { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .85rem; }
.bot-pill .t { flex: 1; line-height: 1.35; }
.bot-pill .t small { display: block; color: var(--muted); font-size: .74rem; }

.main { min-width: 0; }
.view { max-width: 1120px; margin: 0 auto; padding: 2rem 2rem 6rem; }
.view.anim { animation: in .35s var(--ease); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: .3rem; }
.row { display: flex; align-items: center; gap: .6rem; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: 1.4fr 1fr; }
.grid.kpis { grid-template-columns: repeat(4, 1fr); }
.stack { display: flex; flex-direction: column; gap: 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; }
.card-head p { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* hero status */
.hero { position: relative; overflow: hidden; padding: 1.4rem; display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.hero::before { content: ""; position: absolute; inset: 0; background: var(--ig); opacity: .07; pointer-events: none; }
.hero .state { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--ig); color: #fff; flex: none; }
.hero .state svg.i { width: 24px; height: 24px; }
.hero.off .state { background: var(--surface-3); color: var(--muted); }
.hero .txt { flex: 1; min-width: 200px; }
.hero .txt h2 { font-size: 1.15rem; }
.hero .txt p { color: var(--text-2); font-size: .88rem; margin-top: .2rem; }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: .7rem; }
.kpi .top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .85rem; }
.kpi .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.kpi b { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }

/* checklist */
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: .2rem 0 1rem; }
.progress span { display: block; height: 100%; background: var(--ig); border-radius: 99px; transition: width .6s var(--ease); }
.check { display: flex; align-items: center; gap: .75rem; padding: .65rem .2rem; border-top: 1px solid var(--border); text-decoration: none; }
.check:first-of-type { border-top: none; }
.check .box { width: 22px; height: 22px; border-radius: 50%; border: 1.5px dashed var(--border-strong); display: grid; place-items: center; flex: none; }
.check.done .box { background: var(--ok); border: none; color: #fff; }
.check.done .box svg.i { width: 13px; height: 13px; stroke-width: 3; }
.check .t { flex: 1; }
.check.done .t b { color: var(--muted); text-decoration: line-through; font-weight: 500; }
.check .t small { display: block; color: var(--muted); font-size: .78rem; }
.check .go { color: var(--muted); }

/* =========================================================
   Activity feed
   ========================================================= */
.feed { display: flex; flex-direction: column; }
.item { display: flex; gap: .8rem; padding: .9rem 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: none; padding-top: .2rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 600;
  color: #fff; font-size: .85rem; position: relative; text-transform: uppercase; }
.avatar .k { position: absolute; bottom: -3px; inset-inline-end: -3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; color: var(--text-2); border: 1px solid var(--border); }
.avatar .k svg.i { width: 11px; height: 11px; }
.item .body { flex: 1; min-width: 0; }
.item .meta { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.item .meta b { color: var(--text); font-weight: 600; font-size: .87rem; }
.item .msg { margin: .2rem 0 .35rem; overflow-wrap: anywhere; }
.reply-line { display: flex; gap: .45rem; align-items: flex-start; font-size: .87rem; color: var(--text-2);
  padding: .45rem .6rem; border-radius: 10px; background: var(--surface-2); margin-top: .3rem; overflow-wrap: anywhere; }
.reply-line svg.i { width: 15px; height: 15px; margin-top: .2rem; color: var(--muted); }
.reply-line.dm { background: var(--info-soft); }
.reply-line.err { background: var(--err-soft); color: var(--err); }
.reply-line.err svg.i { color: var(--err); }
.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search svg.i { position: absolute; inset-inline-start: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-inline-start: 2.2rem; height: 38px; }

/* =========================================================
   Automations
   ========================================================= */
.autos { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1rem; }
.auto { display: flex; flex-direction: column; gap: .9rem; transition: border-color .15s, box-shadow .2s, transform .2s; cursor: pointer; }
.auto:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.auto.off .flow, .auto.off .auto-head .t { opacity: .55; }
.auto-head { display: flex; align-items: center; gap: .7rem; }
.auto-head .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.ic.comment { background: var(--brand-soft); color: var(--brand); }
.ic.dm { background: var(--info-soft); color: var(--info); }
.ic.welcome { background: var(--warn-soft); color: var(--warn); }
.auto-head .t { flex: 1; min-width: 0; }
.auto-head .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auto-head .t small { color: var(--muted); font-size: .78rem; }

/* flow visual: trigger -> actions */
.flow { display: flex; flex-direction: column; }
.node { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: .6rem .7rem; font-size: .85rem; }
.node .lbl { display: flex; align-items: center; gap: .35rem; font-size: .72rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.node .lbl svg.i { width: 13px; height: 13px; }
.node .txt { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.node .chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.trigger-row { display: flex; gap: .6rem; align-items: center; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-3);
  display: grid; place-items: center; color: var(--muted); }
.thumb.all { background: var(--ig); color: #fff; }
.thumb svg.i { width: 18px; height: 18px; }
.link { width: 2px; height: 14px; margin-inline-start: 1.3rem; background: repeating-linear-gradient(var(--border-strong) 0 3px, transparent 3px 6px); }
.auto-foot { display: flex; align-items: center; gap: .3rem; margin-top: auto; }

.empty { text-align: center; padding: 3rem 1rem; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); }
.empty .art { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 20px; background: var(--ig); display: grid; place-items: center; color: #fff; }
.empty .art svg.i { width: 28px; height: 28px; }
.empty > p { color: var(--muted); max-width: 400px; margin: .4rem auto 1.4rem; }
.templates { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .7rem; max-width: 780px; margin: 0 auto; text-align: start; }
.template { padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; font: inherit; color: inherit;
  text-align: start; transition: border-color .15s, transform .15s, box-shadow .15s; }
.template:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.template .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.template b { display: block; margin: .6rem 0 .2rem; }
.template small { color: var(--muted); font-size: .8rem; }

/* =========================================================
   Drawer + live preview
   ========================================================= */
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 14, .45); backdrop-filter: blur(2px); z-index: 40; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(1040px, 100vw); background: var(--bg); z-index: 50;
  box-shadow: var(--shadow-lg); transform: translateX(-102%); transition: transform .35s var(--ease); display: flex; flex-direction: column; }
[dir=ltr] .drawer { transform: translateX(102%); }
.drawer.open, [dir=ltr] .drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.4rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-head h2 { flex: 1; }
.drawer-body { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.drawer-form { overflow-y: auto; padding: 1.4rem 1.6rem; }
.drawer-preview { border-inline-start: 1px solid var(--border); background: var(--surface-2); padding: 1.4rem; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.drawer-foot { display: flex; gap: .6rem; padding: .9rem 1.4rem; border-top: 1px solid var(--border); background: var(--surface); }
.step { display: flex; gap: .9rem; margin-bottom: 1.7rem; }
.step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg);
  font-size: .8rem; font-weight: 600; flex: none; margin-top: .05rem; }
.step .c { flex: 1; min-width: 0; }
.step .c > h3 { margin-bottom: .15rem; }
.step .c > .hint { display: block; margin-bottom: .8rem; }
.post-strip { display: flex; gap: .6rem; overflow-x: auto; padding: .2rem .2rem .6rem; scroll-snap-type: x mandatory; }
.post-opt { flex: none; width: 104px; border: 2px solid transparent; border-radius: 12px; padding: 0; background: var(--surface);
  cursor: pointer; overflow: hidden; scroll-snap-align: start; outline: 1px solid var(--border); font: inherit; color: inherit; text-align: start; }
.post-opt.on { border-color: var(--brand); outline-color: transparent; box-shadow: 0 0 0 3px var(--brand-soft); }
.post-opt .img { width: 100%; aspect-ratio: 1; object-fit: cover; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.post-opt .img.all { background: var(--ig); color: #fff; }
.post-opt .cap { font-size: .72rem; padding: .3rem .4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counter { font-size: .72rem; color: var(--muted); text-align: end; margin-top: .25rem; }
.inline-toggle { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); margin-bottom: .8rem; cursor: pointer; }
.inline-toggle .t { flex: 1; }
.inline-toggle .t small { display: block; color: var(--muted); font-size: .78rem; }

/* phone */
.phone { width: 290px; background: #0a0a0a; border-radius: 42px; padding: 9px; box-shadow: var(--shadow-lg), inset 0 0 0 2px #2a2a2a; flex: none; }
.screen { background: #fff; color: #000; border-radius: 34px; overflow: hidden; height: 560px; display: flex; flex-direction: column;
  font-size: 13px; line-height: 1.45; }
[data-theme="dark"] .screen { background: #000; color: #f5f5f5; }
.screen .bar { height: 38px; flex: none; position: relative; }
.screen .bar::after { content: ""; width: 86px; height: 24px; border-radius: 99px; background: #000; position: absolute; top: 7px; left: 50%; transform: translateX(-50%); }
.screen .topnav { display: flex; align-items: center; gap: .5rem; padding: .3rem .8rem .55rem; border-bottom: 1px solid rgba(128,128,128,.2); font-weight: 600; flex: none; }
.screen .topnav small { display: block; font-weight: 400; color: #8e8e8e; font-size: 11px; }
.screen .scroll { flex: 1; overflow-y: auto; padding: .7rem .8rem; display: flex; flex-direction: column; gap: .7rem; }
.screen .av { width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--ig); padding: 2px; }
.screen .av i { display: block; width: 100%; height: 100%; border-radius: 50%; background: #d9d9d9; border: 2px solid #fff; }
[data-theme="dark"] .screen .av i { border-color: #000; background: #444; }
.screen .av.me { background: none; padding: 0; }
.screen .av.me i { background: var(--ig); border: none; }
.screen .post-img { width: 100%; aspect-ratio: 1.2; border-radius: 6px; object-fit: cover; display: block;
  background: linear-gradient(135deg, #f6e9ff, #ffe7f1 60%, #fff1e2); }
[data-theme="dark"] .screen .post-img { background: linear-gradient(135deg, #2b1f3a, #3a1f2c); }
.ig-comment { display: flex; gap: .55rem; align-items: flex-start; }
.ig-comment .b { overflow-wrap: anywhere; }
.ig-comment .b b { font-weight: 600; margin-inline-end: .3rem; }
.ig-comment .b small { display: block; color: #8e8e8e; font-size: 11px; margin-top: .1rem; }
.ig-comment.reply { margin-inline-start: 2.2rem; }
.ig-comment.reply .av { width: 22px; height: 22px; }
.bubbles { display: flex; flex-direction: column; gap: .35rem; }
.bubble { max-width: 80%; padding: .5rem .8rem; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; animation: pop .3s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.92) translateY(4px); } }
.bubble.them { align-self: flex-start; background: #efefef; color: #000; }
[data-theme="dark"] .bubble.them { background: #262626; color: #fff; }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg, #a033ff, #5b51d8); color: #fff; }
.screen .sep { text-align: center; color: #8e8e8e; font-size: 11px; margin: .3rem 0; }
.ph-empty { color: #8e8e8e; text-align: center; margin: auto; font-size: 12px; padding: 1rem; }
.preview-label { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .8rem; }

/* =========================================================
   Chat simulator
   ========================================================= */
.sim { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; height: calc(100vh - 180px); min-height: 520px; }
.sim-side { display: flex; flex-direction: column; gap: 1rem; }
.sim-chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.sim-head { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.sim-log { flex: 1; overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: .45rem; }
.sim-log .bubble { max-width: 72%; font-size: .92rem; }
.sim-log .bubble.them { align-self: flex-start; background: var(--surface-3); color: var(--text); border-end-start-radius: 6px; }
.sim-log .bubble.me { align-self: flex-end; border-end-end-radius: 6px; }
.sim-log .bubble.pub { align-self: flex-end; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); border-end-end-radius: 6px; }
.sim-tag { align-self: flex-end; font-size: .72rem; color: var(--muted); display: flex; gap: .3rem; align-items: center; margin-top: .4rem; }
.sim-tag svg.i { width: 12px; height: 12px; }
.sim-tag.user { align-self: flex-start; }
.sim-input { display: flex; gap: .5rem; padding: .8rem; border-top: 1px solid var(--border); background: var(--surface); }
.sim-input input { border-radius: 99px; padding-inline: 1.1rem; }
.sim-input .btn { border-radius: 99px; width: 42px; height: 42px; padding: 0; flex: none; }
.sim-empty { margin: auto; text-align: center; color: var(--muted); max-width: 300px; }
.sim-empty .chips { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-top: .9rem; }
.sim-empty .chip { cursor: pointer; font: inherit; font-size: .82rem; }
.sim-empty .chip:hover { border-color: var(--brand); color: var(--brand); }
.typing { align-self: flex-end; display: flex; gap: 4px; padding: .75rem .9rem; background: var(--surface-2); border-radius: 18px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* misc */
.code { display: flex; align-items: center; gap: .5rem; padding: .45rem .5rem .45rem .7rem; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; direction: ltr; }
.code span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setting { display: flex; align-items: center; gap: 1rem; padding: .95rem 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: none; padding-top: 0; }
.setting .t { flex: 1; }
.setting .t small { display: block; color: var(--muted); font-size: .8rem; }
.tone-presets { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.tone-presets .chip { cursor: pointer; font: inherit; font-size: .8rem; }
.tone-presets .chip:hover, .tone-presets .chip.brand { border-color: var(--brand); color: var(--brand); }
.callout { display: flex; gap: .7rem; padding: .85rem 1rem; border-radius: 12px; background: var(--info-soft); color: var(--text-2); font-size: .86rem; }
.callout svg.i { color: var(--info); margin-top: .15rem; }
.callout.warn { background: var(--warn-soft); } .callout.warn svg.i { color: var(--warn); }
.save-state { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }
.save-state svg.i { width: 14px; height: 14px; color: var(--ok); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
kbd { font-family: inherit; font-size: .72rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 .3rem; color: var(--muted); }

/* toasts */
.toasts { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 80; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: .5rem; background: var(--text); color: var(--bg); padding: .6rem 1rem;
  border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .88rem; animation: toast .35s var(--ease); }
.toast.err { background: var(--err); color: #fff; }
.toast svg.i { width: 16px; height: 16px; }
@keyframes toast { from { opacity: 0; transform: translateY(12px) scale(.96); } }

/* =========================================================
   Auth (login / signup)
   ========================================================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-side { position: relative; overflow: hidden; background: #0b0c10; color: #fff; padding: 2.4rem 2.6rem;
  display: flex; flex-direction: column; gap: 2rem; justify-content: space-between; }
.auth-side .mesh { opacity: .7; }
.auth-side > * { position: relative; }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-size: 1.15rem; }
.auth-pitch h2 { font-size: clamp(1.6rem, 2.6vw, 2.3rem); font-weight: 700; line-height: 1.25; max-width: 15em; letter-spacing: -.02em; }
.auth-pitch ul { list-style: none; padding: 0; margin: 1.6rem 0 0; display: grid; gap: .75rem; }
.auth-pitch li { display: flex; gap: .6rem; align-items: center; color: rgba(255,255,255,.86); }
.auth-pitch li svg.i { width: 22px; height: 22px; padding: 4px; border-radius: 50%; background: rgba(255,255,255,.14); stroke-width: 2.6; }
.auth-mock { display: grid; gap: .6rem; max-width: 360px; }
.mock-card { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px); border-radius: 16px; padding: .75rem .9rem; display: flex; gap: .6rem; align-items: flex-start;
  font-size: .88rem; animation: float 6s ease-in-out infinite; }
.mock-card:nth-child(2) { margin-inline-start: 2.4rem; animation-delay: -3s; }
.mock-card .avatar { width: 30px; height: 30px; font-size: .75rem; }
.mock-card small { display: block; color: rgba(255,255,255,.6); font-size: .75rem; }
@keyframes float { 50% { transform: translateY(-6px); } }
.auth-main { position: relative; display: grid; place-items: center; padding: 4.5rem 1.5rem 2rem; }
.auth-form { width: min(390px, 100%); }
.auth-form .logo.lg { margin: 0 0 1.4rem; }
.auth-form h1 { font-size: 1.6rem; }
.auth-form > p.muted { margin: .35rem 0 1.6rem; }
.auth-form input { height: 46px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 2.8rem; }
.pw-wrap button { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); }
.btn.lg { height: 46px; font-size: .97rem; border-radius: 12px; }
.auth-switch { text-align: center; color: var(--muted); margin-top: 1.4rem !important; font-size: .9rem; }
.auth-switch a { color: var(--brand); font-weight: 600; text-decoration: none; }
.lang-btn { position: absolute; top: 1.1rem; inset-inline-end: 1.1rem; }

/* =========================================================
   Account switcher, menu, user row, mobile top bar
   ========================================================= */
.acc-av { position: relative; width: 34px; height: 34px; border-radius: 50%; background: var(--ig); padding: 2px; flex: none; display: grid; }
.acc-av i { display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 2px solid var(--surface);
  font-style: normal; font-weight: 700; font-size: .85rem; text-transform: uppercase; color: var(--text-2); }
.acc-av img { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); border-radius: 50%; object-fit: cover; border: 2px solid var(--surface); }
.acc-av.lg { width: 56px; height: 56px; } .acc-av.lg i { font-size: 1.3rem; }
.acc-av.sm { width: 26px; height: 26px; } .acc-av.sm i { font-size: .7rem; border-width: 1.5px; }
.acc-av .st { position: absolute; bottom: 0; inset-inline-end: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--err); border: 2px solid var(--surface); }
.acc-btn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .6rem; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); cursor: pointer; font: inherit; color: inherit; text-align: start; text-decoration: none;
  transition: border-color .15s, background .15s; }
.acc-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.acc-btn .t { flex: 1; min-width: 0; line-height: 1.3; }
.acc-btn .t b { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-btn .t small { color: var(--muted); font-size: .74rem; }
.acc-btn > svg.i { color: var(--muted); width: 16px; height: 16px; }
.acc-btn.add { border-style: dashed; color: var(--text-2); justify-content: center; }
.menu { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: .4rem; animation: pop .18s var(--ease); max-height: 70vh; overflow-y: auto; }
.menu .mh { font-size: .72rem; font-weight: 600; color: var(--muted); padding: .4rem .6rem .3rem; }
.menu-item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .6rem; border-radius: 9px; border: none;
  background: none; font: inherit; color: var(--text); cursor: pointer; text-align: start; text-decoration: none; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .t { flex: 1; min-width: 0; line-height: 1.3; }
.menu-item .t small { display: block; color: var(--muted); font-size: .74rem; }
.menu-item > svg.i.ok { color: var(--brand); }
.menu .sep { height: 1px; background: var(--border); margin: .35rem .2rem; }
.user-row { display: flex; align-items: center; gap: .55rem; padding: .7rem .3rem 0; margin-top: .7rem; border-top: 1px solid var(--border); }
.user-row .avatar { width: 30px; height: 30px; font-size: .78rem; }
.user-row .t { flex: 1; min-width: 0; line-height: 1.3; }
.user-row .t b { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row .t small { display: block; color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row .btn.icon { width: 30px; height: 30px; font-size: .78rem; font-weight: 700; }
.topbar { display: none; }
.nav-item .count.hot { background: var(--brand); color: #fff; font-weight: 700; }
[dir=ltr] svg.fwd { transform: scaleX(-1); }

/* =========================================================
   Chart (daily replies)
   ========================================================= */
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: .6rem; }
.chart .y { position: relative; height: 180px; font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.4em; }
.chart .y span { position: absolute; inset-inline-end: 0; transform: translateY(-50%); line-height: 1; }
.chart .plot { position: relative; height: 180px; }
.chart .gl { position: absolute; inset-inline: 0; height: 0; border-top: 1px dashed var(--border); }
.chart .gl.base { border-top: 1px solid var(--border-strong); }
.chart .bars { position: absolute; inset: 0; display: flex; gap: 2px; }
.chart .col { flex: 1; min-width: 0; position: relative; display: flex; justify-content: center; align-items: flex-end; border-radius: 6px; outline: none; cursor: default; }
.chart .col:hover, .chart .col:focus-visible { background: color-mix(in srgb, var(--surface-2) 80%, transparent); }
.chart .bar { width: min(14px, 62%); background: var(--chart); border-radius: 4px 4px 0 0; min-height: 0; transition: height .6s var(--ease); }
.chart .col:hover .bar, .chart .col:focus-visible .bar { filter: brightness(1.12); }
.chart .tip { position: absolute; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .3rem .55rem;
  border-radius: 8px; font-size: .76rem; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 2; line-height: 1.35; text-align: center; }
.chart .tip small { display: block; opacity: .7; font-size: .7rem; }
.chart .col.s .tip { left: auto; inset-inline-start: 0; transform: none; }
.chart .col.e .tip { left: auto; inset-inline-end: 0; transform: none; }
.chart .col:hover .tip, .chart .col:focus-visible .tip { opacity: 1; }
.chart .x { grid-column: 2; display: flex; gap: 2px; margin-top: .4rem; }
.chart .x span { flex: 1; min-width: 0; text-align: center; font-size: .68rem; color: var(--muted); white-space: nowrap; overflow: visible; }
.kpi .sub { font-size: .76rem; color: var(--muted); }
.kpi .sub b { font-size: .76rem; color: var(--ok); font-weight: 600; letter-spacing: 0; }

/* =========================================================
   Accounts page
   ========================================================= */
.acc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.acc-card { display: flex; flex-direction: column; gap: .9rem; }
.acc-card.cur { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.acc-card .top { display: flex; gap: .8rem; align-items: center; }
.acc-card .top .t { flex: 1; min-width: 0; }
.acc-card .top b { font-size: 1rem; display: flex; align-items: center; gap: .4rem; }
.acc-card .top small { color: var(--muted); font-size: .82rem; }
.acc-card .nums { display: flex; gap: 1.2rem; font-size: .85rem; color: var(--text-2); }
.acc-card .nums b { color: var(--text); font-variant-numeric: tabular-nums; }
.acc-card .detail { font-size: .78rem; color: var(--err); overflow-wrap: anywhere; }
.acc-card .acts { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; }
.connect { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.6rem; padding: 1.6rem; position: relative; overflow: hidden; margin-bottom: 1rem; }
.connect::before { content: ""; position: absolute; inset-block: 0; inset-inline-end: 0; width: 45%; background: var(--ig); opacity: .06; pointer-events: none; }
.connect > * { position: relative; }
.ig-badge { width: 48px; height: 48px; border-radius: 14px; background: var(--ig); color: #fff; display: grid; place-items: center; margin-bottom: 1rem; }
.ig-badge svg.i { width: 26px; height: 26px; }
.connect h2 { font-size: 1.2rem; }
.connect p { color: var(--text-2); margin: .4rem 0 1.2rem; max-width: 34em; }
.btn.ig { background: var(--ig); color: #fff; border: none; box-shadow: 0 8px 22px -8px rgba(214, 41, 118, .6); padding: 0 1.3rem; }
.btn.ig:hover { filter: brightness(1.05); }
.connect .callout { margin-top: 1rem; }
.checks h3 { font-size: .85rem; color: var(--text-2); margin-bottom: .5rem; }
.checks ul { list-style: none; margin: 0 0 1.1rem; padding: 0; display: grid; gap: .45rem; font-size: .87rem; }
.checks li { display: flex; gap: .5rem; align-items: flex-start; }
.checks li svg.i { width: 16px; height: 16px; margin-top: .2rem; color: var(--ok); stroke-width: 2.4; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.opt { display: flex; gap: .9rem; align-items: flex-start; }
.opt .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.opt .c { flex: 1; min-width: 0; }
.opt .c p { color: var(--muted); font-size: .85rem; margin: .2rem 0 .8rem; }
details.card > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .6rem; font-weight: 600; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .chev { margin-inline-start: auto; transition: transform .2s; color: var(--muted); }
details.card[open] > summary .chev { transform: rotate(-90deg); }
details.card[open] > summary { margin-bottom: 1rem; }
.token-row { display: flex; gap: .5rem; }
.token-row input { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; direction: ltr; }

/* =========================================================
   Inbox
   ========================================================= */
.inbox { display: grid; grid-template-columns: 320px 1fr; padding: 0; overflow: hidden; height: calc(100vh - 180px); min-height: 520px; }
.conv-list { border-inline-end: 1px solid var(--border); overflow-y: auto; }
.conv { display: flex; gap: .7rem; width: 100%; padding: .8rem 1rem; border: none; border-bottom: 1px solid var(--border); background: none;
  font: inherit; color: inherit; text-align: start; cursor: pointer; align-items: flex-start; transition: background .12s; }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--brand-soft); }
.conv .t { flex: 1; min-width: 0; }
.conv .t .r1 { display: flex; align-items: center; gap: .4rem; }
.conv .t .r1 b { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .t .r1 small { color: var(--muted); font-size: .72rem; flex: none; }
.conv .t p { color: var(--muted); font-size: .83rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .1rem; }
.conv.unread .t b, .conv.unread .t p { color: var(--text); font-weight: 600; }
.conv .unr { min-width: 20px; height: 20px; padding: 0 .35rem; border-radius: 99px; background: var(--brand); color: #fff; font-size: .7rem;
  font-weight: 700; display: grid; place-items: center; flex: none; margin-top: 1.2rem; }
.conv .paused svg.i { width: 13px; height: 13px; color: var(--warn); }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.thread-head .t { flex: 1; min-width: 0; line-height: 1.3; }
.thread-head .t small { display: block; color: var(--muted); font-size: .76rem; }
.thread-head .back { display: none; }
.pause-tg { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--text-2); cursor: pointer; }
.thread-log { flex: 1; overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: .35rem; }
.thread-log .bubble { max-width: 72%; font-size: .92rem; animation: none; }
.thread-log .bubble.them { background: var(--surface-3); color: var(--text); border-end-start-radius: 6px; }
.thread-log .bubble.me { border-end-end-radius: 6px; }
.thread-log .bubble.agent { background: var(--text); color: var(--bg); }
.thread-log .who { align-self: flex-end; font-size: .7rem; color: var(--muted); margin-top: .5rem; display: flex; gap: .3rem; align-items: center; }
.thread-log .who svg.i { width: 12px; height: 12px; }
.thread-log .day { align-self: center; font-size: .72rem; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: .1rem .6rem; margin: .6rem 0 .2rem; }
.thread-foot { border-top: 1px solid var(--border); padding: .7rem; background: var(--surface); }
.thread-foot .hint { display: block; padding: 0 .4rem .45rem; }
.thread-empty { margin: auto; text-align: center; color: var(--muted); padding: 2rem; }
.thread-empty .art { width: 56px; height: 56px; margin: 0 auto .8rem; border-radius: 18px; background: var(--surface-2); display: grid; place-items: center; }
.thread-empty .art svg.i { width: 26px; height: 26px; }
.paused-bar { display: flex; gap: .5rem; align-items: center; padding: .5rem 1rem; background: var(--warn-soft); color: var(--warn); font-size: .82rem; }
.paused-bar svg.i { width: 15px; height: 15px; }
.more-links { display: none; }
.auto-foot svg.i { width: 14px; height: 14px; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
  .connect { grid-template-columns: 1fr; }
  .drawer-body { grid-template-columns: 1fr; overflow-y: auto; }
  .drawer-form { overflow: visible; }
  .drawer-preview { border-inline-start: none; border-top: 1px solid var(--border); overflow: visible; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 30; flex-direction: row;
    padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom)); border-inline-end: none; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
  .side-brand, .side-foot { display: none; }
  .nav-item .full { display: none; }
  .page-head .btn kbd { display: none; }
  #nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: .1rem; font-size: .66rem; padding: .35rem .2rem; flex: 1; align-items: center; }
  .nav-item.on { background: none; color: var(--brand); }
  .nav-item.on::before, .nav-item .count { display: none; }
  .view { padding: 1.2rem 1rem 6.5rem; }
  h1 { font-size: 1.3rem; }
  .sim { grid-template-columns: 1fr; height: auto; }
  .sim-chat { height: 70vh; }
  .drawer { width: 100vw; }
  .drawer-form, .drawer-preview { padding: 1rem; }
  .toasts { bottom: 5.5rem; }
  .nav-item.desk { display: none; }
  .nav-item .count.hot { display: grid; position: absolute; top: 0; inset-inline-start: 55%; min-width: 17px; height: 17px;
    padding: 0 .25rem; place-items: center; font-size: .62rem; border-radius: 99px; }
  .topbar { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; position: sticky; top: 0; z-index: 25;
    background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border); }
  .topbar .acc-btn { width: auto; flex: 0 1 auto; min-width: 0; max-width: 260px; padding: .35rem .5rem; }
  .topbar .spacer { flex: 1; }
  .sidebar #accSlot { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { padding-top: 5rem; align-items: start; }
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 230px); }
  .inbox .thread { display: none; }
  .inbox.has-sel .thread { display: flex; }
  .inbox.has-sel .conv-list { display: none; }
  .thread-head .back { display: inline-flex; }
  .pause-tg .full { display: none; }
  .thread-log .bubble { max-width: 85%; }
  .opts { grid-template-columns: 1fr; }
  .more-links { display: block; }
}
@media (max-width: 520px) {
  .grid.kpis { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi b { font-size: 1.4rem; }
  .autos { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.nav-item .short { display: none; }
@media (max-width: 860px) { .nav-item .short { display: inline; } }

/* ---- phone fixes ---- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }
@supports (height: 100dvh) {
  .login, .shell, .auth { min-height: 100dvh; }
  .sidebar { height: 100dvh; }
}
@media (max-width: 860px) {
  /* iPhone zooms into any field smaller than 16px and the page then looks broken */
  input[type=text], input[type=email], input[type=password], input[type=search], textarea, select { font-size: 16px; }
  .sidebar { height: auto !important; }
  .inbox { height: calc(100dvh - 210px - env(safe-area-inset-bottom)); min-height: 420px; }
  .sim-chat { height: calc(100dvh - 210px - env(safe-area-inset-bottom)); min-height: 420px; }
  .topbar { padding-top: calc(.7rem + env(safe-area-inset-top)); }
  .view { padding-bottom: calc(6.5rem + env(safe-area-inset-bottom)); }
  .card, .grid > * { min-width: 0; }
  img, svg, video { max-width: 100%; }
  pre, code, .token-row input { overflow-wrap: anywhere; }
}

/* ---- reply variants & message buttons ---- */
.field.multi .variant { position: relative; display: flex; gap: .4rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .5rem; }
.field.multi .variant textarea { flex: 1; min-width: 0; }
.field.multi .variant .counter { width: 100%; margin-top: -.2rem; }
.variant-n { flex: none; width: 22px; height: 22px; margin-top: .55rem; border-radius: 99px; display: grid; place-items: center;
  font-size: .72rem; font-weight: 700; background: var(--brand-soft); color: var(--brand); }
.variant .btn.icon.sm { width: 30px; height: 30px; margin-top: .4rem; }
.add-variant { align-self: flex-start; color: var(--brand); }
.buttons-ed { margin: .4rem 0 .8rem; padding: .8rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.btn-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1.3fr) 32px; gap: .4rem; align-items: center; margin-top: .5rem; }
.btn-row input, .btn-row select { padding: .5rem .6rem; }
.btn-row .btn.icon.sm { width: 32px; height: 32px; }
input[type=url], input[type=tel] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; outline: none;
}
input[type=url]:focus, input[type=tel]:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.bubble.has-btns { padding-bottom: .35rem; }
.ig-btns { display: flex; flex-direction: column; gap: 1px; margin: .5rem -.8rem 0; border-top: 1px solid rgba(255,255,255,.25); }
.ig-btns span { display: flex; align-items: center; justify-content: center; gap: .35rem; padding: .45rem .6rem; font-weight: 600; font-size: .85em; white-space: nowrap; }
.ig-btns span + span { border-top: 1px solid rgba(255,255,255,.25); }
.ig-btns svg { width: 14px; height: 14px; }
.btn-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.btn-chips .chip svg { width: 12px; height: 12px; vertical-align: -1px; }
.more-chip { font-size: .7rem; padding: .05rem .45rem; margin-inline-start: .3rem; }
.inline-toggle .t b svg { width: 14px; height: 14px; vertical-align: -2px; color: var(--brand); }
@media (max-width: 860px) {
  input[type=url], input[type=tel] { font-size: 16px; }
  .btn-row { grid-template-columns: minmax(0, 1fr) 32px; }
  .btn-row select { grid-column: 1; }
  .btn-row input { grid-column: 1; }
  .btn-row .btn.icon.sm { grid-column: 2; grid-row: 1; }
}
/* editor drawer must never be wider than the phone screen */
@media (max-width: 1100px) {
  .drawer-body { grid-template-columns: minmax(0, 1fr); }
  .drawer-form, .drawer-preview { min-width: 0; }
}
@media (max-width: 520px) {
  .choices { grid-template-columns: minmax(0, 1fr); }
  .drawer-form .step { gap: .6rem; }
}
.reply-line.why { color: var(--muted); font-size: .85rem; background: transparent; padding-inline: 0; }
.sim-why { font-size: .78rem; color: var(--muted); text-align: center; margin-top: -.2rem; }

/* ---- after-the-reply sections in the rule editor ---- */
.xsec { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .2rem .8rem; margin-bottom: .6rem; background: var(--surface); transition: border-color .15s; }
.xsec.on { border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
.xsec .inline-toggle { margin: 0; border: none; background: none; padding: .6rem 0; }
.xsec .inline-toggle .t b svg { width: 15px; height: 15px; vertical-align: -2px; color: var(--brand); }
.xbody { padding: .2rem 0 .8rem; border-top: 1px dashed var(--border); padding-top: .8rem; }
.opt-row { display: flex; flex-direction: column; gap: .4rem; padding: .6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .5rem; background: var(--bg); }
.opt-top { display: flex; gap: .4rem; align-items: center; }
.opt-top input { flex: 1; min-width: 0; }
.opt-top .variant-n { margin-top: 0; }
.chips.pick { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips.pick .chip, .row .chip, .qr-chips .chip { cursor: pointer; padding: .3rem .75rem; font-size: .85rem; }
.chips.pick .chip svg { width: 13px; height: 13px; }
.gate-pv { display: flex; flex-direction: column; gap: .4rem; padding: .7rem .8rem; border-radius: 14px; background: var(--surface-2); font-size: .88rem; margin-bottom: .4rem; }
.gate-pv b { align-self: flex-start; padding: .25rem .8rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-size: .82rem; }
.feat-badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.feat-badges .chip { font-size: .74rem; }
.feat-badges .chip svg { width: 12px; height: 12px; }
.qr-chips { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; align-self: flex-end; max-width: 90%; }
.qr-chips .chip { background: var(--surface); border: 1px solid color-mix(in srgb, #5b51d8 45%, var(--border)); color: #5b51d8; font-weight: 600; }
.qr-chips button.chip:hover:not(:disabled) { background: #5b51d8; color: #fff; }
.qr-chips .chip:disabled { opacity: .45; cursor: default; }
.phone .qr-chips .chip { font-size: 11px; padding: .15rem .55rem; }
.bubble.tap { font-style: italic; opacity: .85; }
.ig-btns button, .ig-btns a { all: unset; display: flex; align-items: center; justify-content: center; gap: .35rem; padding: .45rem .6rem;
  font-weight: 600; font-size: .85em; cursor: pointer; color: inherit; }
.ig-btns button + button, .ig-btns a + a, .ig-btns a + button, .ig-btns button + a { border-top: 1px solid rgba(255,255,255,.25); }
.ig-btns button:hover:not(:disabled), .ig-btns a:hover { background: rgba(255,255,255,.12); }
.ig-btns button:disabled { opacity: .6; cursor: default; }

/* ---- smart automation cards ---- */
.section-t { margin: 2rem 0 .8rem; }
.section-t h2 { font-size: 1.1rem; }
.section-t p { color: var(--muted); font-size: .88rem; margin: .15rem 0 0; }
.autos.smart { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.auto.mini { gap: .6rem; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ib-list { margin-top: auto; display: flex; flex-direction: column; gap: .35rem; padding-bottom: .4rem; }
.ib-list span { align-self: center; padding: .35rem .8rem; border-radius: 99px; border: 1px solid #dbdbdb; font-size: 12px; background: #fff; color: #262626; }
.ig-comment.hidden-c { opacity: .45; }
.ig-comment.hidden-c small svg { width: 11px; height: 11px; vertical-align: -1px; }
input[type=time], input[type=number] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; outline: none;
}

/* ---- customers, tools, team ---- */
.item.contact { cursor: pointer; border-radius: var(--radius-sm); }
.item.contact:hover { background: var(--surface-2); }
.c-details { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; font-size: .84rem; color: var(--text-2); margin-top: .25rem; }
.c-details svg { width: 13px; height: 13px; vertical-align: -2px; }
.c-details .chip { font-size: .74rem; }
.card.list { padding-block: .2rem; }
.card.list > .item:first-child { border-top: none; }
.winner { align-items: center; animation: pop .45s var(--ease) both; }
.winner .place { font-size: 1.4rem; width: 2rem; text-align: center; }
.ga-result .empty-feed svg { width: 32px; height: 32px; }
.steps-list { margin: 0 0 1rem; padding-inline-start: 1.2rem; color: var(--text-2); font-size: .88rem; line-height: 1.9; }
.sim-note { align-self: center; text-align: center; font-size: .8rem; color: var(--muted); background: var(--surface-2); padding: .3rem .8rem; border-radius: 99px; max-width: 90%; }
.sim-note svg { width: 13px; height: 13px; vertical-align: -2px; }
.sim-log .qr-chips { margin-top: -.2rem; }
.drawer.narrow { width: min(560px, 100vw); }
.drawer.narrow .drawer-body { grid-template-columns: minmax(0, 1fr); }
.card-head h2 svg { width: 18px; height: 18px; vertical-align: -3px; color: var(--brand); }
@media (max-width: 860px) {
  input[type=time], input[type=number] { font-size: 16px; }
  .autos.smart { grid-template-columns: minmax(0, 1fr); }
}
