/* 4b — one stylesheet, no build step (D5). Chat left, provenance viewer right. */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1c2733;
  background: #f4f6f8;
}

/* --- chat pane --- */
#chat-pane { flex: 1 1 60%; display: flex; flex-direction: column; min-width: 0; }
#chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid #dde3e9; background: #fff;
}
#chat-header h1 { margin: 0; font-size: 17px; }
#chat-header .sub { font-weight: 400; font-size: 13px; color: #64748b; margin-left: 8px; }
#new-query {
  flex: none; padding: 6px 14px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: #475569; font: inherit; font-size: 13px; cursor: pointer;
}
#new-query:hover { background: #eef2f7; color: #1c2733; }

#messages { flex: 1; overflow-y: auto; padding: 18px 20px; }
.msg { margin-bottom: 14px; max-width: 80ch; }
.msg .bubble { padding: 10px 14px; border-radius: 10px; white-space: pre-wrap; }
.msg.user { margin-left: auto; max-width: 60ch; }
.msg.user .bubble { background: #2563eb; color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant .bubble { background: #fff; border: 1px solid #dde3e9; border-bottom-left-radius: 3px; }
.msg.error .bubble { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.msg .meta { font-size: 12px; color: #64748b; margin: 6px 4px 0; }

.citations { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.chip {
  font: 12px/1.2 inherit; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; transition: filter .1s;
}
.chip:hover { filter: brightness(0.94); }
.chip.vector { background: #e0edff; border-color: #bcd6ff; color: #1d4ed8; }
.chip.graph  { background: #e6f6ec; border-color: #bfe8cd; color: #15803d; }
.chip.row-chip { background: #f1f5f9; border-color: #dbe2ea; color: #475569; }

#composer {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 20px; border-top: 1px solid #dde3e9; background: #fff;
}
#composer-row { display: flex; gap: 10px; }
#input { flex: 1; resize: none; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; }
#input:focus { outline: 2px solid #2563eb33; border-color: #2563eb; }
#send { padding: 0 22px; border: 0; border-radius: 8px; background: #2563eb; color: #fff; font: inherit; cursor: pointer; }
#send:disabled { background: #94a3b8; cursor: default; }

/* --- generated Cypher, collapsed under the answer it produced --- */
.cypher { margin: 8px 0 0; font-size: 12px; }
.cypher > summary { cursor: pointer; color: #15803d; width: fit-content; }
.cypher > summary:hover { text-decoration: underline; }
.cypher .fail-count { color: #b45309; }
.cypher pre {
  margin: 6px 0 0; padding: 9px 11px; overflow-x: auto;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px;
  font: 12px/1.5 ui-monospace, "SF Mono", Consolas, monospace;
}
.cypher pre.rejected { background: #fef7f2; border-color: #f3d3bd; }
.cypher .attempt { margin: 8px 0 0; color: #b45309; }
.cypher .attempt-error { margin: 4px 0 0; color: #991b1b; white-space: pre-wrap; }

/* --- provenance viewer --- */
#viewer {
  flex: 0 0 44%; max-width: 44%; display: flex; flex-direction: column;
  border-left: 1px solid #dde3e9; background: #fff;
}
#viewer[hidden] { display: none; }
#viewer-header {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid #dde3e9; background: #f8fafc;
}
.viewer-title strong { font-size: 15px; }
#viewer-section { color: #64748b; font-size: 13px; margin-left: 8px; }
#viewer-header nav { display: flex; align-items: center; gap: 12px; }
#viewer-pdf { font-size: 13px; color: #2563eb; text-decoration: none; }
#viewer-pdf:hover { text-decoration: underline; }
#viewer-close { border: 0; background: none; font-size: 15px; cursor: pointer; color: #64748b; }

#viewer-text {
  flex: 1; overflow-y: auto; margin: 0; padding: 16px 18px;
  font: 13px/1.55 ui-monospace, "SF Mono", Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
#viewer-text mark {
  background: #fde68a; border-radius: 3px; padding: 1px 2px;
  outline: 2px solid #f59e0b66;
}

@media (max-width: 900px) {
  body.viewer-open #chat-pane { display: none; }
  #viewer { flex: 1; max-width: 100%; }
}
