/* achat read-only viewer (spec 13).
 *
 * Everything is in this file: the page ships a strict CSP with no
 * 'unsafe-inline', so there is no inline <style> and no style= attribute
 * anywhere, and app.js changes appearance by toggling classes and the
 * `hidden` attribute rather than by writing to element.style.
 */

:root {
  --bg: #12151a;
  --bg-raised: #171b22;
  --bg-sunken: #0d1015;
  --line: #262c36;
  --text: #d7dde6;
  --muted: #8b97a8;
  --accent: #6ea8fe;
  --green: #4ec98a;
  --amber: #d8a657;
  --red: #e5686b;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

/* --- token gate ------------------------------------------------------- */

.gate {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 13, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.gate-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  width: min(420px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gate-card h1 { margin: 0; font-size: 18px; }
.gate-hint { margin: 0; color: var(--muted); font-size: 12.5px; }
.gate-label { font-size: 12px; color: var(--muted); }

.gate-input {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--mono);
  padding: 9px 10px;
}

.gate-error { margin: 0; color: var(--red); font-size: 12.5px; }

.gate-submit {
  background: var(--accent);
  border: 0;
  border-radius: 5px;
  color: #0d1015;
  cursor: pointer;
  font-weight: 600;
  padding: 9px 12px;
}

/* --- chrome ----------------------------------------------------------- */

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
  padding: 8px 14px;
}

.brand { font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { color: var(--muted); font-size: 12px; }
.spacer { flex: 1 1 auto; }

.conn { font-size: 12px; color: var(--muted); }
.conn[data-state="live"] { color: var(--green); }
.conn[data-state="retry"] { color: var(--amber); }
.conn[data-state="error"] { color: var(--red); }

.linkish {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  padding: 2px 4px;
  text-decoration: underline;
}

.banner {
  background: #3a1f22;
  border-bottom: 1px solid #5a2f33;
  color: #f0c4c6;
  flex: 0 0 auto;
  font-size: 13px;
  margin: 0;
  padding: 8px 14px;
}

.columns {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 340px;
  flex: 1 1 auto;
  min-height: 0;
}

.col {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  padding: 10px 12px;
}

.col-rooms { border-right: 1px solid var(--line); }
.col-side { border-left: 1px solid var(--line); }

.col-center {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.col-title {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  margin: 4px 0 8px;
  text-transform: uppercase;
}

.empty { color: var(--muted); font-size: 12.5px; padding: 8px 12px; }

/* --- room list -------------------------------------------------------- */

.room-list { list-style: none; margin: 0; padding: 0; }

.room-button {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 5px;
  color: inherit;
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 7px;
  padding: 6px 8px;
  text-align: left;
  width: 100%;
}

.room-button:hover { background: var(--bg-raised); }
.room-button.is-selected { background: #1e2530; }

.dot {
  border-radius: 50%;
  flex: 0 0 auto;
  height: 8px;
  width: 8px;
}

.dot-online { background: var(--green); }
/* Offline is a filled, dim dot: we know the answer. Unknown is a hollow
 * ring: we have not asked. Archived is the dimmest, and only ever appears
 * in the room list. */
.dot-offline { background: #4a5464; }
.dot-unknown { background: transparent; border: 1px solid var(--muted); }
.dot-archived { background: var(--muted); opacity: 0.4; }

.room-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 0 4px;
  text-transform: uppercase;
}

.badge-dm { border-color: #3d4a63; color: var(--accent); }

.member-count { color: var(--muted); flex: 0 0 auto; font-size: 11.5px; }

/* --- timeline --------------------------------------------------------- */

.room-head {
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  padding: 10px 14px;
}

.room-title { font-size: 15px; margin: 0; }
.room-topic { color: var(--muted); font-size: 12.5px; margin: 3px 0 0; }

.timeline {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px 18px;
}

.msg {
  border-left: 2px solid transparent;
  margin: 0 0 10px;
  padding: 2px 0 2px 10px;
}

.msg-head {
  align-items: baseline;
  display: flex;
  gap: 8px;
  font-size: 12px;
}

.handle { color: var(--accent); font-weight: 600; }
.sender-key { color: var(--muted); font-size: 11.5px; }
.ts { color: var(--muted); font-size: 11.5px; }

.msg-body { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

.msg-text { border-left-color: #2c3442; }
.msg-system { border-left-color: var(--muted); }
.msg-system .msg-body { color: var(--muted); font-style: italic; }
.msg-task { border-left-color: var(--amber); }
.msg-artifact { border-left-color: var(--green); }
.msg-mentioned { background: #1b2330; }

.kind-tag {
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 0 4px;
  text-transform: uppercase;
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 5px;
  margin-top: 4px;
  padding: 7px 9px;
}

.card-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.card-title { font-weight: 600; }
.card-meta { color: var(--muted); font-size: 12px; }

.status {
  border-radius: 3px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  text-transform: uppercase;
}

.status-open { background: #2b3547; color: var(--accent); }
.status-accepted { background: #2b3547; color: var(--accent); }
.status-in_progress { background: #3a3122; color: var(--amber); }
.status-done { background: #1f3a2c; color: var(--green); }
.status-failed { background: #3a2224; color: var(--red); }
.status-cancelled { background: #262c36; color: var(--muted); }

.token-link {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-family: var(--mono);
  padding: 0;
  text-decoration: underline;
}

/* --- side panels ------------------------------------------------------ */

.tabs { display: flex; gap: 4px; margin-bottom: 10px; }

.tab {
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 4px 8px;
}

.tab.is-active { background: #1e2530; color: var(--text); }

.panel-note { color: var(--muted); font-size: 11.5px; margin: 0 0 8px; }

.member-list, .task-list, .artifact-list, .pad-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.member, .task, .artifact, .pad {
  border-bottom: 1px solid var(--line);
  padding: 7px 2px;
}

.member-head { align-items: center; display: flex; gap: 7px; }
.member-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.is-focused { background: #23303f; }

.filter-label { color: var(--muted); font-size: 11.5px; margin-right: 6px; }

.filter {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 3px 6px;
}

.pad-item {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 2px 0;
  text-align: left;
  width: 100%;
}

.pad-item:hover { color: var(--accent); }
.pin { color: var(--amber); }

.pad-bar { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.pad-name { font-size: 13.5px; margin: 0; }
.pad-meta { color: var(--muted); font-size: 11.5px; margin: 0 0 8px; }

/* --- markdown --------------------------------------------------------- */

.markdown { overflow-wrap: anywhere; }
.markdown h1 { font-size: 17px; margin: 12px 0 6px; }
.markdown h2 { font-size: 15px; margin: 12px 0 6px; }
.markdown h3, .markdown h4, .markdown h5, .markdown h6 { font-size: 13.5px; margin: 10px 0 5px; }
.markdown p { margin: 6px 0; }
.markdown ul, .markdown ol { margin: 6px 0; padding-left: 20px; }
.markdown li { margin: 2px 0; }
.markdown a { color: var(--accent); }

.markdown code {
  background: var(--bg-sunken);
  border-radius: 3px;
  padding: 1px 4px;
}

.markdown pre {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 5px;
  margin: 8px 0;
  overflow-x: auto;
  padding: 8px 10px;
}

.markdown pre code { background: none; padding: 0; }

.markdown blockquote {
  border-left: 3px solid var(--line);
  color: var(--muted);
  margin: 8px 0;
  padding: 0 0 0 10px;
}

.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* --- diff ------------------------------------------------------------- */

.diff {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 12px;
  margin-top: 10px;
  overflow-x: auto;
  padding: 6px 0;
}

.diff-line { padding: 0 10px; white-space: pre; }
.diff-add { background: #17311f; color: #9fe0b4; }
.diff-del { background: #331a1c; color: #f0a9ab; }
.diff-same { color: var(--muted); }
.diff-gap { color: var(--muted); padding: 2px 10px; }
.diff-empty { color: var(--muted); padding: 6px 10px; }
