:root {
  --bg: #f6f6f9;
  --panel: #ffffff;
  --ink: #16151c;
  --muted: #6b6a78;
  --line: #e7e6ee;
  --brand: #7c3aed;
  --brand-2: #db2777;
  --brand-soft: #f3edff;
  --ok: #16a34a;
  --warn: #b45309;
  --warn-soft: #fff7e6;
  --err: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 4px 16px rgba(20, 20, 40, .05);
  --grad: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.boot { padding: 40px; color: var(--muted); }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 8px 18px; }
.logo i { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink); font-weight: 500; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.side .grow { flex: 1; }
.acct-switch { margin-bottom: 14px; }
.main { padding: 26px 32px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 28px; font-weight: 700; margin-top: 4px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: #cfcde0; }
.btn.primary { background: var(--grad); color: #fff; border: 0; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=url], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label.f { display: block; font-weight: 600; margin: 14px 0 6px; }
label.f span { font-weight: 400; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); }
.pill.on { background: #e8f8ee; color: var(--ok); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.err { background: #fdecec; color: var(--err); }
.banner { background: var(--warn-soft); border: 1px solid #f7deb0; color: var(--warn); padding: 10px 14px; border-radius: 12px; margin-bottom: 18px; font-size: 13px; }
.banner.err { background: #fdecec; border-color: #f6caca; color: var(--err); }
.banner.ok { background: #e8f8ee; border-color: #bfe8cd; color: var(--ok); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* toggle */
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d8d6e3; border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }

/* automations list */
.auto { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; }
.thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--brand-soft) center/cover no-repeat; display: grid; place-items: center; font-size: 22px; }
.auto .meta { display: flex; gap: 16px; color: var(--muted); font-size: 12.5px; margin-top: 4px; flex-wrap: wrap; }
.auto .meta b { color: var(--ink); }

/* editor */
.editor { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.step { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.step .n { width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.choice { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: #fff; text-align: left; font: inherit; }
.choice:hover { border-color: #cfcde0; }
.choice.on { border-color: var(--brand); background: var(--brand-soft); }
.choice b { display: block; }
.choice small { color: var(--muted); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.media { aspect-ratio: 1; border-radius: 10px; background: var(--bg) center/cover no-repeat; border: 2.5px solid transparent; cursor: pointer; position: relative; padding: 0; }
.media.on { border-color: var(--brand); }
.media.any { display: grid; place-items: center; font-weight: 600; color: var(--brand); background: var(--brand-soft); font-size: 12px; text-align: center; padding: 6px; }
.media .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }
.chips input { border: 0; flex: 1; min-width: 120px; padding: 4px; outline: none; }
.chip { background: var(--brand-soft); color: var(--brand); padding: 3px 4px 3px 10px; border-radius: 99px; font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 2px; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; padding: 0 4px; }
.link-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; margin-bottom: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.toggle-row + .toggle-row { border-top: 1px solid var(--line); }
.sticky { position: sticky; top: 20px; }

/* phone preview / chat */
.phone { background: #fff; border: 1px solid var(--line); border-radius: 28px; padding: 14px; box-shadow: var(--shadow); }
.phone .bar { display: flex; align-items: center; gap: 8px; padding: 4px 4px 12px; border-bottom: 1px solid var(--line); margin-bottom: 10px; font-weight: 600; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--grad); flex: none; }
.chat { display: flex; flex-direction: column; gap: 8px; min-height: 280px; max-height: 560px; overflow-y: auto; padding: 2px; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; }
.bubble.me { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.bubble.them { align-self: flex-start; background: #efeff4; border-bottom-left-radius: 6px; }
.bubble.note { align-self: center; background: none; color: var(--muted); font-size: 11.5px; padding: 0; text-align: center; }
.tpl { align-self: flex-end; max-width: 82%; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: #fff; }
.tpl .t { padding: 9px 12px; white-space: pre-wrap; font-size: 13.5px; }
.tpl .b { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); background: #fff; padding: 8px; text-align: center; color: #2563eb; font-weight: 600; font: inherit; font-weight: 600; cursor: default; }
.tpl button.b.live { cursor: pointer; }
.tpl button.b.live:hover { background: #f4f7ff; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 500px at 20% -10%, #efe5ff, transparent), radial-gradient(900px 500px at 110% 110%, #ffe4f1, transparent), var(--bg); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .logo { justify-content: center; font-size: 22px; padding-bottom: 6px; }

/* chart */
.chart svg { width: 100%; height: 180px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500; z-index: 50; box-shadow: var(--shadow); }
.toast.err { background: var(--err); }
.steps-list { margin: 8px 0 0; padding-left: 20px; }
.steps-list li { margin: 6px 0; }
.copy { display: flex; gap: 6px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 4px 4px 10px; margin-top: 4px; }
.copy code { flex: 1; overflow-x: auto; white-space: nowrap; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .grow, .acct-switch { display: none; }
  .logo { padding: 4px 8px; }
  .nav { display: flex; flex-wrap: wrap; }
  .main { padding: 18px 16px 40px; }
  .editor { grid-template-columns: 1fr; }
  .link-row { grid-template-columns: 1fr; }
}
