:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #141b2e;
  --panel-2: #1a233a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8edff;
  --muted: #99a3c4;
  --accent: #7c9cff;
  --accent-2: #3dd9b4;
  --danger: #ff7b87;
  --warning: #ffc86b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #18213c 0%, var(--bg) 42%);
  color: var(--text);
}

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 380px;
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.card {
  background: rgba(20, 27, 46, 0.94);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.sidebar,
.right-rail,
.main {
  padding: 20px;
}

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  min-height: calc(100vh - 32px);
}

.right-rail {
  display: flex;
  flex-direction: column;
}

.stack { display: flex; flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p, pre { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 28px; }
h2 { margin-bottom: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.textarea { min-height: 96px; resize: vertical; }
.small-textarea { min-height: 84px; }

.button,
.ghost-button,
.mini-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button {
  color: #09111d;
  background: linear-gradient(135deg, var(--accent), #c2d1ff);
}

.button.secondary {
  background: linear-gradient(135deg, var(--accent-2), #9ef5e2);
}

.ghost-button,
.mini-button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--line);
}

.mini-button {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.mini-button.success { background: rgba(61, 217, 180, 0.14); }
.mini-button.danger { background: rgba(255, 123, 135, 0.16); }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head.tight { margin-bottom: 8px; }

.room-list,
.staff-list,
.note-list,
.task-list,
.data-source-list,
.ops-list,
.activity-state,
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-button,
.staff-card,
.note-card,
.task-card,
.data-source-card,
.system-card,
.message,
.empty-state,
.identity-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
}

.room-button {
  width: 100%;
  padding: 12px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.room-button span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.room-button.active {
  border-color: rgba(124, 156, 255, 0.7);
  background: rgba(124, 156, 255, 0.16);
}

.identity-card {
  padding: 12px;
}

.status-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-chip.online {
  color: #0c2516;
  background: #8effd5;
}

.message-list {
  overflow: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message,
.staff-card,
.note-card,
.task-card,
.data-source-card,
.empty-state {
  padding: 14px;
}

.message-meta,
.note-meta,
.staff-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.message-body,
.note-card p,
.staff-card p,
.task-card p,
.data-source-card pre {
  white-space: pre-wrap;
  line-height: 1.5;
}

.data-source-card pre {
  margin-bottom: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.composer { display: grid; gap: 10px; }
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.system-card { padding: 12px; }
.system-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.button-row.compact { margin-top: 12px; }

.pill {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
}

.pill.active { background: rgba(61, 217, 180, 0.14); color: #9ef5e2; }
.pill.asleep { background: rgba(124, 156, 255, 0.14); color: #c2d1ff; }
.pill.off { background: rgba(255, 123, 135, 0.12); color: #ffc0c8; }
.pill.backlog { background: rgba(124, 156, 255, 0.14); color: #c2d1ff; }
.pill.blocked { background: rgba(255, 200, 107, 0.14); color: #ffd98e; }
.pill.done { background: rgba(61, 217, 180, 0.14); color: #9ef5e2; }
.pill.info { background: rgba(124, 156, 255, 0.14); color: #c2d1ff; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 18, 0.78);
  display: grid;
  place-items: center;
  z-index: 20;
}

.overlay.hidden { display: none; }

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
}

.error-text {
  min-height: 20px;
  color: #ffc0c8;
  font-size: 13px;
}

@media (max-width: 1320px) {
  .shell { grid-template-columns: 1fr; }
  .main { min-height: auto; }
}
