:root {
  --bg: #0f1117; --bg2: #171b25; --card: #1c2230; --line: #2a3244;
  --text: #e9edf6; --muted: #8f9cb5; --primary: #6c8cff; --primary2: #8f6cff;
  --ok: #49d59a; --danger: #ff6b6b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Noto Sans SC', sans-serif; }
body { overscroll-behavior: none; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.auth { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 24px; gap: 18px; }
.brand { text-align: center; }
.brandIcon { font-size: 52px; }
.brand h1 { margin: 8px 0 4px; font-size: 26px; letter-spacing: 1px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.authTabs { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; }
.authTab { flex: 1; padding: 10px; border: none; background: transparent; color: var(--muted);
  border-radius: 9px; font-size: 15px; font-weight: 600; }
.authTab.active { background: var(--card); color: var(--text); }
.authForm { display: flex; flex-direction: column; gap: 10px; }

input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 16px; outline: none; }
input:focus { border-color: var(--primary); }

.btn { border: none; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600;
  color: #fff; background: var(--card); cursor: pointer; font-family: inherit; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary2)); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn.big { padding: 15px; font-size: 16px; width: 100%; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }

/* ---------- 主界面 ---------- */
.app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px calc(4px); gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; background: #2a3550; font-size: 15px; }
.meName { font-size: 15px; font-weight: 600; }
.meSub { font-size: 12px; color: var(--muted); }

main { flex: 1; min-height: 0; position: relative; }
.pane { display: none; height: 100%; }
.pane.active { display: flex; flex-direction: column; }

/* ---------- 群列表 ---------- */
.roomList { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.rooms { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.roomItem { display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; }
.roomItem .avatar { background: linear-gradient(135deg, #2f3a55, #3b2f55); }
.roomMeta { flex: 1; min-width: 0; }
.roomMeta b { display: block; font-size: 15px; }
.roomMeta span { font-size: 12px; color: var(--muted); }

/* ---------- 聊天 ---------- */
.chatView { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chatHead { display: flex; align-items: center; gap: 10px; padding: 6px 12px 10px; border-bottom: 1px solid var(--line); }
.chatTitle { flex: 1; min-width: 0; }
.chatTitle b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messages { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 14px 14px 4px;
  display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 8px; max-width: 84%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--card); padding: 9px 12px; border-radius: 14px; font-size: 15px;
  line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.msg.mine .bubble { background: linear-gradient(135deg, #4a5fd0, #6c4ad0); }
.msgName { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.msgTime { font-size: 10px; color: #5d6a83; align-self: flex-end; white-space: nowrap; }
.bubble img { max-width: 220px; max-height: 260px; border-radius: 10px; display: block; }
.bubble audio { width: 200px; height: 38px; }
.sys { align-self: center; font-size: 12px; color: var(--muted); background: rgba(255,255,255,.04);
  padding: 4px 10px; border-radius: 999px; }
.typing { height: 18px; font-size: 12px; color: var(--muted); padding: 0 16px; }

.composer { display: flex; align-items: center; gap: 8px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer input { flex: 1; padding: 11px 14px; }
.iconBtn { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  width: 42px; height: 42px; font-size: 18px; color: var(--text); cursor: pointer; }
.iconBtn.recording { background: var(--danger); border-color: var(--danger); }

/* ---------- 通用卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 12px 16px; }
.cardTitle { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 10px; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.colors { display: flex; gap: 10px; }
.colorDot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.colorDot.on { border-color: #fff; }

/* ---------- 底部标签 ---------- */
.tabbar {
  position: relative; display: flex; align-items: stretch;
  border-top: 1px solid rgba(255,255,255,.10);
  background: linear-gradient(180deg, rgba(24,29,45,.62), rgba(14,17,26,.82));
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  box-shadow: 0 -8px 30px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.14);
}

/* 会跟着走的液态玻璃块 */
.tabPill {
  position: absolute; top: 7px; bottom: calc(7px + env(safe-area-inset-bottom));
  left: 0; width: 0; border-radius: 16px; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.05));
  border: 1px solid rgba(255,255,255,.16);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.45),
    inset 0 -6px 12px rgba(255,255,255,.04),
    0 6px 18px rgba(0,0,0,.35);
  backdrop-filter: blur(6px) saturate(160%);
  -webkit-backdrop-filter: blur(6px) saturate(160%);
  transition: transform .52s cubic-bezier(.32,1.6,.52,1), width .52s cubic-bezier(.32,1.6,.52,1);
  will-change: transform, width;
  z-index: 0;
}
/* 高光扫过（液态感） */
.tabPill::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(120% 90% at 30% -10%, rgba(255,255,255,.38), transparent 65%);
  opacity: .5; mix-blend-mode: screen;
}
.tabGlow {
  position: absolute; top: -40%; left: 0; width: 0; height: 180%;
  background: radial-gradient(closest-side, rgba(108,140,255,.35), transparent 70%);
  filter: blur(14px); pointer-events: none; opacity: .35;
  transition: transform .52s cubic-bezier(.32,1.6,.52,1), width .52s cubic-bezier(.32,1.6,.52,1);
  z-index: 0;
}
.tab { position: relative; z-index: 1; flex: 1; background: transparent; border: none;
  color: var(--muted); padding: 9px 0 10px; font-size: 19px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
  transition: color .28s ease, transform .18s ease; }
.tab span { font-size: 11px; letter-spacing: .3px; }
.tab.active { color: #fff; text-shadow: 0 1px 8px rgba(140,170,255,.6); }
.tab:active { transform: scale(.94); }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 12px);
  background: #2c3550; padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: 84vw; text-align: center; z-index: 90; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.imgViewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: grid; place-items: center; z-index: 95; }
.imgViewer img { max-width: 96vw; max-height: 88vh; border-radius: 8px; }

.sectionTitle { font-size: 12px; color: var(--muted); margin: 14px 4px 6px; display: flex; align-items: center; gap: 8px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #232b3d; color: var(--muted); font-size: 11px; }
.roomItem .btn.small { margin-left: auto; }

/* ---- 新建面板 ---- */
.sheet {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(6,8,14,.66); backdrop-filter: blur(3px);
}
.sheetCard {
  width: 100%; max-width: 560px; max-height: 82vh; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--line); border-bottom: none;
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(22px + env(safe-area-inset-bottom));
  animation: sheetUp .18s ease;
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheetHead { display: flex; align-items: center; justify-content: space-between; }
.sectionTitle { font-size: 12px; color: var(--muted); margin: 6px 2px 8px; }
