:root {
  color-scheme: dark;
  --bg: #0a0d15;
  --surface: #141926;
  --surface-2: #1b2231;
  --surface-3: #242d40;
  --border: #283147;
  --text: #e9edf7;
  --muted: #8d97ad;
  --faint: #626d84;
  --accent: #6c8cff;
  --accent-2: #a06cff;
  --bubble: #212939;
  --danger: #f4707d;
  --online: #37d39b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .32);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --surface-3: #e9edf6;
  --border: #dce2ee;
  --text: #1c2437;
  --muted: #66708a;
  --faint: #929bb0;
  --accent: #4968e8;
  --accent-2: #8255d9;
  --bubble: #eff2f9;
  --danger: #e04c5c;
  --online: #14b884;
  --shadow: 0 18px 50px rgba(40, 55, 95, .13);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(800px 500px at 5% 0%, rgba(108, 140, 255, .12), transparent 60%), var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* ---------- 登录 ---------- */
.auth-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: radial-gradient(700px 500px at 70% 10%, rgba(160, 108, 255, .16), transparent 60%), var(--bg); }
.auth-card { width: min(100%, 400px); padding: 34px 32px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.auth-logo { width: 60px; height: 60px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 18px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 30px rgba(108, 140, 255, .3); }
.auth-card h1 { margin: 0; font-size: 24px; letter-spacing: 1px; }
.auth-sub { margin: 7px 0 24px; font-size: 12px; color: var(--muted); }
.auth-tabs { display: flex; gap: 6px; padding: 4px; margin-bottom: 20px; border-radius: 11px; background: var(--surface-2); }
.auth-tab { flex: 1; padding: 9px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; }
.auth-tab.active { background: var(--surface-3); color: var(--text); font-weight: 600; box-shadow: 0 3px 10px rgba(0,0,0,.14); }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-form label { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--muted); }
.auth-form input, .field input, .field select, .field textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; outline: 0; background: var(--surface-2); color: var(--text); font-size: 14px; }
.auth-form input:focus, .field input:focus, .field textarea:focus { border-color: var(--accent); }
.auth-error { margin: 14px 0 0; color: var(--danger); font-size: 12px; }
.primary-btn { padding: 11px 16px; border: 0; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 14px; font-weight: 600; }
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn.small { padding: 7px 13px; font-size: 12px; }

/* ---------- 主框架 ---------- */
.app { display: grid; grid-template-columns: 66px 300px minmax(0, 1fr); height: 100dvh; }
.rail, .list-panel, .chat-panel { min-height: 0; background: var(--surface); }
.rail { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 0; border-right: 1px solid var(--border); }
.rail-me { width: 38px; height: 38px; margin-bottom: 14px; display: grid; place-items: center; border-radius: 12px; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.rail-nav, .rail-bottom { display: flex; flex-direction: column; gap: 8px; }
.rail-bottom { margin-top: auto; }
.rail-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 19px; transition: .16s ease; }
.rail-btn:hover, .rail-btn.active { background: var(--surface-2); color: var(--accent); }
.rail-dot { position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }

/* ---------- 会话列表 ---------- */
.list-panel { display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 12px; }
.list-head h2 { margin: 0; font-size: 17px; }
.icon-btn { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: 12px; display: inline-grid; place-items: center; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.list-search { padding: 0 12px 12px; }
.list-search input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; outline: 0; background: var(--surface-2); color: var(--text); font-size: 12px; }
.list-search input:focus { border-color: var(--accent); }
.item-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 12px; }
.item-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 7px; }
.item-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.list-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 10px; border: 0; border-radius: 11px; background: transparent; color: var(--text); text-align: left; transition: .15s ease; }
.list-item:hover { background: var(--surface-2); }
.list-item.active { background: var(--surface-3); }
.avatar { position: relative; flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: #fff; font-size: 14px; font-weight: 700; user-select: none; }
.avatar.small { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }
.avatar.xlarge { width: 52px; height: 52px; border-radius: 15px; font-size: 18px; }
.avatar .presence { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border: 2px solid var(--surface); border-radius: 50%; background: var(--online); }
.item-main { flex: 1; min-width: 0; }
.item-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.item-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-time { flex: none; font-size: 10px; color: var(--faint); }
.item-preview { margin-top: 4px; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: none; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; }
.badge.mention { background: var(--accent); }
.mute-mark { color: var(--faint); font-size: 11px; }
.list-empty { padding: 40px 20px; text-align: center; color: var(--faint); font-size: 13px; }

/* ---------- 聊天区 ---------- */
.chat-panel { position: relative; display: flex; flex-direction: column; min-width: 0; }
.chat-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.chat-heading { flex: 1; min-width: 0; }
.chat-heading h3 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-heading span { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
.chat-actions { display: flex; gap: 7px; }
.mobile-back { display: none; font-size: 22px; line-height: 1; }
.announce-bar { flex: none; padding: 9px 18px; background: rgba(108,140,255,.1); border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; cursor: pointer; }
.announce-bar b { color: var(--accent); }
.typing-bar { flex: none; padding: 5px 18px; color: var(--accent); font-size: 11px; }

.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 22px 10px; display: flex; flex-direction: column; gap: 15px; }
.msg { display: flex; align-items: flex-start; gap: 10px; max-width: min(76%, 680px); align-self: flex-start; animation: rise .2s ease-out both; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.msg-body { min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 5px; }
.msg.mine .msg-meta { flex-direction: row-reverse; }
.msg-name { font-size: 12px; font-weight: 600; color: var(--muted); }
.msg-time { font-size: 10px; color: var(--faint); }
.bubble { position: relative; padding: 10px 13px; border: 1px solid var(--border); border-radius: 5px 14px 14px 14px; background: var(--bubble); font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .bubble { border-color: transparent; border-radius: 14px 5px 14px 14px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.bubble .link { color: #86b0ff; text-decoration: underline; }
.msg.mine .bubble .link { color: #fff; }
.bubble .mention { color: #9db6ff; font-weight: 600; }
.msg.mine .bubble .mention { color: #fff; text-decoration: underline; }
.bubble .quote { margin-bottom: 7px; padding: 6px 9px; border-left: 3px solid var(--accent); border-radius: 4px; background: rgba(127,127,127,.14); font-size: 11px; line-height: 1.5; opacity: .85; white-space: normal; }
.bubble .quote b { display: block; }
.read-state { margin-top: 4px; text-align: right; font-size: 10px; color: var(--faint); }
.msg.system { align-self: center; max-width: 92%; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--faint); font-size: 11px; text-align: center; }
.msg.recalled { align-self: center; color: var(--faint); font-size: 11px; }
.fav-star { position: absolute; top: -7px; right: -7px; font-size: 12px; color: #f4c451; }

.msg-image { display: block; max-width: 300px; max-height: 240px; border-radius: 9px; cursor: zoom-in; }
.msg-video { display: block; width: min(320px, 60vw); border-radius: 9px; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: 190px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); text-decoration: none; color: var(--text); }
.msg.mine .file-card { background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.2); }
.file-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; }
.file-info { min-width: 0; }
.file-name { display: block; max-width: 190px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 10px; color: var(--muted); }
.msg.mine .file-size { color: rgba(255,255,255,.75); }
.voice-card { min-width: 170px; }
.voice-card audio { width: 100%; height: 32px; }
.voice-transcript { margin-top: 6px; font-size: 12px; opacity: .85; }
.merged-card { display: flex; align-items: center; gap: 10px; min-width: 190px; cursor: pointer; }
.merged-icon { width: 36px; height: 40px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.16); font-size: 18px; }
.merged-title { font-size: 13px; font-weight: 600; }
.merged-count { font-size: 10px; color: var(--muted); }
.jump-btn { position: absolute; right: 22px; bottom: 140px; z-index: 4; padding: 7px 13px; border: 1px solid var(--accent); border-radius: 999px; background: var(--surface-3); color: var(--text); font-size: 12px; box-shadow: var(--shadow); }

/* ---------- 输入框 ---------- */
.composer { position: relative; flex: none; margin: 0 14px 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.composer:focus-within { border-color: var(--accent); }
.composer-tools { position: relative; display: flex; gap: 6px; }
.tool-btn { padding: 5px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 11px; }
.tool-btn:hover { background: var(--surface-3); color: var(--text); }
#input { width: 100%; min-height: 46px; max-height: 150px; margin-top: 5px; padding: 4px 2px; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font-size: 14px; line-height: 1.55; }
#input::placeholder { color: var(--faint); }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; }
.hint { font-size: 10px; color: var(--faint); }
.send-btn { padding: 8px 18px; border: 0; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 12px; font-weight: 600; }
.send-btn:disabled { opacity: .5; cursor: not-allowed; }
.reply-bar { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; padding: 7px 10px; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--surface-3); font-size: 11px; color: var(--muted); }
.reply-bar button { border: 0; background: transparent; color: var(--muted); }
.mention-popup { position: absolute; left: 8px; bottom: 100%; z-index: 12; max-height: 220px; overflow-y: auto; padding: 5px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-3); box-shadow: var(--shadow); }
.mention-popup button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font-size: 12px; text-align: left; }
.mention-popup button:hover { background: var(--surface-2); }
.emoji-picker { position: absolute; left: 0; bottom: 100%; z-index: 12; width: 300px; max-height: 220px; overflow-y: auto; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-3); box-shadow: var(--shadow); }
.emoji-picker button { padding: 5px; border: 0; border-radius: 6px; background: transparent; font-size: 20px; }
.emoji-picker button:hover { background: var(--surface-2); }
.voice-bar { display: flex; align-items: center; gap: 10px; padding: 8px 4px; color: var(--muted); font-size: 12px; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.voice-bar button { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.voice-bar .primary-btn { margin-left: 0; }
.empty-chat { position: absolute; inset: 60px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--faint); pointer-events: none; }
.empty-chat p { margin: 0; font-size: 14px; color: var(--muted); }
.empty-chat span { font-size: 12px; }

/* ---------- 弹窗 / 菜单 ---------- */
.modal-root { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(5,8,15,.68); backdrop-filter: blur(6px); }
.modal { width: min(100%, 520px); max-height: 82vh; overflow-y: auto; padding: 22px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); animation: rise .2s ease-out both; }
.modal.wide { width: min(100%, 720px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.close-btn { width: 28px; height: 28px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.ghost-btn { padding: 9px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: 12px; }
.danger-btn { padding: 9px 14px; border: 1px solid var(--danger); border-radius: 9px; background: transparent; color: var(--danger); font-size: 12px; }
.check-row { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 9px; font-size: 13px; }
.check-row:hover { background: var(--surface-2); }
.check-row input { accent-color: var(--accent); }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.member-row .info { flex: 1; min-width: 0; }
.member-row .info b { display: block; font-size: 13px; }
.member-row .info small { font-size: 10px; color: var(--muted); }
.mini-btn { padding: 5px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--muted); font-size: 11px; }
.mini-btn:hover { color: var(--text); border-color: var(--accent); }
.mini-btn.danger { color: var(--danger); }
.search-results { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.result-row { padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); text-align: left; color: var(--text); font-size: 12px; }
.result-row:hover { border-color: var(--accent); }
.result-row b { color: var(--accent); }
.result-row small { display: block; margin-top: 4px; color: var(--faint); }
.context-menu { position: fixed; z-index: 90; min-width: 140px; padding: 5px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-3); box-shadow: var(--shadow); }
.context-menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font-size: 12px; text-align: left; }
.context-menu button:hover { background: var(--surface-2); }
.context-menu button.danger { color: var(--danger); }
.lightbox { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgba(0,0,0,.88); }
.lightbox img { max-width: 90vw; max-height: 86vh; object-fit: contain; }
#lightboxClose { position: absolute; top: 18px; right: 22px; border: 0; background: transparent; color: #fff; font-size: 30px; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 110; transform: translateX(-50%); padding: 10px 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-3); color: var(--text); font-size: 13px; box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .app { grid-template-columns: 58px 250px minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .app { display: block; }
  .rail { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: 56px; flex-direction: row; justify-content: space-around; padding: 6px; border-right: 0; border-top: 1px solid var(--border); }
  .rail-me, .rail-bottom { display: none; }
  .rail-nav { flex-direction: row; gap: 10px; }
  .list-panel, .chat-panel { position: absolute; inset: 0 0 56px; border: 0; }
  .chat-panel { z-index: 10; display: none; }
  .app.chat-open .chat-panel { display: flex; }
  .app.chat-open .list-panel { display: none; }
  .mobile-back { display: inline-grid; }
  .messages { padding: 14px 10px 8px; }
  .msg { max-width: 88%; }
  .jump-btn { bottom: 132px; right: 14px; }
}

/* ---------- 关于与合作 ---------- */
.about-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.about-tabs button { padding: 7px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.about-tabs button.active { border-color: var(--accent); background: var(--surface-3); color: var(--text); font-weight: 600; }
.about-body { min-height: 260px; }
.about-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2); }
.about-logo { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; color: #fff; font-size: 24px; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.about-hero h3 { margin: 0; font-size: 18px; }
.about-hero p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.markdown { font-size: 13px; line-height: 1.8; color: var(--text); }
.markdown h3 { margin: 18px 0 8px; font-size: 17px; }
.markdown h4 { margin: 16px 0 6px; font-size: 14px; color: var(--accent); }
.markdown h5 { margin: 12px 0 5px; font-size: 13px; }
.markdown p { margin: 6px 0; }
.markdown ul { margin: 6px 0; padding-left: 22px; }
.markdown blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--muted); }
.markdown code { padding: 1px 5px; border-radius: 5px; background: var(--surface-3); font-size: 12px; }
.markdown hr { margin: 18px 0; border: 0; border-top: 1px solid var(--border); }
.req-card { margin-bottom: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.req-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.req-meta { margin-top: 5px; font-size: 11px; color: var(--muted); }
.req-content { margin-top: 9px; font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.req-note { margin-top: 7px; font-size: 11px; color: var(--accent); }
.status-pill { padding: 3px 9px; border-radius: 999px; font-size: 10px; font-weight: 600; }
.status-pill.pending { background: rgba(240, 164, 75, .16); color: #f0a44b; }
.status-pill.approved { background: rgba(55, 211, 155, .16); color: var(--online); }
.status-pill.rejected { background: rgba(244, 112, 125, .16); color: var(--danger); }

/* ---------- 自定义头像 ---------- */
img.avatar { display: block; object-fit: cover; background: var(--surface-3); }
.profile-avatar-wrap { position: relative; flex: none; cursor: pointer; }
.profile-avatar { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 17px; color: #fff; font-size: 22px; font-weight: 800; overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-avatar-tip { position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
#myAvatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
