/* IG Automation Platform — Phoenix UI design system (all-blue palette) */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  color-scheme: light;
  /* Trustworthy vibrant blue on clean cool whites — a calm all-blue palette. */
  --bg: hsl(210 40% 98%);
  --bg-elev: hsl(0 0% 100%);
  --bg-sunken: hsl(210 40% 96.5%);
  --ink: hsl(222 47% 11%);
  --ink-2: hsl(215 19% 34%);
  --ink-3: hsl(215 16% 47%);
  --ink-4: hsl(215 22% 66%);
  --line: hsl(214 32% 91%);
  --line-2: hsl(214 28% 85%);
  --accent: hsl(221 83% 53%);        /* the signature brand blue */
  --accent-ink: hsl(221 83% 45%);    /* deeper blue for text/icons on a tint */
  --accent-soft: hsl(221 83% 96%);   /* blue wash for surfaces */
  --accent-line: hsl(221 70% 88%);   /* blue hairline (e.g. outgoing bubbles) */
  --accent-2: hsl(199 89% 48%);      /* sky blue — gradients & 2nd highlight */
  --accent-2-soft: hsl(199 89% 95%);
  --brand-grad: linear-gradient(135deg, hsl(221 83% 53%), hsl(199 89% 52%));
  --success: hsl(142 71% 42%);
  --success-ink: hsl(142 64% 30%);
  --success-soft: hsl(142 71% 95%);
  --success-line: hsl(142 45% 78%);
  --warn: hsl(38 92% 50%);
  --warn-soft: hsl(38 92% 95%);
  --danger: hsl(0 78% 56%);
  --danger-soft: hsl(0 84% 96%);
  --info: hsl(221 83% 53%);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px hsl(222 47% 11% / .06), 0 1px 1px hsl(222 47% 11% / .04);
  --shadow-md: 0 4px 12px hsl(222 47% 11% / .07), 0 1px 2px hsl(222 47% 11% / .05);
  --shadow-lg: 0 12px 34px hsl(222 47% 11% / .12), 0 2px 6px hsl(222 47% 11% / .06);
  --shadow-primary: 0 8px 22px hsl(221 83% 53% / .26);
  --ease-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --font-ui: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: hsl(222 47% 11%);
  --bg-elev: hsl(222 41% 15%);
  --bg-sunken: hsl(222 47% 9%);
  --ink: hsl(210 40% 98%);
  --ink-2: hsl(215 22% 76%);
  --ink-3: hsl(215 18% 60%);
  --ink-4: hsl(215 16% 45%);
  --line: hsl(217 19% 24%);
  --line-2: hsl(217 19% 31%);
  --accent: hsl(217 91% 62%);
  --accent-ink: hsl(213 94% 80%);
  --accent-soft: hsl(217 48% 20%);
  --accent-line: hsl(217 38% 32%);
  --accent-2: hsl(199 89% 56%);
  --accent-2-soft: hsl(199 60% 20%);
  --brand-grad: linear-gradient(135deg, hsl(217 91% 60%), hsl(199 89% 56%));
  --success: hsl(142 60% 50%);
  --success-ink: hsl(142 55% 72%);
  --success-soft: hsl(142 38% 17%);
  --success-line: hsl(142 28% 30%);
  --warn: hsl(38 90% 56%);
  --warn-soft: hsl(38 38% 20%);
  --danger: hsl(0 70% 60%);
  --danger-soft: hsl(0 40% 22%);
  --info: hsl(217 91% 62%);
  --shadow-primary: 0 8px 22px hsl(217 91% 60% / .30);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}

/* Headings use the display face (Outfit), bold + tight — the Phoenix signature. */
h1, h2, h3, h4, h5, h6, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

button { font-family: inherit; cursor: default; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* Hamburger + drawer scrim: desktop-hidden, switched on inside the mobile breakpoint. */
.nav-toggle {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background-color .18s, border-color .18s;
}
.nav-toggle:hover { background: var(--bg-sunken); border-color: var(--line-2); }
.nav-scrim { display: none; }

/* ────────── Sidebar ────────── */
.sidebar {
  background: var(--bg-sunken);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0;
}
.brand-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 4px;
}

.workspace {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 10px;
  margin-bottom: 14px;
  cursor: default;
}
.workspace:hover { border-color: var(--line-2); }
.workspace-avatar {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--brand-grad);
  color: white;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
}
.workspace-name { font-size: 12.5px; font-weight: 600; line-height: 1.1; }
.workspace-sub { font-size: 10.5px; color: var(--ink-3); font-family: var(--font-mono); }
.workspace-chevron { margin-left: auto; color: var(--ink-3); }

.nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  padding: 14px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: default;
  border: 1px solid transparent;
  position: relative;
}
.nav-item:hover { background: var(--bg-elev); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}
.nav-icon {
  width: 16px; height: 16px;
  color: var(--ink-3);
  flex-shrink: 0;
}
.nav-item.active .nav-icon { color: var(--accent); }
.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
}
.nav-dot {
  margin-left: auto;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--line);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px;
}
.sidebar-user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: white;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}
.sidebar-user-name { font-size: 12.5px; font-weight: 500; }
.sidebar-user-mail { font-size: 10.5px; color: var(--ink-3); font-family: var(--font-mono); }

/* ────────── Main / Topbar ────────── */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  min-height: 56px;
  flex-shrink: 0;
}
.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0;
}
.topbar .crumb {
  color: var(--ink-3);
  font-size: 13px;
}
.topbar .crumb-sep { color: var(--ink-4); margin: 0 6px; }
.topbar-spacer { flex: 1; }

.theme-toggle {
  width: 58px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--ink-3);
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--line-2);
  color: var(--ink);
}
.theme-toggle-icon {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  z-index: 1;
}
.theme-toggle-thumb {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease;
}
[data-theme="dark"] .theme-toggle-thumb { transform: translateX(28px); }
[data-theme="dark"] .theme-toggle-moon,
[data-theme="light"] .theme-toggle-sun { color: var(--ink); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 8px;
  width: 260px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
}
.search kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink-3);
}

.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ────────── Buttons ────────── */
.input,
.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}
.input:focus,
.form-control:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input,
textarea.form-control {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: default;
  font-family: inherit;
  white-space: nowrap;
  transition: background-color .18s var(--ease-soft), border-color .18s var(--ease-soft),
              box-shadow .18s var(--ease-soft), transform .18s var(--ease-soft), color .18s;
}
.btn:hover { background: var(--bg-sunken); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: hsl(221 83% 48%);
  border-color: hsl(221 83% 48%);
  transform: translateY(-1px);
  box-shadow: 0 10px 26px hsl(221 83% 53% / .34);
}
[data-theme="dark"] .btn-primary:hover { background: hsl(217 91% 66%); border-color: hsl(217 91% 66%); }
.btn-accent {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
  font-weight: 600;
}
.btn-accent:hover { background: hsl(199 89% 42%); border-color: hsl(199 89% 42%); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: hsl(0 72% 48%);
  border-color: hsl(0 72% 48%);
}
.btn-instagram {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, #FED576, #F47133, #BC3081, #4C63D2);
}
.btn-instagram:hover {
  border-color: transparent;
  filter: saturate(1.05) brightness(0.98);
}
.btn-block {
  width: 100%;
  justify-content: center;
}
.btn-sm { padding: 4px 8px; font-size: 11.5px; }
.btn-icon {
  width: 30px; height: 30px;
  padding: 0;
  display: grid; place-items: center;
}

/* ────────── Cards ────────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-pad { padding: 18px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}
.card-sub { font-size: 11.5px; color: var(--ink-3); }

/* ────────── Pills / chips ────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-sunken);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.chip-mono { font-family: var(--font-mono); font-size: 10.5px; }
.chip-accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-line);
}
.chip-warn {
  background: var(--warn-soft);
  color: oklch(0.42 0.1 60);
  border-color: oklch(0.85 0.08 60);
}
.chip-dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-3);
}

.mono { font-family: var(--font-mono); }

/* ────────── Tables ────────── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunken);
  position: sticky;
  top: 0;
}
.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tr:hover td { background: var(--bg-sunken); }
.tbl tr:last-child td { border-bottom: 0; }

/* ────────── Misc ────────── */
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }
.tabular { font-variant-numeric: tabular-nums; }

.avatar {
  border-radius: 50%;
  background: var(--bg-sunken);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
}

/* connection state dot */
.live-dot {
  position: relative;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.live-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0.4;
  animation: ping 1.6s cubic-bezier(0,0,0.2,1) infinite;
}
@keyframes ping {
  0% { transform: scale(.8); opacity: .6; }
  80%, 100% { transform: scale(1.6); opacity: 0; }
}

/* sparkline / bars */
.spark { display: flex; align-items: end; gap: 2px; height: 28px; }
.spark span {
  flex: 1;
  background: var(--ink-4);
  border-radius: 1px;
  min-height: 3px;
}
.spark span.hi { background: var(--ink); }
.spark.accent span { background: var(--accent); opacity: 0.5; }
.spark.accent span.hi { background: var(--accent); opacity: 1; }

/* page padding */
.page { padding: 24px 28px 60px; max-width: 1500px; animation: animate-in 0.32s var(--ease-soft); }

/* Signature soft entrance (opacity + small rise). Phoenix motion is CSS-only. */
@keyframes animate-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: animate-in 0.32s var(--ease-soft); }
@media (prefers-reduced-motion: reduce) {
  .page, .animate-in { animation: none; }
  * { scroll-behavior: auto; }
}
.page h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
  margin: 0 0 4px;
}
.page-sub { color: var(--ink-3); font-size: 13px; margin-bottom: 24px; }

/* grid helpers */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* segmented */
.seg {
  display: inline-flex;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.seg button,
.seg a {
  background: transparent;
  border: 0;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  color: var(--ink-2);
  font-family: inherit;
  font-weight: 500;
  text-decoration: none;
}
.seg button.on,
.seg a.on {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ────────── Builder canvas ────────── */
.canvas {
  position: relative;
  background:
    radial-gradient(circle, var(--line) 1px, transparent 1px) 0 0/22px 22px,
    var(--bg-sunken);
  flex: 1;
  overflow: hidden;
}
[data-theme="dark"] .canvas {
  background:
    radial-gradient(circle, oklch(0.26 0.008 80) 1px, transparent 1px) 0 0/22px 22px,
    var(--bg-sunken);
}

.node {
  position: absolute;
  min-width: 240px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
  user-select: none;
}
.node-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 11.5px;
}
.node-head .pip {
  width: 18px; height: 18px;
  border-radius: 5px;
  background: var(--bg-sunken);
  display: grid; place-items: center;
  color: var(--ink-2);
}
.node-body { padding: 10px; }
.node.selected { border-color: var(--ink); box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-soft); }
.node-port {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 2px solid var(--ink-3);
  top: 50%;
  transform: translateY(-50%);
}
.node-port.left { left: -5px; }
.node-port.right { right: -5px; }

.node[data-kind="trigger"] .node-head { background: oklch(0.96 0.05 60); color: oklch(0.4 0.1 60); border-bottom-color: oklch(0.85 0.06 60); }
[data-theme="dark"] .node[data-kind="trigger"] .node-head { background: oklch(0.3 0.04 60); color: oklch(0.85 0.08 60); }
.node[data-kind="ai"] .node-head { background: var(--accent-soft); color: var(--accent-ink); border-bottom-color: oklch(0.85 0.06 142); }
.node[data-kind="condition"] .node-head { background: oklch(0.96 0.04 240); color: oklch(0.42 0.1 240); border-bottom-color: oklch(0.85 0.06 240); }
[data-theme="dark"] .node[data-kind="condition"] .node-head { background: oklch(0.3 0.04 240); color: oklch(0.85 0.08 240); }
.node[data-kind="action"] .node-head { background: var(--bg-sunken); }

/* connector svg overlay */
.canvas svg.wires {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.builder-toolbar {
  position: absolute;
  top: 14px; left: 14px;
  display: flex; gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}
.builder-zoom {
  position: absolute;
  bottom: 14px; right: 14px;
  display: flex; gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
  z-index: 5;
  align-items: center;
}
.builder-zoom .lvl { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); padding: 0 8px; }

.minimap {
  position: absolute;
  bottom: 14px; left: 14px;
  width: 180px; height: 110px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  z-index: 5;
  overflow: hidden;
}

.builder-rail {
  width: 280px;
  border-left: 1px solid var(--line);
  background: var(--bg);
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}
.builder-palette {
  width: 240px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 14px;
  overflow-y: auto;
  flex-shrink: 0;
}
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  margin-bottom: 6px;
  font-size: 12.5px;
  cursor: grab;
}
.palette-item:hover { border-color: var(--line-2); background: var(--bg-sunken); }
.palette-item .glyph {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--bg-sunken);
  display: grid; place-items: center;
  color: var(--ink-2);
}

/* workflow builder */
.workflow-builder {
  display: grid;
  grid-template-columns: 258px minmax(560px, 1fr) 380px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.workflow-left,
.workflow-inspector {
  background: var(--bg);
  min-height: 0;
  overflow-y: auto;
}
.workflow-left {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.workflow-left-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line);
}
.workflow-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 14px 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--ink-3);
}
.workflow-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
}
.workflow-palette-scroll {
  padding: 0 14px 14px;
  overflow-y: auto;
  min-height: 0;
}
.workflow-palette-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 4px 5px;
  font-weight: 600;
}
.workflow-palette-item {
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.workflow-palette-item[disabled] {
  opacity: .48;
  cursor: not-allowed;
}
.workflow-left-foot {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.workflow-canvas {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.workflow-canvas-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: color-mix(in oklab, var(--bg-elev) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  z-index: 8;
  backdrop-filter: blur(10px);
}
.workflow-toolbar-divider {
  width: 1px;
  align-self: stretch;
  background: var(--line);
}
.workflow-canvas-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.1;
}
.workflow-canvas-sub {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.workflow-canvas-sub.error {
  color: var(--danger);
}
.workflow-canvas-sub.success {
  color: var(--accent-ink);
}
.workflow-stage {
  position: absolute;
  left: 52px;
  top: 86px;
  width: 1800px;
  height: 1000px;
  transform-origin: 0 0;
  transition: transform .16s ease;
}
.workflow-wires,
.workflow-minimap svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.workflow-wires {
  z-index: 1;
}
.workflow-wires path,
.workflow-minimap path {
  fill: none;
  stroke: var(--ink-4);
  stroke-width: 2;
}
.workflow-edge-group {
  cursor: pointer;
}
.workflow-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  pointer-events: stroke;
}
.workflow-edge-line {
  fill: none;
  stroke: color-mix(in oklab, var(--ink-3) 70%, var(--line));
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 9 10;
  animation: workflowFlow 1.2s linear infinite;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 color-mix(in oklab, var(--bg-elev) 85%, transparent));
}
.workflow-edge-arrow {
  fill: color-mix(in oklab, var(--ink-3) 70%, var(--line));
}
.workflow-edge-terminal {
  fill: var(--bg-elev);
  stroke: color-mix(in oklab, var(--ink-3) 70%, var(--line));
  stroke-width: 2;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
.workflow-edge-group:hover .workflow-edge-line,
.workflow-edge-group.selected .workflow-edge-line {
  stroke: var(--ink);
  stroke-width: 3;
}
.workflow-edge-group:hover .workflow-edge-terminal,
.workflow-edge-group.selected .workflow-edge-terminal {
  stroke: var(--ink);
  fill: var(--accent-soft);
}
.workflow-edge-group:hover .workflow-edge-arrow,
.workflow-edge-group.selected .workflow-edge-arrow {
  fill: var(--ink);
}
.workflow-edge-group.selected .workflow-edge-line {
  filter: drop-shadow(0 0 6px color-mix(in oklab, var(--accent) 38%, transparent));
}
.workflow-edge-preview {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 6 6;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
  animation: workflowDash 650ms linear infinite;
}
@keyframes workflowDash {
  to { stroke-dashoffset: -12; }
}
@keyframes workflowFlow {
  to { stroke-dashoffset: -19; }
}
#workflowNodes {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.workflow-wire-muted {
  opacity: .48;
  stroke-dasharray: 5 5;
}
.workflow-node {
  position: absolute;
  width: 220px;
  min-height: 98px;
  padding: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  overflow: visible;
  cursor: default;
}
.workflow-node:hover {
  border-color: var(--line-2);
}
.workflow-node.selected {
  border-color: var(--ink);
  box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-soft);
}
.workflow-node.is-disabled {
  opacity: .58;
}
.workflow-node-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px 12px 0 0;
}
.workflow-node-icon {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--bg-sunken);
  color: var(--ink-2);
  flex-shrink: 0;
}
.workflow-node-trigger .workflow-node-head {
  background: oklch(0.96 0.045 60);
  border-bottom-color: oklch(0.86 0.06 60);
}
[data-theme="dark"] .workflow-node-trigger .workflow-node-head {
  background: oklch(0.3 0.035 60);
  border-bottom-color: oklch(0.42 0.04 60);
}
.workflow-node-action .workflow-node-icon,
.workflow-node-type-preview .workflow-node-icon {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.workflow-node-type-preview .workflow-node-head {
  background: var(--accent-soft);
  border-bottom-color: color-mix(in oklab, var(--accent) 42%, var(--line));
}
.workflow-node-condition .workflow-node-head {
  background: oklch(0.96 0.035 240);
  border-bottom-color: oklch(0.86 0.05 240);
}
[data-theme="dark"] .workflow-node-condition .workflow-node-head {
  background: oklch(0.29 0.035 240);
  border-bottom-color: oklch(0.4 0.04 240);
}
.workflow-node-utility .workflow-node-icon {
  background: var(--bg-sunken);
  color: var(--ink-2);
}
.workflow-node-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.15;
}
.workflow-node-sub {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-top: 1px;
}
.workflow-node-body {
  padding: 11px;
  font-size: 12.5px;
  line-height: 1.45;
}
.workflow-node-value {
  display: inline-flex;
  max-width: 100%;
  margin-top: 5px;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.workflow-node-text {
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.workflow-port,
.workflow-port-btn {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 2px solid var(--ink-3);
  transform: translateY(-50%);
  z-index: 2;
}
.workflow-port-btn {
  padding: 0;
  cursor: crosshair;
}
.workflow-port-btn:hover,
.workflow-port-btn.pending,
.workflow-port-btn.can-connect {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.workflow-stage.is-connecting .workflow-port-btn.in {
  transform: translateY(-50%) scale(1.08);
}
.workflow-stage.is-connecting .workflow-port-btn.out:not(.pending) {
  opacity: .52;
}
.workflow-port.in,
.workflow-port-btn.in { left: -6px; }
.workflow-port.out,
.workflow-port-btn.out { right: -6px; }
.workflow-preview-bubble {
  margin-top: 8px;
  margin-left: auto;
  max-width: 100%;
  background: var(--accent-soft);
  border-color: oklch(0.85 0.08 142);
  color: var(--accent-ink);
}
.workflow-zoom {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 3px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
  z-index: 8;
}
.workflow-zoom .lvl {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  padding: 0 8px;
}
.workflow-minimap {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 184px;
  height: 112px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  z-index: 8;
}
.workflow-minimap svg {
  position: relative;
  height: 78px;
  padding: 8px;
}
.workflow-minimap rect {
  fill: var(--ink-3);
  opacity: .55;
}
.workflow-inspector {
  border-left: 1px solid var(--line);
}
.workflow-form {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.inspector-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 3;
}
.inspector-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 72px;
}
.inspector-section.active {
  background: color-mix(in oklab, var(--accent-soft) 30%, transparent);
}
.inspector-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.065em;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 12px;
}
.connection-summary {
  display: grid;
  gap: 8px;
}
.connection-summary > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  font-size: 12.5px;
}
.connection-summary span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.connection-summary b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workflow-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}
.workflow-thread-preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  padding: 12px;
}
.workflow-bot-preview {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.workflow-bot-preview.compact {
  align-items: stretch;
}
.workflow-preview-card {
  width: min(100%, 240px);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-sunken);
}
.workflow-preview-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--bg-elev);
  color: var(--ink-2);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.workflow-preview-url {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
}
.workflow-preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.workflow-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.workflow-quick-replies button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--accent-ink);
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
}
.workflow-preview-simulation {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-sunken);
  font-size: 12px;
  color: var(--ink-2);
}
.workflow-preview-simulation b,
.workflow-preview-simulation span {
  display: block;
}
.workflow-preview-simulation.success {
  border-color: color-mix(in oklab, var(--accent) 42%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.workflow-preview-simulation.error {
  border-color: oklch(0.85 0.07 25);
  background: oklch(0.97 0.025 25);
  color: var(--danger);
}
.workflow-preview-path {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.workflow-preview-step {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.workflow-preview-step span {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-size: 10px;
  font-family: var(--font-mono);
}
.workflow-existing-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.automation-mini {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
  padding: 10px;
}
.workflow-form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  margin-top: auto;
}

.workflow-index-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.search.compact {
  flex: 1;
  min-width: 180px;
}
.workflow-index-list {
  padding: 4px 0;
}
.workflow-index-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.workflow-index-row:last-child {
  border-bottom: 0;
}
.workflow-index-row:hover {
  background: var(--bg-sunken);
}
.workflow-index-metrics {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
  font-size: 11.5px;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .workflow-builder {
    grid-template-columns: 220px minmax(500px, 1fr) 340px;
  }
  .workflow-stage {
    left: 28px;
  }
}

/* inbox */
.inbox {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  height: 100%;
  overflow: hidden;
}
.chat-layout {
  display: grid;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}
.inbox-list {
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto;
}
.inbox-list-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.thread {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; gap: 12px;
  cursor: default;
  position: relative;
}
.thread:hover { background: var(--bg-sunken); }
.thread.active { background: var(--bg-sunken); }
.thread.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--ink);
}
.thread-meta {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.thread-name { font-size: 12.5px; font-weight: 600; }
.thread-snippet { font-size: 12px; color: var(--ink-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }

.thread-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: white;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}

.chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg {
  display: flex; gap: 10px;
  max-width: 70%;
  position: relative;
  align-items: flex-end;
}
.msg.me { flex-direction: row-reverse; align-self: flex-end; }
.msg-stack {
  max-width: 100%;
  min-width: 0;
}
.bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.msg.me .bubble {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.msg.bot .bubble {
  background: var(--accent-soft);
  border-color: oklch(0.85 0.08 142);
  color: var(--accent-ink);
}
.msg-meta {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-top: 4px;
}
.message-delete-form {
  position: absolute;
  top: -8px;
  right: -34px;
  opacity: 0;
  transition: opacity .14s ease, transform .14s ease;
  transform: translateY(2px);
}
.msg.me .message-delete-form {
  left: -34px;
  right: auto;
}
.msg:hover .message-delete-form,
.msg:focus-within .message-delete-form {
  opacity: 1;
  transform: translateY(0);
}
.message-delete-btn {
  width: 26px;
  height: 26px;
  color: var(--danger);
  background: var(--bg-elev);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.chat-compose {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.compose-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: var(--bg-elev);
}
.compose-box textarea {
  width: 100%; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--ink);
  font-family: inherit; font-size: 13px;
  min-height: 36px;
}
.compose-actions { display: flex; align-items: center; gap: 6px; margin-top: 4px; }

.copilot {
  border-left: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.copilot-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.copilot-card.ai {
  background: linear-gradient(180deg, var(--accent-soft), var(--bg-elev));
  border-color: oklch(0.85 0.08 142);
}

/* templates */
.template-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: default;
  transition: transform .15s, box-shadow .15s;
}
.template-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.template-thumb {
  height: 130px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.template-body { padding: 12px 14px; }
.template-title { font-size: 13px; font-weight: 600; }
.template-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; font-family: var(--font-mono); }

/* connect screen */
.connect-account {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
}
.connect-account .ca-info { flex: 1 1 200px; min-width: 0; }
.connect-account .ca-info .mono,
.connect-account .ca-info > div { overflow-wrap: anywhere; }
.connect-account .ca-actions { display: flex; flex-wrap: wrap; align-items: center; row-gap: 6px; }
/* On phones/tablets the action buttons drop to their own full-width row instead of
   overflowing the account info beside them. */
@media (max-width: 640px) {
  .connect-account > .spacer { display: none; }
  .connect-account .ca-actions { flex: 1 1 100%; }
  .connect-account .ca-actions .btn { flex: 0 0 auto; }
  .card-pad .row { flex-wrap: wrap; }
}
.connect-account.live { border-color: var(--success-line); }

.ig-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #FED576, #F47133, #BC3081, #4C63D2);
  flex-shrink: 0;
}
.tg-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(180deg, #4FB3F1, #2A8DD8);
  display: grid; place-items: center;
  color: white; font-weight: 700;
  flex-shrink: 0;
}
.tt-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: #0a0a0a;
  display: grid; place-items: center;
  color: white; font-weight: 700;
  flex-shrink: 0;
}

/* analytics */
.analytics-grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.analytics-grid-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.metric {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.metric-label { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.metric-value { font-size: 26px; font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.metric-delta { font-size: 11.5px; font-family: var(--font-mono); color: var(--accent-ink); }
.metric-delta.down { color: var(--danger); }

/* line chart */
.chart {
  padding: 16px 18px 20px;
  height: 220px;
  display: flex; flex-direction: column;
}
.chart svg { flex: 1; width: 100%; }

/* AI sparkle */
.ai-glow {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 600;
}

/* small dot bg pattern for connect */
.bg-dots {
  background-image: radial-gradient(circle, var(--line-2) 1px, transparent 1px);
  background-size: 18px 18px;
}

/* auth */
.auth-shell {
  min-height: 100vh;
  width: 100vw;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(480px, 1.1fr);
  overflow: hidden;
  background: var(--bg);
}
.auth-panel {
  display: flex;
  flex-direction: column;
  padding: 40px 56px;
  overflow-y: auto;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 48px;
}
.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 390px;
  width: 100%;
}
.auth-kicker {
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 8px;
}
.auth-title {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0 0 8px;
}
.auth-copy {
  color: var(--ink-3);
  font-size: 13.5px;
  margin-bottom: 28px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-form .form-row {
  margin-bottom: 0;
}
.auth-form label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.auth-check {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  font-size: 12px;
  margin-top: 2px;
}
.auth-check label {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth-divider span {
  color: var(--ink-3);
  font-size: 11px;
}
.auth-side {
  background: var(--bg-sunken);
  border-left: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.auth-hero {
  width: min(560px, 100%);
}
.auth-hero-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.auth-hero-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.auth-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 18px;
}
.auth-preview-stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-sunken);
  padding: 12px;
}
.auth-preview-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.auth-preview-label {
  color: var(--ink-3);
  font-size: 11px;
  margin-top: 4px;
}
.auth-flow {
  padding: 0 18px 18px;
}
.auth-flow-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.auth-flow-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  flex-shrink: 0;
}
.auth-footer {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--ink-3);
  font-size: 11.5px;
  margin-top: 32px;
}
.auth-link {
  color: var(--ink);
  font-weight: 500;
}
.auth-message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  font-size: 12.5px;
  margin-bottom: 10px;
}
.form-error,
.errorlist {
  color: var(--danger);
  font-size: 11.5px;
}
.errorlist {
  list-style: none;
  margin: 5px 0 0;
  padding: 0;
}

/* confirm pages */
.confirm-shell {
  flex: 1;
  overflow-y: auto;
}
.confirm-page {
  padding: 54px 24px;
  max-width: 720px;
  margin: 0 auto;
}
.danger-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: oklch(0.95 0.05 25);
  color: var(--danger);
  border: 1px solid oklch(0.85 0.07 25);
}
.danger-panel {
  padding: 12px 14px;
  background: oklch(0.97 0.025 25);
  border: 1px solid oklch(0.88 0.05 25);
  border-radius: 8px;
  color: oklch(0.36 0.11 25);
  font-size: 12.5px;
  line-height: 1.5;
}

/* scrollbars */
.scroll::-webkit-scrollbar, .inbox-list::-webkit-scrollbar, .chat-msgs::-webkit-scrollbar,
.copilot::-webkit-scrollbar, .builder-rail::-webkit-scrollbar, .builder-palette::-webkit-scrollbar,
.sidebar::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb, .inbox-list::-webkit-scrollbar-thumb, .chat-msgs::-webkit-scrollbar-thumb,
.copilot::-webkit-scrollbar-thumb, .builder-rail::-webkit-scrollbar-thumb, .builder-palette::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 6px;
  border: 2px solid var(--bg);
}

/* contacts */
.tag {
  display: inline-flex;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  background: var(--bg-sunken);
  color: var(--ink-2);
  border: 1px solid var(--line);
  margin-right: 4px;
}
.tag.hot { background: oklch(0.95 0.05 25); color: oklch(0.4 0.14 25); border-color: oklch(0.85 0.07 25); }
.tag.lead { background: var(--accent-soft); color: var(--accent-ink); border-color: oklch(0.85 0.08 142); }
.tag.cold { background: oklch(0.95 0.04 240); color: oklch(0.42 0.1 240); border-color: oklch(0.85 0.06 240); }

/* status indicator */
.status-on { color: var(--success-ink); }
.status-off { color: var(--ink-3); }

/* header logo dotted accent */
.brand-mark::after {
  content: "";
  display: block;
  width: 4px; height: 4px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: 9px;
  margin-top: -3px;
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
    overflow-y: auto;
  }
  .auth-panel {
    padding: 28px 24px;
  }
  .auth-main {
    max-width: 520px;
  }
  .auth-side {
    display: none;
  }
  .auth-footer {
    flex-wrap: wrap;
  }
}

@media (max-width: 1280px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3,
  .analytics-grid-three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .analytics-grid-main {
    grid-template-columns: minmax(0, 1fr);
  }
  .inbox {
    grid-template-columns: 300px minmax(0, 1fr);
  }
  .inbox > .copilot {
    display: none;
  }
  .chat-layout {
    grid-template-columns: minmax(0, 1fr) 300px !important;
  }
  .workflow-builder {
    grid-template-columns: 220px minmax(0, 1fr) 320px;
  }
  .workflow-inspector {
    width: auto;
  }
}

@media (max-width: 900px) {
  html,
  body {
    height: 100%;
  }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }
  /* Sidebar becomes a slide-in drawer on mobile (the Phoenix mobile pattern):
     full nav stays intact, it just slides off-canvas until the hamburger opens it. */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 272px; max-width: 86vw;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .28s var(--ease-soft);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .nav-toggle { display: inline-flex; }
  /* Dim scrim behind the open drawer. */
  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: hsl(222 47% 11% / .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s var(--ease-soft), visibility .28s;
  }
  .app.nav-open .nav-scrim { opacity: 1; visibility: visible; }
  .topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg-elev);
  }
  .topbar-spacer {
    flex: 1 1 auto;
  }
  .search {
    width: 100%;
    order: 10;
  }
  .scroll {
    min-height: 0;
  }
  .page {
    padding: 18px 14px 44px;
  }
  .page > .row {
    flex-wrap: wrap;
  }
  .grid-2,
  .grid-3,
  .grid-4,
  .analytics-grid-three {
    grid-template-columns: minmax(0, 1fr);
  }
  .card-head {
    padding: 12px 14px;
    flex-wrap: wrap;
  }
  .card-pad {
    padding: 14px;
  }
  .metric {
    padding: 14px;
  }
  .metric-value {
    font-size: 24px;
  }
  .workflow-index-tools,
  .workflow-index-row {
    grid-template-columns: minmax(0, 1fr);
    flex-direction: column;
    align-items: stretch;
  }
  .workflow-index-metrics {
    text-align: left;
  }
  .inbox {
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto;
    height: auto;
    min-height: 0;
  }
  .inbox-list {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .chat-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    overflow-y: auto;
    height: auto;
    min-height: 0;
  }
  .chat {
    min-height: 70vh;
  }
  .chat-head {
    padding: 12px 14px;
    flex-wrap: wrap;
  }
  .chat-msgs {
    padding: 16px 12px;
  }
  .msg {
    max-width: 92%;
  }
  .message-delete-form,
  .msg.me .message-delete-form {
    position: static;
    opacity: 1;
    transform: none;
    align-self: center;
  }
  .chat-compose {
    padding: 10px;
  }
  .compose-actions {
    flex-wrap: wrap;
  }
  .chat-layout .copilot {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }
  .workflow-builder {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(520px, 1fr) auto;
    overflow-y: auto;
  }
  .workflow-left {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 280px;
  }
  .workflow-palette-scroll {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .workflow-palette-item {
    margin-bottom: 0;
  }
  .workflow-canvas {
    min-height: 560px;
  }
  .workflow-canvas-toolbar {
    left: 12px;
    right: 12px;
    flex-wrap: wrap;
  }
  .workflow-stage {
    left: 16px;
    top: 86px;
    transform: scale(.78);
    transform-origin: top left;
  }
  .workflow-inspector {
    position: static;
    width: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
    box-shadow: none;
  }
  .workflow-minimap {
    display: none;
  }
  .connect-account {
    flex-wrap: wrap;
  }
  .chart {
    height: 240px;
    padding: 12px 14px 16px;
  }
  .tbl {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  /* The sidebar is a full drawer on mobile, so nav items keep their labels —
     no icon-only collapse here (that was for the old horizontal strip). */
  .topbar h1 {
    max-width: 58vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .theme-toggle {
    width: 54px;
  }
  .btn {
    white-space: normal;
  }
  .btn-icon {
    white-space: nowrap;
  }
  .thread-snippet {
    max-width: 54vw;
  }
  .chat-head .chip {
    max-width: 100%;
  }
  .msg {
    max-width: 100%;
  }
  .thread-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
  .bubble {
    font-size: 12.5px;
  }
  .compose-actions .muted {
    width: 100%;
  }
  .workflow-palette-scroll {
    grid-template-columns: minmax(0, 1fr);
  }
  .workflow-stage {
    transform: scale(.64);
  }
  .workflow-node {
    width: 220px;
  }
  .analytics-grid-main,
  .analytics-grid-three,
  .grid-2,
  .grid-3,
  .grid-4 {
    gap: 10px;
  }
  .auth-panel {
    padding: 24px 18px;
  }
  .auth-brand {
    margin-bottom: 28px;
  }
  .auth-title {
    font-size: 26px;
  }
  .auth-preview-grid {
    grid-template-columns: 1fr;
  }
}

/* Real Instagram profile pictures, layered over the initials placeholder. If the
   image is absent or fails to load (onerror removes it), the initials show through. */
.workspace-avatar, .thread-avatar, .sidebar-user-avatar { position: relative; overflow: hidden; }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
