/* Live chat + LangGraph UI */

* { box-sizing: border-box; }
body.chat-standalone,
.chat-app-mount.chat-page {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f5f7;
  color: #111827;
}
.dev-banner {
  text-align: center;
  padding: 8px 16px;
  background: #f59e0b;
  color: #1f2937;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.dev-banner a { color: #1f2937; text-decoration: underline; }
html.chat-embed .app-wrap {
  min-height: 100%;
}
.app-wrap {
  display: flex;
  min-height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
}
.chat-column {
  flex: 1;
  min-width: 0;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
}
.graph-column {
  width: 400px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}
h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.version {
  font-size: 0.7rem;
  color: #9ca3af;
  font-weight: 400;
  vertical-align: middle;
  margin-left: 6px;
}
.subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
}
.chat-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  padding: 20px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
.messages {
  flex: 1;
  min-height: 200px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* When viewing a loaded transcript, messages fill the whole chat card */
.chat-card.transcript-view .messages {
  max-height: none;
}
.bubble {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 90%;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.user {
  align-self: flex-end;
  background: #2563eb;
  color: white;
  border-bottom-right-radius: 4px;
}
.bubble.bot {
  align-self: flex-start;
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 4px;
}
.bubble.thinking {
  align-self: flex-start;
  background: #f3f4f6;
  color: #9ca3af;
  font-style: italic;
  border-bottom-left-radius: 4px;
}
.input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: flex-end;
}
textarea {
  flex: 1;
  min-height: 60px;
  max-height: 120px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  font-size: 0.9rem;
  font-family: inherit;
}
textarea:focus {
  outline: 2px solid #2563eb33;
  border-color: #2563eb;
}
button {
  border: none;
  background: #2563eb;
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
button:disabled { opacity: 0.5; cursor: default; }
.footer-note {
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: center;
  margin-top: 4px;
}
.upload-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.transcript-btn {
  background: #f3f4f6;
  color: #374151;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.transcript-btn:hover { background: #e5e7eb; }
.transcript-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px;
}
.transcript-bar .filename {
  font-size: 0.8rem;
  color: #6b7280;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble.llm-entry {
  align-self: flex-start;
  background: #fef9c3;
  color: #92400e;
  font-size: 0.78rem;
  border-bottom-left-radius: 4px;
  font-family: monospace;
}

/* Graph panel */
.graph-panel h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: #374151;
}
.graph-svg-wrap {
  flex: 1;
  min-height: 320px;
  min-width: 0;
  width: 100%;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}
.graph-svg-wrap svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}
.graph-node {
  fill: #f3f4f6;
  stroke: #d1d5db;
  stroke-width: 1.5;
  rx: 6;
  transition: fill 0.15s, stroke 0.15s, filter 0.15s;
}
.graph-node.active {
  fill: #dbeafe;
  stroke: #2563eb;
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.4));
}
.graph-node.llm-active {
  fill: #fef3c7;
  stroke: #f59e0b;
  stroke-width: 2;
  animation: pulse-llm 0.8s ease-in-out infinite;
}
.graph-node.handoff {
  /* Same as default node when inactive — orange only when .active */
  fill: #f3f4f6;
  stroke: #d1d5db;
  stroke-width: 1.5;
}
.graph-node.handoff.active {
  fill: #ffedd5;
  stroke: #ea580c;
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(234, 88, 12, 0.4));
}
@keyframes pulse-llm {
  50% { filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.6)); }
}
.graph-edge {
  stroke: #d1d5db;
  stroke-width: 1.5;
  fill: none;
  transition: stroke 0.15s, stroke-width 0.15s;
}
.graph-edge.taken {
  stroke: #2563eb;
  stroke-width: 2.5;
}
.graph-node-label {
  font-size: 10px;
  fill: #374151;
  font-weight: 500;
  pointer-events: none;
}
.graph-internal-group rect {
  fill: rgba(37, 99, 235, 0.06);
  stroke: rgba(37, 99, 235, 0.25);
  stroke-width: 1;
}
.graph-internal-label {
  font-size: 9px;
  fill: #6b7280;
  font-weight: 600;
}
.graph-legend {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-size: 0.75rem;
  color: #6b7280;
}
.graph-legend span { margin-right: 10px; }
.graph-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.graph-legend .dot.active { background: #2563eb; }
.graph-legend .dot.llm { background: #f59e0b; }
.graph-status {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 8px;
  min-height: 1.2em;
}
.graph-3d-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}
.graph-3d-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 8px 0;
}
.graph-3d-wrap {
  position: relative;
  width: 100%;
  min-width: 200px;
  height: 260px;
  min-height: 200px;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #020617 100%);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.4);
}

.graph-3d-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.graph-3d-hint {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 6px;
}
.graph-state-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}
.graph-state-panel h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 4px 0;
}
.graph-state-panel .llm-meta {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-bottom: 8px;
  display: block;
}
.graph-state-wrap {
  max-height: 240px;
  overflow: auto;
  background: #f9fafb;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  color: #374151;
}
.graph-state-wrap .state-row {
  word-break: break-all;
}
.graph-state-wrap .state-key {
  color: #6b7280;
  margin-right: 6px;
}
.graph-state-wrap .state-null {
  color: #9ca3af;
  font-style: italic;
}

/* Graph toggle button (mobile only) */
.graph-toggle {
  display: none;
  width: 100%;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  margin-bottom: 8px;
}
.graph-toggle::after { content: " ▸"; }
.graph-toggle.open::after { content: " ▾"; }

/* ── Mobile responsive ── */
@media (max-width: 768px) {
  .app-wrap {
    flex-direction: column;
    min-height: 100dvh;
  }
  .chat-column {
    padding: 16px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  h1 { font-size: 1.3rem; }
  .subtitle { font-size: 0.82rem; margin-bottom: 1rem; }
  .chat-card {
    padding: 14px 12px 12px;
    border-radius: 12px;
  }
  .messages {
    max-height: 55vh;
    min-height: 140px;
  }
  textarea {
    font-size: 16px;
    min-height: 48px;
    max-height: 96px;
    resize: none;
    padding: 10px 12px;
  }
  button {
    padding: 14px 20px;
    font-size: 16px;
    min-height: 48px;
  }
  .footer-note { display: none; }
  .graph-toggle { display: block; }
  .graph-column {
    width: 100%;
    border-left: none;
    border-top: 1px solid #e5e7eb;
    padding: 12px;
    display: none;
  }
  .graph-column.visible { display: flex; }
  .graph-svg-wrap { min-height: 0; }
  .graph-svg-wrap svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
  }
}
    