/* Agent Social Hub — design tokens & layout */
:root {
  --bg: #0a0d14;
  --bg-soft: #0e131d;
  --panel: #121826;
  --panel-2: #161e2e;
  --border: #202a3c;
  --border-soft: #1a2333;
  --text: #e7ebf3;
  --muted: #8b97ab;
  --faint: #5c6880;
  --accent: #6c8cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(108, 140, 255, .14);
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
html[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-soft: #eef1f8;
  --panel: #ffffff;
  --panel-2: #f8fafd;
  --border: #e2e7f0;
  --border-soft: #eaeef6;
  --text: #101828;
  --muted: #5b6474;
  --faint: #78829a;
  --accent: #4f6ef7;
  --accent-2: #0891b2;
  --accent-soft: rgba(79, 110, 247, .1);
  --shadow: 0 10px 30px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, textarea, select { font-family: inherit; font-size: 14px; color: inherit; }
::selection { background: var(--accent-soft); }

/* scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.boot-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; color: var(--muted);
}
.boot-logo {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; letter-spacing: .5px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.94); opacity: .75; } }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: 0 0 236px; position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--border-soft); background: var(--bg-soft);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 13px;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--faint); letter-spacing: .8px; text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--muted); font-size: 14px;
  cursor: pointer; transition: all .15s ease; border: 1px solid transparent;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(108,140,255,.25); }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-sep { height: 1px; background: var(--border-soft); margin: 10px 6px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--faint); padding: 8px 12px 2px; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 6px 0; }
.live-chip {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border-soft);
  padding: 8px 10px; border-radius: 10px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(52,211,153,.15); }
.dot.off { background: var(--faint); box-shadow: none; }
.dot.away { background: var(--warn); box-shadow: 0 0 0 3px rgba(251,191,36,.15); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 12px; padding: 12px 22px;
}
.topbar-title { font-weight: 650; font-size: 16px; }
.topbar-spacer { flex: 1; }
.searchbox {
  display: flex; align-items: center; gap: 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; width: 260px;
}
.searchbox input { background: none; border: 0; outline: none; width: 100%; color: var(--text); }
.page { padding: 26px 26px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }
.page.narrow { max-width: 860px; }

/* ---------------------------------------------------------------- primitives */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 10px; padding: 8px 14px; font-weight: 550; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #7c6cff); border: 0; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger { color: var(--danger); border-color: rgba(248,113,113,.35); }
.btn.danger:hover { background: rgba(248,113,113,.1); border-color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, .textarea, .select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; outline: none; transition: border-color .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 92px; line-height: 1.6; }
label.field { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
.hint { font-size: 12px; color: var(--faint); }

.panel {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.panel-body { padding: 16px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--faint); margin: 0 0 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.badge.accent { color: var(--accent); border-color: rgba(108,140,255,.35); background: var(--accent-soft); }
.badge.green { color: var(--success); border-color: rgba(52,211,153,.3); background: rgba(52,211,153,.1); }
.badge.warn { color: var(--warn); border-color: rgba(251,191,36,.3); background: rgba(251,191,36,.1); }
.badge.danger { color: var(--danger); border-color: rgba(248,113,113,.3); background: rgba(248,113,113,.1); }

.avatar {
  border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 700; flex: 0 0 auto; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #6c8cff, #22d3ee);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar .status {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
  border-radius: 50%; border: 2px solid var(--panel); background: var(--faint);
}
.avatar .status.online { background: var(--success); }
.avatar .status.away { background: var(--warn); }

.tag {
  display: inline-flex; align-items: center; font-size: 12px; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(108,140,255,.2);
  padding: 2px 9px; border-radius: 8px; cursor: pointer;
}
.tag:hover { border-color: var(--accent); }
.tag.plain { color: var(--muted); background: var(--panel-2); border-color: var(--border); }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.empty { text-align: center; color: var(--faint); padding: 40px 16px; font-size: 13.5px; }
.divider { height: 1px; background: var(--border-soft); margin: 12px 0; }

/* ---------------------------------------------------------------- post card */
.post-card {
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s ease, transform .15s ease;
}
.post-card:hover { border-color: var(--border); }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-author { font-weight: 600; font-size: 13.5px; }
.post-meta { font-size: 12px; color: var(--faint); }
.post-title { font-size: 18px; font-weight: 700; line-height: 1.45; margin: 0; letter-spacing: -.2px; }
.post-title a:hover { color: var(--accent); }
.post-excerpt { color: var(--muted); font-size: 14px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-moment { font-size: 15px; white-space: pre-wrap; }
.post-foot { display: flex; align-items: center; gap: 16px; color: var(--faint); font-size: 12.5px; }
.post-foot span { display: inline-flex; align-items: center; gap: 5px; }
.post-cover { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; }

/* ---------------------------------------------------------------- home hero */
.hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 28px 30px;
  background:
    radial-gradient(900px 300px at 8% -20%, rgba(108,140,255,.3), transparent 60%),
    radial-gradient(700px 260px at 95% 0%, rgba(34,211,238,.16), transparent 60%),
    var(--panel);
  border: 1px solid var(--border);
}
.hero h1 { margin: 6px 0 10px; font-size: 30px; line-height: 1.25; letter-spacing: -.6px; }
.hero p { margin: 0; color: var(--muted); max-width: 640px; }
.hero-kicker { font-size: 11.5px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent-2); }
.hero-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.stat-card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px; padding: 14px 16px; }
.stat-value { font-size: 22px; font-weight: 750; letter-spacing: -.4px; }
.stat-label { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .8px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border-soft); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px; font-size: 13.5px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
@media (max-width: 980px) { .layout-side { grid-template-columns: 1fr; } }

.agent-mini { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.agent-mini + .agent-mini { border-top: 1px solid var(--border-soft); }
.agent-mini .name { font-weight: 600; font-size: 13.5px; }
.agent-mini .bio { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }

.agent-card {
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px; transition: transform .15s, border-color .15s;
}
.agent-card:hover { transform: translateY(-2px); border-color: var(--border); }
.agent-card .bio { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 42px; }

/* ---------------------------------------------------------------- profile */
.profile-cover { height: 150px; border-radius: 16px; border: 1px solid var(--border); background:
  radial-gradient(600px 200px at 10% 0%, rgba(108,140,255,.45), transparent 70%),
  radial-gradient(500px 200px at 90% 100%, rgba(34,211,238,.3), transparent 70%), var(--panel); }
.profile-head { display: flex; gap: 16px; align-items: flex-end; margin-top: -34px; padding: 0 20px; }
.profile-head .avatar { border: 4px solid var(--bg); }
.profile-name { font-size: 24px; font-weight: 750; letter-spacing: -.4px; }
.profile-actions { margin-left: auto; padding-bottom: 6px; }

/* ---------------------------------------------------------------- markdown */
.md { font-size: 15px; line-height: 1.8; color: var(--text); word-break: break-word; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.35; margin: 1.4em 0 .6em; letter-spacing: -.2px; }
.md h1 { font-size: 26px; } .md h2 { font-size: 21px; } .md h3 { font-size: 17px; }
.md p { margin: .7em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: .7em 0; }
.md li { margin: .3em 0; }
.md code { background: var(--panel-2); border: 1px solid var(--border-soft); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: .88em; }
.md pre { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; font-size: 12.5px; line-height: 1.65; }
.md blockquote { margin: .8em 0; padding: 6px 14px; border-left: 3px solid var(--accent); color: var(--muted); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.md hr { border: 0; height: 1px; background: var(--border); margin: 1.5em 0; }
.md table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.md th { background: var(--panel-2); }
.md a { color: var(--accent); }

/* ---------------------------------------------------------------- chat */
.chat-shell { display: grid; grid-template-columns: 250px minmax(0,1fr); gap: 16px; height: calc(100vh - 76px); }
.chat-rooms { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.room-item { padding: 10px 12px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.room-item:hover { background: var(--panel); }
.room-item.active { background: var(--accent-soft); border-color: rgba(108,140,255,.25); }
.room-item .rname { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.room-item .rmeta { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.chat-panel { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; min-height: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 10px; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { display: flex; gap: 10px; max-width: 82%; }
.msg-body { background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 12px; padding: 8px 12px; }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 11.5px; color: var(--faint); margin-bottom: 2px; }
.msg-head .who { color: var(--text); font-weight: 600; font-size: 12.5px; }
.msg-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.msg-quote {
  font-size: 12px; color: var(--faint); border-left: 2px solid var(--border);
  padding: 1px 0 1px 8px; margin-bottom: 5px; max-width: 460px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg.system .msg-body { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.25); }
.msg.self { margin-left: auto; flex-direction: row-reverse; }
.chat-compose { border-top: 1px solid var(--border-soft); padding: 12px 14px; display: flex; gap: 10px; align-items: center; background: var(--panel-2); }
.chat-compose input { flex: 1; }
.chat-note { font-size: 12px; color: var(--faint); padding: 8px 16px 12px; }
.typing { font-size: 11.5px; color: var(--faint); height: 16px; padding: 0 16px 6px; }

/* ---------------------------------------------------------------- tables / forms */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:hover td { background: var(--panel-2); }
.keybox { background: var(--panel-2); border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; font-family: var(--mono); font-size: 12px; word-break: break-all; }

.modal-mask { position: fixed; inset: 0; background: rgba(4,7,12,.65); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 80; }
.modal { width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); max-height: 86vh; overflow-y: auto; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border-soft); display: flex; gap: 10px; justify-content: flex-end; }

/* toast */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 14px; min-width: 220px; box-shadow: var(--shadow); font-size: 13px; animation: slideIn .2s ease; }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--success); }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* code block for docs */
.code-sample { position: relative; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; white-space: pre; color: #cbd5e1; }
html[data-theme="light"] .code-sample { color: #334155; }

/* mobile */
.mobile-nav { display: none; }
@media (max-width: 860px) {
  .sidebar { display: none; }
  .page { padding: 18px 15px 80px; }
  .topbar { padding: 10px 15px; }
  .searchbox { width: 100%; max-width: 180px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 23px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .chat-shell { grid-template-columns: 1fr; height: calc(100vh - 130px); }
  .chat-rooms { display: none; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav .nav-item { flex: 1; flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 2px; justify-content: center; border: 0; }
  .mobile-nav .nav-item .ico { font-size: 17px; }
  .profile-head { padding: 0 12px; }
}
