:root {
  --bg-page: #0d0d0f;
  --bg-widget: #17171a;
  --bg-bubble-bot: #2a2a2e;
  --bg-bubble-user: #2f6fed;
  --text-primary: #f2f2f3;
  --text-muted: #8a8a90;
  --header-bg: #131315;
  --accent: #f2b90c;
  --accent-purple: #6200EA;
  --border: #29292d;
  --step-webhook: #8a8a90;
  --step-conversation: #4f8cff;
  --step-internal: #f2b90c;
  --step-crm: #33c17c;
  --step-handoff: #ff6b6b;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-primary);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand .dot { color: var(--accent); }

.topbar nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  margin-left: 18px;
  padding: 6px 10px;
  border-radius: 6px;
}

.topbar nav a.active,
.topbar nav a:hover {
  color: var(--text-primary);
  background: var(--bg-bubble-bot);
}

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: calc(100vh - 49px);
}

/* ---------- Chat widget (left) ---------- */
.chat-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  padding: 24px;
  border-right: 1px solid var(--border);
}

.widget {
  width: 360px;
  height: 720px;
  background: var(--bg-widget);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid #2a2a2e;
}

.widget-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #1c1c1f;
  border-bottom: 1px solid var(--border);
}

.widget-header .back {
  color: #4f8cff;
  font-size: 20px;
  text-decoration: none;
}

.widget-header .category {
  color: #4f8cff;
  font-size: 13px;
  flex: 1;
}

.widget-header .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #d68b00);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.widget-header .agent-name {
  font-size: 14px;
  font-weight: 600;
}

.widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  margin-bottom: 10px;
}

.msg-row.bot { align-self: flex-start; }
.msg-row.user { align-self: flex-end; align-items: flex-end; }

.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.msg-row.bot .msg-bubble {
  background: var(--bg-bubble-bot);
  border-top-left-radius: 4px;
  color: var(--text-primary);
}

.msg-row.user .msg-bubble {
  background: var(--bg-bubble-user);
  border-top-right-radius: 4px;
  color: #fff;
}

.msg-bubble img { max-width: 100%; border-radius: 8px; margin-top: 6px; display: block; }

.typing-dots {
  display: inline-flex;
  gap: 3px;
  padding: 12px 14px;
  background: var(--bg-bubble-bot);
  border-radius: 16px;
  border-top-left-radius: 4px;
  width: fit-content;
}
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.widget-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-widget);
}

.widget-input .plus {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.widget-input input {
  flex: 1;
  background: transparent;
  border: 1.5px solid #3a3a3e;
  border-radius: 20px;
  padding: 9px 14px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.widget-input input::placeholder { color: var(--text-muted); }

.widget-input .send {
  color: var(--text-muted);
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.widget-input .send.ready { color: #4f8cff; }

.chat-controls {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

.btn {
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-widget);
  color: var(--text-primary);
  cursor: pointer;
}
.btn:hover { background: var(--bg-bubble-bot); }
.btn.primary { background: var(--accent); color: #1a1200; border-color: var(--accent); font-weight: 600; }

.status-pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--bg-bubble-bot);
  color: var(--text-muted);
  margin-top: 10px;
}
.status-pill.live { color: #33c17c; }
.status-pill.live::before { content: "● "; }

/* ---------- Steps panel (right) ---------- */
.steps-pane {
  overflow-y: auto;
  padding: 20px 24px;
  background: #0d0d0f;
}

.steps-pane h2 {
  font-size: 15px;
  margin: 0 0 4px;
}
.steps-pane .subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.step-card {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--bg-widget);
  border: 1px solid var(--border);
  border-left: 3px solid var(--step-internal);
  border-radius: 8px;
  animation: stepIn .25s ease-out;
}
@keyframes stepIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.step-card.webhook { border-left-color: var(--step-webhook); }
.step-card.conversation-api { border-left-color: var(--step-conversation); }
.step-card.internal { border-left-color: var(--step-internal); }
.step-card.crm { border-left-color: var(--step-crm); }
.step-card.handoff { border-left-color: var(--step-handoff); }

.step-icon { font-size: 18px; line-height: 1.4; flex-shrink: 0; }

.step-body { flex: 1; min-width: 0; }

.step-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.step-card.webhook .step-label { color: var(--step-webhook); }
.step-card.conversation-api .step-label { color: var(--step-conversation); }
.step-card.internal .step-label { color: var(--step-internal); }
.step-card.crm .step-label { color: var(--step-crm); }
.step-card.handoff .step-label { color: var(--step-handoff); }

.step-title { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.step-detail { font-size: 12px; color: var(--text-muted); word-break: break-word; }
.step-detail code {
  background: #000;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: #d0d0d5;
}
.step-badge {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 0;
  text-align: center;
}

/* ---------- Architecture / handoff page ---------- */
.doc-page { max-width: 920px; margin: 0 auto; padding: 40px 24px 80px; }
.doc-page h1 { font-size: 24px; margin-bottom: 6px; }
.doc-page .lede { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }
.doc-page h2 { font-size: 17px; margin: 40px 0 12px; }
.doc-page p { line-height: 1.6; color: #d6d6d8; font-size: 14px; }
.doc-page pre {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  color: #d0d0d5;
}
.diagram-wrap {
  background: var(--bg-widget);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 12px;
}
.diagram-wrap svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
