/* ========================================
           CSS 变量定义区域
           定义全局颜色、间距、圆角、过渡效果等设计系统变量
           ======================================== */
        :root {
            --bg-primary: #1a1c23;
            --bg-secondary: #262933;
            --bg-tertiary: #2d303a;
            --bg-sidebar: #1f222b;
            --text-primary: #e0e0e0;
            --text-secondary: #aaa;
            --text-muted: #888;
            --accent-gold: #e6c78a;
            --accent-gold-rgb: 230, 199, 138;
            --border-color: #333;
            --border-light: rgba(255, 255, 255, 0.1);
            --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
            --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
            --radius-sm: 6px;
            --radius-md: 8px;
            --radius-lg: 12px;
            --radius-xl: 20px;
            --transition-fast: 0.2s;
            --transition-normal: 0.3s;
            --spacing-xs: 5px;
            --spacing-sm: 8px;
            --spacing-md: 12px;
            --spacing-lg: 15px;
            --spacing-xl: 20px;
            --spacing-2xl: 25px;
            --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            --z-index-overlay: 100;
            --z-index-modal: 1000;
            --sidebar-width: 280px;
            --avatar-size-sm: 40px;
            --avatar-size-md: 45px;
            --bubble-max-width-desktop: 85%;
            --bubble-max-width-mobile: 90%;
        }

        /* ========================================
           全局重置样式
           移除所有元素的默认外边距和内边距，统一盒模型
           ======================================== */
        * { margin: 0; padding: 0; box-sizing: border-box; }

        /* ========================================
           主体容器样式
           设置页面背景、字体、高度，使用 Flexbox 居中布局
           ======================================== */
        html {
            height: 100%;
        }

        body {
            font-family: var(--font-family);
            background-color: var(--bg-primary);
            color: var(--text-primary);
            min-height: 100vh;
            min-height: 100dvh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
            padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
        }

        /* ========================================
           应用主容器
           包含侧边栏和聊天区域的响应式容器
           ======================================== */
        .app-container {
            width: 95vw;
            height: 90vh;
            max-width: 1400px;
            background-color: var(--bg-secondary);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-lg);
            display: flex;
            overflow: hidden;
            position: relative;
        }

        /* ========================================
           聊天区域样式
           占据剩余空间，包含头部、消息区和输入区
           支持背景图片自定义，带有半透明遮罩层
           ======================================== */
        .chat-area {
            flex: 1 1 0;
            min-width: 0;
            /* 必须有确定高度，才能让中间消息列表独立滚动而不挤掉输入框。 */
            min-height: 0;
            height: 100%;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            background-color: var(--bg-tertiary);
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            position: relative;
            transition: background-image 0.5s ease;
        }

        /* 聊天区域背景遮罩层，确保文字可读性
           注意：--chat-bg-overlay-opacity 默认 1（无背景图时等同纯色底）；
           设置了聊天背景图后由 JS 调低，否则遮罩会把背景图完全盖住。 */
        .chat-area::before {
            content: '';
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            background-color: #2d303a;
            opacity: var(--chat-bg-overlay-opacity, 1);
            transition: opacity 0.3s ease;
            z-index: 0;
            pointer-events: none;
        }

        /* 确保头部、消息区和输入区在遮罩层之上 */
        .chat-header, .chat-messages, .chat-input-area {
            position: relative;
            z-index: 1;
        }

        /* 头部、搜索栏和输入区不可被消息内容压缩；仅消息区允许收缩并滚动。 */
        .chat-header,
        .chat-search-bar,
        .chat-input-area {
            flex: 0 0 auto;
            flex-shrink: 0;
        }

        /* 3D 实验室 */
        .laboratory-panel h3 { margin-bottom: 15px; color: #e6c78a; }
        .laboratory-switch { display:flex; align-items:flex-start; gap:10px; cursor:pointer; padding:12px; border:1px solid var(--border-color); border-radius:var(--radius-md); background:rgba(255,255,255,.03); }
        .laboratory-switch input { width:18px; height:18px; margin-top:2px; flex:none; }
        .laboratory-switch span { display:flex; flex-direction:column; gap:4px; }
        .laboratory-switch small, .laboratory-hint { color:var(--text-secondary); font-size:.82em; line-height:1.5; }
        .laboratory-options { margin-top:15px; padding:15px; border-left:2px solid var(--accent-gold); background:rgba(0,0,0,.12); }
        #laboratory-3d-viewer { position:absolute; z-index:4; right:18px; bottom:105px; width:210px; height:276px; border:1px solid rgba(var(--accent-gold-rgb),.55); border-radius:12px; overflow:hidden; background:rgba(20,22,30,.78); box-shadow:var(--shadow-lg); touch-action:none; }
        #laboratory-3d-viewer canvas { display:block; cursor:grab; }
        #laboratory-3d-viewer canvas:active { cursor:grabbing; }
        .laboratory-3d-title { height:26px; display:flex; align-items:center; gap:6px; padding:0 9px; color:var(--accent-gold); font-size:.78em; background:rgba(0,0,0,.4); cursor:move; user-select:none; }
        @media (max-width: 600px) { #laboratory-3d-viewer { transform:scale(.78); transform-origin:bottom right; right:-5px; bottom:84px; } }

        /* ========================================
           侧边栏样式
           显示联系人列表、搜索框和功能按钮
           ======================================== */
        .sidebar {
            width: var(--sidebar-width);
            background-color: var(--bg-sidebar);
            display: flex;
            flex-direction: column;
            padding: var(--spacing-xl);
            border-right: 1px solid var(--border-color);
            z-index: 2;
            transition: transform var(--transition-normal) ease;
            flex-shrink: 0;
            position: relative;
        }


        .sidebar.hidden {
            transform: translateX(-100%);
            position: absolute;
            height: 100%;
            box-shadow: 2px 0 10px rgba(0,0,0,0.5);
        }

        .sidebar-header { font-size: 1.2em; font-weight: bold; margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }


        .search-box-container {
            margin-bottom: 15px;
            position: relative;
        }
        .search-box {
            width: 100%;
            padding: 8px 12px 8px 35px;
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            color: var(--text-primary);
            font-size: 0.9em;
            outline: none;
            transition: all var(--transition-fast);
        }
        .search-box:focus {
            border-color: var(--accent-gold);
            box-shadow: 0 0 8px rgba(230, 199, 138, 0.3);
        }
        .search-box::placeholder {
            color: var(--text-muted);
        }
        .search-icon {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
            font-size: 1em;
            pointer-events: none;
        }

        .friend-list { flex-grow: 1; overflow-y: auto; margin-bottom: 20px; }
        .friend-list::-webkit-scrollbar { width: 6px; }
        .friend-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 3px; }
        .friend-list::-webkit-scrollbar-thumb { background-color: rgba(255,255,255,0.3); border-radius: 3px; transition: background-color 0.2s; }
        .friend-list::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,0.5); }
        .friend-item {
            display: flex; align-items: center; padding: var(--spacing-md) var(--spacing-sm);
            border-radius: var(--radius-md); cursor: pointer; transition: background-color var(--transition-fast);
            margin-bottom: var(--spacing-sm); position: relative;
        }
        .friend-item:hover { background-color: var(--bg-tertiary); }
        .friend-item.active { background-color: #3a3d47; border-left: 3px solid var(--accent-gold); }
        .friend-avatar { width: var(--avatar-size-sm); height: var(--avatar-size-sm); border-radius: 50%; object-fit: cover; margin-right: 12px; border: 2px solid transparent; background-color: #3a3d47; }
        .friend-avatar.lazy-avatar { background: linear-gradient(90deg, #3a3d47 25%, #4a4d57 50%, #3a3d47 75%); background-size: 200% 100%; animation: lazyShimmer 1.5s infinite; }
        @keyframes lazyShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
        .friend-item.active .friend-avatar { border-color: var(--accent-gold); }
        .friend-name { font-size: 1em; font-weight: 500; }
        .friend-status { font-size: 0.75em; color: var(--text-muted); margin-left: auto; }
        .friend-pin {
            position: absolute;
            top: 5px;
            right: 5px;
            color: var(--accent-gold);
            font-size: 0.8em;
            display: none;
        }
        .friend-item.pinned .friend-pin { display: block; }
        /* 长按/拖动角色排序时的反馈；排序不影响置顶和分组规则。 */
        .friend-item.reordering { opacity: .55; outline: 1px dashed var(--accent-gold); cursor: grabbing; user-select: none; }
        /* 排序启动前仍允许页面/列表正常滚动；启动后由 JS 阻止默认移动行为。 */
        .friend-item { -webkit-user-drag: none; user-select: none; }
        .friend-item img { -webkit-user-drag: none; }
        @media (pointer: coarse) { .friend-item { touch-action: pan-y; } }

        .sidebar-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
        .forum-entry { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 3px 8px; border: 1px solid rgba(230,199,138,.45); border-radius: 999px; color: var(--accent-gold); font-size: .72em; font-weight: 500; text-decoration: none; }
        .forum-entry:hover { background: rgba(230,199,138,.14); }
        .icon-btn {
            background: none; border: 1px solid #555; color: var(--text-secondary);
            border-radius: 50%; width: 40px; height: 40px;
            display: flex; justify-content: center; align-items: center;
            cursor: pointer; transition: all var(--transition-fast);
        }
        .icon-btn:hover { border-color: var(--accent-gold); color: #fff; transform: scale(1.1); }


        /* 悬浮方形按钮（汉堡菜单 / 视图切换）共用几何与居中规则。
           修复：过去 .mobile-menu-btn 基础样式只写 display:none，媒体查询改成 display:flex 后
           没有 justify-content / align-items，加上 <button> 自带 padding，
           导致三条杠图标被挤到按钮左上角。这里统一强制居中。 */
        .mobile-menu-btn,
        .view-toggle-btn {
            position: absolute;
            top: 15px;
            z-index: 10;
            box-sizing: border-box;
            width: 40px;
            height: 40px;
            padding: 0;          /* 清掉按钮默认内边距，否则图标偏移 */
            margin: 0;
            background-color: rgba(31, 34, 43, 0.9);
            border: 1px solid #555;
            color: #aaa;
            border-radius: 8px;
            font-size: 1.2em;
            line-height: 1;      /* 避免行高把图标顶偏 */
            cursor: pointer;
            transition: all 0.2s;
            /* 关键：flex 居中，图标始终位于按钮正中 */
            align-items: center;
            justify-content: center;
            text-align: center;
            -webkit-appearance: none;
            appearance: none;
        }

        /* 图标本身也归零，防止 remixicon 的伪元素带来额外偏移 */
        .mobile-menu-btn > i,
        .view-toggle-btn > i {
            display: block;
            line-height: 1;
            margin: 0;
            pointer-events: none;
        }

        .mobile-menu-btn {
            display: none;       /* 桌面隐藏；移动端媒体查询会改为 flex */
            left: 15px;
        }

        .view-toggle-btn {
            display: flex;
            right: 15px;
        }

        .mobile-menu-btn:hover,
        .view-toggle-btn:hover {
            border-color: var(--accent-gold);
            color: #fff;
            background-color: rgba(31, 34, 43, 1);
        }


        .sidebar-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.3s, visibility 0.3s;
        }
        .sidebar-overlay.show {
            opacity: 1;
            visibility: visible;
        }


        .friend-context-menu {
            position: fixed;
            background-color: #2d303a;
            border: 1px solid #444;
            border-radius: 8px;
            padding: 8px;
            display: none;
            flex-direction: column;
            gap: 5px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.5);
            z-index: 1000;
            min-width: 140px;
        }
        .friend-context-menu.show { display: flex; }


        .friend-group-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .friend-group-option {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 16px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s;
            background-color: #383b45;
            border: 1px solid transparent;
        }
        .friend-group-option:hover {
            background-color: #4a4d57;
        }
        .friend-group-option.active {
            background-color: #e3f2fd;
            color: #1976d2;
            border-color: #1976d2;
        }
        .friend-group-option i {
            font-size: 1.2em;
        }


        .friend-group-header {
            display: flex;
            align-items: center;
            padding: 10px 8px 6px;
            margin-top: 12px;
            margin-bottom: 4px;
            color: #888;
            font-size: 0.85em;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            border-bottom: 1px solid #3a3d47;
            cursor: pointer;
            user-select: none;
            transition: all 0.2s;
        }
        .friend-group-header:hover {
            color: var(--accent-gold);
            background-color: rgba(230, 199, 138, 0.1);
        }
        .friend-group-header:first-child {
            margin-top: 0;
        }
        .friend-group-header i {
            margin-right: 6px;
            font-size: 1em;
            transition: transform 0.3s;
        }
        .friend-group-header.collapsed i {
            transform: rotate(-90deg);
        }
        .friend-group-header .group-count {
            margin-left: auto;
            font-size: 0.9em;
            opacity: 0.7;
        }
        .friend-group-content {
            overflow: hidden;
            transition: max-height 0.3s ease-out;
        }
        .friend-group-content.collapsed {
            max-height: 0 !important;
        }
        .friend-menu-item {
            display: flex;
            align-items: center;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            color: #ddd;
            font-size: 0.9em;
            transition: background-color 0.2s;
        }
        .friend-menu-item:hover { background-color: #3a3d47; color: var(--accent-gold); }
        .friend-menu-item i { margin-right: 10px; font-size: 1.1em; }
        .friend-menu-item.danger:hover { color: #f44336; }


        /* 桌面视图下右上角同样悬浮着「切换视图」按钮（right:15px + 40px 宽 = 55px），
           且其 z-index:10 高于 chat-header 的 z-index:1，
           若右内边距仍是 25px，清空聊天记录的垃圾桶按钮会被盖住且无法点击。
           因此右侧统一预留 62px。 */
        .chat-header {
            padding: 15px 62px 15px 25px;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            font-size: 1.1em; font-weight: bold; display: flex;
            justify-content: space-between; align-items: center;
            gap: 10px;
        }

        /* 长角色名可省略号收缩，右侧按钮组不被挤压 */
        .chat-header > #current-friend-name {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .chat-header > div {
            flex-shrink: 0;
        }

        .editable-name {
            cursor: pointer; padding: 4px 8px; border-radius: 4px;
            transition: background-color 0.2s; display: inline-block;
        }
        .editable-name:hover { background-color: rgba(255,255,255,0.1); color: var(--accent-gold); }
        .name-input {
            background: transparent; border: 1px solid var(--accent-gold);
            color: var(--accent-gold); font-size: 1.1em; font-weight: bold;
            padding: 4px 8px; border-radius: 4px; outline: none; width: 150px;
        }

        .chat-messages {
            /* 只让消息区域占用并滚动剩余高度，不能因长记录挤压底部输入框。 */
            flex: 1 1 0;
            min-height: 0;
            padding: 25px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 20px;
            overscroll-behavior: contain;
            -webkit-overflow-scrolling: touch;
        }
        .chat-messages::-webkit-scrollbar { width: 8px; }
        .chat-messages::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
        .chat-messages::-webkit-scrollbar-thumb { background-color: rgba(255,255,255,0.2); border-radius: 4px; }

        /* ========================================
           「回到最新消息」悬浮按钮
           未滑到底部时出现，点击平滑滑到聊天记录最后
           ======================================== */
        .scroll-to-bottom-btn {
            position: absolute;
            right: 22px;
            /* 距聊天区底部的距离由 JS 写进 --stb-bottom：
               输入区高度会随输入行数、待发送附件与手机键盘变化，
               写死数值会让按钮压在输入框上面。 */
            bottom: var(--stb-bottom, 96px);
            width: 40px;
            height: 40px;
            padding: 0;
            border-radius: 50%;
            border: 1px solid rgba(var(--accent-gold-rgb, 230, 199, 138), 0.5);
            background-color: rgba(28, 30, 38, 0.92);
            color: var(--accent-gold);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2em;
            cursor: pointer;
            z-index: 4;
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
            opacity: 0;
            transform: translateY(10px) scale(0.9);
            pointer-events: none;
            transition: opacity 0.22s ease, transform 0.22s ease, background-color 0.2s ease;
        }
        /* hidden 属性必须真的不显示：.scroll-to-bottom-btn 自带 display:flex，
           作者样式会盖掉浏览器默认的 [hidden]{display:none}，所以显式补一条。 */
        .scroll-to-bottom-btn[hidden] { display: none; }
        .scroll-to-bottom-btn.show {
            opacity: 1;
            transform: translateY(0) scale(1);
            pointer-events: auto;
        }
        .scroll-to-bottom-btn:hover {
            background-color: rgba(230, 199, 138, 0.2);
            border-color: var(--accent-gold);
        }
        .scroll-to-bottom-btn:active { transform: translateY(1px) scale(0.96); }
        .scroll-to-bottom-btn .stb-badge {
            position: absolute;
            top: -5px;
            right: -5px;
            min-width: 18px;
            height: 18px;
            padding: 0 5px;
            border-radius: 9px;
            background: #e05a5a;
            color: #fff;
            font-size: 0.62em;
            line-height: 18px;
            text-align: center;
            font-weight: 700;
        }
        .scroll-to-bottom-btn .stb-badge[hidden] { display: none; }

        /* ========================================
           全屏模式：界面铺满整个视口
           由 body.fullscreen-mode 驱动（见 main.js 的 applyFullscreenMode）
           ======================================== */
        body.fullscreen-mode {
            padding: 0;
            align-items: stretch;
            justify-content: stretch;
        }
        body.fullscreen-mode .app-container {
            width: 100vw;
            height: 100vh;
            height: 100dvh;
            max-width: none;
            border-radius: 0;
            box-shadow: none;
        }
        /* 全屏模式下纵向位置同样交给 --stb-bottom 计算（输入区永远是动态高度），
           这里只把横向内收一点，避免贴到窗口边缘。 */
        body.fullscreen-mode .scroll-to-bottom-btn { right: 20px; }

        /* 手机上「全屏模式」和「手机视图」效果一致，都铺满屏幕，无需重复规则 */
        @media (max-width: 768px) {
            body.fullscreen-mode .app-container { border-radius: 0; }
        }

        .message { display: flex; align-items: flex-start; max-width: 60%; animation: fadeIn 0.3s ease; }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

        .avatar {
            width: 45px; height: 45px; border-radius: 50%;
            object-fit: cover; flex-shrink: 0; cursor: pointer;
            transition: transform 0.2s; border: 2px solid transparent;
        }
        .avatar:hover { transform: scale(1.05); border-color: var(--accent-gold); }

        .message-content { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
        .nickname { font-size: 0.85em; color: #ccc; margin-bottom: 5px; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }

        /* border-radius 由 JS 写入的 --bubble-radius 变量驱动，
           使「气泡样式」切换后已渲染的气泡也能立即生效 */
        .bubble {
            padding: 12px 16px;
            border-radius: var(--bubble-radius, 12px);
            line-height: 1.5;
            word-wrap: break-word; overflow-wrap: break-word;
            max-width: 100%; position: relative;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
            background-size: cover !important;
            background-position: center !important;
            background-repeat: no-repeat !important;
            transition: all 0.3s;
        }


        .bubble p { margin: 0 0 8px 0; }
        .bubble p:last-child { margin-bottom: 0; }
        .bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 {
            margin: 12px 0 8px 0;
            font-weight: bold;
            line-height: 1.4;
        }
        .bubble h1 { font-size: 1.5em; }
        .bubble h2 { font-size: 1.3em; }
        .bubble h3 { font-size: 1.2em; }
        .bubble ul, .bubble ol { margin: 8px 0; padding-left: 20px; }
        .bubble li { margin: 4px 0; }
        .bubble blockquote {
            border-left: 3px solid var(--accent-gold);
            padding-left: 12px;
            margin: 8px 0;
            color: var(--text-secondary);
            font-style: italic;
        }
        .bubble code {
            background-color: rgba(0,0,0,0.3);
            padding: 2px 6px;
            border-radius: 4px;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 0.9em;
        }
        .bubble pre {
            background-color: rgba(0,0,0,0.4);
            padding: 12px;
            border-radius: 6px;
            overflow-x: auto;
            max-width: 100%;
            margin: 8px 0;
            -webkit-overflow-scrolling: touch;
        }
        .bubble pre code {
            background-color: transparent;
            padding: 0;
        }
        .bubble table {
            border-collapse: collapse;
            width: 100%;
            margin: 8px 0;
        }
        .bubble th, .bubble td {
            border: 1px solid rgba(255,255,255,0.2);
            padding: 8px;
            text-align: left;
        }
        .bubble th { background-color: rgba(230, 199, 138, 0.2); }
        .bubble hr {
            border: none;
            border-top: 1px solid rgba(255,255,255,0.2);
            margin: 12px 0;
        }
        .bubble a {
            color: var(--accent-gold);
            text-decoration: underline;
        }


        /* ========================================
           平板竖屏适配 (Portrait Tablet)
           针对 769px-1024px 且高度大于宽度的设备
           使用类似手机的布局体验
           ======================================== */
        @media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
            .app-container {
                width: 100vw;
                height: 100vh;
                height: 100dvh;
                max-width: none;
                border-radius: 0;
                box-shadow: none;
            }

            .sidebar {
                position: absolute;
                width: min(82vw, 340px);
                max-width: calc(100vw - 56px);
                height: 100%;
                z-index: 100;
                box-shadow: 2px 0 10px rgba(0,0,0,0.5);
            }

            .sidebar.hidden {
                transform: translateX(-105%);
            }

            .mobile-menu-btn {
                display: flex;
            }

            /* 右侧需为悬浮的「切换视图」按钮（right:15px + 40px 宽）让位，
               否则会盖住清空聊天记录的垃圾桶按钮 */
            .chat-header {
                min-height: 56px;
                padding: 12px max(62px, calc(env(safe-area-inset-right) + 62px)) 12px max(50px, env(safe-area-inset-left));
                font-size: 1em;
                gap: 8px;
            }

            #current-friend-name,
            #my-display-name {
                min-width: 0;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            .chat-header > div {
                flex-shrink: 0;
            }

            .chat-messages {
                padding: 15px;
            }

            .chat-input-area {
                padding: 12px 15px;
                gap: 12px;
            }

            .input-wrapper input, .input-wrapper textarea {
                padding: 12px 14px;
                font-size: 1em;
            }

            .input-icons i {
                font-size: 1.2em;
            }

            #send-btn {
                font-size: 1.4em;
            }

            .message {
                max-width: 88%;
            }

            .avatar {
                width: 42px;
                height: 42px;
            }

            .bubble {
                padding: 11px 15px;
                font-size: 1em;
            }

            .modal-content {
                width: 90%;
                max-height: 85vh;
            }

            /* 与手机端同样的问题：fixed 定位的角色/联系人菜单不能被塞 bottom，
               否则 top 与 bottom 同时生效会把菜单拉伸成长条。 */
            .avatar-context-menu {
                left: 15px !important;
                bottom: 70px !important;
                min-width: 150px;
            }

            .ai-avatar-context-menu,
            .friend-context-menu {
                left: 15px !important;
                min-width: 150px;
                max-height: min(62vh, 380px);
                overflow-y: auto;
            }

            .message-actions, .quick-replies {
                margin-left: 50px;
            }

            .view-toggle-btn {
                display: none;
            }
        }

        /* 平板横屏适配 (Landscape Tablet) - 保持桌面布局但优化间距 */
        @media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
            .app-container {
                width: 98vw;
                height: 95vh;
            }

            .sidebar {
                width: 240px;
                padding: var(--spacing-lg);
            }

            .bubble {
                max-width: 80% !important;
            }

            .message-actions, .quick-replies {
                margin-left: 50px;
            }
        }

        @media (min-width: 769px) {
            .bubble {
                max-width: var(--bubble-max-width, 85%) !important;
                width: fit-content;
            }
        }


        @media (max-width: 768px) {
            .bubble {
                max-width: 90% !important;
            }
        }


        .bubble.has-custom-bg {
            color: #fff;
            text-shadow: 0 1px 3px rgba(0,0,0,0.9);
            background-color: rgba(0,0,0,0.4) !important;
            border: 1px solid rgba(255,255,255,0.1);
        }

        .bubble.proactive {
            border: 1px solid var(--accent-gold);
            background: linear-gradient(135deg, rgba(230, 199, 138, 0.1), rgba(45, 48, 58, 0.4));
            box-shadow: 0 0 10px rgba(230, 199, 138, 0.2);
        }
        .proactive-tag {
            font-size: 0.7em;
            color: var(--accent-gold);
            margin-bottom: 4px;
            display: block;
            font-style: italic;
        }


        .message-actions {
            display: flex;
            gap: 8px;
            margin-top: 8px;
            margin-left: 0;
        }
        .regenerate-btn {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 6px 12px;
            background: rgba(230, 199, 138, 0.15);
            border: 1px solid rgba(230, 199, 138, 0.3);
            border-radius: 6px;
            color: var(--accent-gold);
            font-size: 0.85em;
            cursor: pointer;
            transition: all 0.2s;
        }
        .regenerate-btn:hover {
            background: rgba(230, 199, 138, 0.25);
            transform: translateY(-1px);
        }
        .regenerate-btn:active { transform: translateY(0); }
        .regenerate-btn i { font-size: 0.9em; }


        .quick-replies {
            display: flex;
            gap: 10px;
            margin-top: 10px;
            margin-left: 0;
            flex-wrap: wrap;
        }
        .quick-reply-btn {
            padding: 8px 16px;
            background: rgba(100, 150, 200, 0.2);
            border: 1px solid rgba(100, 150, 200, 0.4);
            border-radius: 20px;
            color: #a8d8ff;
            font-size: 0.9em;
            cursor: pointer;
            transition: all 0.2s;
            max-width: 70%;
            word-break: break-word;
        }
        .quick-reply-btn:hover {
            background: rgba(100, 150, 200, 0.35);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }

        .system-bubble {
            background-color: rgba(0,0,0,0.4);
            border: 1px dashed rgba(255,255,255,0.3);
            color: #ddd;
            font-size: 0.9em;
            text-align: center;
            width: 100%;
            max-width: 100% !important;
            align-self: center;
            margin: 10px 0;
        }

        .message-image {
            /* 宽图必须按容器缩放，不能只限制高度，否则移动端会横向溢出而被裁掉。 */
            display: block;
            width: auto;
            height: auto;
            max-width: min(100%, 420px);
            max-height: 300px;
            object-fit: contain;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.3);
            cursor: zoom-in;
        }
        @media (max-width: 560px) {
            .message-image { max-width: 100%; max-height: 52vh; }
            .message-content { min-width: 0; }
        }
        .message-image:hover { transform: scale(1.02); }

        .message-video {
            max-width: 100%;
            max-height: 300px;
            border-radius: 8px;
            display: block;
            box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        }

        .message.other { align-self: flex-start; }
        .message.other .bubble { background-color: var(--accent-gold); color: #333; border-top-left-radius: var(--bubble-radius, 12px); }
        .message.other .message-content { margin-left: 12px; }

        .message.mine { align-self: flex-end; flex-direction: row-reverse; }
        .message.mine .bubble { background-color: var(--accent-gold); color: #333; border-top-right-radius: var(--bubble-radius, 12px); }
        .message.mine .message-content { margin-right: 12px; align-items: flex-end; }

        .chat-input-area {
            padding: 15px 25px; border-top: 1px solid rgba(255,255,255,0.1);
            display: flex; align-items: center; gap: 15px;
            background-color: #2d303a; position: relative;
            flex-direction: column;
            flex: 0 0 auto;
            flex-shrink: 0;
        }
        .input-stack { flex-grow: 1; width: 100%; display: flex; flex-direction: column; gap: 8px; }
        .pending-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; background: rgba(0,0,0,0.18); }
        .pending-attachments[hidden] { display: none; }
        .pending-attachment-item { position: relative; width: 74px; height: 74px; border-radius: 10px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.16); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #ddd; overflow: visible; }
        .pending-attachment-item img, .pending-attachment-item video { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }
        .pending-attachment-icon { font-size: 1.8em; color: var(--accent-gold); }
        .pending-attachment-name { width: 100%; padding: 0 5px; margin-top: 3px; font-size: 0.68em; color: #ccc; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .pending-attachment-remove { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.35); background: #2d303a; color: #fff; display: grid; place-items: center; cursor: pointer; z-index: 2; }
        .pending-attachment-remove:hover { background: #ff5757; }

        /* 待发送引用：以单行预览展示，不将完整被引用内容写入输入框。 */
        .pending-reply-preview { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 9px; border: 1px solid rgba(230,199,138,0.42); border-radius: 10px; background: rgba(230,199,138,0.09); color: #ddd; }
        .pending-reply-preview[hidden] { display: none; }
        .pending-reply-preview > .ri-double-quotes-l { flex: 0 0 auto; color: var(--accent-gold); font-size: 1.05em; }
        .pending-reply-content { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 0.82em; }
        .pending-reply-content strong { color: var(--accent-gold); font-weight: 500; }
        .pending-reply-cancel { flex: 0 0 auto; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #aaa; display: grid; place-items: center; cursor: pointer; }
        .pending-reply-cancel:hover { background: rgba(255,87,87,0.18); color: #ff7777; }
        .input-wrapper { flex-grow: 1; position: relative; display: flex; align-items: center; width: 100%; }
        .input-wrapper input, .input-wrapper textarea {
            width: 100%; padding: 12px 15px; border-radius: 20px;
            border: 1px solid rgba(255,255,255,0.2); background-color: rgba(0,0,0,0.3);
            color: #eee; outline: none;
        }
        .input-wrapper input::placeholder, .input-wrapper textarea::placeholder { color: #aaa; }
        .input-icons { display: flex; gap: 15px; color: #aaa; font-size: 1.2em; }
        .input-icons i { cursor: pointer; transition: color 0.2s; }
        .input-icons i:hover { color: #fff; }

        #image-upload, #avatar-upload, #bg-upload, #import-upload, #char-import-upload, #char-avatar-upload, #bubble-bg-upload { display: none; }

        .emoji-picker {
            position: absolute; bottom: 70px; left: 25px;
            background-color: #383b45; border: 1px solid #555;
            border-radius: 8px; padding: 10px;
            display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 100;
            display: none; max-height: 250px; overflow-y: auto;
        }
        .emoji-picker.show { display: grid; }
        .emoji-item { font-size: 1.5em; cursor: pointer; text-align: center; padding: 5px; border-radius: 4px; }
        .emoji-item:hover { background-color: #4a4d58; }


        .avatar-context-menu {
            position: absolute;
            bottom: 80px;
            left: 25px;
            background-color: #2d303a;
            border: 1px solid #444;
            border-radius: 8px;
            padding: 8px;
            display: none;
            flex-direction: column;
            gap: 5px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.5);
            z-index: 101;
            min-width: 160px;
        }
        .avatar-context-menu.show { display: flex; }
        .avatar-menu-item {
            display: flex;
            align-items: center;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            color: #ddd;
            font-size: 0.9em;
            transition: background-color 0.2s;
        }
        .avatar-menu-item:hover { background-color: #3a3d47; color: var(--accent-gold); }
        .avatar-menu-item i { margin-right: 10px; font-size: 1.1em; }


        .ai-avatar-context-menu {
            position: fixed;
            background-color: #2d303a;
            border: 1px solid #444;
            border-radius: 8px;
            padding: 8px;
            display: none;
            flex-direction: column;
            gap: 5px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.5);
            z-index: 1001;
            min-width: 160px;
        }
        .ai-avatar-context-menu.show { display: flex; }


        .modal-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background-color: rgba(0, 0, 0, 0.6);
            display: flex; justify-content: center; align-items: center;
            z-index: 1000; opacity: 0; visibility: hidden;
            transition: opacity 0.3s, visibility 0.3s;
        }
        .modal-overlay.show { opacity: 1; visibility: visible; }

        .modal-content {
            background-color: #2d303a;
            width: 500px;
            max-width: 90%;
            max-height: 85vh;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column;
            transform: translateY(-20px);
            transition: transform 0.3s;
            border: 1px solid #444;
        }
        .modal-overlay.show .modal-content { transform: translateY(0); }

        .modal-header {
            padding: 20px;
            border-bottom: 1px solid #3a3d47;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }
        .modal-header h2 { font-size: 1.5em; }
        .settings-search-wrap {
            flex: 1;
            max-width: 420px;
            margin: 0 18px;
            position: relative;
        }
        .settings-search-wrap i {
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: #aaa;
            pointer-events: none;
        }
        .settings-search-wrap input {
            width: 100%;
            padding: 10px 12px 10px 38px;
            border-radius: 999px;
            border: 1px solid #444;
            background: #383b45;
            color: #eee;
            outline: none;
        }
        .settings-search-wrap input:focus { border-color: var(--accent-gold); }
        .settings-no-results {
            padding: 28px;
            text-align: center;
            color: #aaa;
            border: 1px dashed #555;
            border-radius: 10px;
            margin-top: 12px;
        }
        .close-modal { background: none; border: none; color: #aaa; font-size: 1.5em; cursor: pointer; }
        .close-modal:hover { color: #fff; }

        .modal-body {
            padding: 25px;
            flex-grow: 1;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: #555 #2d303a;
        }

        .modal-body::-webkit-scrollbar { width: 6px; }
        .modal-body::-webkit-scrollbar-track { background: #2d303a; border-radius: 3px; }
        .modal-body::-webkit-scrollbar-thumb { background-color: #555; border-radius: 3px; }
        .modal-body::-webkit-scrollbar-thumb:hover { background-color: #777; }

        .settings-tabs { display: flex; gap: 15px; margin-bottom: 25px; border-bottom: 1px solid #3a3d47; overflow-x: auto; }
        .tab-button {
            background: none; border: none; color: #aaa; font-size: 1em;
            padding-bottom: 10px; cursor: pointer; position: relative;
            white-space: nowrap;
        }
        .tab-button.active { color: var(--accent-gold); font-weight: bold; }
        .tab-button.active::after {
            content: ''; position: absolute; bottom: -1px; left: 0;
            width: 100%; height: 2px; background-color: var(--accent-gold);
        }
        .tab-content { display: none; }
        .tab-content.active { display: block; }

        .form-group { margin-bottom: 20px; }
        .form-group label { display: block; margin-bottom: 8px; color: #aaa; font-size: 0.9em; }
        /* 设置面板控件基线：原先只有一条 padding 加「focus 换个边框色」，
           没有过渡、没有 placeholder 配色、focus 也无可见反馈，
           这是「其他功能的输入框也丑」最主要的来源。
           层叠纪律：主选择器保持与原文件完全相同的特异性 (0,1,1)，
           不新增 :not() 链 —— 一旦特异性涨过 `body.light-theme .form-group input`
           (0,2,2)，这套暗色值就会反向覆盖浅色主题。 */
        .form-group input, .form-group select, .form-group textarea {
            width: 100%; padding: 10px 12px; border-radius: 9px;
            border: 1px solid var(--ui-field-border, #454a57);
            background-color: var(--ui-field-bg, #383b45);
            color: var(--ui-field-text, #eee); outline: none;
            font-family: inherit; font-size: 0.92em; line-height: 1.5;
            box-sizing: border-box;
            transition: border-color .18s, box-shadow .18s, background-color .18s;
        }
        .form-group textarea { resize: vertical; min-height: 80px; }
        .form-group input::placeholder, .form-group textarea::placeholder {
            color: var(--ui-field-placeholder, #8b90a0); opacity: 1;
        }
        /* 复选框不能被 width:100% 拉成一条；带内联 style 的那些仍由内联决定 */
        .form-group input[type="checkbox"], .form-group input[type="radio"] { width: auto; height: auto; }
        .form-group input, .form-group select, .form-group textarea { accent-color: var(--accent-gold); }
        /* hover / focus 用 .form-group input:focus 形式（特异性 0,2,1）：
           必须高于上面基础规则 (0,1,1) 才能真正改到边框色；
           又必须低于 `body.light-theme .form-group input` (0,2,2)，
           才不会被这套暗色值反向压住浅色主题。 */
        .form-group input:hover, .form-group select:hover, .form-group textarea:hover {
            background-color: var(--ui-field-bg-hover, #383b45);
            border-color: #565c6b;
        }
        .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
            border-color: var(--accent-gold);
            box-shadow: var(--ui-focus-ring, 0 0 0 3px rgba(230, 199, 138, .18));
        }


        .message.system {
            justify-content: center;
            opacity: 0.92;
        }
        .message.system .avatar,
        .message.system .message-actions,
        .message.system .message-time {
            display: none;
        }
        .message.system .message-content {
            max-width: 82%;
            align-items: center;
        }
        .message.system .message-sender {
            color: var(--accent-gold);
            text-align: center;
        }
        .message.system .bubble {
            background: rgba(230, 199, 138, 0.14);
            border: 1px solid rgba(230, 199, 138, 0.35);
            color: #f0e6c8;
            border-radius: 999px;
        }

        .group-error-continue-modal { z-index: 1300; }
        .group-error-continue-modal .modal-content { max-width: 460px; }
        .group-error-continue-modal .modal-header h2 { color: #f0b27a; }
        .group-error-continue-tip { margin-top: 10px; color: #aaa; font-size: 0.88em; line-height: 1.55; }
        .group-error-continue-check {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-top: 18px;
            color: #e6c78a;
            cursor: pointer;
            user-select: none;
        }
        .group-error-continue-check input { width: auto; accent-color: var(--accent-gold); }
        .group-error-continue-actions { gap: 12px; justify-content: flex-end; }
        .group-error-continue-actions .btn { flex: 1; justify-content: center; }

        .modal-footer {
            padding: 20px;
            border-top: 1px solid #3a3d47;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }
        .btn {
            padding: 10px 20px; border-radius: 6px; border: none;
            font-size: 1em; cursor: pointer; display: flex; align-items: center; gap: 8px;
        }
        .btn-secondary { background-color: #555; color: #eee; }
        .btn-secondary:hover { background-color: #666; }
        .btn-primary { background-color: #4CAF50; color: white; }
        .btn-primary:hover { background-color: #45a049; }
        .btn-test { background-color: #2196F3; color: white; }
        .btn-test:hover { background-color: #1e88e5; }
        .btn-danger { background-color: #f44336; color: white; }
        .btn-danger:hover { background-color: #d32f2f; }
        .btn-outline { background: transparent; border: 1px solid #666; color: #ddd; }
        .btn-outline:hover { border-color: var(--accent-gold); color: var(--accent-gold); }
        .btn-success { background-color: #28a745; color: white; }
        .btn-success:hover { background-color: #218838; }
        .btn-sm { padding: 5px 10px; font-size: 0.85em; }

        /* ==========================================================
           多站点 API 配置面板（设置 → AI 配置）
           ========================================================== */
        .ep-block { border-bottom: 1px dashed #3a3d47; padding-bottom: 16px; }
        .ep-current-row { display: flex; gap: 10px; align-items: center; }
        .ep-current-row select { flex: 1 1 auto; min-width: 0; }
        .ep-current-row .btn { flex: 0 0 auto; }
        .ep-check-row {
            display: flex; align-items: flex-start; gap: 9px;
            margin-top: 12px; cursor: pointer; font-size: .84em; color: #c6cad6;
        }
        .ep-check-row input { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
        .ep-check-row span { flex: 1 1 auto; line-height: 1.55; }
        .ep-check-inline { margin: 0; }
        .ep-quick-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
        .ep-hint { font-size: .76em; color: #8b93a5; flex: 1 1 100%; line-height: 1.6; }
        .ep-hint i { color: var(--accent-gold, #e6c78a); margin-right: 3px; }
        #endpoint-list-empty.ep-hint { flex: 0 0 100%; padding: 10px 0 0; }

        .ep-list { display: flex; flex-direction: column; gap: 8px; }
        .ep-site {
            border: 1px solid #3d414c; border-radius: 10px;
            background: rgba(255,255,255,.025); padding: 10px 12px;
        }
        .ep-site.is-active { border-color: rgba(230,199,138,.55); background: rgba(230,199,138,.07); }
        .ep-site.is-off { opacity: .55; }
        .ep-site-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
        .ep-order {
            flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
            display: inline-flex; align-items: center; justify-content: center;
            background: rgba(230,199,138,.18); color: #e6c78a;
            font-size: .74em; font-weight: 700; margin-top: 2px;
        }
        .ep-site-main { flex: 1 1 220px; min-width: 0; }
        .ep-site-name { font-size: .92em; color: #eee; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
        .ep-site-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: .76em; color: #98a0b0; }
        .ep-meta-item { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
        .ep-meta-item i { color: #7d8496; }
        .ep-meta-item.ep-warn { color: #f0b27a; }
        .ep-site-actions { display: flex; flex-wrap: wrap; gap: 5px; flex: 0 0 auto; }
        .ep-site-actions .btn { height: 26px; padding: 0 8px; font-size: .76em; }
        .ep-badge {
            font-size: .68em; font-weight: 600; padding: 1px 7px; border-radius: 999px;
            border: 1px solid rgba(255,255,255,.16); color: #aeb6c6; background: rgba(255,255,255,.05);
        }
        .ep-badge--active { border-color: rgba(230,199,138,.6); color: #e6c78a; background: rgba(230,199,138,.14); }
        .ep-badge--off { border-color: rgba(244,67,54,.5); color: #f4837a; }
        .ep-badge--backup { border-color: rgba(120,180,255,.4); color: #8fbaff; }
        .ep-badge--models { border-style: dashed; color: #8fd18f; border-color: rgba(143,209,143,.45); }
        .ep-site-test { margin-top: 6px; font-size: .76em; line-height: 1.5; overflow-wrap: anywhere; }
        .ep-site-test.ep-tone-ok { color: #8fd18f; }
        .ep-site-test.ep-tone-err { color: #f4837a; }
        .ep-site-test.ep-tone-info { color: #8ab6e8; }

        .ep-editor { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #3d414c; }
        .ep-editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
        .ep-editor-grid label { display: block; font-size: .76em; color: #9aa1b2; }
        .ep-editor-grid input, .ep-editor-grid textarea {
            width: 100%; margin-top: 4px; padding: 7px 9px; border-radius: 7px;
            border: 1px solid #444; background: #383b45; color: #eee; outline: none; font-family: inherit;
        }
        .ep-editor-grid textarea { resize: vertical; min-height: 54px; }
        .ep-editor-grid input:focus, .ep-editor-grid textarea:focus { border-color: var(--accent-gold, #e6c78a); }
        .ep-editor-wide { grid-column: 1 / -1; }
        .ep-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
        .ep-editor-actions .btn { height: 28px; font-size: .78em; }
        .ep-editor-current { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

        /* 「测试对话模型」现在会逐条列出主模型 / 备用模型的结果，需要竖排 */
        .test-result:has(.ep-test-line) { display: block; flex-direction: column; align-items: flex-start; }
        .ep-test-line { padding: 1px 0; line-height: 1.65; }
        .ep-test-note { margin-top: 4px; opacity: .78; font-size: .92em; }

        body.light-theme .ep-site { border-color: #d5d8e0; background: rgba(0,0,0,.02); }
        body.light-theme .ep-site-name { color: #2b2f3a; }
        body.light-theme .ep-site-meta { color: #6b7180; }
        body.light-theme .ep-editor-grid input,
        body.light-theme .ep-editor-grid textarea { background: #fff; border-color: #c9ccd6; color: #22262e; }

        /* 长期记忆档案操作按钮：button 与 label 统一尺寸、颜色和基线。 */
        .memory-archive-actions .memory-archive-action {
            box-sizing: border-box;
            min-height: 32px;
            margin: 0;
            padding: 5px 10px;
            border: 1px solid #666;
            border-radius: 6px;
            background: transparent;
            color: #ddd;
            font-size: 0.85em;
            line-height: normal;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            cursor: pointer;
        }
        .memory-archive-actions .memory-archive-action:hover {
            border-color: var(--accent-gold);
            color: var(--accent-gold);
        }

        .test-result { font-size: 0.9em; margin-top: 5px; min-height: 1.2em; word-break: break-word; display: flex; align-items: center; gap: 8px; }
        .test-result.success { color: #4CAF50; }
        .test-result.error { color: #f44336; }
        .test-result.info { color: #2196F3; }
        .test-result.warning { color: #ff9800; }

        @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
        .loading-spinner {
            display: inline-block;
            width: 14px;
            height: 14px;
            border: 2px solid rgba(255,255,255,0.3);
            border-radius: 50%;
            border-top-color: #fff;
            animation: spin 0.8s linear infinite;
            vertical-align: middle;
            margin-right: 6px;
        }


        @keyframes thinking-dot {
            0%, 100% { transform: translateY(0); opacity: 0.4; }
            50% { transform: translateY(-4px); opacity: 1; }
        }
        .thinking-dots {
            display: inline-flex;
            gap: 4px;
            align-items: center;
            justify-content: center;
            height: 20px;
        }
        .thinking-dots span {
            display: inline-block;
            width: 6px;
            height: 6px;
            background-color: #aaa;
            border-radius: 50%;
            animation: thinking-dot 1.4s ease-in-out infinite;
        }
        .thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
        .thinking-dots span:nth-child(3) { animation-delay: 0.4s; }


        .config-export-btn, .config-import-label {
            background: #2d303a;
            color: var(--accent-gold);
            border: 1px solid #444;
            padding: 8px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9em;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            transition: all 0.2s;
            margin-right: 10px;
        }
        .config-export-btn:hover, .config-import-label:hover {
            background: #3a3d4a;
            border-color: var(--accent-gold);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(230, 199, 138, 0.2);
        }
        #config-import-input {
            display: none;
        }


        .shortcut-hint {
            font-size: 0.75em;
            color: #888;
            margin-left: 8px;
            padding: 2px 6px;
            background: rgba(255,255,255,0.1);
            border-radius: 4px;
        }

        .import-section {
            border: 1px dashed #555;
            border-radius: 8px;
            padding: 20px;
            text-align: center;
            margin-bottom: 20px;
            transition: all 0.2s;
        }
        .import-section:hover {
            border-color: var(--accent-gold);
            background-color: rgba(230, 199, 138, 0.05);
        }
        .import-section p { color: #888; font-size: 0.85em; margin-bottom: 15px; }
        .import-hint { font-size: 0.8em; color: #666; margin-top: 10px; }

        .memory-list, .context-edit-list {
            max-height: 200px;
            overflow-y: auto;
            border: 1px solid #444;
            border-radius: 6px;
            padding: 10px;
            background: #262933;
            margin-top: 10px;
        }
        .memory-item, .context-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px;
            border-bottom: 1px solid #333;
            font-size: 0.9em;
        }
        .memory-item:last-child, .context-item:last-child { border-bottom: none; }
        .memory-key { color: var(--accent-gold); font-weight: bold; margin-right: 10px; }
        .memory-val { color: #ccc; flex: 1; }
        .del-memory, .del-context, .edit-context {
            cursor: pointer; font-size: 1.2em; padding: 0 5px;
        }
        .del-memory, .del-context { color: #f44336; }
        .del-memory:hover, .del-context:hover { color: #ff6b6b; }
        .edit-context { color: #4CAF50; }
        .edit-context:hover { color: #66bb6a; }

        .context-text {
            flex: 1;
            margin-right: 10px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: #ddd;
        }
        .context-role {
            font-weight: bold;
            margin-right: 5px;
            font-size: 0.8em;
            padding: 2px 4px;
            border-radius: 3px;
        }
        .role-mine { background-color: #3a3d47; color: var(--accent-gold); }
        .role-other { background-color: #3a3d47; color: #aaa; }


        .add-friend-modal .modal-content {
            width: 400px;
            max-height: 80vh;
            display: flex;
            flex-direction: column;
        }
        .add-friend-modal .modal-body {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            position: relative;
        }

        .add-friend-footer {
            padding: 15px 20px;
            border-top: 1px solid #444;
            background-color: #262933;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        #friend-options-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
            min-height: 100px;
        }

        .friend-option {
            display: flex;
            align-items: center;
            padding: 15px;
            border: 1px solid #444;
            border-radius: 8px;
            margin-bottom: 10px;
            cursor: pointer;
            transition: background-color 0.2s;
            flex-shrink: 0;
            position: relative;
        }
        .friend-option:hover {
            background-color: #383b45;
            border-color: var(--accent-gold);
        }
        .friend-option img {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            margin-right: 15px;
            object-fit: cover;
            flex-shrink: 0;
        }
        .friend-option-info {
            flex: 1;
            overflow: hidden;
            margin-right: 10px;
        }

        .group-member-select-content {
            width: 640px;
        }

        .group-member-select-toolbar {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            margin-bottom: 12px;
            color: #cfd3df;
        }

        .group-member-select-toolbar span {
            margin-right: auto;
            color: var(--accent-gold);
            font-weight: 600;
        }

        .group-member-select-search {
            width: 100%;
            padding: 12px 14px;
            border-radius: 8px;
            border: 1px solid #444;
            background: #232631;
            color: #eee;
            margin-bottom: 14px;
            outline: none;
        }

        .group-member-select-search:focus {
            border-color: var(--accent-gold);
            box-shadow: 0 0 0 2px rgba(230, 199, 138, 0.15);
        }

        .group-member-select-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
            gap: 10px;
            max-height: 48vh;
            overflow-y: auto;
            padding-right: 4px;
        }

        .group-member-option {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px;
            border: 1px solid #444;
            border-radius: 10px;
            background: #262933;
            cursor: pointer;
            transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
        }

        .group-member-option:hover {
            border-color: var(--accent-gold);
            background: #303440;
            transform: translateY(-1px);
        }

        .group-member-option.selected {
            border-color: var(--accent-gold);
            background: rgba(230, 199, 138, 0.12);
        }

        .group-member-option.disabled {
            opacity: 0.55;
            cursor: not-allowed;
        }

        .group-member-option input {
            width: 18px;
            height: 18px;
            accent-color: var(--accent-gold);
        }

        .group-member-option img {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            object-fit: cover;
            flex-shrink: 0;
        }

        .group-member-option-info {
            min-width: 0;
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .group-member-option-info strong,
        .group-member-option-info small {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .group-member-option-info small {
            color: #999;
        }

        .group-member-option-check {
            color: var(--accent-gold);
            opacity: 0;
            transition: opacity 0.2s;
        }

        .group-member-option.selected .group-member-option-check {
            opacity: 1;
        }

        .friend-option-info h3 {
            font-size: 1.1em;
            margin-bottom: 5px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .friend-option-info p {
            font-size: 0.85em;
            color: #aaa;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .custom-badge {
            position: absolute;
            top: 5px;
            right: 5px;
            background-color: var(--accent-gold);
            color: #333;
            font-size: 0.7em;
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: bold;
        }

        .export-char-btn {
            background: none;
            border: 1px solid #555;
            color: #aaa;
            border-radius: 50%;
            width: 32px;
            height: 32px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            transition: all 0.2s;
            flex-shrink: 0;
            font-size: 1.1em;
        }
        .export-char-btn:hover {
            border-color: var(--accent-gold);
            color: var(--accent-gold);
            background-color: rgba(230, 199, 138, 0.1);
        }

       /* 创建/编辑角色弹窗样式 */
        .character-edit-modal .modal-content {
            width: 500px;
            max-height: 85vh;
        }

        .create-character-section {
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px dashed #444;
        }
        .create-character-section h3 {
            color: var(--accent-gold);
            margin-bottom: 15px;
            font-size: 1.1em;
        }
        .import-char-section {
            margin-top: 15px;
            padding: 15px;
            border: 1px dashed #666;
            border-radius: 8px;
            text-align: center;
            background-color: rgba(0,0,0,0.1);
        }
        .import-char-section p {
            font-size: 0.85em;
            color: #aaa;
            margin-bottom: 10px;
        }


        .avatar-select-group {
            display: flex;
            gap: 10px;
            align-items: center;
        }
        .avatar-select-group input {
            flex: 1;
            min-width: 0;
        }
        .avatar-select-btn {
            padding: 10px 15px;
            border-radius: 6px;
            border: 1px solid #555;
            background-color: #383b45;
            color: #ddd;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 0.9em;
            transition: all 0.2s;
        }
        .avatar-select-btn:hover {
            border-color: var(--accent-gold);
            color: var(--accent-gold);
            background-color: rgba(230, 199, 138, 0.1);
        }

        /* 头像行在窄屏有三个控件（地址框 + 选择文件 + 裁切），
           一行摆不下就把按钮换到第二行并等宽铺开，避免地址框被压成一条缝。 */
        @media (max-width: 560px) {
            .avatar-select-group {
                flex-wrap: wrap;
            }
            .avatar-select-group input {
                flex: 1 1 100%;
            }
            .avatar-select-group .avatar-select-btn {
                flex: 1 1 auto;
                justify-content: center;
            }
        }


        @media (max-width: 768px) {
            body {
                padding: 0;
            }

            .app-container,
            .app-container.mobile-view {
                width: 100vw;
                height: 100vh;
                height: 100dvh;
                border-radius: 0;
                box-shadow: none;
            }

            .sidebar,
            .app-container.mobile-view .sidebar {
                position: absolute;
                width: min(86vw, 320px);
                max-width: calc(100vw - 52px);
                height: 100%;
                z-index: 100;
                box-shadow: 2px 0 10px rgba(0,0,0,0.5);
            }

            .mobile-menu-btn {
                display: flex;
            }

            /* 同上：为右上角悬浮的切换视图按钮预留 62px，避免遮挡垃圾桶按钮 */
            .chat-header {
                min-height: 56px;
                padding: 12px max(62px, calc(env(safe-area-inset-right) + 62px)) 12px max(50px, env(safe-area-inset-left));
                font-size: 1em;
                gap: 8px;
            }

            #current-friend-name,
            #my-display-name {
                min-width: 0;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            .chat-header > div {
                flex-shrink: 0;
            }

            /* 手机上聊天头部按钮较多（全屏/摘要/统计/清空），横排会互相挤压；
               允许换行并让名字区优先收缩，避免出现按钮被挤出屏幕或「错位」观感。 */
            .chat-header {
                flex-wrap: wrap;
                row-gap: 6px;
            }
            .chat-header > div {
                display: flex;
                flex-wrap: wrap;
                justify-content: flex-end;
                gap: 6px !important;
                max-width: 100%;
            }
            .chat-header .icon-btn {
                width: 32px !important;
                height: 32px !important;
                font-size: 0.85em !important;
            }

            .chat-messages {
                padding: 14px max(12px, env(safe-area-inset-right)) 14px max(12px, env(safe-area-inset-left));
                gap: 14px;
            }

            /* 悬浮按钮在手机上略微内收，避免贴到屏幕边缘
               （纵向位置仍由 JS 写进 --stb-bottom，不能在这里写死 bottom） */
            .scroll-to-bottom-btn {
                right: 12px;
                width: 38px;
                height: 38px;
            }

            .chat-input-area {
                padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
                gap: 10px;
            }

            .input-wrapper input, .input-wrapper textarea {
                padding: 10px 12px;
                font-size: 0.9em;
            }

            .input-icons i {
                font-size: 1.1em;
            }

            #send-btn {
                font-size: 1.3em;
            }

            .message {
                max-width: 94%;
            }

            .avatar {
                width: 38px;
                height: 38px;
            }

            .bubble {
                padding: 9px 12px;
                font-size: 0.9em;
            }

            /* 【手机端修复】以前这里给 .modal-content 加了 padding:15px，
               而 .modal-header / .modal-body / .modal-footer 各自还有自己的内边距，
               叠加后底部按钮区被挤得只剩一点点宽度：`margin-left:auto` 的「保存设置」
               被顶到换行，和「恢复默认」错位成两行、还可能被屏幕裁掉。
               这里去掉重复的外层 padding，并让底部按钮区在窄屏改成上下堆叠的整行按钮。 */
            .modal-content {
                width: 96%;
                max-width: none;
                max-height: 90vh;
                padding: 0;
                overflow: hidden;
            }

            .modal-header {
                padding: 12px 14px;
                flex-wrap: wrap;
                gap: 8px;
            }

            /* 设置弹窗的搜索框在手机上会挤压标题与关闭按钮，改成整行 */
            .settings-search-wrap {
                order: 3;
                flex: 1 1 100%;
                max-width: none;
                margin: 0;
            }

            /* 标签栏在手机上必须能横向滑动且不换行、不被压扁：
               以前 10 个标签挤在一行会被压缩到看不清，甚至把关闭按钮顶走。
               这里改成横向滚动 + 惯性滑动，并用 scroll-snap 让选中项落在中间。 */
            .settings-tabs {
                gap: 8px;
                margin-bottom: 16px;
                padding-bottom: 4px;
                overflow-x: auto;
                overflow-y: hidden;
                flex-wrap: nowrap;
                -webkit-overflow-scrolling: touch;
                overscroll-behavior-x: contain;
                scrollbar-width: none;
            }
            .settings-tabs::-webkit-scrollbar { display: none; }
            .settings-tabs .tab-button {
                flex: 0 0 auto;
                font-size: 0.92em;
                padding: 8px 4px 10px;
            }

            .modal-footer {
                padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
                flex-wrap: wrap;
                gap: 10px;
                /* 关键：从 space-between 换成纵向堆叠，彻底消灭错位 */
                flex-direction: column;
                align-items: stretch;
            }
            .modal-footer > div {
                margin-left: 0 !important;
                width: 100%;
                flex-wrap: wrap;
                gap: 10px !important;
            }
            .modal-footer .btn {
                flex: 1 1 auto;
                justify-content: center;
                min-width: 120px;
                padding: 11px 14px;
            }
            /* 「恢复默认 / 保存设置」在手机上都是整行按钮，点按区域更大 */
            #reset-settings-btn,
            #save-settings-btn,
            #test-connection-btn {
                width: 100%;
                flex: 1 1 100%;
            }

            /* 设置页里的多列开关网格在窄屏改单列，避免文字被压在按钮下面 */
            .feature-toggle-grid {
                grid-template-columns: 1fr !important;
            }

            .modal-header h2 {
                font-size: 1.3em;
            }

            .modal-body {
                padding: 15px;
                font-size: 0.9em;
                line-height: 1.6;
            }

            .modal-body h3 {
                font-size: 1.1em;
                margin-top: 15px;
            }

            .modal-body p {
                font-size: 0.9em;
            }

        .modal-footer {
                /* 与上面同一媒体查询里的规则保持一致：这里只续航内边距，
                   布局（纵向堆叠 / 整行按钮）由上面的规则决定，不要再改回 space-between。 */
                padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
            }

            .avatar-context-menu {
                /* 「我的头像」菜单是 position:absolute，锚定在输入区上方，
                   窄屏直接钉在左下更省事，纵向往上交给这条 bottom。 */
                left: 15px !important;
                bottom: 70px !important;
                min-width: 140px;
            }

            /* 【手机端修复】角色头像菜单与联系人右键菜单是 position:fixed，
               且由 JS 按点击位置写入 top/left。旧规则对它们也加了 bottom:70px !important，
               于是同一个元素同时存在 top 与 bottom、又没有固定高度 ——
               盒子会被拉伸成「从点击处一直连到屏幕底部」的长条，
               手机上看起来就是「菜单错位/变形、点不中」。
               现在这两个菜单纵向只由 JS 的 top 决定，这里只收窄左右边距并限制最大高度。 */
            .ai-avatar-context-menu,
            .friend-context-menu {
                left: 12px !important;
                max-width: calc(100vw - 24px);
                min-width: 0;
                max-height: min(62vh, 340px);
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
            }

            .message-actions, .quick-replies {
                margin-left: 52px;
            }

            .disclaimer-text {
                font-size: 0.7em !important;
                padding: 0 10px;
            }
        }


        .app-container.mobile-view {
            width: min(100vw, 430px);
            height: min(100vh, 844px);
            height: min(100dvh, 844px);
            max-width: none;
        }

        .app-container.mobile-view .sidebar {
            position: absolute;
            height: 100%;
            z-index: 100;
            box-shadow: 2px 0 10px rgba(0,0,0,0.5);
        }

        .app-container.mobile-view .mobile-menu-btn {
            display: flex;
        }

        /* 修复：右侧 padding 原为 50px，而 .view-toggle-btn 占据右侧 15+40=55px，
           导致「清空聊天记录」垃圾桶按钮被切换视图按钮盖住无法点击。
           这里按「按钮右偏移 + 按钮宽度 + 间隙」预留 62px。 */
        .app-container.mobile-view .chat-header {
            min-height: 56px;
            padding: 12px 62px 12px 50px;
            font-size: 1em;
            gap: 8px;
        }

        /* 移动视图下头部空间紧张：名字可省略号收缩，右侧按钮组不许被压缩 */
        .app-container.mobile-view .chat-header > #current-friend-name {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .app-container.mobile-view .chat-header > div {
            flex-shrink: 0;
            gap: 6px !important;
        }

        @media (max-width: 768px), (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
            body {
                padding: 0;
            }

            .app-container.mobile-view {
                width: 100vw;
                height: 100vh;
                height: 100dvh;
                border-radius: 0;
                box-shadow: none;
            }
        }


        /* ========================================
           移动端软键盘避让（body.kb-shrink 由 main.js 在键盘弹出时加上）
           Chrome/Edge 安卓由 <meta viewport interactive-widget=resizes-content>
           直接压缩布局视口；iOS Safari 等不支持该属性的内核走这里：
           JS 把容器高度压成 visualViewport.height，因此必须让容器顶对齐，
           否则 body 的居中 flex 会把这块「变矮的容器」垂直居中，
           结果输入框的下半截仍然躲在键盘后面。
           ======================================== */
        body.kb-shrink {
            align-items: flex-start;
            justify-content: center;
            min-height: 0;
            height: 100%;
            overflow: hidden;
        }

        /* html 也要一起钉住：iOS/Safari 弹出键盘时会自动把整篇文档向上滚，
           若 html 高度仍是「键盘遮挡前的全高」，被压扁的容器会被一起推出可视区，
           表现就是「输入框还是被键盘挡住」。--kb-h 由 main.js 写入可见高度。 */
        html.kb-active {
            height: var(--kb-h, 100%);
            overflow: hidden;
        }

        html.kb-active body {
            height: var(--kb-h, 100%);
            overflow: hidden;
        }

        /* 键盘弹出时，全屏遮罩类弹窗（.modal-overlay / 应用内对话框）也必须改用
           「可见高度」：fixed 元素不受容器压扁影响，iOS 下 vh 也不随键盘变化，
           不显式约束的话弹窗里的输入框会永远躲在键盘后面。
           顶部对齐 + 允许滚动，保证内容再高也够得着。 */
        html.kb-active .modal-overlay {
            align-items: flex-start;
            overflow-y: auto;
            padding-top: 10px;
        }

        html.kb-active .modal-overlay .modal-content {
            max-height: calc(var(--kb-h, 100vh) - 24px);
            overflow-y: auto;
        }

        html.kb-active .ad-overlay {
            align-items: flex-start;
            padding-top: 10px;
            height: var(--kb-h, 100%);
        }

        html.kb-active .ad-card {
            max-height: calc(var(--kb-h, 100vh) - 24px);
        }

        body.kb-shrink .app-container,
        body.kb-shrink .app-container.mobile-view {
            border-radius: 0;
            box-shadow: none;
        }

        /* 键盘已经占掉这块空间：免责条与 safe-area 底部留白都该让位给输入框 */
        body.kb-shrink .disclaimer-text { display: none !important; }
        body.kb-shrink .chat-input-area { padding-bottom: 8px !important; }
        body.kb-shrink .toast-container { bottom: 12px; }

        .toast-container {
            position: fixed;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%) translateY(100px);
            background-color: #2d303a;
            border: 1px solid var(--accent-gold);
            border-radius: var(--radius-md);
            padding: 12px 24px;
            color: var(--text-primary);
            font-size: 0.95em;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
            z-index: 10000;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .toast-container.show {
            opacity: 1;
            visibility: visible;
            transform: translateX(-50%) translateY(0);
        }
        .toast-container i {
            font-size: 1.2em;
            color: var(--accent-gold);
        }

/* 拆分后的增强功能样式 */
.small-icon-btn {
    width: 28px;
    height: 28px;
    font-size: 0.85em;
    margin-left: auto;
}

body.light-theme {
    --bg-primary: #f4f6fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1f7;
    --bg-sidebar: #f9fafc;
    --text-primary: #20242c;
    --text-secondary: #4f5b6b;
    --text-muted: #6f7c8d;
    --border-color: #d9deea;
    --border-light: rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(20, 30, 50, 0.15);
    --shadow-md: 0 4px 12px rgba(20, 30, 50, 0.12);
}

body.light-theme .chat-area::before {
    background-color: #eef1f7;
}

.global-search-results {
    max-height: 220px;
    overflow-y: auto;
    margin: -5px 0 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    padding: 8px;
}

.search-result-group-title {
    color: var(--accent-gold);
    font-size: 0.82em;
    margin: 6px 0 4px;
    font-weight: 600;
}

.search-result-item {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 7px;
    margin-bottom: 5px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.84em;
    line-height: 1.35;
}

.search-result-item:hover {
    border-color: var(--accent-gold);
    color: var(--text-primary);
}

.message.search-highlight .bubble {
    outline: 2px solid var(--accent-gold);
    box-shadow: 0 0 14px rgba(230, 199, 138, 0.55);
}

.code-block-wrapper {
    position: relative;
}

.copy-code-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.55);
    color: #fff;
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.75em;
    z-index: 2;
}

.command-panel {
    position: absolute;
    right: 18px;
    bottom: 86px;
    width: min(360px, calc(100vw - 40px));
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    z-index: 5;
}

.command-panel.show { display: block; }
.command-card {
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
    cursor: pointer;
}
.command-card:hover { border-color: var(--accent-gold); }
.command-card code { color: var(--accent-gold); }

@media print {
    body * { visibility: hidden; }
    #chat-messages, #chat-messages * { visibility: visible; }
    #chat-messages {
        position: absolute;
        inset: 0;
        overflow: visible !important;
        color: #111;
        background: white;
    }
    .message-actions, .chat-input-area, .sidebar, .chat-header { display: none !important; }
}
.friend-batch-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-gold);
    flex-shrink: 0;
}
.input-icons .recording,
/* 图片预览：缩放、旋转与下载 */
.image-preview-modal{position:fixed;inset:0;z-index:10000;background:rgba(0,0,0,.9);display:flex;align-items:center;justify-content:center;overflow:hidden}.image-preview-modal[hidden]{display:none!important}.image-preview-stage{width:100%;height:100%;padding:76px 24px 28px;display:flex;align-items:center;justify-content:center;overflow:auto;touch-action:none}.image-preview-stage img{max-width:92vw;max-height:82vh;object-fit:contain;transform-origin:center;transition:transform .18s ease;user-select:none;-webkit-user-drag:none;box-shadow:0 8px 35px rgba(0,0,0,.55)}.image-preview-toolbar{position:absolute;z-index:1;top:16px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:7px;padding:7px;border:1px solid rgba(255,255,255,.2);border-radius:12px;background:rgba(32,32,32,.82);backdrop-filter:blur(8px)}.image-preview-toolbar button,.image-preview-toolbar a{width:38px;height:38px;display:grid;place-items:center;border:0;border-radius:8px;background:transparent;color:#fff;font-size:1.25rem;cursor:pointer;text-decoration:none}.image-preview-toolbar button:hover,.image-preview-toolbar a:hover{background:rgba(255,255,255,.17);color:var(--accent-gold)}.message-image{display:block;cursor:zoom-in;max-width:min(100%,420px)!important;width:auto!important;height:auto!important;object-fit:contain;box-sizing:border-box}.message .message-content{min-width:0;max-width:calc(100% - 50px)}@media(max-width:560px){.message-image{max-width:100%!important;max-height:52vh!important}.message .message-content{max-width:calc(100vw - 70px)}.image-preview-stage{padding:72px 10px 16px}.image-preview-stage img{max-width:96vw;max-height:80vh}.image-preview-toolbar{top:10px;gap:2px;padding:5px}.image-preview-toolbar button,.image-preview-toolbar a{width:34px;height:34px;font-size:1.1rem}}

#voice-input-btn.recording {
    color: #ff6b6b !important;
    animation: pulseMic 1s infinite;
}
@keyframes pulseMic {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.emoji-category-title {
    grid-column: 1 / -1;
    color: var(--accent-gold);
    font-size: 0.82em;
    padding: 6px 4px 2px;
}
.feature-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}
.feature-toggle-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
}

/* 离线提示与多行输入框 */
.offline-banner {
    padding: 8px 16px;
    background: rgba(255, 176, 32, 0.16);
    border-bottom: 1px solid rgba(255, 176, 32, 0.35);
    color: #ffd28a;
    font-size: 0.88em;
    text-align: center;
}

.input-wrapper textarea {
    width: 100%;
    min-height: 44px;
    max-height: 140px;
    padding: 12px 15px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.2);
    background-color: rgba(0,0,0,0.3);
    color: #eee;
    outline: none;
    resize: none;
    line-height: 1.45;
    font-family: inherit;
}

.input-wrapper textarea::placeholder { color: #aaa; }

#send-btn.disabled {
    opacity: 0.55;
}

.chat-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(38, 41, 51, 0.96);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chat-search-bar input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(0,0,0,0.25);
    color: #eee;
    outline: none;
}
.chat-search-bar .icon-btn { width: 28px; height: 28px; font-size: 0.9em; }
.message.search-match .bubble { box-shadow: 0 0 0 2px rgba(255, 211, 105, 0.75); }
.message.search-active .bubble { box-shadow: 0 0 0 3px var(--accent-gold), 0 0 18px rgba(230, 199, 138, 0.45); }
.audio-bubble audio { max-width: 260px; width: 100%; }
.message-meta { font-size: 0.72em; color: #888; margin-top: 4px; text-align: right; }
.message.mine .message-meta { text-align: right; }
.shortcut-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.shortcut-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
kbd { background: #1f222b; border: 1px solid #555; border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; color: var(--accent-gold); font-family: inherit; }


.reply-preview {
    margin: 2px 0 6px;
    padding: 6px 10px;
    border-left: 3px solid var(--accent-gold);
    background: rgba(230, 199, 138, 0.12);
    color: #cfc6b0;
    border-radius: 6px;
    font-size: 0.82em;
    max-width: var(--bubble-max-width);
    word-break: break-word;
}
.markdown-preview-popover {
    position: absolute;
    left: 0;
    right: 42px;
    bottom: calc(100% + 8px);
    max-height: 220px;
    overflow: auto;
    padding: 12px;
    border: 1px solid rgba(230, 199, 138, 0.35);
    border-radius: 10px;
    background: rgba(26, 28, 35, 0.96);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color: #eee;
    z-index: 20;
}
.markdown-preview-popover[hidden] { display: none; }
.memory-tag { display: inline-block; margin-right: 4px; color: var(--accent-gold); }

/* 修复：操作按钮现在在 message-content 内部，不需要左边距 */
.message-actions {
    margin-left: 0 !important;
}

        .group-name-content {
            width: 420px;
        }

        .group-manage-content {
            width: min(920px, 94vw);
        }

        .group-manage-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 14px;
        }

        .group-manage-panel {
            background: #232631;
            border: 1px solid #3f4350;
            border-radius: 12px;
            padding: 16px;
        }

        .group-manage-panel h3 {
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--accent-gold);
            margin-bottom: 12px;
            font-size: 1em;
        }

        .group-manage-wide {
            grid-column: 1 / -1;
        }

        .group-manage-hint {
            color: #999;
            font-size: 0.85em;
            line-height: 1.5;
            margin-bottom: 12px;
        }

        .group-manage-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 10px;
            max-height: 32vh;
            overflow-y: auto;
            padding-right: 4px;
        }

        .group-manage-row,
        .group-activity-row {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px;
            border: 1px solid #444;
            border-radius: 10px;
            background: #2b2f3a;
        }

        .group-manage-row input[type="checkbox"] {
            width: 18px;
            height: 18px;
            accent-color: var(--accent-gold);
        }

        .group-manage-row img,
        .group-activity-row img {
            width: 34px;
            height: 34px;
            border-radius: 50%;
            object-fit: cover;
            flex-shrink: 0;
        }

        .group-manage-row span,
        .group-activity-row span {
            min-width: 0;
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .group-manage-row em {
            color: var(--accent-gold);
            font-size: 0.8em;
            font-style: normal;
        }

        .group-admin-actions {
            display: grid;
            grid-template-columns: 1fr 110px auto auto;
            gap: 10px;
            align-items: center;
        }

        .group-member-select-modal { z-index: 1200; }

        .group-admin-actions select,
        .group-admin-actions input,
        .group-activity-row input[type="number"] {
            padding: 9px 10px;
            border-radius: 8px;
            border: 1px solid #444;
            background: #1f222b;
            color: #eee;
        }

        .group-title-row {
            display: grid;
            grid-template-columns: 34px minmax(80px, 1fr) minmax(120px, 1.4fr);
            align-items: center;
            gap: 10px;
            padding: 10px;
            border: 1px solid #444;
            border-radius: 10px;
            background: #2b2f3a;
        }
        .group-title-row img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
        .group-title-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .group-title-row input,
        .group-manage-panel textarea,
        .group-manage-panel > input {
            width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 8px;
            border: 1px solid #444; background: #1f222b; color: #eee;
        }
        .group-manage-panel textarea { min-height: 72px; resize: vertical; margin: 0 0 9px; }
        .group-manage-panel > input { margin: 0 0 9px; }
        .group-feature-list { display: grid; gap: 8px; max-height: 190px; overflow-y: auto; margin-top: 12px; }
        .group-feature-item { padding: 10px; border-left: 3px solid var(--accent-gold); background: #2b2f3a; border-radius: 6px; }
        .group-feature-item strong, .group-feature-item small { display: block; }
        .group-feature-item small { color: #999; margin-top: 6px; font-size: .78em; }
        .poll-result-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; color: #ddd; font-size: .9em; }

        .group-activity-row input[type="range"] {
            flex: 1.4;
            accent-color: var(--accent-gold);
        }

        .group-activity-row input[type="number"] {
            width: 76px;
        }

        @media (max-width: 768px) {
            .group-manage-grid,
            .group-manage-list,
            .group-admin-actions {
                grid-template-columns: 1fr;
            }
        }

/* 重做浅色主题：降低纯白面积，改为暖灰卡片层级与清晰边界 */
body.light-theme {
    --bg-primary: #e9edf5;
    --bg-secondary: #f7f3ea;
    --bg-tertiary: #ece4d6;
    --bg-sidebar: #efe7d9;
    --text-primary: #242833;
    --text-secondary: #566174;
    --text-muted: #7a8494;
    --border-color: #d6c9b5;
    --border-light: rgba(82, 62, 35, 0.14);
    --shadow-lg: 0 18px 45px rgba(92, 78, 58, 0.18);
    --shadow-md: 0 8px 22px rgba(92, 78, 58, 0.12);
    background:
        radial-gradient(circle at top left, rgba(var(--accent-gold-rgb), 0.22), transparent 34%),
        linear-gradient(135deg, #e3e8f2 0%, #f3eee4 54%, #e8ddcc 100%);
}

body.light-theme .app-container {
    background: rgba(247, 243, 234, 0.96);
    border: 1px solid rgba(151, 124, 82, 0.22);
    box-shadow: var(--shadow-lg);
}

body.light-theme .sidebar,
body.light-theme .chat-header,
body.light-theme .chat-input-area,
body.light-theme .modal-content,
body.light-theme .command-panel {
    background: rgba(239, 231, 217, 0.96);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.light-theme .chat-area::before {
    background:
        linear-gradient(rgba(247, 243, 234, 0.84), rgba(247, 243, 234, 0.84)),
        radial-gradient(circle at 20% 10%, rgba(var(--accent-gold-rgb), 0.2), transparent 28%);
}

body.light-theme .friend-item,
body.light-theme .friend-option,
body.light-theme .command-card,
body.light-theme .import-char-section,
body.light-theme .settings-nav,
body.light-theme .settings-content {
    background: rgba(255, 251, 242, 0.72);
    border-color: rgba(151, 124, 82, 0.18);
}

body.light-theme .friend-item:hover,
body.light-theme .friend-option:hover,
body.light-theme .command-card:hover {
    background: rgba(var(--accent-gold-rgb), 0.16);
}

body.light-theme .search-box,
body.light-theme .input-wrapper input,
body.light-theme .input-wrapper textarea,
body.light-theme .form-group input,
body.light-theme .form-group select,
body.light-theme .form-group textarea,
body.light-theme .chat-search-bar input,
body.light-theme .settings-search-wrap input {
    background: #fffaf2;
    color: var(--text-primary);
    border-color: #cdbb9f;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

body.light-theme .search-box::placeholder,
body.light-theme .input-wrapper textarea::placeholder {
    color: #8a7760;
}

body.light-theme .message.other .bubble {
    background: #fffaf2;
    color: var(--text-primary);
    border: 1px solid rgba(151, 124, 82, 0.18);
}

body.light-theme .message.mine .bubble {
    background: linear-gradient(135deg, #e6c78a, #d6a95e);
    color: #221a10;
}

.global-search-results {
    position: relative;
    z-index: 8;
    background: #252934;
    box-shadow: var(--shadow-md);
}

body.light-theme .global-search-results {
    background: #fffaf2;
    color: var(--text-primary);
    border-color: #cdbb9f;
    box-shadow: 0 10px 24px rgba(92, 78, 58, 0.18);
}

body.light-theme .search-result-item {
    color: var(--text-secondary);
    background: rgba(239, 231, 217, 0.62);
}

body.light-theme .search-result-item:hover {
    background: rgba(var(--accent-gold-rgb), 0.18);
    color: var(--text-primary);
}

        /* 插件权限面板 */
        .plugin-permissions {
            border: 1px solid rgba(230,199,138,0.35);
            border-radius: 12px;
            padding: 14px;
            margin-bottom: 16px;
            background: rgba(230,199,138,0.06);
        }
        .plugin-permissions-title {
            display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
            color: var(--accent-gold); font-weight: bold; margin-bottom: 12px;
        }
        .plugin-permissions-hint {
            font-weight: normal; font-size: 0.78em; color: #999;
            border: 1px solid #555; border-radius: 999px; padding: 2px 8px;
        }
        .plugin-permissions-desc {
            font-size: 0.8em; color: #9a9a9a; line-height: 1.6;
            margin: -4px 0 10px; padding-left: 2px;
        }
        .plugin-permissions-desc b { color: var(--accent-gold); }
        .plugin-permission-item {
            display: flex; align-items: flex-start; gap: 10px;
            padding: 10px; border-radius: 8px; cursor: pointer;
            transition: background-color 0.2s;
        }
        .plugin-permission-item:hover { background: rgba(255,255,255,0.04); }
        .plugin-permission-item > input[type="checkbox"] {
            margin-top: 3px; flex-shrink: 0; width: 16px; height: 16px;
            accent-color: var(--accent-gold); cursor: pointer;
        }
        .plugin-permission-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
        .plugin-permission-body strong { color: #f0e6c8; font-size: 0.95em; }
        .plugin-permission-body small { color: #9a9a9a; font-size: 0.8em; line-height: 1.5; }
        .plugin-permission-body small b { color: #e6a8a8; font-weight: bold; }

        /* 插件卡片上的「单个插件独立授权」勾选区 */
        .plugin-grants {
            display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
            margin-top: 10px; padding: 8px 10px;
            background: rgba(255,255,255,0.03);
            border: 1px dashed #4a4d57; border-radius: 8px;
        }
        .plugin-grants-title { font-size: 0.8em; color: #999; white-space: nowrap; }
        .plugin-grant {
            display: inline-flex; align-items: center; gap: 5px;
            font-size: 0.82em; color: #ddd; cursor: pointer;
            padding: 2px 6px; border-radius: 6px;
        }
        .plugin-grant:hover { background: rgba(255,255,255,0.05); }
        .plugin-grant input[type="checkbox"] {
            width: 14px; height: 14px; cursor: pointer;
            accent-color: var(--accent-gold);
        }
        .plugin-grant-disabled { opacity: 0.5; cursor: not-allowed; }
        .plugin-grant-disabled input { cursor: not-allowed; }
        .plugin-grant-note { font-style: normal; font-size: 0.88em; color: #f0b27a; }
        .plugin-blocked-tip {
            margin-top: 10px; font-size: 0.8em; color: #f0b27a;
            background: rgba(240,178,122,0.1); border-left: 3px solid #f0b27a;
            padding: 8px 10px; border-radius: 4px; line-height: 1.5;
        }
        .plugin-card.plugin-blocked { opacity: 0.72; }

        .plugin-settings-list { display: flex; flex-direction: column; gap: 14px; }
        .plugin-card { border: 1px solid #3a3d47; border-radius: 12px; padding: 14px; background: rgba(255,255,255,0.03); }
        .plugin-card-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
        .plugin-card-header strong { color: #f0e6c8; font-size: 1.05em; }
        .plugin-card-header p { color: #aaa; font-size: 0.85em; margin-top: 5px; }
        .plugin-switch { color: #ddd; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
        .plugin-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
        .plugin-params label { color: #bbb; font-size: 0.9em; }
        .plugin-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
        .plugin-builtin-badge { color: var(--accent-gold); font-size: 0.85em; }
        .chat-plugin-window { position: absolute; right: 18px; bottom: 96px; z-index: 35; min-width: 120px; min-height: 120px; max-width: calc(100% - 36px); max-height: calc(100% - 128px); background: #15171d; border: 1px solid rgba(230,199,138,0.55); border-radius: 12px; overflow: hidden; box-shadow: 0 14px 40px rgba(0,0,0,0.45); }
        .chat-plugin-window.dragging { user-select: none; }
        .chat-plugin-window-header { height: 36px; cursor: move; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; color: #f0e6c8; background: rgba(230,199,138,0.12); border-bottom: 1px solid rgba(230,199,138,0.25); }
        .chat-plugin-window-close { background: transparent; border: none; color: #ddd; cursor: pointer; font-size: 1.1em; }
        .chat-plugin-window iframe { width: 100%; height: calc(100% - 36px); border: 0; background: #fff; }

.search-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--accent-gold);
    font-size: 0.86em;
    font-weight: 700;
    margin: 6px 0 8px;
    padding: 6px 4px;
    border-bottom: 1px solid rgba(var(--accent-gold-rgb), 0.22);
}

.search-section-toggle {
    width: 26px;
    height: 26px;
    border: 1px solid rgba(var(--accent-gold-rgb), 0.35);
    border-radius: 50%;
    background: rgba(var(--accent-gold-rgb), 0.08);
    color: var(--accent-gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-section-toggle:hover {
    background: rgba(var(--accent-gold-rgb), 0.18);
    transform: scale(1.06);
}

body.light-theme .search-section-header {
    border-bottom-color: rgba(var(--accent-gold-rgb), 0.28);
}

/* ========================================
   动效模式：兼容模式 / ？？？模式
   ======================================== */
body.compatibility-mode,
body.compatibility-mode *,
body.compatibility-mode *::before,
body.compatibility-mode *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

body.mystery-mode {
    background:
        radial-gradient(circle at 15% 20%, rgba(0, 245, 255, 0.22), transparent 28%),
        radial-gradient(circle at 85% 15%, rgba(255, 0, 204, 0.2), transparent 30%),
        linear-gradient(135deg, #080a18 0%, #17121f 45%, #071b27 100%);
    animation: mysteryAurora 10s ease-in-out infinite alternate;
}

body.mystery-mode .app-container {
    border: 1px solid rgba(0, 245, 255, 0.35);
    box-shadow: 0 0 28px rgba(0, 245, 255, 0.22), 0 0 70px rgba(255, 0, 204, 0.14), var(--shadow-lg);
    animation: mysteryFloat 5s ease-in-out infinite, mysteryGlow 3.6s ease-in-out infinite alternate;
}

body.mystery-mode .sidebar,
body.mystery-mode .chat-header,
body.mystery-mode .chat-input-area,
body.mystery-mode .modal-content {
    backdrop-filter: blur(12px) saturate(1.25);
    box-shadow: inset 0 0 24px rgba(0, 245, 255, 0.05);
}

body.mystery-mode .friend-item:hover,
body.mystery-mode .friend-item.active,
body.mystery-mode .icon-btn:hover,
body.mystery-mode .btn:hover,
body.mystery-mode .tab-button.active {
    animation: mysteryPulse 1.35s ease-in-out infinite alternate;
}

body.mystery-mode .avatar,
body.mystery-mode .friend-avatar {
    animation: mysteryAvatarOrbit 4s linear infinite;
}

body.mystery-mode .message {
    animation: mysteryMessageIn 0.55s cubic-bezier(0.2, 1.4, 0.3, 1) both;
}

body.mystery-mode .bubble {
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 18px rgba(0, 245, 255, 0.14), 0 0 24px rgba(255, 0, 204, 0.08);
}

body.mystery-mode .bubble::after {
    content: '';
    position: absolute;
    inset: -60% -25%;
    background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.28) 50%, transparent 65%);
    transform: translateX(-120%) rotate(8deg);
    animation: mysteryShine 2.8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes mysteryAurora {
    from { background-position: 0% 50%; filter: hue-rotate(0deg); }
    to { background-position: 100% 50%; filter: hue-rotate(18deg); }
}

@keyframes mysteryFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.004); }
}

@keyframes mysteryGlow {
    from { box-shadow: 0 0 22px rgba(0, 245, 255, 0.2), 0 0 58px rgba(255, 0, 204, 0.12), var(--shadow-lg); }
    to { box-shadow: 0 0 36px rgba(0, 245, 255, 0.34), 0 0 86px rgba(255, 0, 204, 0.22), var(--shadow-lg); }
}

@keyframes mysteryPulse {
    from { box-shadow: 0 0 0 rgba(0, 245, 255, 0); transform: translateY(0) scale(1); }
    to { box-shadow: 0 0 18px rgba(0, 245, 255, 0.3); transform: translateY(-1px) scale(1.025); }
}

@keyframes mysteryAvatarOrbit {
    0% { box-shadow: 0 0 0 0 rgba(0, 245, 255, 0.15); filter: saturate(1); }
    50% { box-shadow: 0 0 0 4px rgba(255, 0, 204, 0.16), 0 0 16px rgba(0, 245, 255, 0.28); filter: saturate(1.35); }
    100% { box-shadow: 0 0 0 0 rgba(0, 245, 255, 0.15); filter: saturate(1); }
}

@keyframes mysteryMessageIn {
    from { opacity: 0; transform: translateY(18px) scale(0.96) rotateX(12deg); filter: blur(6px); }
    to { opacity: 1; transform: translateY(0) scale(1) rotateX(0); filter: blur(0); }
}

@keyframes mysteryShine {
    0%, 45% { transform: translateX(-120%) rotate(8deg); }
    100% { transform: translateX(120%) rotate(8deg); }
}
