/* =========================================================
   聊天系统样式 · 9 套主题（CSS 变量） · 响应式
   ========================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---------------- 主题 1：气泡蓝 ---------------- */
body[data-theme="bubble_blue"] {
  --bg: linear-gradient(135deg, #dbeafe 0%, #e0f2fe 60%, #eff6ff 100%);
  --panel: #ffffff; --panel-2: #f1f5f9;
  --text: #1e293b; --muted: #64748b; --border: #e2e8f0;
  --accent: #3b82f6; --accent-text: #fff;
  --bubble-me: #3b82f6; --bubble-me-text: #fff;
  --bubble-them: #ffffff; --bubble-them-text: #1e293b;
  --blur: 0px;
}
/* ---------------- 主题 2：简约亮色 ---------------- */
body[data-theme="light"] {
  --bg: #fafafa;
  --panel: #ffffff; --panel-2: #f4f4f5;
  --text: #18181b; --muted: #71717a; --border: #e4e4e7;
  --accent: #18181b; --accent-text: #fff;
  --bubble-me: #18181b; --bubble-me-text: #fff;
  --bubble-them: #f4f4f5; --bubble-them-text: #18181b;
  --blur: 0px;
}
/* ---------------- 主题 3：暗夜沉浸 ---------------- */
body[data-theme="dark"] {
  --bg: #0b0f17;
  --panel: #111827; --panel-2: #1f2937;
  --text: #e5e7eb; --muted: #9ca3af; --border: #273449;
  --accent: #60a5fa; --accent-text: #0b0f17;
  --bubble-me: #2563eb; --bubble-me-text: #fff;
  --bubble-them: #1f2937; --bubble-them-text: #e5e7eb;
  --blur: 0px;
}
/* ---------------- 主题 4：粉紫气泡 ---------------- */
body[data-theme="pink"] {
  --bg: linear-gradient(135deg, #fdf2f8 0%, #ede9fe 100%);
  --panel: #ffffff; --panel-2: #fdf2f8;
  --text: #4a044e; --muted: #a78bba; --border: #f5d0fe;
  --accent: #d946ef; --accent-text: #fff;
  --bubble-me: linear-gradient(135deg, #ec4899, #a855f7); --bubble-me-text: #fff;
  --bubble-them: #ffffff; --bubble-them-text: #4a044e;
  --blur: 0px;
}
/* ---------------- 主题 5：玻璃拟态 ---------------- */
body[data-theme="glass"] {
  --bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --panel: rgba(255, 255, 255, .16); --panel-2: rgba(255, 255, 255, .24);
  --text: #ffffff; --muted: rgba(255, 255, 255, .72); --border: rgba(255, 255, 255, .25);
  --accent: rgba(255, 255, 255, .9); --accent-text: #4c1d95;
  --bubble-me: rgba(255, 255, 255, .34); --bubble-me-text: #fff;
  --bubble-them: rgba(255, 255, 255, .12); --bubble-them-text: #fff;
  --blur: 16px;
}
/* ---------------- 主题 6：iOS 玻璃 ---------------- */
body[data-theme="ios"] {
  --bg: linear-gradient(180deg, #eef2f7 0%, #dbe4ee 100%);
  --panel: rgba(255, 255, 255, .66); --panel-2: rgba(255, 255, 255, .9);
  --text: #1c1c1e; --muted: #8e8e93; --border: rgba(0, 0, 0, .08);
  --accent: #007aff; --accent-text: #fff;
  --bubble-me: #007aff; --bubble-me-text: #fff;
  --bubble-them: rgba(255, 255, 255, .92); --bubble-them-text: #1c1c1e;
  --blur: 20px;
}
/* ---------------- 主题 7：黄金（VIP） ---------------- */
body[data-theme="gold"] {
  --bg: radial-gradient(circle at 30% 20%, #3a2c10 0%, #221906 70%);
  --panel: #241a0c; --panel-2: #2f2413;
  --text: #f3e7c8; --muted: #b39b6a; --border: #4a3a1c;
  --accent: #f5c542; --accent-text: #3a2a05;
  --bubble-me: linear-gradient(135deg, #f7d774, #c9962e); --bubble-me-text: #3a2a05;
  --bubble-them: #2f2413; --bubble-them-text: #f3e7c8;
  --blur: 0px;
}
/* ---------------- 主题 8：白金（VIP） ---------------- */
body[data-theme="platinum"] {
  --bg: linear-gradient(135deg, #f8fafc 0%, #e8edf3 100%);
  --panel: #ffffff; --panel-2: #f1f5f9;
  --text: #334155; --muted: #94a3b8; --border: #e2e8f0;
  --accent: #64748b; --accent-text: #fff;
  --bubble-me: linear-gradient(135deg, #cbd5e1, #94a3b8); --bubble-me-text: #0f172a;
  --bubble-them: #ffffff; --bubble-them-text: #334155;
  --blur: 0px;
}
/* ---------------- 主题 9：黑金（SVIP） ---------------- */
body[data-theme="blackgold"] {
  --bg: radial-gradient(circle at 70% 10%, #1c1a12 0%, #0a0a0a 65%);
  --panel: #141414; --panel-2: #1f1f1f;
  --text: #e8e0c9; --muted: #8c8570; --border: #2e2a1c;
  --accent: #d4af37; --accent-text: #14120a;
  --bubble-me: linear-gradient(135deg, #d4af37, #8c6d1f); --bubble-me-text: #14120a;
  --bubble-them: #1f1f1f; --bubble-them-text: #e8e0c9;
  --blur: 0px;
}

/* ---------------- 布局 ---------------- */
.app { display: flex; height: 100dvh; }
.sidebar {
  width: 340px; min-width: 280px; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
}
.main { flex: 1; position: relative; display: flex; flex-direction: column; min-width: 0; }

/* 聊天背景层 */
.chat-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.chat-bg img, .chat-bg video { width: 100%; height: 100%; object-fit: cover; }
.chat > * { position: relative; z-index: 1; }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.empty-icon { font-size: 56px; opacity: .8; }
.empty-text { font-size: 16px; color: var(--muted); }
.empty-tip { font-size: 12px; color: var(--muted); opacity: .7; }

/* ---------------- 顶栏个人信息 ---------------- */
.me-bar { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--border); }
.me-info { flex: 1; min-width: 0; }
.me-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.me-level { font-size: 11px; color: var(--muted); margin: 3px 0 4px; }
.xp-bar { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.xp-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s; }

/* ---------------- 导航 ---------------- */
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs button {
  flex: 1; position: relative; padding: 10px 0; font-size: 19px; background: none; border: none;
  opacity: .55; transition: .15s;
}
.tabs button.on { opacity: 1; background: var(--panel-2); }
.badge {
  position: absolute; top: 4px; right: 12%; background: #ef4444; color: #fff;
  font-style: normal; font-size: 10px; min-width: 16px; height: 16px; line-height: 16px;
  border-radius: 8px; padding: 0 4px;
}

/* ---------------- 面板 ---------------- */
.panels { flex: 1; overflow: hidden; }
.panel { height: 100%; overflow-y: auto; padding: 8px; }
.panel-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 10px; line-height: 1.8; }
.sec-title { font-size: 12px; color: var(--muted); font-weight: 600; padding: 12px 6px 6px; }

/* 会话列表 */
.conv-item {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px;
  cursor: pointer; transition: background .12s; animation: itemIn .25s ease;
}
.conv-item:hover { background: var(--panel-2); }
.conv-item.on { background: var(--panel-2); }
@keyframes itemIn { from { opacity: 0; transform: translateY(6px); } }
.conv-mid { flex: 1; min-width: 0; }
.conv-name { font-size: 14px; font-weight: 600; }
.conv-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-right { text-align: right; flex-shrink: 0; }
.conv-time { font-size: 11px; color: var(--muted); }
.unread {
  display: inline-block; margin-top: 4px; background: #ef4444; color: #fff;
  font-size: 10px; min-width: 17px; height: 17px; line-height: 17px; text-align: center;
  border-radius: 9px; padding: 0 5px;
}

/* 头像 */
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; position: relative;
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.online::after {
  content: ""; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px;
  background: #22c55e; border: 2px solid var(--panel); border-radius: 50%;
}

/* 好友 */
.search-box { display: flex; gap: 6px; padding: 4px; }
.search-box input, .group-bar input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2); color: var(--text); font-size: 13px; outline: none; min-width: 0;
}
.search-box input:focus, .group-bar input:focus { border-color: var(--accent); }
.search-results { border-bottom: 1px dashed var(--border); margin-bottom: 4px; }
.friend-row { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-radius: 10px; }
.friend-row:hover { background: var(--panel-2); }
.friend-row .avatar { width: 38px; height: 38px; font-size: 15px; }
.fr-mid { flex: 1; min-width: 0; }
.fr-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.fr-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.vip-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 6px; font-weight: 700;
  background: linear-gradient(90deg, #f59e0b, #f97316); color: #fff;
}
.vip-badge.vip-2 { background: linear-gradient(90deg, #7c3aed, #db2777); }

/* 群组 */
.group-bar { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px; }
.group-bar input { flex-basis: 120px; }

/* 排行榜 */
.board-tabs { display: flex; gap: 6px; padding: 4px; }
.board-tab {
  flex: 1; padding: 8px 0; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); border-radius: 10px; font-size: 12px;
}
.board-tab.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-radius: 10px; }
.board-row:nth-child(-n+3) { background: var(--panel-2); }
.board-row .avatar { width: 36px; height: 36px; font-size: 14px; }
.rank { width: 30px; text-align: center; font-weight: 800; font-size: 16px; color: var(--muted); }
.board-name { flex: 1; font-size: 14px; font-weight: 600; min-width: 0; }
.board-val { font-size: 13px; font-weight: 700; color: var(--accent); }

/* 设置 */
.set-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 6px; }
.set-col { display: flex; flex-direction: column; gap: 12px; padding: 8px 6px; }
.set-col label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.set-col input[type="range"] { width: 100%; accent-color: var(--accent); }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px; }
.theme-card {
  position: relative; border: 2px solid var(--border); border-radius: 12px; padding: 12px 4px;
  text-align: center; cursor: pointer; background: var(--panel-2); transition: .15s;
}
.theme-card.on { border-color: var(--accent); }
.theme-card.locked { opacity: .6; }
.theme-icon { font-size: 22px; }
.theme-name { font-size: 12px; margin-top: 4px; }
.theme-vip {
  position: absolute; top: 4px; right: 4px; font-size: 9px; padding: 1px 4px;
  background: linear-gradient(90deg, #f59e0b, #f97316); color: #fff; border-radius: 5px; font-weight: 700;
}
.member-box .mem-status { font-size: 13px; color: var(--muted); }
.redeem-row { display: flex; gap: 6px; }
.redeem-row input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2); color: var(--text); outline: none;
}
.acc-box .acc-line { font-size: 13px; color: var(--muted); }
.acc-box .acc-line b { color: var(--text); }

/* 按钮 */
button.mini {
  padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 12px;
}
button.mini.good { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.mini.danger { color: #ef4444; }
.btn-line {
  padding: 9px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--text); font-size: 14px;
}
.btn-fill {
  padding: 9px 18px; border-radius: 10px; border: none;
  background: var(--accent); color: var(--accent-text); font-size: 14px; font-weight: 600;
}
.btn-fill.danger-b { background: #ef4444; color: #fff; }

/* ---------------- 聊天窗口 ---------------- */
.chat { position: absolute; inset: 0; display: flex; flex-direction: column; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
}
.btn-back { display: none; background: none; border: none; font-size: 20px; color: var(--text); }
.btn-ghost { background: none; border: none; font-size: 18px; color: var(--muted); }
.chat-title { flex: 1; min-width: 0; }
.ct-name { font-size: 15px; font-weight: 700; }
.ct-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

.messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.messages.pop { animation: popIn .28s cubic-bezier(.34, 1.4, .64, 1); }
@keyframes popIn { from { opacity: 0; transform: scale(.985) translateY(10px); } }

.msg { display: flex; gap: 8px; max-width: 100%; animation: msgIn .2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.msg .avatar { width: 34px; height: 34px; font-size: 13px; align-self: flex-end; }
.msg .body { max-width: 65%; min-width: 0; }
.msg .meta { font-size: 10px; color: var(--muted); margin-bottom: 3px; }
.msg.me { flex-direction: row-reverse; }
.msg.me .meta { text-align: right; }
.bubble {
  padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
  background: var(--bubble-them); color: var(--bubble-them-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); border-bottom-right-radius: 4px; }
.msg.them .bubble { border-bottom-left-radius: 4px; }
.bubble img { max-width: 220px; max-height: 220px; border-radius: 10px; display: block; cursor: zoom-in; }
.file-card {
  display: flex; align-items: center; gap: 6px; text-decoration: none; color: inherit;
  background: rgba(127, 127, 127, .15); padding: 8px 12px; border-radius: 10px; font-size: 13px;
}
.msg.sys { justify-content: center; }
.msg.sys { font-size: 11px; color: var(--muted); background: var(--panel); padding: 3px 12px; border-radius: 10px; align-self: center; }
.burn-chip {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px;
  background: rgba(239, 68, 68, .14); color: #ef4444; font-size: 10px;
}

/* 输入区 */
.composer { position: relative; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--border);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); }
.composer-bar { display: flex; align-items: flex-end; gap: 8px; }
#burnSel {
  padding: 7px 6px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 12px; outline: none; max-width: 110px;
}
.cbtn { background: none; border: none; font-size: 19px; padding: 6px; opacity: .8; }
.cbtn:hover { opacity: 1; }
#msgInput {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 12px; font-size: 14px; background: var(--panel-2); color: var(--text);
  outline: none; max-height: 120px; line-height: 1.4;
}
#msgInput:focus { border-color: var(--accent); }
.btn-send {
  padding: 9px 20px; border: none; border-radius: 12px; background: var(--accent);
  color: var(--accent-text); font-size: 14px; font-weight: 600;
}
.btn-send:hover { filter: brightness(1.08); }
.drop-tip {
  display: none; position: absolute; inset: 0; z-index: 5; align-items: center; justify-content: center;
  background: var(--panel); border: 2px dashed var(--accent); border-radius: 12px;
  font-size: 15px; color: var(--accent); font-weight: 600;
}
.composer.drag .drop-tip { display: flex; }

/* ---------------- 弹窗 / Toast ---------------- */
.modal-root .modal-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 380px; background: var(--panel); color: var(--text);
  border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  animation: modalIn .22s cubic-bezier(.34, 1.3, .64, 1);
  max-height: 80dvh; overflow-y: auto;
}
.modal.wide { max-width: 640px; background: transparent; box-shadow: none; padding: 0; }
@keyframes modalIn { from { opacity: 0; transform: scale(.92) translateY(12px); } }
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal-desc { font-size: 13px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.modal-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2); color: var(--text); font-size: 14px; outline: none; margin-bottom: 14px;
}
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
.modal-img { width: 100%; border-radius: 12px; display: block; }
.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.field input { width: 100%; margin-top: 5px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel-2); color: var(--text); outline: none; }
.member-list { max-height: 260px; overflow-y: auto; margin-bottom: 14px; }
.member-row { padding: 7px 4px; font-size: 13px; border-bottom: 1px solid var(--border); }

.toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(15, 23, 42, .88); color: #fff; padding: 10px 20px; border-radius: 12px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: toastIn .25s ease;
  max-width: 80vw;
}
.toast.out { opacity: 0; transform: translateY(-8px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* ---------------- 登录页 ---------------- */
.auth-body { display: flex; align-items: center; justify-content: center; overflow: auto; }
.auth-wrap { width: 100%; max-width: 400px; padding: 20px; }
.auth-card {
  background: var(--panel); border-radius: 20px; padding: 34px 30px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .14); text-align: center;
  animation: modalIn .3s ease;
}
.auth-logo { font-size: 44px; }
.auth-card h1 { font-size: 22px; margin: 8px 0 4px; }
.auth-sub { font-size: 12px; color: var(--muted); margin-bottom: 20px; }
.auth-tabs { display: flex; background: var(--panel-2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button {
  flex: 1; padding: 8px 0; border: none; background: none; border-radius: 9px;
  font-size: 14px; color: var(--muted);
}
.auth-tabs button.on { background: var(--panel); color: var(--text); font-weight: 700; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 14px; background: var(--panel-2); color: var(--text); outline: none; width: 100%;
}
.auth-form input:focus { border-color: var(--accent); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.btn-code {
  padding: 0 14px; border: 1px solid var(--accent); color: var(--accent);
  background: none; border-radius: 12px; font-size: 13px; white-space: nowrap;
}
.btn-main {
  padding: 12px; border: none; border-radius: 12px; background: var(--accent);
  color: var(--accent-text); font-size: 15px; font-weight: 700;
}
.btn-main:hover { filter: brightness(1.07); }
.auth-links { text-align: right; }
.auth-links a { font-size: 12px; color: var(--muted); text-decoration: none; }
.auth-foot { text-align: center; font-size: 11px; color: var(--muted); margin-top: 16px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 768px) {
  .sidebar { width: 100%; border-right: none; }
  .main { display: none; }
  body.chat-open .sidebar { display: none; }
  body.chat-open .main { display: flex; }
  .btn-back { display: block; }
  .msg .body { max-width: 78%; }
  .bubble img { max-width: 180px; max-height: 180px; }
  #burnSel { max-width: 86px; font-size: 11px; }
  .btn-send { padding: 9px 14px; }
}
