:root {
  --bg: #0a0a0b;
  --sidebar: #0f0f10;
  --panel: #131315;
  --panel2: #17171a;
  --border: #1f1f22;
  --border-hi: #2a2a2f;
  --text: #e5e5e5;
  --muted: #6b7280;
  --muted-hi: #9ca3af;
  --accent: #22c55e;
  --accent-dim: rgba(34,197,94,0.12);
  --danger: #ef4444;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ── APP LAYOUT ── */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 18px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand .logo {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  display: inline-flex; align-items: center; justify-content: center;
  color: #0a0a0b; font-size: 12px; font-weight: 800;
}
.nav-section {
  display: flex; flex-direction: column;
  margin-bottom: 16px;
}
.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 6px 10px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted-hi);
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  user-select: none;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel); color: var(--text); }
.nav-item .icon { width: 16px; font-size: 14px; display: inline-flex; justify-content: center; color: var(--muted); }
.nav-item.active .icon { color: var(--accent); }
.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: #0a0a0b;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}
.nav-item .badge.new { background: var(--accent-dim); color: var(--accent); }

.recent {
  padding: 0 10px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-bottom: 12px;
}
.recent-title {
  font-size: 11px; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.recent-item {
  font-size: 12.5px;
  color: var(--muted-hi);
  padding: 5px 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.recent-item:hover { color: var(--text); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.community-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px;
  font-size: 12px; color: var(--muted);
}
.community-row .icons { display: flex; gap: 6px; margin-left: auto; }
.community-row .icons span {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #0a0a0b;
}
.user-info { line-height: 1.2; min-width: 0; flex: 1; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-email { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── MAIN ── */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.topbar .pill {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}
.topbar .spacer { flex: 1; }
.topbar .icon-btn {
  width: 30px; height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.topbar .icon-btn:hover { color: var(--text); border-color: var(--border-hi); }
.topbar .status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
}
.topbar .status-dot.ok { background: var(--accent); }
.topbar .status-dot.err { background: var(--danger); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 40px;
}
.content-inner {
  max-width: 860px;
  margin: 0 auto;
}

/* ── SHARED UI ── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.tag {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}
.tag.queued { background: var(--accent-dim); color: var(--accent); }
.tag.running { color: var(--accent); background: transparent; border: 1px solid var(--accent); }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--border-hi); }
.btn.primary {
  background: var(--accent);
  color: #0a0a0b;
  border-color: var(--accent);
  font-weight: 600;
}
.btn.primary:hover { background: #16a34a; border-color: #16a34a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, textarea.input {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font: inherit;
}
.input:focus, textarea.input:focus { outline: none; border-color: var(--accent); }

/* ── CHAT FOOTER (used by chat page) ── */
.chat-footer {
  border-top: 1px solid var(--border);
  padding: 12px 24px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-footer-inner { max-width: 780px; margin: 0 auto; width: 100%; }
.suggest-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.suggest-chip {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted-hi);
}
.suggest-chip:hover { border-color: var(--border-hi); color: var(--text); }
.chat-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
}
.chat-input-row:focus-within { border-color: var(--border-hi); }
.chat-input-row textarea {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  resize: none;
  outline: none;
  min-height: 28px;
  max-height: 200px;
  padding: 4px 0;
}
.chat-input-row textarea::placeholder { color: var(--muted); }
.chat-send {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #0a0a0b;
  border: 0;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-send:disabled { background: var(--panel2); color: var(--muted); }

/* ── MESSAGES ── */
.messages { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  max-width: 80%;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
}
.msg.user .bubble { background: var(--panel2); }
.msg.error .bubble { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.empty-state { text-align: center; color: var(--muted); padding: 80px 20px; font-size: 14px; }
.empty-state h2 { font-size: 22px; color: var(--text); font-weight: 600; margin: 0 0 6px; }
