/* ==========================================================================
   Bot Flow Explorer — Technical Blueprint Theme (Light + Dark)
   ========================================================================== */

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-alt: #f1f5fb;
  --border: #c9d6ea;
  --border-strong: #133b9c;
  --text: #10203a;
  --text-muted: #526582;
  --accent: #133b9c;
  --accent-hover: #0d2c78;
  --accent-soft: #e6eefc;
  --grid-line: rgba(19, 59, 156, 0.065);
  --line-idle: #9db2d3;
  --node-fill: #ffffff;
  --node-stroke: #133b9c;
  --node-active-fill: #eaf1ff;
  --iso-top: #ffffff;
  --iso-left: #dbe7fb;
  --iso-right: #b5ccf5;
  --iso-screen: #e8f1ff;
  --iso-shadow: rgba(19, 59, 156, 0.14);
  --iso-highlight: #2563eb;
  --code-bg: #0f1b33;
  --code-text: #dce8ff;
  --tg-bg: #e7eff9;
  --tg-user-bg: #133b9c;
  --tg-user-text: #ffffff;
  --tg-bot-bg: #ffffff;
  --tg-bot-text: #10203a;

  --cat-input: #2563eb;
  --cat-security: #d97706;
  --cat-engine: #7c3aed;
  --cat-data: #0d9488;
  --cat-output: #16a34a;

  --font-mono: "JetBrains Mono", "Cascadia Code", "IBM Plex Mono", Consolas, monospace;
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #0a101d;
  --surface: #11192b;
  --surface-alt: #17223a;
  --border: #253657;
  --border-strong: #5c8dff;
  --text: #e6eefc;
  --text-muted: #92a6c7;
  --accent: #5c8dff;
  --accent-hover: #7aa3ff;
  --accent-soft: rgba(92, 141, 255, 0.16);
  --grid-line: rgba(92, 141, 255, 0.085);
  --line-idle: #3c527a;
  --node-fill: #152036;
  --node-stroke: #6f9bff;
  --node-active-fill: #1c2d52;
  --iso-top: #1d2d4f;
  --iso-left: #16233e;
  --iso-right: #0f192d;
  --iso-screen: #243b6b;
  --iso-shadow: rgba(0, 0, 0, 0.42);
  --iso-highlight: #7aa3ff;
  --code-bg: #090e1a;
  --code-text: #cfe0ff;
  --tg-bg: #0d1526;
  --tg-user-bg: #2952b3;
  --tg-user-text: #ffffff;
  --tg-bot-bg: #18243d;
  --tg-bot-text: #e6eefc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo { color: var(--accent); display: flex; align-items: center; }

.brand-text h1 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--accent);
  line-height: 1.1;
}

.brand-text h1 em {
  font-style: italic;
  font-weight: 700;
}

.brand-text p {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

/* ---------- BUTTONS & SEGMENTED ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-icon { width: 34px; height: 34px; padding: 0; font-size: 15px; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { color: var(--accent); }
.seg-btn.active {
  background: var(--accent);
  color: #ffffff;
}

/* ---------- SUBBAR ---------- */
.subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 20px;
  background: var(--bg);
  flex-wrap: wrap;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}

.active-flow-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.active-flow-pill:hover {
  background: var(--accent-soft);
}

.active-pill-avatar {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.active-pill-bot {
  font-weight: 700;
  color: var(--text);
}

.active-pill-sep {
  color: var(--text-muted);
}

.active-pill-cmd {
  font-weight: 700;
  color: var(--accent);
}

.search-trigger:hover { border-color: var(--accent); }
.search-placeholder { flex: 1; }
.search-trigger kbd, .shortcuts-list kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-alt);
  color: var(--accent);
}

.subbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.layer-strip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layer-strip-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.layer-pills { display: flex; gap: 4px; flex-wrap: wrap; }

.layer-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-muted);
  transition: all 0.2s;
}

.layer-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ---------- MAIN WORKSPACE ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.95fr) minmax(320px, 1fr);
  gap: 14px;
  padding: 0 20px 14px;
}

.stage-card, .inspector-card, .timeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.stage-header, .inspector-header, .timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.inspector-header h2, .timeline-title-group h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.stage-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.chip-blue { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-neutral { background: var(--surface-alt); color: var(--text-muted); }
.chip-accent { background: rgba(22, 163, 74, 0.14); color: #15803d; border-color: rgba(22, 163, 74, 0.3); }
[data-theme="dark"] .chip-accent { color: #4ade80; }

/* ---------- STAGE VIEWS ---------- */
.stage-view { display: none; min-height: 430px; }
.stage-view.active { display: block; }

.canvas-wrapper {
  width: 100%;
  height: 430px;
  background-color: var(--surface);
  background-image:
    linear-gradient(30deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(150deg, var(--grid-line) 1px, transparent 1px);
  background-size: 36px 21px;
  position: relative;
}

#network-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* SVG elements */
.edge-line {
  stroke: var(--line-idle);
  stroke-width: 1.7;
  stroke-dasharray: 5 4;
  fill: none;
  transition: stroke 0.25s, stroke-width 0.25s;
}

.edge-line.active {
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-dasharray: 6 4;
  animation: dashMove 0.7s linear infinite;
}

@keyframes dashMove {
  to { stroke-dashoffset: -20; }
}

.node-group { cursor: pointer; }

.node-iso-art {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), filter 0.25s ease;
}

.node-iso-img {
  pointer-events: none;
  user-select: none;
}

[data-theme="dark"] .node-iso-img {
  filter: invert(0.92) hue-rotate(180deg) brightness(1.12) contrast(1.06);
}

.node-group:hover .node-iso-art {
  transform: translateY(-4px);
}

.node-group.active .node-iso-art {
  transform: translateY(-6px) scale(1.04);
  filter: url(#glow);
}

.node-active-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-dasharray: 5 4;
  opacity: 0;
  transition: opacity 0.25s;
}

.node-group.active .node-active-ring {
  opacity: 0.92;
  animation: ringPulse 1.8s ease-in-out infinite;
}

@keyframes ringPulse {
  0%, 100% { stroke-opacity: 0.95; stroke-width: 1.8; }
  50%      { stroke-opacity: 0.35; stroke-width: 2.6; }
}

.node-label-pill {
  fill: var(--surface);
  fill-opacity: 0.88;
  stroke: var(--border);
  stroke-width: 0.9;
}

.node-group.active .node-label-pill {
  stroke: var(--accent);
  fill-opacity: 0.96;
}

.node-group.visited .node-visited-dot {
  opacity: 1;
}

.node-visited-dot {
  opacity: 0;
  transition: opacity 0.2s;
}

.node-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  fill: var(--text);
}

.node-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--text-muted);
}

.packet-pill-rect {
  stroke: #ffffff;
  stroke-width: 1.5;
}

.packet-pill-text {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  fill: #ffffff;
}

.callout-rect {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 1.6;
}

.callout-text {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  fill: var(--accent);
}

/* ---------- FLOATING TELEGRAM OVERLAYS ON CANVAS ---------- */
.canvas-tg-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  padding: 16px;
  z-index: 10;
}

.canvas-tg-overlay.pos-start {
  align-items: flex-end;
  justify-content: flex-start;
}

.canvas-tg-overlay.pos-end {
  align-items: center;
  justify-content: flex-end;
}

.tg-float-card {
  pointer-events: auto;
  background: var(--surface);
  border: 1.5px solid #26a4e2;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(16, 32, 58, 0.18);
  overflow: hidden;
  animation: tgPopIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] .tg-float-card {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

@keyframes tgPopIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Step 1: Typing command in Telegram */
.tg-float-input {
  width: 340px;
  max-width: 88%;
}

.tg-float-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  background: #26a4e2;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.tg-float-close {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.85;
}

.tg-float-close:hover { opacity: 1; }

.tg-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--tg-bg);
}

.tg-composer-field {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  min-height: 34px;
  display: flex;
  align-items: center;
}

.tg-caret {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: #26a4e2;
  margin-left: 2px;
  animation: tgBlink 0.75s step-end infinite;
}

@keyframes tgBlink {
  50% { opacity: 0; }
}

.tg-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #26a4e2;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.tg-send-btn.sent {
  transform: scale(1.14);
  background: #16a34a;
}

/* Final Step: Rendered Telegram bot response */
.tg-float-reply {
  width: 390px;
  max-width: 92%;
  max-height: 365px;
  display: flex;
  flex-direction: column;
}

.tg-reply-body {
  padding: 12px 13px;
  background: var(--tg-bg);
  overflow-y: auto;
}

.tg-reply-bubble {
  background: var(--tg-bot-bg);
  color: var(--tg-bot-text);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.tg-reply-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.tg-ticks { color: #26a4e2; font-weight: 700; }

/* ---------- SEQUENCE VIEW ---------- */
.sequence-container {
  padding: 18px 20px;
  max-height: 430px;
  overflow-y: auto;
}

.seq-row {
  display: grid;
  grid-template-columns: 38px 135px 1fr 135px 86px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-bottom-color: var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11.5px;
  transition: background 0.15s, border-color 0.15s;
}

.seq-row:hover { background: var(--surface-alt); }
.seq-row.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.seq-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

.seq-node { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seq-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.seq-arrow-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
}

.seq-arrow-line {
  width: 100%;
  height: 2px;
  background: var(--accent);
  position: relative;
}

.seq-arrow-line::after {
  content: "▶";
  position: absolute;
  right: -2px;
  top: -7px;
  font-size: 10px;
  color: var(--accent);
}

.seq-time { text-align: right; color: var(--text-muted); font-size: 11px; }

/* ---------- TELEGRAM PREVIEW ---------- */
.tg-shell {
  display: flex;
  flex-direction: column;
  height: 430px;
  background: var(--tg-bg);
}

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

.tg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.tg-title-wrap { flex: 1; }
.tg-name { font-weight: 700; font-size: 13.5px; }
.tg-status { font-size: 11px; color: var(--text-muted); }

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

.tg-bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
}

.tg-bubble.user {
  align-self: flex-end;
  background: var(--tg-user-bg);
  color: var(--tg-user-text);
  border-color: transparent;
  font-family: var(--font-mono);
}

.tg-bubble.status {
  align-self: flex-start;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
}

.tg-bubble.bot {
  align-self: flex-start;
  background: var(--tg-bot-bg);
  color: var(--tg-bot-text);
  font-family: var(--font-sans);
}

.tg-bubble.bot code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface-alt);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ---------- INSPECTOR PANEL ---------- */
.inspector-body {
  padding: 16px;
  max-height: 430px;
  overflow-y: auto;
}

.ov-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ov-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--accent);
}

.ov-subtitle {
  margin: 4px 0 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.ov-desc {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 13.5px;
}

.cmd-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 14px;
}

.cmd-box code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.kv-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.kv-row {
  display: grid;
  grid-template-columns: 115px 1fr;
  gap: 8px;
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
}

.kv-key {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.kv-val { color: var(--text); word-break: break-word; }

.resilience-box {
  padding: 10px 12px;
  border-left: 3px solid var(--cat-security);
  background: var(--surface-alt);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  margin-top: 10px;
}

.resilience-box strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cat-security);
  margin-bottom: 3px;
}

.step-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.tech-block {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.tech-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.tech-pre {
  margin: 0;
  padding: 10px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-x: auto;
  line-height: 1.45;
}

/* ---------- TIMELINE BOTTOM ---------- */
.timeline-card { margin: 0 20px 20px; }

.timeline-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.legend { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.playback-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.speed-select {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.progress-track {
  height: 3px;
  background: var(--surface-alt);
  width: 100%;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.timeline-table-wrap { overflow-x: auto; }

.timeline-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

.timeline-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.timeline-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.timeline-table tbody tr { cursor: pointer; transition: background 0.12s; }
.timeline-table tbody tr:hover { background: var(--surface-alt); }
.timeline-table tbody tr.active { background: var(--accent-soft); }

.step-badge-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

/* ---------- DRAWER & MODALS ---------- */
.hidden { display: none !important; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 29, 0.45);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 340px;
  max-width: 90vw;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.drawer-search { padding: 10px 14px; border-bottom: 1px solid var(--border); }

.drawer-search input, .modal-head input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 20px;
}

.drawer-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

/* ---------- PRIVATE AUTH MODAL ---------- */
.btn-auth.unlocked {
  border-color: #16a34a;
  color: #16a34a;
}

.auth-body {
  padding: 14px 16px 18px;
}

.auth-desc {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.auth-tab {
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.auth-pane { display: none; }
.auth-pane.active { display: block; }

.auth-label {
  display: block;
  margin: 8px 0 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.auth-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  box-sizing: border-box;
}

.auth-status {
  margin-top: 12px;
  padding: 9px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
}

.auth-status.pending { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.auth-status.ok { border-color: #16a34a; color: #15803d; background: rgba(22, 163, 74, 0.08); }
.auth-status.err { border-color: #dc2626; color: #dc2626; background: rgba(220, 38, 38, 0.08); }

.accordion-group {
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--surface);
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 11px;
  background: var(--surface-alt);
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s;
}

.accordion-header:hover {
  background: var(--accent-soft);
}

.accordion-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.accordion-avatar {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.accordion-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.accordion-count {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.accordion-chevron {
  font-size: 11px;
  color: var(--accent);
  transition: transform 0.18s ease;
}

.accordion-group.open .accordion-chevron {
  transform: rotate(90deg);
}

.accordion-body {
  display: none;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.accordion-group.open .accordion-body {
  display: block;
}

.drawer-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: block;
}

.accordion-body .drawer-item:last-child {
  margin-bottom: 0;
}

.drawer-item:hover { border-color: var(--accent); }
.drawer-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.drawer-item-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--accent);
}

.drawer-item-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 29, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 60;
}

.modal-box {
  width: 560px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.modal-sm { width: 420px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
}

.modal-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 10px 14px;
}

.shortcuts-list {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.shortcuts-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 9px 14px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: 4px;
  z-index: 80;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1020px) {
  .workspace { grid-template-columns: 1fr; }
  .inspector-body { max-height: none; }
}

@media (max-width: 640px) {
  .topbar, .subbar, .workspace { padding-left: 12px; padding-right: 12px; }
  .timeline-card { margin: 0 12px 16px; }
  .seq-row { grid-template-columns: 30px 95px 1fr 95px 60px; font-size: 10.5px; }
}
