/* Psychopathia Clinic — palette/typography align with mcp.html and main site. */

:root {
  --mcp-primary: #2c3e50;
  --mcp-primary-dark: #1a252f;
  --mcp-accent: #5a7a9b;
  --mcp-accent-warm: #a0826d;
  --mcp-surface: #fafafa;
  --mcp-card: #ffffff;
  --mcp-border: #e1e4e8;
  --mcp-code-bg: #f5f6f7;
  --mcp-text: #2c3e50;
  --mcp-text-muted: #5a6c7d;
  --mcp-warn: #b7791f;
  --mcp-warn-bg: #fbf5ec;
  --mcp-danger: #b91c1c;
  --mcp-danger-bg: #fef2f2;
  --mcp-ok: #047857;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', -apple-system, system-ui, sans-serif;
  background: var(--mcp-surface);
  color: var(--mcp-text);
  line-height: 1.6;
  font-size: 15px;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid var(--mcp-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  font-weight: 600;
  color: var(--mcp-primary);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.topbar .brand-tag {
  color: var(--mcp-text-muted);
  font-weight: 400;
  margin-left: 6px;
  font-size: 0.88rem;
}
.topbar .actions { display: flex; gap: 10px; align-items: center; }
.topbar .actions a,
.topbar .actions button {
  font: inherit;
  font-size: 0.82rem;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--mcp-border);
  background: var(--mcp-surface);
  color: var(--mcp-primary);
  cursor: pointer;
  text-decoration: none;
}
.topbar .actions a:hover,
.topbar .actions button:hover {
  border-color: var(--mcp-primary);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 0.73rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 999px;
  background: var(--mcp-warn-bg);
  color: var(--mcp-warn);
  border: 1px solid var(--mcp-warn);
}
.pill::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--mcp-warn);
  border-radius: 50%;
}

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0;
  /* 60px = site-nav height (see /css/site-nav.css) */
  min-height: calc(100vh - 60px);
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .provenance { display: none; }
}

/* ---- Chat pane ---- */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--mcp-surface);
}
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}
.msg {
  margin-bottom: 22px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--mcp-border);
}
.msg.user {
  background: #fff;
  border-color: var(--mcp-border);
}
.msg.assistant {
  background: var(--mcp-card);
}
.msg.tool {
  background: var(--mcp-code-bg);
  font-size: 0.85rem;
}
.msg.refuse {
  background: var(--mcp-danger-bg);
  border-color: var(--mcp-danger);
  border-left: 3px solid var(--mcp-danger);
  border-radius: 0 8px 8px 0;
}
.msg.refuse .refuse-title {
  color: var(--mcp-danger);
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.msg .role {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mcp-text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.msg .content {
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.assistant .content code {
  background: var(--mcp-code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.88em;
  font-family: 'SF Mono', Menlo, monospace;
}
.msg.tool details summary {
  cursor: pointer;
  color: var(--mcp-text-muted);
  list-style: none;
  font-size: 0.82rem;
}
.msg.tool details summary::-webkit-details-marker { display: none; }
.msg.tool details summary::before {
  content: '▸';
  margin-right: 6px;
  color: var(--mcp-text-muted);
}
.msg.tool details[open] summary::before { content: '▾'; }
.msg.tool pre {
  background: #fff;
  border: 1px solid var(--mcp-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0 0;
  font-size: 0.75rem;
  overflow-x: auto;
  max-height: 240px;
  font-family: 'SF Mono', Menlo, monospace;
}

/* ---- Input ---- */
.input-row {
  padding: 16px 32px 20px;
  border-top: 1px solid var(--mcp-border);
  background: #fff;
}
.input-row form {
  display: flex;
  gap: 10px;
  max-width: 820px;
  margin: 0 auto;
}
.input-row textarea {
  flex: 1;
  font: inherit;
  min-height: 46px;
  max-height: 200px;
  padding: 12px 14px;
  border: 1px solid var(--mcp-border);
  border-radius: 8px;
  resize: vertical;
  background: var(--mcp-surface);
  color: var(--mcp-text);
}
.input-row textarea:focus {
  outline: none;
  border-color: var(--mcp-primary);
}
.input-row button {
  font: inherit;
  padding: 12px 22px;
  border-radius: 8px;
  border: none;
  background: var(--mcp-primary);
  color: #fff;
  cursor: pointer;
  font-weight: 500;
}
.input-row button:disabled {
  background: var(--mcp-border);
  cursor: not-allowed;
}

.note {
  text-align: center;
  color: var(--mcp-text-muted);
  font-size: 0.78rem;
  padding: 10px 32px 0;
  max-width: 820px;
  margin: 0 auto;
}

/* ---- Provenance sidebar ---- */
.provenance {
  border-left: 1px solid var(--mcp-border);
  background: #fff;
  padding: 24px 22px;
  overflow-y: auto;
}
.provenance h2 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mcp-text-muted);
  margin: 0 0 14px;
}
.provenance h2:not(:first-child) {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--mcp-border);
}
.prov-item {
  padding: 10px 12px;
  background: var(--mcp-surface);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.83rem;
  border: 1px solid var(--mcp-border);
}
.prov-item .name { font-weight: 600; color: var(--mcp-primary); }
.prov-item .display-id {
  color: var(--mcp-text-muted);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.78rem;
  margin-right: 5px;
}
.prov-item .meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--mcp-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--mcp-code-bg);
  color: var(--mcp-text-muted);
  border: 1px solid var(--mcp-border);
}
.badge.warn {
  background: var(--mcp-warn-bg);
  color: var(--mcp-warn);
  border-color: var(--mcp-warn);
}
.badge.compromised {
  background: var(--mcp-danger-bg);
  color: var(--mcp-danger);
  border-color: var(--mcp-danger);
}
.badge.ok {
  background: #f0fdf4;
  color: var(--mcp-ok);
  border-color: var(--mcp-ok);
}

/* ---- Modal / interstitial ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 37, 47, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  padding: 28px 32px;
  box-shadow: 0 10px 40px rgba(26, 37, 47, 0.3);
}
.modal h2 {
  margin-top: 0;
  color: var(--mcp-primary);
  font-size: 1.25rem;
  font-weight: 600;
}
.modal .disclaimer {
  background: var(--mcp-warn-bg);
  border-left: 3px solid var(--mcp-warn);
  padding: 12px 14px;
  border-radius: 0 6px 6px 0;
  margin: 14px 0 18px;
  font-size: 0.88rem;
  color: var(--mcp-primary);
}
.modal .disclaimer strong { color: var(--mcp-warn); }
.modal label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin: 14px 0 4px;
  color: var(--mcp-primary);
}
.modal input[type="password"],
.modal input[type="text"],
.modal select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--mcp-border);
  border-radius: 6px;
  background: var(--mcp-surface);
  font-size: 0.93rem;
}
.modal input:focus, .modal select:focus {
  outline: none;
  border-color: var(--mcp-primary);
}
.modal .hint {
  font-size: 0.78rem;
  color: var(--mcp-text-muted);
  margin-top: 4px;
}
.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.modal .actions button {
  font: inherit;
  padding: 9px 20px;
  border-radius: 6px;
  border: 1px solid var(--mcp-border);
  background: #fff;
  cursor: pointer;
}
.modal .actions button.primary {
  background: var(--mcp-primary);
  color: #fff;
  border-color: var(--mcp-primary);
}
.modal .actions button.primary:hover { background: var(--mcp-primary-dark); }
.modal .actions button.primary:disabled {
  background: var(--mcp-border);
  border-color: var(--mcp-border);
  color: var(--mcp-text-muted);
  cursor: not-allowed;
}

.loader-line {
  font-size: 0.82rem;
  color: var(--mcp-text-muted);
  padding: 6px 32px 0;
  max-width: 820px;
  margin: 0 auto;
}

/* ---- Utility ---- */
.hidden { display: none !important; }
.muted { color: var(--mcp-text-muted); }
