/* BuildHall UI — colours come from the brand kit (variables.css: navy/amber/slate).
   Layout is a three-column shell: groups on the left, feed or thread in the
   middle, agents on the right. */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--bh-ink);
  background: var(--bh-slate-100);
  min-height: 100vh;
}

h1, h2, .brand span { font-family: "Space Grotesk", Inter, system-ui, sans-serif; }

/* --- top bar -------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bh-navy-900);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 1.1rem;
  box-shadow: 0 1px 3px rgb(10 37 64 / 22%);
}
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: #fff; }
.brand span { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.session { font-size: 0.88rem; color: var(--bh-navy-200); }
.session b { color: var(--bh-amber-500); }

/* --- shell ---------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr) 300px;
  gap: 1.1rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.1rem;
  align-items: start;
}
.rail { position: sticky; top: 68px; display: flex; flex-direction: column; gap: 1.1rem; }

.card {
  background: var(--bh-surface);
  border: 1px solid var(--bh-slate-200);
  border-radius: 12px;
  padding: 0.95rem 1rem;
}
.card h2 {
  margin: 0 0 0.7rem; font-size: 0.82rem; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--bh-slate-500);
}

.rail-nav { display: flex; flex-direction: column; gap: 0.3rem; }
.nav-item {
  text-align: left; background: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--bh-ink);
  padding: 0.6rem 0.8rem; border-radius: 10px;
}
.nav-item:hover { background: var(--bh-slate-200); }
.nav-item.active { background: var(--bh-navy-900); color: #fff; }

/* --- groups list ---------------------------------------------------------- */

.group-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.group-list li {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.6rem; border-radius: 9px; cursor: pointer; font-size: 0.94rem;
}
.group-list li:hover { background: var(--bh-slate-100); }
.group-list li.active { background: var(--bh-navy-50); color: var(--bh-navy-800); font-weight: 600; }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  background: var(--bh-navy-900); color: #fff;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}
.avatar.amber { background: var(--bh-amber-500); color: var(--bh-navy-900); }

/* --- centre column -------------------------------------------------------- */

.center { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.feed-head h1, .thread-title h1 { margin: 0; font-size: 1.4rem; letter-spacing: -0.02em; }
.feed-head { padding: 0 0.2rem; }
.muted { color: var(--bh-slate-500); font-size: 0.9rem; margin: 0.25rem 0 0; }

.feed { display: flex; flex-direction: column; gap: 1.1rem; }
.post {
  background: var(--bh-surface); border: 1px solid var(--bh-slate-200);
  border-radius: 12px; padding: 1rem 1.1rem;
}
.post-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.7rem; }
.post-head h3 { margin: 0; font-size: 1.02rem; font-family: "Space Grotesk", sans-serif; }
.post-meta { font-size: 0.8rem; color: var(--bh-slate-500); }
.post-body { font-size: 0.96rem; line-height: 1.5; }
.post-body .label {
  display: inline-block; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.07em; font-weight: 700; color: var(--bh-amber-700);
  background: var(--bh-amber-50); border: 1px solid var(--bh-amber-200);
  padding: 0.1rem 0.4rem; border-radius: 5px; margin-right: 0.45rem;
}
.post-foot {
  display: flex; align-items: center; gap: 0.6rem;
  margin-top: 0.9rem; padding-top: 0.75rem; border-top: 1px solid var(--bh-slate-200);
}

/* --- thread --------------------------------------------------------------- */

.thread-head {
  display: flex; align-items: flex-start; gap: 0.8rem;
  background: var(--bh-surface); border: 1px solid var(--bh-slate-200);
  border-radius: 12px; padding: 0.9rem 1rem;
}
.messages {
  background: var(--bh-surface); border: 1px solid var(--bh-slate-200);
  border-radius: 12px; padding: 0.9rem 1rem;
  min-height: 320px; max-height: 58vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.8rem;
}
.msg { display: flex; flex-direction: column; gap: 0.2rem; }
.msg .meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--bh-slate-500); }
.msg .author { font-weight: 600; color: var(--bh-navy-800); }
.msg .body { font-size: 0.96rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg.ai .body { border-left: 3px solid var(--bh-amber-500); padding-left: 0.65rem; }
.msg.checkpoint .body {
  background: var(--bh-amber-50); border: 1px solid var(--bh-amber-200);
  border-radius: 9px; padding: 0.6rem 0.75rem;
}
.msg.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--bh-amber-100); } to { background: transparent; } }

.badge {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  padding: 0.08rem 0.36rem; border-radius: 5px;
  background: var(--bh-slate-200); color: var(--bh-slate-700);
}
.badge.agent { background: var(--bh-amber-100); color: var(--bh-amber-800); }
.badge.checkpoint { background: var(--bh-navy-900); color: #fff; }

.checkpoint-banner {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--bh-navy-900); color: #fff;
  border-radius: 12px; padding: 0.7rem 0.9rem; font-size: 0.9rem;
}
.checkpoint-banner .cp-text { flex: 1; }
.checkpoint-banner .cp-when { color: var(--bh-navy-300); font-size: 0.78rem; }
.checkpoint-banner.clickable { cursor: pointer; }
.checkpoint-banner.clickable:hover { background: var(--bh-navy-800); }

/* --- composer ------------------------------------------------------------- */

.composer {
  background: var(--bh-surface); border: 1px solid var(--bh-slate-200);
  border-radius: 12px; padding: 0.8rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.composer textarea {
  width: 100%; resize: vertical; font: inherit; font-size: 0.95rem;
  border: 1px solid var(--bh-slate-300); border-radius: 9px; padding: 0.6rem 0.7rem;
}
.composer-row { display: flex; align-items: center; gap: 0.7rem; }
.grow { flex: 1; }

/* --- right rail ----------------------------------------------------------- */

.hint { font-size: 0.8rem; color: var(--bh-slate-500); line-height: 1.45; margin: 0 0 0.7rem; }
.bridge-list { list-style: none; margin: 0 0 0.7rem; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.bridge-list li {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem;
  background: var(--bh-slate-50); border: 1px solid var(--bh-slate-200);
  border-radius: 8px; padding: 0.4rem 0.55rem;
}
.bridge-list .name { flex: 1; font-weight: 600; }
.bridge-list li.revoked { opacity: 0.5; }
.reveal {
  margin-top: 0.7rem; padding: 0.6rem 0.7rem; border-radius: 9px;
  background: var(--bh-navy-950); color: var(--bh-slate-100);
  font-size: 0.76rem; word-break: break-all;
}
.reveal code { display: block; margin-top: 0.35rem; color: var(--bh-amber-500); font-size: 0.78rem; }

/* --- controls ------------------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: 0.5rem; }
input, select, textarea {
  font: inherit; font-size: 0.92rem; color: var(--bh-ink);
  border: 1px solid var(--bh-slate-300); border-radius: 9px;
  padding: 0.52rem 0.65rem; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--bh-navy-400); outline-offset: -1px; border-color: transparent;
}
.btn {
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--bh-slate-300); background: #fff; color: var(--bh-ink);
  border-radius: 9px; padding: 0.5rem 0.85rem;
}
.btn:hover { background: var(--bh-slate-100); }
.btn.primary { background: var(--bh-navy-900); border-color: var(--bh-navy-900); color: #fff; }
.btn.primary:hover { background: var(--bh-navy-800); }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; }
.btn.ghost:hover { background: rgb(255 255 255 / 12%); }
.btn.small { font-size: 0.82rem; padding: 0.32rem 0.6rem; }
.btn.tiny { font-size: 0.74rem; padding: 0.18rem 0.42rem; border-radius: 6px; }
.checkbox { display: flex; align-items: center; gap: 0.4rem; font-size: 0.86rem; color: var(--bh-slate-600); }
.checkbox input { width: auto; }
.linkish {
  background: none; border: 0; padding: 0; font: inherit; font-weight: 600;
  color: var(--bh-navy-600); cursor: pointer; text-decoration: underline;
}
.empty { font-size: 0.86rem; color: var(--bh-slate-500); margin: 0.4rem 0 0; }

.conn-status { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.16rem 0.45rem; border-radius: 999px; }
.conn-status.live { background: var(--bh-success-bg); color: var(--bh-success); }
.conn-status.reconnecting { background: var(--bh-amber-100); color: var(--bh-amber-800); }
.conn-status.offline { background: var(--bh-error-bg); color: var(--bh-error); }

/* --- auth ----------------------------------------------------------------- */

.auth {
  border: 0; border-radius: 14px; padding: 1.8rem 1.6rem; width: min(94vw, 380px);
  box-shadow: 0 18px 50px rgb(10 37 64 / 28%);
}
.auth::backdrop { background: rgb(10 37 64 / 60%); }
.auth-logo { display: block; margin: 0 auto 0.4rem; width: 140px; }
.auth .muted { text-align: center; margin-bottom: 0.5rem; }
.auth-error {
  background: var(--bh-error-bg); color: var(--bh-error);
  font-size: 0.85rem; border-radius: 8px; padding: 0.45rem 0.6rem; margin: 0;
}
.switch { text-align: center; font-size: 0.86rem; color: var(--bh-slate-500); margin: 0.2rem 0 0; }
.auth-h { text-align: center; font-size: 1.15rem; color: var(--bh-navy-900); margin: 0.2rem 0 0.6rem; }
.oauth-row { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.2rem; }
.btn.oauth {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; font-weight: 600; padding: 0.6rem;
}
.oauth-ic { display: inline-flex; align-items: center; }
.auth-divider {
  display: flex; align-items: center; text-align: center; gap: 0.6rem;
  color: var(--bh-slate-500); font-size: 0.8rem; margin: 0.7rem 0;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--bh-slate-200, #e5e7eb);
}

/* --- responsive ----------------------------------------------------------- */

@media (max-width: 1180px) {
  .shell { grid-template-columns: 260px minmax(0, 1fr); }
  .rail.right { display: none; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; padding: 0.8rem; }
  .rail { position: static; }
}

/* download card */
.btn.dl{display:block;text-align:center;text-decoration:none;margin-top:.2rem}
.dl-alt{text-align:center;margin-top:.5rem}
.cmdbox{display:flex;align-items:center;gap:.4rem;margin:.4rem 0;padding:.5rem .6rem;
  background:var(--bh-navy-900);border-radius:8px;overflow:hidden}
.cmdbox code{flex:1;min-width:0;color:var(--bh-amber-500);font-size:.76rem;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:nowrap;
  overflow-x:auto;-webkit-overflow-scrolling:touch}
.cmdbox .btn.small{flex:none;background:#fff;color:var(--bh-navy-900);border-color:#fff}

/* --- moderation ------------------------------------------------------------ */
.report-btn { margin-left: auto; font-size: 11px; color: #9ca3af; opacity: 0; transition: opacity .15s; }
.msg:hover .report-btn { opacity: 1; }
.report-btn:hover { color: #b91c1c; }

/* --- day separators --------------------------------------------------------- */
.day-sep {
  display: flex; align-items: center; gap: .7rem; margin: .4rem 0;
  color: var(--bh-slate-500); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
}
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--bh-slate-200); }

/* --- members card ------------------------------------------------------------ */
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.member-list li { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .88rem; }
.member-list .name { font-weight: 600; color: var(--bh-navy-800); }
