/* ========================================
   Chat-graph page (/chat/<id>)
   Loaded only on chat pages via {% block head %}; does not affect /style.css.
   ======================================== */

.chat-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
}

.chat-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chat-provisional {
  font-size: 11px;
  background: rgba(241, 196, 15, 0.15);
  color: #d4a017;
  border: 1px solid rgba(241, 196, 15, 0.4);
  padding: 2px 8px;
  border-radius: 4px;
}

.chat-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.chat-meta-item { white-space: nowrap; }

.chat-rooted-link {
  color: var(--accent);
  text-decoration: none;
}
.chat-rooted-link:hover { text-decoration: underline; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 2px;
  scroll-behavior: smooth;
}

.chat-msg {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 92%;
}

.chat-msg-user {
  align-self: flex-end;
  max-width: 80%;
  background: rgba(106, 27, 154, 0.12);
  border-color: rgba(106, 27, 154, 0.35);
}

.chat-msg-assistant {
  align-self: flex-start;
}

.chat-msg-system {
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  align-self: center;
  max-width: 70%;
}

.chat-msg-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.chat-msg-content {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.chat-msg-source {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  opacity: 0.7;
}

.chat-msg-tools {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chat-msg-tools code {
  font-size: 11px;
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  color: #6A1B9A;
}

.chat-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 4px;
  font-style: italic;
}

.chat-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--muted);
  border-right-color: transparent;
  border-radius: 50%;
  animation: chat-spin 0.7s linear infinite;
}

@keyframes chat-spin {
  to { transform: rotate(360deg); }
}

.chat-input-form {
  display: flex;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
  min-height: 60px;
  max-height: 200px;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

#chatSendBtn {
  align-self: flex-end;
}
