/* ProofedMesh chat UI.
 *
 * One stylesheet, no framework, no web fonts — a web font would be a
 * cross-origin fetch the CSP would have to allow, for a typeface.
 */

:root {
  --bg: #11131a;
  --panel: #171a23;
  --panel-2: #1e222d;
  --line: #2a2f3d;
  --text: #e6e8ee;
  --muted: #9aa2b4;
  --accent: #5b8def;
  --warn: #e0a34a;
  --error: #e05a5a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { font-weight: 650; letter-spacing: 0.01em; }
.brand-sub { color: var(--muted); font-weight: 400; margin-left: 0.5rem; }
.who { color: var(--muted); font-size: 0.9rem; }

.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 17rem 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 0.9rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.6rem;
}

.sidebar-title {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin: 0.6rem 0 0;
}

.conversation-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }

.conversation {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  background: transparent; border: 1px solid transparent; color: var(--text);
  padding: 0.5rem 0.6rem; border-radius: var(--radius);
  text-align: left; cursor: pointer; font: inherit;
}
.conversation:hover { background: var(--panel-2); }
.conversation.active { background: var(--panel-2); border-color: var(--line); }
.conversation-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); flex: none;
}
.badge-bound { color: var(--accent); border-color: var(--accent); }
.badge-aborted { color: var(--error); border-color: var(--error); }

.capabilities { margin-top: auto; display: flex; flex-direction: column; gap: 0.4rem; }
.capability-note {
  margin: 0; font-size: 0.8rem; color: var(--warn);
  border-left: 2px solid var(--warn); padding-left: 0.5rem;
}

.chat { min-width: 0; display: flex; flex-direction: column; }

.chat-state {
  margin: 0; padding: 0.6rem 1.1rem;
  background: var(--panel-2); border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 0.9rem;
}
.chat-state-error { color: var(--error); border-bottom-color: var(--error); }

.messages {
  list-style: none; margin: 0; padding: 1.1rem;
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.8rem;
}

.msg { max-width: 46rem; }
.msg-user { align-self: flex-end; }
.msg-head { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.76rem; color: var(--muted); }
.msg-body {
  margin-top: 0.2rem; padding: 0.6rem 0.8rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-user .msg-body { background: #1b2740; border-color: #2c3f66; }
.msg-system .msg-body { background: transparent; border-style: dashed; color: var(--muted); }
.msg-kind-error .msg-body { border-color: var(--error); color: #f2b5b5; }
.msg-kind-notice .msg-body { border-color: var(--warn); color: #ecc88f; }

.attachment {
  margin-top: 0.35rem; padding: 0.5rem 0.7rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2);
  display: flex; flex-direction: column; gap: 0.15rem;
}
.attachment-name { font-size: 0.86rem; }
.attachment-ref, .attachment-hash {
  font-size: 0.72rem; color: var(--muted); overflow-wrap: anywhere;
}

.approval-link {
  display: inline-block; margin-top: 0.4rem;
  color: var(--accent); font-size: 0.88rem;
}

.composer {
  border-top: 1px solid var(--line); background: var(--panel);
  padding: 0.7rem 1.1rem; display: flex; flex-direction: column; gap: 0.5rem;
}
.composer textarea {
  width: 100%; resize: vertical;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.55rem 0.7rem; font: inherit;
}
.composer-actions { display: flex; align-items: center; justify-content: space-between; }

.attach { color: var(--muted); font-size: 0.88rem; cursor: pointer; }
.attach:hover { color: var(--text); }

button.primary {
  background: var(--accent); color: #0b0e14; border: 0;
  padding: 0.45rem 0.9rem; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer;
}
button.primary:disabled { opacity: 0.55; cursor: default; }

.empty-hint { color: var(--muted); padding: 1.1rem; margin: 0; }

.toast {
  position: fixed; bottom: 1.1rem; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 0.55rem 0.9rem; border-radius: var(--radius);
  max-width: 44rem;
}
.toast-error { border-color: var(--error); color: #f2b5b5; }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
