:root {
  --bg: #0b0d10;
  --bg2: #12151a;
  --bg3: #1a1f27;
  --border: #2a3140;
  --text: #e6edf7;
  --muted: #8b95a8;
  --accent: #7c9cff;
  --accent2: #5ce1b8;
  --danger: #ff6b7a;
  --warn: #f0c14a;
  --ok: #5ce1b8;
  --sidebar-w: 220px;
  --status-w: 240px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
}

button, input, textarea {
  font: inherit;
  color: inherit;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
}

button {
  cursor: pointer;
  padding: 6px 12px;
  background: linear-gradient(180deg, #1e2530, #161b22);
}
button:hover { border-color: var(--accent); }
button.primary {
  background: linear-gradient(180deg, #3a4f8c, #2a3a6a);
  border-color: #4a62a8;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.topbar .brand {
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.topbar .tag {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}
.topbar .spacer { flex: 1; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--status-w);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.sidebar, .status {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 10px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.status { border-right: none; border-left: 1px solid var(--border); }

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

.bot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 4px;
}
.bot:hover { background: var(--bg3); }
.bot.active {
  background: var(--bg3);
  border-color: var(--accent);
}
.bot .name { font-weight: 600; }
.bot .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted);
}
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--danger); }
.dot.off { background: #444; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.thread {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 860px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: #162033;
  border-color: #2a3f66;
}
.msg.bot {
  align-self: flex-start;
  background: var(--bg2);
}
.msg .who {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
  font-family: var(--mono);
  text-transform: uppercase;
}
.msg.error { border-color: var(--danger); color: #ffc0c6; }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 56px;
  padding: 8px 10px;
}
.composer .actions { display: flex; flex-direction: column; gap: 6px; }

.status dl {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 6px 8px;
}
.status dt { color: var(--muted); }
.status dd { font-family: var(--mono); font-size: 12px; word-break: break-all; }

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: radial-gradient(ellipse at top, #141a28, var(--bg));
}
.login-card {
  width: 360px;
  padding: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.login-card h1 {
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--accent);
}
.login-card p { color: var(--muted); margin-bottom: 16px; }
.login-card input {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.login-card .err { color: var(--danger); margin-bottom: 8px; min-height: 1.2em; }

.empty {
  color: var(--muted);
  padding: 40px 20px;
  text-align: center;
}

/* Status badges (configured vs not_configured) */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  border: 1px solid var(--border);
}
.badge-ok { color: var(--ok); border-color: #2a5a48; background: #12241c; }
.badge-off { color: #8b95a8; border-color: #333a48; background: #161a22; }
.badge-err { color: var(--danger); border-color: #5a2a32; background: #241218; }
.badge-warn { color: var(--warn); border-color: #5a4a20; background: #241e10; }
.badge-muted { color: var(--muted); }

.install-hint {
  text-align: left;
  margin: 16px auto 0;
  max-width: 640px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Rooms v0.3 */
.row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
button.tiny {
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1.2;
  min-width: 28px;
}
.empty-sm {
  color: var(--muted);
  padding: 8px 4px;
  font-size: 12px;
}
.room-item .name { font-weight: 600; }

.room-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.room-title {
  font-weight: 650;
  color: var(--accent2);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 11px;
  border-radius: 999px;
  background: #1a2436;
  border-color: #2a3f66;
  color: var(--accent);
}
.chip:hover { border-color: var(--accent2); color: var(--accent2); }
.chip-all { color: var(--accent2); }

.composer-wrap {
  position: relative;
  flex: 1;
  display: flex;
}
.composer-wrap textarea { width: 100%; }

.mention-pop {
  position: absolute;
  left: 0;
  bottom: calc(100% + 4px);
  min-width: 160px;
  max-width: 280px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 20;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mention-pop.hidden { display: none; }
.mention-item {
  text-align: left;
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 12px;
  border-radius: 4px;
}
.mention-item:hover { background: var(--bg2); border-color: transparent; color: var(--accent); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 92vw);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 18px 14px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal h2 { font-size: 15px; color: var(--accent); }
.modal .muted { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.modal label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.modal input[type="text"] {
  width: 100%;
  padding: 8px 10px;
}
.member-pick {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  background: var(--bg);
}
.pick-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  cursor: pointer;
}
.pick-row .meta { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.modal .err { color: var(--danger); min-height: 1.2em; font-size: 12px; }

/* v0.4 — Hermes sessions + typing indicator */
.session-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #0e1218;
}
.session-title {
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-actions { display: flex; gap: 6px; }

.session-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 8px;
  margin-bottom: 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.session-item:hover { background: var(--bg3); border-color: var(--border); }
.session-item.active {
  background: var(--bg3);
  border-color: var(--accent);
}
.session-item .s-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-item .s-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.msg.typing {
  min-width: 64px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 14px;
  padding: 2px 2px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}
