:root {
  --bg: #0f1420; --panel: #171e2e; --panel2: #1d2639; --line: #2a3550;
  --text: #e8ecf4; --muted: #8b96ad; --primary: #4f7cff; --primary2: #3b63d9;
  --gate: #f5a623; --ok: #2fbf71; --err: #e5534b; --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
.btn { border: none; border-radius: 8px; padding: 9px 18px; font-size: 14px; cursor: pointer; touch-action: manipulation; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary2); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--text); border-color: var(--primary); }
.btn-danger { background: transparent; color: var(--err); border: 1px solid var(--err); }

/* 登录卡 */
.auth-mask { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 30% 20%, #1a2340 0%, var(--bg) 60%); z-index: 10; }
.auth-card { width: calc(100vw - 28px); max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 36px 32px; text-align: center; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: 12px; margin-bottom: 24px; }
.auth-card input { width: 100%; padding: 11px 14px; font-size: 16px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); margin-bottom: 12px; }
.auth-err { color: var(--err); font-size: 13px; margin-top: 10px; }

/* 主界面 */
#main { display: flex; flex-direction: column; height: 100vh; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { display: inline-flex; width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #7b5cff); color: #fff; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.chat-area { flex: 1; overflow-y: auto; padding: 18px 14px; }
.msg-list { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: 86%; padding: 11px 15px; border-radius: var(--radius); line-height: 1.65; word-break: break-word; }
.msg.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant.gate .bubble { border-color: var(--gate); box-shadow: 0 0 0 1px var(--gate) inset; }
.bubble h3 { font-size: 15px; margin: 8px 0 4px; color: #9db8ff; }
.bubble h4 { font-size: 14px; margin: 6px 0 3px; color: #b9c8ee; }
.bubble ul { margin: 4px 0 4px 20px; }
.bubble li { margin: 2px 0; }
.bubble .codeblock, .bubble pre { background: #0c1018; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 8px 0; font-family: Consolas, monospace; font-size: 13px; white-space: pre-wrap; }
.bubble code { background: #0c1018; border-radius: 4px; padding: 1px 5px; font-family: Consolas, monospace; font-size: 13px; }
.typing { color: var(--muted); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* 输入区 */
.composer { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--panel); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 11px 13px; font-size: 16px; font-family: inherit; max-height: 160px; }
.composer textarea:focus { outline: none; border-color: var(--primary); }
@media (max-width: 640px) {
  .msg .bubble { max-width: 94%; }
  .composer { padding: 10px; }
}
