/* ==========================================================================
   简川综合漫研社 · 社娘聊天室  公共样式
   两套主题：pink（羽樱） / blue（绫汐）
   ========================================================================== */

:root {
    --accent: #ec4899;
    --accent-2: #f472b6;
    --accent-soft: rgba(236, 72, 153, 0.12);
    --accent-glow: rgba(236, 72, 153, 0.35);

    --bg: #fdf6f9;
    --panel: #ffffff;
    --panel-2: #faf7f9;
    --text: #1e293b;
    --text-dim: #64748b;
    --text-faint: #94a3b8;
    --border: #f0e4ec;

    --radius: 16px;
    --shadow-sm: 0 2px 8px rgba(30, 41, 59, 0.06);
    --shadow-md: 0 8px 24px rgba(30, 41, 59, 0.08);
    --shadow-lg: 0 20px 50px -12px rgba(30, 41, 59, 0.22);
}

/* 绫汐：蓝紫主题 */
body.theme-blue {
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --accent-glow: rgba(99, 102, 241, 0.35);
    --bg: #f7f8fe;
    --panel-2: #f8f8fd;
    --border: #e6e6f5;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

button, input, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ---------- 通用组件 ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 16px -4px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px -4px var(--accent-glow);
}

.btn-ghost {
    color: var(--text-dim);
    background: transparent;
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.field {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field::placeholder { color: var(--text-faint); }

.notice {
    display: none;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    border-radius: 10px;
    line-height: 1.5;
}

.notice.show { display: block; }
.notice.error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; }
.notice.success { color: #15803d; background: #f0fdf4; border: 1px solid #bbf7d0; }

/* ==========================================================================
   登录页
   ========================================================================== */

.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    position: relative;
    background:
        radial-gradient(circle at 15% 20%, rgba(236, 72, 153, 0.14), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(99, 102, 241, 0.14), transparent 45%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 36px 32px 28px;
    background: var(--panel);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 2;
}

.auth-logo {
    text-align: center;
    margin-bottom: 26px;
}

.auth-logo .mark {
    width: 168px;
    height: 168px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 26px;
    background: #faf8fd;
    border: 3px solid #fff;
    box-shadow: 0 10px 26px -8px rgba(236, 72, 153, 0.45),
                0 0 0 1px rgba(139, 92, 246, 0.1);
}

/* 登录页 LOGO：羽樱与绫汐（原图 1:1，完整显示不裁切） */
.auth-logo .mark img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.auth-logo h1 {
    margin: 0 0 6px;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.auth-logo p {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-faint);
    letter-spacing: 0.5px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 22px;
    background: var(--panel-2);
    border-radius: 12px;
}

.auth-tabs button {
    flex: 1;
    padding: 9px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tabs button.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 4px 12px -3px var(--accent-glow);
}

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-form label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
}

.auth-form .form-row { margin-bottom: 16px; }

.auth-submit {
    width: 100%;
    padding: 13px;
    margin-top: 6px;
    font-size: 15px;
}

.auth-foot {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
    color: var(--text-faint);
    line-height: 1.7;
}

/* ==========================================================================
   聊天页
   ========================================================================== */

.app {
    display: flex;
    height: 100%;
}

/* ---- 侧栏 ---- */

.sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-right: 1px solid var(--border);
    /* 窗口一矮，侧栏内容就比视口还高。
       body 上有 overflow: hidden，页面本身滚不动，
       底部的「改密码 / 后台 / 退出」会被直接裁掉、完全够不着。
       给侧栏自己一条滚动条兜底。 */
    overflow-y: auto;
}

.sidebar-head {
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-head .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.sidebar-head .brand .dot {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    overflow: hidden;
    border-radius: 12px;
    background: #faf8fd;
    border: 2px solid #fff;
    box-shadow: 0 3px 10px -3px rgba(236, 72, 153, 0.45);
}

.sidebar-head h2 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
}

.sidebar-head .sub {
    margin: 0 0 0 52px;
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 0.3px;
}

.sidebar-label {
    padding: 16px 18px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-faint);
    text-transform: uppercase;
}

/* 侧栏里的玩法入口（狼人杀等） */
.side-nav {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 0 12px;
    padding: 11px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    transition: all 0.18s ease;
}

.side-nav:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px -12px var(--accent-glow);
}

.side-nav .ico {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    background: var(--accent-soft);
    border-radius: 9px;
}

.side-nav .nm {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
}

.side-nav .tag {
    font-size: 11px;
    color: var(--text-faint);
}

/* 社娘切换 */

.persona-list {
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.persona-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.persona-item:hover {
    background: var(--panel-2);
}

.persona-item.active {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.persona-item .avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    border-radius: 50%;
    background: var(--panel-2);
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.persona-item.active .avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 4px 12px -3px var(--accent-glow);
}

.persona-item .meta { min-width: 0; flex: 1; }

.persona-item .name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.persona-item .desc {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 社娘头像 / 社团 LOGO 以图片呈现 */
.persona-item .avatar,
.chat-head .avatar,
.msg .ava,
.sidebar-head .brand .dot {
    overflow: hidden;
}

.persona-item .avatar img,
.chat-head .avatar img,
.msg .ava img,
.sidebar-head .brand .dot img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: inherit;
}

.sidebar-spacer { flex: 1; }

.sidebar-foot {
    padding: 14px;
    border-top: 1px solid var(--border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin-bottom: 8px;
    background: var(--panel-2);
    border-radius: 12px;
}

.user-chip .ico {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.user-chip .info { min-width: 0; flex: 1; }

.user-chip .nm {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-chip .tag {
    font-size: 11px;
    color: var(--text-faint);
}

.sidebar-foot .actions {
    display: flex;
    gap: 6px;
}

.sidebar-foot .actions .btn {
    flex: 1;
    padding: 8px;
    font-size: 12.5px;
}

/* 用户卡片（可点击改头像） */
.user-chip {
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.user-chip:hover {
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px var(--accent);
}

.user-chip .ico {
    overflow: hidden;
}

.user-chip .ico img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: inherit;
}

/* 头像弹层 */
.avatar-preview {
    display: flex;
    justify-content: center;
    margin: 4px 0 6px;
}

.avatar-preview-box {
    width: 112px;
    height: 112px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 34px;
    font-weight: 600;
    color: #fff;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 8px 20px -6px var(--accent-glow);
}

.avatar-preview-box img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* ---- 主聊天区 ---- */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 14px 22px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.chat-head .avatar {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 14px -4px var(--accent-glow);
}

.chat-head .who { flex: 1; min-width: 0; }

.chat-head .who h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.chat-head .who .status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-faint);
}

.chat-head .who .status .live {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
}

.chat-head .tools { display: flex; gap: 6px; }

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* 消息区 */

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 26px 22px 8px;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}
.messages::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.msg {
    display: flex;
    gap: 11px;
    margin-bottom: 20px;
    animation: msgIn 0.28s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg .ava {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--border);
}

.msg.assistant .ava {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

.msg .body { max-width: min(660px, 76%); }

.msg .bubble {
    padding: 11px 15px;
    font-size: 14.5px;
    line-height: 1.75;
    border-radius: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg.assistant .bubble {
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.msg.user {
    flex-direction: row-reverse;
}

.msg.user .body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.msg.user .bubble {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-top-right-radius: 4px;
    box-shadow: 0 6px 16px -6px var(--accent-glow);
}

.msg.error .bubble {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-top-left-radius: 4px;
    box-shadow: none;
}

.msg .time {
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-faint);
}

/* 输入中动画 */

.typing-status {
    margin-bottom: 6px;
    font-size: 12.5px;
    color: var(--text-dim);
}

.typing {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 20px;
}

.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.5;
    animation: typing 1.3s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* 输入区 */

.composer {
    padding: 14px 22px 18px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}

.composer-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 7px 7px 7px 14px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.composer-box:focus-within {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer-box textarea {
    flex: 1;
    max-height: 150px;
    padding: 9px 0;
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
}

.composer-box textarea::placeholder { color: var(--text-faint); }

.send-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px -5px var(--accent-glow);
}

.send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.composer-tip {
    margin: 9px 2px 0;
    font-size: 11.5px;
    color: var(--text-faint);
    display: flex;
    justify-content: space-between;
}

/* 待发送图片的预览条 */
.composer-preview {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.composer-preview.show { display: flex; }

.preview-thumb {
    position: relative;
    width: 62px;
    height: 62px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--accent);
    box-shadow: 0 4px 12px -4px var(--accent-glow);
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 19px;
    height: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    color: #fff;
    background: rgba(15, 23, 42, 0.6);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.18s ease;
}

.preview-remove:hover { background: #dc2626; }

.preview-tip {
    font-size: 12px;
    color: var(--text-faint);
}

/* 好友私聊：输入框正上方的「按住说话」整条按钮。
   语音是私聊里最常用的入口，单独给一整条，拇指一伸就到，不用去戳输入框边上的小图标。 */
.voice-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    margin-bottom: 10px;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 14px;
    cursor: pointer;
    /* 手指按住不放的时候，别让浏览器把这一下当成长按选中 */
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, box-shadow 0.18s ease,
                background 0.18s ease, color 0.18s ease;
}

.voice-bar .vb-ico { font-size: 19px; line-height: 1; }

.voice-bar:hover:not(.recording) {
    background: #fff;
    box-shadow: 0 8px 18px -10px var(--accent-glow);
}

/* 正在录音：整条变成实心，给一个一眼能看出来的反馈 */
.voice-bar.recording {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    transform: scale(0.99);
    box-shadow: 0 8px 20px -8px var(--accent-glow);
}

/* 输入框左侧的图片按钮 */
.attach-btn {
    width: 38px;
    height: 40px;
    flex-shrink: 0;
    font-size: 17px;
    line-height: 1;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.18s ease, background 0.18s ease;
}

.attach-btn:hover {
    opacity: 1;
    background: var(--panel-2);
}

/* 消息气泡里的图片 */
.msg .bubble .msg-image {
    display: block;
    max-width: 100%;
    max-height: 320px;
    margin-bottom: 8px;
    border-radius: 10px;
    cursor: zoom-in;
    background: rgba(15, 23, 42, 0.04);
}

.msg .bubble .msg-image:last-child { margin-bottom: 0; }

.msg .bubble.img-only { padding: 5px; }

/* 输入区下方的轻提示（替代原生 alert，避免阻塞） */
.chat-toast {
    display: none;
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
}

.chat-toast.show {
    display: block;
    animation: toastIn 0.22s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 移动端顶栏（默认隐藏） */

.mobile-bar { display: none; }

/* ==========================================================================
   管理后台
   ========================================================================== */

.admin-body { overflow: auto; }

.admin-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

.admin-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.admin-head .mark {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    border-radius: 13px;
    background: linear-gradient(135deg, #ec4899, #6366f1);
}

.admin-head h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.admin-head p {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--text-faint);
}

.admin-head .spacer { flex: 1; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-card .k {
    font-size: 12px;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.stat-card .v {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, #ec4899, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 22px;
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.panel-head .spacer { flex: 1; }

.panel-body { padding: 18px 20px; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

th, td {
    padding: 11px 12px;
    text-align: left;
    white-space: nowrap;
}

th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border);
}

td { border-bottom: 1px solid var(--panel-2); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }

.pill {
    display: inline-block;
    padding: 2px 9px;
    font-size: 11.5px;
    font-weight: 500;
    border-radius: 99px;
}

.pill.on { color: #15803d; background: #f0fdf4; }
.pill.off { color: #b91c1c; background: #fef2f2; }
.pill.admin { color: #a21caf; background: #fdf4ff; }
.pill.user { color: #475569; background: #f1f5f9; }

.row-actions { display: flex; gap: 5px; }

.mini-btn {
    padding: 5px 10px;
    font-size: 12px;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.mini-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.mini-btn.danger:hover {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fef2f2;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    align-items: end;
}

.form-grid .grid-full {
    grid-column: 1 / -1;
}

.panel-hint {
    margin: 0 0 14px;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text-dim);
    padding: 10px 12px;
    background: var(--accent-soft);
    border-radius: 10px;
}

textarea.field {
    resize: vertical;
    min-height: 72px;
    line-height: 1.65;
    font-family: inherit;
}

select.field {
    cursor: pointer;
}

.form-grid label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding-bottom: 12px;
    font-size: 13px;
    color: var(--text-dim);
}

.check-row input { accent-color: var(--accent); }

/* ==========================================================================
   弹层
   ========================================================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.modal.show { display: flex; }

.modal-card {
    width: 100%;
    max-width: 380px;
    padding: 24px;
    background: var(--panel);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    animation: msgIn 0.22s ease;
}

.modal-card h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
}

.modal-card p {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
}

.modal-card .row { margin-bottom: 13px; }

.modal-card .foot {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

.modal-card .foot .btn { flex: 1; }

/* 空状态 */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 50px 20px;
    color: var(--text-faint);
    font-size: 13.5px;
}

.empty .big { font-size: 30px; opacity: 0.6; }

/* ==========================================================================
   好友私聊
   ========================================================================== */

/* 侧栏的好友入口本身是 button，先把浏览器默认样式抹掉 */
.side-nav-btn {
    width: calc(100% - 24px);
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    cursor: pointer;
    appearance: none;
}

.side-nav { position: relative; }

.nav-badge {
    display: none;
    position: absolute;
    top: -5px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    color: #fff;
    text-align: center;
    background: #ef4444;
    border-radius: 99px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45);
}

.nav-badge.show { display: block; }

/* ---- 好友抽屉 ---- */

.friend-card {
    max-width: 440px;
    max-height: 88vh;
    overflow-y: auto;
}

.friend-search {
    display: flex;
    gap: 8px;
}

.friend-search .field { flex: 1; min-width: 0; }
.friend-search .btn { flex-shrink: 0; padding: 0 16px; }

.friend-section { margin-top: 18px; }

.friend-section-title {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-faint);
    text-transform: uppercase;
}

.friend-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 6px 10px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    touch-action: manipulation;
}

.friend-item.clickable {
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease;
    /* 行的点击由容器上的委托统一处理：整行（含头像、名字、摘要）落到哪一块都算数。
       顺带禁掉长按选中文字，免得手机上点着点着弹出选择框。 */
    -webkit-user-select: none;
    user-select: none;
}

.friend-item.clickable:hover {
    border-color: var(--accent);
    background: #fff;
}

.friend-ava {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 50%;
}

.friend-ava img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.friend-item .meta { flex: 1; min-width: 0; }

.friend-item .nm {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-item .sub {
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-item .btn {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 12.5px;
    touch-action: manipulation;
}

.friend-dot {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    color: #fff;
    text-align: center;
    background: #ef4444;
    border-radius: 99px;
}

.friend-empty {
    padding: 14px;
    font-size: 12.5px;
    color: var(--text-faint);
    text-align: center;
}

/* ---- 录音浮层 ---- */

.voice-hud {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
}

.voice-hud.show { display: flex; }

.voice-hud-box {
    min-width: 170px;
    padding: 22px 24px;
    text-align: center;
    color: #fff;
    background: rgba(30, 41, 59, 0.92);
    border-radius: 16px;
    animation: msgIn 0.18s ease;
}

.voice-hud-time {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.voice-hud-tip {
    margin-top: 8px;
    font-size: 12.5px;
    opacity: 0.85;
}

.voice-hud.cancel .voice-hud-box { background: rgba(185, 28, 28, 0.94); }

/* 麦克风按钮：录音时手指会拖动（上滑取消），别让它触发页面滚动 */
#btn-voice { touch-action: none; }

/* ---- 语音消息气泡 ---- */

.voice-msg {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 100px;
    /* 气泡自己有 11px / 15px 的内边距，按钮要是只有 23px 高，
       手指点在气泡的留白上就没反应。用负外边距把按钮撑满整个气泡，
       点哪儿都能播；42px 也满足手机端点按尺寸的约定。 */
    min-height: 42px;
    margin: -11px -15px;
    padding: 0 15px;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
}

.voice-play {
    font-size: 15px;
    line-height: 1;
}

.voice-bars {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 16px;
}

.voice-bars i {
    display: block;
    width: 3px;
    background: currentColor;
    border-radius: 2px;
    opacity: 0.45;
}

.voice-bars i:nth-child(1) { height: 6px; }
.voice-bars i:nth-child(2) { height: 11px; }
.voice-bars i:nth-child(3) { height: 16px; }
.voice-bars i:nth-child(4) { height: 9px; }
.voice-bars i:nth-child(5) { height: 13px; }

.voice-msg.playing .voice-bars i {
    opacity: 1;
    animation: voiceBar 0.9s ease-in-out infinite;
}

.voice-msg.playing .voice-bars i:nth-child(2) { animation-delay: 0.12s; }
.voice-msg.playing .voice-bars i:nth-child(3) { animation-delay: 0.24s; }
.voice-msg.playing .voice-bars i:nth-child(4) { animation-delay: 0.36s; }
.voice-msg.playing .voice-bars i:nth-child(5) { animation-delay: 0.48s; }

@keyframes voiceBar {
    0%, 100% { transform: scaleY(0.55); }
    50% { transform: scaleY(1.15); }
}

.voice-sec {
    font-size: 12px;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   手机端
   ========================================================================== */

@media (max-width: 760px) {
    .app { flex-direction: column; }

    /* 侧栏在手机上是一条顶栏。
       原来这里用横向滚动（overflow-x: auto），但头像列表 + 两个游戏入口
       加起来比一屏还宽，排在最后的「改密码 / 后台 / 退出」会被整个挤出可视区，
       必须把这条横向滑到底才看得到——用户就以为入口不见了。
       改成自动换行：任何一项都不会再被推出屏幕。 */
    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
        padding: 8px 10px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow: visible;
    }

    .sidebar-head,
    .sidebar-label,
    .sidebar-spacer { display: none; }

    .persona-list {
        flex-direction: row;
        padding: 0;
        gap: 6px;
    }

    .persona-item {
        padding: 6px 12px 6px 6px;
        border-radius: 99px;
    }

    .persona-item .avatar {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }

    .persona-item .desc { display: none; }
    .persona-item .name { font-size: 13px; white-space: nowrap; }

    /* 游戏入口也收成一颗药丸，和上面的社娘保持一致 */
    .side-nav {
        margin: 0;
        padding: 6px 12px 6px 6px;
        gap: 8px;
        border-radius: 99px;
    }
    .side-nav .ico { width: 32px; height: 32px; font-size: 15px; }
    .side-nav .nm { font-size: 13px; line-height: 1.2; }
    .side-nav .tag { display: none; }

    .sidebar-foot {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 0;
        border-top: none;
        margin-left: auto;
    }

    .user-chip { padding: 5px; margin-bottom: 0; }
    .user-chip .info { display: none; }
    .user-chip .ico { width: 32px; height: 32px; }

    .sidebar-foot .actions .btn { padding: 7px 10px; }
    .sidebar-foot .actions .btn .lbl { display: none; }

    .messages { padding: 18px 14px 6px; }
    .msg .body { max-width: 84%; }
    .composer { padding: 10px 14px 14px; }
    .chat-head { padding: 11px 15px; }
    .chat-head .avatar { width: 40px; height: 40px; font-size: 19px; }
    .composer-tip .hint { display: none; }

    /* 好友抽屉：手机上接近全屏，列表项和输入框都按触摸尺寸来 */
    .friend-card {
        max-height: 92vh;
        padding: 20px 16px;
    }

    /* 好友入口在手机上也是一颗药丸，别占满整行 */
    .side-nav-btn { width: auto; }

    .friend-search .field { font-size: 16px; }
    .friend-search .btn { min-height: 44px; }

    .friend-item { min-height: 52px; }
    .friend-item .btn { min-height: 40px; }

    /* 图片按钮：手机上要够大好点 */
    .composer-box .attach-btn {
        width: 44px;
        height: 44px;
        font-size: 19px;
    }

    /* 按住说话：手机上再高一点，按住的整个过程手指不容易滑出去 */
    .voice-bar {
        min-height: 52px;
        margin-bottom: 8px;
        font-size: 15px;
    }
}


/* 侧栏「返回官网」链接（聊天室现在是官网的一个功能模块） */
.back-site {
    color: #b9a7d6;
    text-decoration: none;
    font-size: 12px;
    transition: color .18s ease;
}
.back-site:hover { color: #f472b6; }
