:root {
  --bg: #171c2a;
  --glass: rgba(17, 21, 33, 0.86);
  --glass-strong: rgba(14, 18, 28, 0.96);
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef2fb;
  --muted: #9aa6c0;
  --accent: #7fdcff;
  --ok: #3ddc84;
  --warn: #ffcc4d;
  --err: #ff6b6b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
.muted { color: var(--muted); margin: 0; }

/* ── 顶栏 ── */
.topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 12px; align-items: center;
  padding: 14px 16px; pointer-events: none; z-index: 5; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px;
  background: var(--glass); border: 1px solid var(--line); padding: 8px 12px; border-radius: 999px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.actions { margin-left: auto; display: flex; gap: 8px; }
.actions .btn { background: var(--glass); backdrop-filter: blur(6px); }
.actions .btn-primary { background: var(--accent); }
.btn-small { padding: 5px 10px; font-size: 12.5px; }
.section-row.first { margin-top: 0; }
.company { background: var(--glass); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; font: inherit; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--glass); border: 1px solid var(--line); }
.pill-ok { color: var(--ok); } .pill-warn { color: var(--warn); } .pill-muted { color: var(--muted); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ── 3D 上方的标签（照截图：深色胶囊 + 彩色图标块） ── */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.tag { position: absolute; transform: translate(-50%, -100%); display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 8px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(6px); box-shadow: 0 8px 24px rgba(0,0,0,.35); white-space: nowrap; pointer-events: auto; cursor: pointer;
  transition: transform .15s ease, border-color .15s ease; }
.tag:hover, .tag:focus-visible { border-color: rgba(255,255,255,.28); outline: none; transform: translate(-50%, -100%) scale(1.04); }
.tag .team-icon { width: 30px; height: 30px; }
.tag-name { font-weight: 700; font-size: 14px; line-height: 1.1; }
.tag-sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #56627d; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.faces { display: flex; margin-left: 4px; }
.face { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #11151f; margin-left: -6px; font-size: 9px; display: grid; place-items: center; font-weight: 700; color: #11151f; }
.tag-brain { flex-direction: column; gap: 2px; padding: 8px 14px; text-align: center; cursor: pointer; }
.tag-brain .tag-name { color: var(--accent); letter-spacing: 2.5px; font-size: 12px; }
.tag-brain .tag-sub { justify-content: center; margin: 0; }

.team-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.team-icon svg { width: 60%; height: 60%; stroke: #fff; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ── 通知 ── */
.toasts { position: fixed; top: 64px; right: 16px; display: grid; gap: 8px; z-index: 6; width: min(300px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--glass);
  border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: in .3s ease; }
.toast .team-icon { width: 30px; height: 30px; }
.toast b { display: block; font-size: 13px; } .toast span { font-size: 12px; color: var(--muted); }
.toast.out { animation: out .35s ease forwards; }
@keyframes in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes out { to { opacity: 0; transform: translateX(16px); } }

/* ── 右侧面板 ── */
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100vw); z-index: 8; display: flex; flex-direction: column;
  background: var(--glass-strong); border-left: 1px solid var(--line); backdrop-filter: blur(10px);
  transform: translateX(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.panel.open { transform: none; }
.panel-head { display: flex; gap: 12px; align-items: center; padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.panel-titles { flex: 1; min-width: 0; }
.panel-titles h2 { margin: 0; font-size: 18px; }
.icon-btn { background: transparent; color: var(--muted); border: 1px solid var(--line); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.icon-btn:hover { color: var(--text); }
.panel-body { padding: 14px 16px; overflow-y: auto; flex: 1; min-height: 0; }
.section { margin: 6px 0 10px; font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.section-row { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.agents, .rooms, .messages { list-style: none; margin: 0; padding: 0; }
.agents li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #11151f; flex: none; }
.agents .who { flex: 1; min-width: 0; }
.agents .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agents .who small { color: var(--muted); }
.badge-head { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(127,220,255,.15); color: var(--accent); margin-left: 6px; }
.rooms li button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 12px; margin-bottom: 6px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--text); font: inherit; cursor: pointer; }
.rooms li button:hover { border-color: rgba(255,255,255,.25); }
.rooms .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { color: var(--muted); font-size: 12px; margin-top: 12px; }
.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 8px 14px; border: 1px solid var(--line); cursor: pointer; background: rgba(255,255,255,.06); color: var(--text); }
.btn-primary { background: var(--accent); color: #0e1320; border-color: transparent; }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: progress; }

.chat { display: flex; flex-direction: column; padding-bottom: 0; }
.back { background: none; border: none; color: var(--muted); font: inherit; cursor: pointer; padding: 0 0 10px; align-self: flex-start; }
.back:hover { color: var(--text); }
.chat-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.chat-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages { flex: 1; overflow-y: auto; padding: 14px 0; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg { max-width: 86%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg small { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.msg.you { align-self: flex-end; background: var(--accent); color: #0e1320; border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: rgba(255,255,255,.07); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.demo { border-style: dashed; }
.typing { align-self: flex-start; color: var(--muted); font-size: 12px; }
.composer { display: flex; gap: 8px; padding: 12px 0 16px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; font: inherit; color: var(--text); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.composer textarea:focus, .login input:focus, .company:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── 小地图 / 帮助 ── */
.minimap { position: fixed; right: 16px; bottom: 16px; width: 200px; height: 140px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); z-index: 3; }
.help { position: fixed; left: 16px; bottom: 16px; font-size: 12px; color: var(--muted); background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; z-index: 3; }
kbd { font: 11px/1 ui-monospace, monospace; padding: 2px 5px; border-radius: 4px; border: 1px solid var(--line); background: rgba(255,255,255,.06); }

/* ── 对话框（开部门 / 加成员 / 连接 MCP） ── */
.dialog { border: none; padding: 0; background: transparent; color: var(--text); width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.dialog::backdrop { background: rgba(10,13,20,.6); backdrop-filter: blur(4px); }
.dialog-card { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: grid; gap: 12px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; }
.fields { display: grid; gap: 12px; }
.fields label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.fields input, .fields textarea { font: inherit; color: var(--text); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; width: 100%; }
.fields textarea { resize: vertical; min-height: 70px; }
.fields input:focus, .fields textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.fields small { color: var(--muted); font-size: 12px; }
.code { position: relative; }
.code pre { margin: 0; padding: 12px 72px 12px 12px; background: #0b0f18; border: 1px solid var(--line); border-radius: 10px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; color: #d6e2ff; }
.code .copy { position: absolute; top: 6px; right: 6px; }
.tabs { display: flex; gap: 6px; }
.tabs button[aria-selected="true"] { background: rgba(127,220,255,.15); color: var(--accent); border-color: rgba(127,220,255,.4); }
.warn-box { background: rgba(255,204,77,.08); border: 1px solid rgba(255,204,77,.3); color: #ffe2a0; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; }

/* ── 登录 ── */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(10,13,20,.6); backdrop-filter: blur(4px); z-index: 20; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--glass-strong); border: 1px solid var(--line); border-radius: 18px; padding: 24px; display: grid; gap: 12px; }
.login-card h2 { margin: 0; }
.login label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login input { font: inherit; color: var(--text); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.error { color: var(--err); min-height: 1em; margin: 0; font-size: 13px; }

/* ── 窄屏：面板变底部抽屉，藏起次要元素 ── */
@media (max-width: 720px) {
  .panel { top: auto; height: 78vh; width: 100vw; border-left: none; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; transform: translateY(105%); }
  .minimap, .help { display: none; }
  /* 竖屏只留图标 + 名字：人数和状态点进面板看 */
  .tag { padding: 4px 8px 4px 4px; gap: 6px; border-radius: 9px; }
  .tag .team-icon { width: 20px; height: 20px; border-radius: 6px; }
  .tag-name { font-size: 11.5px; } .tag-sub, .faces { display: none; }
  .tag-brain { padding: 4px 10px; } .tag-brain .tag-name { font-size: 10px; letter-spacing: 1.5px; }
  .toasts { top: 58px; }
  .brand { padding: 11px; }
  .brand-name { display: none; }
  .status { display: none; }
  .actions .btn { padding: 7px 10px; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
