* { box-sizing: border-box; margin: 0; padding: 0; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
:root {
  --bg1: #1a1c2e; --bg2: #232645; --panel: #ffffff; --ink: #1f2233;
  --muted: #8890a8; --line: #e6e8f0;
  --leader: #6c5ce7; --leader-soft: #efecff;
  --agent: #0984e3; --agent-soft: #eaf4ff;
  --human: #00b894; --sys: #b2bec3;
  --accent: #6c5ce7;
}
body {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #1a1c2e 0%, #2a2d52 100%);
  color: var(--ink); min-height: 100vh; -webkit-font-smoothing: antialiased;
}
.app { max-width: 1080px; margin: 0 auto; padding: 16px 14px 120px;
  display: grid; grid-template-columns: 240px 1fr; grid-template-areas:
  "top top" "roster chat" "roster composer" "roster foot"; gap: 14px; }
.topbar { grid-area: top; text-align: center; padding: 6px 0 2px; }
.topbar h1 { font-size: 24px; letter-spacing: 3px; color: #fff; }
.topbar .sub { font-size: 12px; color: #aab0d0; margin-top: 4px; }
.hidden { display: none !important; }

/* 用户徽标 */
.user-badge { position: absolute; top: 10px; right: 14px; font-size: 12px;
  color: #cfd3ec; display: flex; align-items: center; gap: 6px; }
.user-badge .admin-tag { background: var(--leader); color: #fff; border-radius: 6px;
  padding: 1px 6px; font-size: 10px; }
.user-badge .link { background: none; border: 1px solid #4a4f78; color: #cfd3ec;
  border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 11px; }
.user-badge .link:hover { border-color: var(--leader); color: #fff; }
.topbar { position: relative; }

/* 登录遮罩 */
.auth-overlay { position: fixed; inset: 0; z-index: 100; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #1a1c2e 0%, #2a2d52 100%); }
.auth-card { background: #fff; border-radius: 18px; padding: 32px 28px; width: 100%;
  max-width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.4); text-align: center; }
.auth-card h2 { font-size: 24px; letter-spacing: 3px; color: var(--leader); margin-bottom: 6px; }
.auth-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 20px; line-height: 1.6; }
.auth-card input { width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font-size: 14px; margin-bottom: 11px; outline: none; color: var(--ink); }
.auth-card input:focus { border-color: var(--leader); }
.auth-err { color: #e74c3c; font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }
.auth-btns { display: flex; gap: 10px; }
.auth-btns button { flex: 1; border-radius: 10px; padding: 11px 0; font-size: 14px;
  cursor: pointer; border: none; transition: filter .15s; }
.auth-btns .primary { background: var(--leader); color: #fff; }
.auth-btns .primary:hover { filter: brightness(1.08); }
.auth-btns .ghost { background: var(--leader-soft); color: var(--leader); }
.auth-hint { font-size: 11.5px; color: var(--muted); margin-top: 14px; line-height: 1.6; }
.blur { filter: blur(3px); pointer-events: none; user-select: none; }

/* 花名册侧栏 */
.roster { grid-area: roster; background: rgba(255,255,255,.06); border-radius: 14px;
  padding: 14px 12px; align-self: start; position: sticky; top: 12px; }
.roster-title { font-size: 13px; color: #cfd3ec; margin-bottom: 10px; font-weight: 600; }
.roster-title span { color: var(--accent); background: #fff; border-radius: 8px;
  padding: 0 7px; margin-left: 4px; font-size: 12px; }
.roster-list { display: flex; flex-direction: column; gap: 8px; }
.roster-empty { font-size: 12px; color: #9097b8; line-height: 1.6; }
.rcard { background: rgba(255,255,255,.95); border-radius: 10px; padding: 9px 10px;
  animation: pop .3s ease; }
.rcard .rname { font-size: 13px; font-weight: 600; color: var(--ink); }
.rcard .rrole { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.rcard .rdomain { display: inline-block; font-size: 10px; color: var(--agent);
  background: var(--agent-soft); border-radius: 6px; padding: 1px 6px; margin-top: 5px; }

/* 聊天主区 */
.chat { grid-area: chat; background: var(--panel); border-radius: 16px;
  padding: 18px; min-height: 60vh; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.welcome { text-align: center; padding: 30px 16px; }
.welcome h2 { font-size: 19px; color: var(--ink); margin-bottom: 10px; }
.welcome p { font-size: 13px; color: var(--muted); line-height: 1.7; max-width: 560px;
  margin: 0 auto 20px; }
.examples { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.examples button { background: var(--leader-soft); color: var(--leader); border: none;
  border-radius: 10px; padding: 10px 14px; font-size: 13px; cursor: pointer;
  transition: transform .12s; }
.examples button:hover { transform: translateY(-2px); }

/* 消息气泡 */
.messages { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; flex-direction: column; max-width: 86%; animation: pop .3s ease; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; padding: 0 4px;
  display: flex; align-items: center; gap: 6px; }
.msg .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.msg .bubble { border-radius: 14px; padding: 11px 14px; font-size: 14px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; }

/* human 靠右 */
.msg.human { align-self: flex-end; align-items: flex-end; }
.msg.human .bubble { background: var(--human); color: #fff; border-bottom-right-radius: 4px; }
.msg.human .dot { background: var(--human); }

/* leader */
.msg.leader .bubble { background: var(--leader-soft); color: #2d2456;
  border-left: 3px solid var(--leader); border-bottom-left-radius: 4px; }
.msg.leader .dot { background: var(--leader); }

/* agent */
.msg.agent .bubble { background: var(--agent-soft); color: #0a3d62;
  border-bottom-left-radius: 4px; }
.msg.agent .dot { background: var(--agent); }

/* system 居中细条 */
.msg.system { align-self: center; max-width: 92%; }
.msg.system .bubble { background: #f4f5f8; color: #7a8094; font-size: 12.5px;
  border-radius: 20px; padding: 6px 14px; text-align: center; }
.msg.system .who { display: none; }

/* leader 的最终总结(含 markdown) 用更醒目的卡片 */
.msg.summary .bubble { background: #fff; border: 1.5px solid var(--leader);
  box-shadow: 0 4px 16px rgba(108,92,231,.15); color: var(--ink); }
.msg.summary h1, .msg.summary h2, .msg.summary h3 { font-size: 15px; margin: 10px 0 6px;
  color: var(--leader); }
.msg.summary ul, .msg.summary ol { margin: 6px 0 6px 20px; }
.msg.summary li { margin: 3px 0; }
.msg.summary strong { color: #2d2456; }
.msg.summary p { margin: 6px 0; }

/* "正在思考" 跳动点 */
.typing .bubble { display: inline-flex; gap: 4px; align-items: center; }
.typing .b { width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite; }
.typing .b:nth-child(2) { animation-delay: .2s; }
.typing .b:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 输入区 */
.composer { grid-area: composer; display: flex; gap: 10px; background: var(--panel);
  border-radius: 14px; padding: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.composer textarea { flex: 1; border: none; resize: none; font-size: 14px; outline: none;
  font-family: inherit; line-height: 1.5; max-height: 120px; color: var(--ink); }
.send { background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 0 18px; font-size: 14px; cursor: pointer; white-space: nowrap; transition: filter .15s; }
.send:hover { filter: brightness(1.08); }
.send:disabled { background: #b6b0e8; cursor: not-allowed; }

/* 脚注/状态 */
.footnote { grid-area: foot; display: flex; align-items: center; gap: 14px;
  font-size: 12px; color: #aab0d0; padding: 0 4px; }
.footnote .link { background: none; border: none; color: #cfd3ec; cursor: pointer;
  font-size: 12px; text-decoration: underline; padding: 0; }
#statusLine { flex: 1; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(20,22,40,.6); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-card { background: #fff; border-radius: 16px; max-width: 560px; width: 100%;
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15px; color: var(--ink); }
.close { background: none; border: none; font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.alib { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 10px; }
.alib .an { font-size: 14px; font-weight: 600; color: var(--ink); }
.alib .ar { font-size: 12px; color: var(--muted); margin: 3px 0; }
.alib .ak { font-size: 12px; color: #4a4a6a; line-height: 1.6; }
.alib .au { font-size: 11px; color: var(--agent); margin-top: 4px; }
.hist-item { cursor: pointer; transition: background .12s, border-color .12s; }
.hist-item:hover { background: var(--leader-soft); border-color: var(--leader); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "chat" "composer" "foot" "roster"; }
  .roster { position: static; }
  .roster-list { flex-direction: row; flex-wrap: wrap; }
  .rcard { flex: 1; min-width: 130px; }
  .msg { max-width: 94%; }
}

