:root {
  --bg: #12141a;
  --panel: #1a1e27;
  --panel2: #212633;
  --text: #d7dce6;
  --muted: #7c8598;
  --accent: #5aa9e6;
  --human: #e6b45a;
  --claude: #c98a6b;
  --codex: #7fc98a;
  --danger: #e66a6a;
  --border: #2c3342;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  background: var(--accent); color: #0d1117; border: 0; border-radius: 6px;
  padding: 7px 14px; font-weight: 600; cursor: pointer;
}
button.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  font-weight: 400; padding: 3px 8px; font-size: 13px;
}
button.ghost:hover { color: var(--text); }
button.danger { color: var(--danger); }
input, textarea, select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px; font: inherit; width: 100%;
}
label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.stack button { margin-top: 4px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 18px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); }
.topbar-mid { flex: 1; display: flex; align-items: center; gap: 12px; }
.roomname { font-weight: 600; }
.logout button { font-size: 13px; }

.page { flex: 1; min-height: 0; padding: 20px; max-width: 900px; margin: 0 auto; width: 100%; }
.page.roompage { max-width: none; padding: 0; display: flex; }

.authbox { max-width: 380px; margin: 8vh auto; background: var(--panel);
  padding: 24px; border-radius: 10px; border: 1px solid var(--border); }
.authbox h1 { margin-top: 0; }

.roomlist ul { list-style: none; padding: 0; }
.roomcard { background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 10px; }
.roomcard.archived { opacity: 0.55; }
.roomcard .goal { color: var(--muted); font-size: 13px; margin-top: 4px; white-space: pre-wrap; }
.roomlist form { max-width: 480px; }

.room-layout { display: flex; flex: 1; min-height: 0; width: 100%; }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#message-list { flex: 1; overflow-y: auto; padding: 18px 22px; }
.compose { display: flex; gap: 10px; padding: 12px 22px; border-top: 1px solid var(--border);
  background: var(--panel); }
.compose textarea { resize: none; }

.msg { margin-bottom: 12px; max-width: 900px; }
.meta { display: flex; gap: 10px; align-items: baseline; }
.who { font-weight: 700; }
.kind-human { color: var(--human); }
.kind-claude { color: var(--claude); }
.kind-codex { color: var(--codex); }
.kind-other { color: var(--accent); }
.kind-system { color: var(--muted); }
.when { color: var(--muted); font-size: 12px; }
.mentions { color: var(--muted); font-size: 13px; }
.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.sysline { color: var(--muted); font-size: 13px; font-style: italic; }
.sysline.status { font-style: normal; }
.filecard { background: var(--panel2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; display: inline-block; }
.filedesc { color: var(--muted); font-size: 13px; margin-top: 4px; }

#sidebar { width: 340px; border-left: 1px solid var(--border); background: var(--panel);
  padding: 16px; overflow-y: auto; }
#sidebar h3 { margin: 4px 0 10px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
#sidebar h3 .count { background: var(--panel2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 8px; font-size: 11px; letter-spacing: 0;
  color: var(--muted); }
#filespanel { margin-top: 18px; }

.plist { list-style: none; padding: 0; margin: 0; }
.prow { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 8px; }
.prow-top { display: flex; align-items: center; gap: 7px; }
.prow-top .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; }
.dot.on, .dot.ready { background: #61d095; box-shadow: 0 0 5px #61d09577; }
.dot.off, .dot.offline { background: #4a5163; }
.dot.working { background: #61d095; box-shadow: 0 0 5px #61d09577;
  animation: dotblink 1s ease-in-out infinite; }
@keyframes dotblink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}
.pmeta { color: var(--muted); font-size: 11.5px; margin: 2px 0 0 16px; }
.pstatus { color: var(--text); font-size: 12.5px; margin: 6px 0 0 16px;
  padding-left: 8px; border-left: 2px solid var(--accent);
  white-space: pre-wrap; overflow-wrap: anywhere; }
.prole { color: var(--muted); font-size: 12px; margin: 5px 0 0 16px;
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.pactions { display: flex; gap: 4px; opacity: 0.35; transition: opacity 0.15s; }
.prow:hover .pactions { opacity: 1; }
.iconbtn { background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--muted); font-size: 13px; font-weight: 400; padding: 1px 6px;
  cursor: pointer; line-height: 1.4; }
.iconbtn:hover { border-color: var(--border); color: var(--text); }
.iconbtn.danger:hover { color: var(--danger); }

.addagent { margin: 4px 0 14px; }
.addagent summary { cursor: pointer; color: var(--muted); font-size: 13px;
  border: 1px dashed var(--border); border-radius: 8px; padding: 7px 12px;
  list-style: none; user-select: none; }
.addagent summary::-webkit-details-marker { display: none; }
.addagent summary:hover { color: var(--text); border-color: var(--muted); }
.addagent[open] summary { color: var(--text); margin-bottom: 10px; }
.addagent form { padding: 0 2px; }

.invite { background: var(--panel2); border: 1px solid var(--accent);
  border-radius: 8px; padding: 12px; margin: 10px 0; }
.cmd { background: #0d1017; padding: 10px; border-radius: 6px; font-size: 12px;
  user-select: all; white-space: pre-wrap; word-break: break-all; }
.invite-actions { margin-top: 8px; display: flex; gap: 8px; align-items: center; }

.flist { list-style: none; padding: 0; margin: 0; }
.flist li { padding: 7px 2px; border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere; }
.flist li:last-child { border-bottom: 0; }
.frow-top { font-size: 13.5px; }
.fmeta { color: var(--muted); font-size: 11.5px; margin: 1px 0 0 22px; }
.fdesc { color: var(--muted); font-size: 12px; margin: 2px 0 0 22px;
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 1;
  -webkit-box-orient: vertical; overflow: hidden; }

.settings { max-width: 560px; }
