/* ==========================================================================
   AI 虚拟伴侣 Agent — 设计系统
   继承 5.html 的深色玻璃拟态 + 橙色强调色，扩展为多主题色动态系统
   ========================================================================== */

:root {
    /* 强调色由角色切换时动态注入 */
    --accent: #ff9f43;
    --accent-rgb: 255, 159, 67;

    --glass-bg: rgba(25, 25, 35, 0.55);
    --glass-bg-strong: rgba(18, 18, 26, 0.82);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-hi: rgba(255, 255, 255, 0.22);
    --blur: 28px;

    --text-main: #ffffff;
    --text-sub: rgba(255, 255, 255, 0.65);
    --text-dim: rgba(255, 255, 255, 0.38);

    --msg-right-bg: var(--accent);
    --msg-left-bg: rgba(40, 40, 50, 0.7);

    --ok: #2ecc71;
    --warn: #f1c40f;
    --danger: #ff4757;
    --info: #54a0ff;
    --purple: #a55eea;

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 26px;

    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.55);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%; height: 100%; overflow: hidden;
    font-family: var(--font);
    color: var(--text-main);
    background: #05050a;
    -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.26); }

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { display: block; }

/* ========================= 通用玻璃拟态 ========================= */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
}

.btn {
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex; align-items: center; gap: 7px;
    white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.16); transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn-primary {
    background: var(--accent); border-color: transparent; color: #16161f; font-weight: 600;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.12); }
.btn-danger { background: rgba(255, 71, 87, 0.18); border-color: rgba(255, 71, 87, 0.4); color: #ff8a94; }
.btn-danger:hover { background: rgba(255, 71, 87, 0.32); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 16px; }
.btn-block { width: 100%; justify-content: center; }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 14px; font-size: 11.5px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-sub);
}

/* 表单控件 */
.field { margin-bottom: 16px; }
.field > label {
    display: block; font-size: 12px; color: var(--text-sub);
    margin-bottom: 7px; letter-spacing: 0.3px;
}
.field-label-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.field-label-row label { font-size: 12px; color: var(--text-sub); }
.field-hint { font-size: 11px; color: var(--text-dim); }

.input, .select, .textarea {
    width: 100%; padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-md);
    color: var(--text-main); font-size: 13px; outline: none;
    transition: border-color 0.2s, background 0.2s;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--accent); background: rgba(255, 255, 255, 0.09);
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.textarea { resize: vertical; min-height: 74px; line-height: 1.6; }
.select { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23ffffff' fill-opacity='0.5' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 32px;
}
.select option { background: #1a1a24; color: #fff; }

/* 开关 */
.switch { position: relative; width: 42px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; cursor: pointer;
    background: rgba(255, 255, 255, 0.16); border-radius: 23px;
    transition: background 0.25s;
}
.switch .slider::before {
    content: ''; position: absolute; height: 17px; width: 17px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: transform 0.25s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(19px); }

.switch-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .txt { font-size: 13px; }
.switch-row .desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* 滑块 */
input[type=range] {
    -webkit-appearance: none; appearance: none;
    height: 4px; border-radius: 2px; outline: none; cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
    background: var(--accent); cursor: pointer; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.22);
}
input[type=range].full { width: 100%; }

/* ========================= 舞台：全屏视频角色 ========================= */
#stage {
    position: fixed; inset: 0; z-index: 1;
    background: radial-gradient(ellipse at 50% 30%, #1b1b28 0%, #08080d 70%);
    overflow: hidden;
}
#stage canvas, #stage .vid {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; object-position: center top;
    opacity: 0; transition: opacity 0.55s ease;
    /* 舞台视频是纯展示层：不接收指针事件，悬浮时不会触发原生控制条 / 画中画 */
    pointer-events: none;
}
/* 彻底隐藏 Chromium 的原生媒体控制层 */
#stage .vid::-webkit-media-controls,
#stage .vid::-webkit-media-controls-enclosure,
#stage .vid::-webkit-media-controls-panel,
#stage .vid::-webkit-media-controls-start-playback-button {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
#stage .vid::cue { display: none; }
#stage .vid.active { opacity: 1; }
#stage .vid-fallback {
    /* z-index 明确低于视频：HTML 中它排在两个 video 之后，
       同层级时会盖住已就绪的视频画面，导致「视频加载成功但看不到」 */
    position: absolute; inset: 0; display: none; z-index: 1;
    align-items: center; justify-content: center;
}
#stage .vid-fallback.show { display: flex; }
#stage .vid.active { z-index: 2; }
/* 未配置视频时用角色头像（或后台配置的立绘）兜底：
   默认按头像圆形完整展示；加 .is-portrait 时改为立绘式完整呈现，
   避免方形立绘被裁成圆形 */
#stage .vid-fallback img {
    width: min(46%, 340px); height: auto; aspect-ratio: 1;
    border-radius: 50%;
    object-fit: cover; object-position: center;
    filter: drop-shadow(0 12px 60px rgba(var(--accent-rgb), 0.35));
    animation: breathe 4s ease-in-out infinite;
}
#stage .vid-fallback img.is-portrait {
    width: auto; max-width: min(86%, 560px);
    max-height: 82%; height: auto; aspect-ratio: auto;
    border-radius: 18px;
    object-fit: contain; object-position: center bottom;
}
#stage .vid-fallback img.is-avatar {
    width: min(46%, 340px); height: auto; aspect-ratio: 1;
    border-radius: 50%; object-fit: cover;
}
@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.035); }
}
#stage .vid-fallback .ring {
    position: absolute; width: 340px; height: 340px; border-radius: 50%;
    border: 1px solid rgba(var(--accent-rgb), 0.35);
    animation: ringPulse 3s ease-out infinite;
}
@keyframes ringPulse {
    0% { transform: scale(0.8); opacity: 0.9; }
    100% { transform: scale(1.5); opacity: 0; }
}
#stageLoader {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    font-size: 13px; color: var(--text-sub); z-index: 5;
}
.spinner {
    width: 32px; height: 32px; border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 舞台暗角，保证 UI 可读 */
#vignette {
    position: fixed; inset: 0; z-index: 2; pointer-events: none;
    background:
        radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(0, 0, 0, 0.55) 100%),
        linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 18%, transparent 62%, rgba(0,0,0,0.6) 100%);
}

/* 角色名牌 */
#charBadge {
    position: absolute; top: 78px; left: 50%; transform: translateX(-50%);
    z-index: 40; text-align: center; pointer-events: none;
}
#charBadge .name {
    font-size: 22px; font-weight: 600; letter-spacing: 2px;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7);
}
#charBadge .mood {
    font-size: 12px; color: var(--text-sub); margin-top: 4px;
    display: inline-flex; align-items: center; gap: 6px;
}
#charBadge .mood .dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
    box-shadow: 0 0 8px var(--ok); animation: blink 2s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* 说话时的口型/律动反馈 */
#stage.speaking .char-fallback-img { animation: talk 0.42s ease-in-out infinite alternate; }
@keyframes talk { from { transform: scale(1); } to { transform: scale(1.06); } }

/* ========================= 顶部栏 ========================= */
.top-bar {
    position: fixed; top: 0; left: 0; width: 100%; padding: 18px 28px;
    display: flex; justify-content: space-between; align-items: center;
    z-index: 100; pointer-events: none;
}
.top-bar > * { pointer-events: auto; }
.top-left, .top-right { display: flex; align-items: center; gap: 14px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: #16161f;
    box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.4);
}
.brand .txt { line-height: 1.25; }
.brand .txt b { font-size: 14px; letter-spacing: 0.5px; display: block; }
.brand .txt span { font-size: 10.5px; color: var(--text-dim); }

.resource-item {
    display: flex; align-items: center; gap: 7px;
    background: rgba(0, 0, 0, 0.32); padding: 6px 13px; border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.06); font-size: 12.5px;
}
.resource-item i.plus { font-size: 10px; color: var(--text-dim); cursor: pointer; }
.resource-item i.plus:hover { color: var(--accent); }
/* 游客登录入口：主色实心，一眼可点 */
.resource-item.guest-cta {
    background: rgba(var(--accent-rgb), .16);
    border-color: rgba(var(--accent-rgb), .45);
    color: var(--accent); font-weight: 500;
    animation: ctaPulse 2.6s ease-in-out infinite;
}
.resource-item.guest-cta:hover {
    background: var(--accent); color: #16161f; transform: translateY(-2px);
}
.resource-item.guest-cta:hover i { color: #16161f; }
@keyframes ctaPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .35); }
    50% { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0); }
}

/* 可点击的资源项 */
#rechargeItem, #likeBtn { transition: background .2s, transform .2s; }
#rechargeItem:hover, #likeBtn:hover {
    background: rgba(255, 255, 255, 0.14); transform: translateY(-2px);
}
/* 点赞心跳 */
#likeBtn i { transition: transform .3s cubic-bezier(.175,.885,.32,1.275); }
.icon-blue { color: var(--info); }
.icon-pink { color: var(--danger); }

/* ========================= 左侧悬浮导航 FAB ========================= */
.floating-nav {
    position: fixed; left: 26px; top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 16px; z-index: 90;
}
.fab {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--glass-bg); backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.fab i { font-size: 18px; color: var(--text-main); transition: color 0.25s; }
.fab:hover { background: rgba(255, 255, 255, 0.16); transform: scale(1.12); border-color: var(--accent); }
.fab:hover i { color: var(--accent); }
.fab.active { background: var(--accent); border-color: var(--accent); }
.fab.active i { color: #16161f; }
.fab .badge {
    position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px;
    padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff;
    font-size: 10px; display: flex; align-items: center; justify-content: center;
    border: 2px solid #12121a; font-weight: 600;
}
.fab-avatar { border: 2px solid var(--accent); padding: 2px; }
.fab-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #222; }
.fab-label {
    position: absolute; left: 66px; top: 50%;
    transform: translateY(-50%) translateX(-8px);
    background: rgba(0, 0, 0, 0.88); padding: 6px 13px; border-radius: 8px;
    font-size: 12.5px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: all 0.28s ease;
}
.fab:hover .fab-label { opacity: 1; transform: translateY(-50%) translateX(0); }

/* ========================= 情绪控制台 ========================= */
/* 已移入 .input-dock 的纵向流内（见下方 .input-dock），
   不再 fixed 定位，从结构上杜绝与快捷语/输入框重叠 */
.emotion-console {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center;
    background: rgba(0, 0, 0, 0.5); padding: 7px 14px; border-radius: 30px;
    backdrop-filter: blur(14px); border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 100%;
}
.emo-btn {
    background: rgba(255, 255, 255, 0.09); border: none; color: #fff;
    padding: 7px 14px; border-radius: 18px; font-size: 12px; cursor: pointer;
    display: flex; align-items: center; gap: 6px; transition: all 0.22s;
}
.emo-btn:hover { background: rgba(255, 255, 255, 0.2); }
.emo-btn.active { background: var(--accent); color: #16161f; }
.console-sep { width: 1px; height: 18px; background: rgba(255, 255, 255, 0.14); }
.console-vol { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-sub); }
.console-vol input[type=range] { width: 58px; }

/* ========================= 左下 游戏 + 通话 ========================= */
.bottom-left {
    position: fixed; left: 100px; bottom: 34px;
    display: flex; align-items: center; gap: 16px; z-index: 70;
}
.games-card { padding: 14px 16px; min-width: 288px; }
.games-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12.5px; margin-bottom: 12px; color: var(--text-sub);
}
.game-row { display: flex; gap: 10px; justify-content: space-between; }
.game-item {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    cursor: pointer; transition: transform 0.2s;
}
.game-item:hover { transform: translateY(-3px); }
.game-ico {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.game-ico i { font-size: 18px; line-height: 1; }
.game-ico-text { font-size: 12px; font-weight: 700; letter-spacing: 0.5px; }
.g-val { background: #ff4757; }
.g-cs2 { background: #1e272e; border: 1px solid rgba(255, 255, 255, 0.2); }
.g-lol { background: #0fb9b1; }
.g-hsr { background: #7b5cff; }
.g-ys { background: #2f7fd1; }
.game-name { font-size: 10px; color: var(--text-dim); white-space: nowrap; }

.call-orb {
    width: 54px; height: 54px; border-radius: 50%;
    background: radial-gradient(circle at 32% 30%, #ffbe76, var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff; cursor: pointer; position: relative;
    box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.45);
    transition: transform 0.2s;
}
.call-orb:hover { transform: scale(1.09); }
.call-orb::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3); animation: orbPulse 2s infinite;
}
@keyframes orbPulse {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(1.42); opacity: 0; }
}
.call-orb.ringing { animation: shake 0.5s infinite; background: radial-gradient(circle at 32% 30%, #ff8a94, var(--danger)); }
@keyframes shake {
    0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); }
}

/* ========================= 底部输入区 ========================= */
/* 单一纵向流容器：情绪控制台 → 快捷语 → 输入框 → 版权
   全部在同一 flex 列中排布，天然不会互相重叠 */
.input-dock {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    width: 600px; max-width: 94vw; z-index: 95;
    display: flex; flex-direction: column; align-items: center; gap: 9px;
    pointer-events: none;
}
.input-dock > * { pointer-events: auto; }
.quick-replies {
    display: flex; gap: 7px; flex-wrap: nowrap; justify-content: center;
    max-width: 100%; overflow-x: auto; overflow-y: hidden;
    padding-bottom: 2px; scrollbar-width: none;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-replies .chip { cursor: pointer; transition: all 0.2s; }
.quick-replies .chip:hover {
    background: rgba(var(--accent-rgb), 0.2); border-color: var(--accent); color: #fff;
}
.input-bar {
    width: 100%; height: 54px; display: flex; align-items: center;
    padding: 0 10px 0 18px; border-radius: 27px;
}
.input-bar input {
    flex: 1; background: transparent; border: none; color: #fff;
    font-size: 14px; outline: none; padding-right: 12px;
}
.input-bar input::placeholder { color: var(--text-dim); }
.input-tools { display: flex; align-items: center; gap: 9px; }
.icon-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px; color: #fff; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.2); }
.icon-btn.send { background: var(--accent); color: #16161f; }
.icon-btn.send:disabled { opacity: 0.35; cursor: not-allowed; }
/* 自动播报开关：关闭时置灰并斜杠提示 */
.icon-btn.tts.off { color: var(--text-dim); position: relative; }
.icon-btn.tts.off::after {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: 26px; height: 1.5px; background: var(--danger);
    transform: translate(-50%, -50%) rotate(-45deg); border-radius: 2px;
}
.icon-btn.tts.off i { opacity: .55; }
.icon-btn.mic { position: relative; }
.icon-btn.mic.rec { background: var(--danger); color: #fff; animation: micPulse 1.2s infinite; }
@keyframes micPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.5); }
    100% { box-shadow: 0 0 0 14px rgba(255, 71, 87, 0); }
}
.ai-tag { font-size: 10px; color: var(--text-dim); }

/* 录音浮层 */
.rec-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(5, 5, 10, 0.72); backdrop-filter: blur(10px);
    display: none; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
}
.rec-overlay.show { display: flex; }
.rec-wave { display: flex; align-items: center; gap: 4px; height: 76px; }
.rec-wave span {
    width: 4px; border-radius: 2px; background: var(--accent);
    height: 8px; transition: height 0.09s linear;
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.5);
}
.rec-text {
    font-size: 17px; color: #fff; min-height: 26px; text-align: center;
    max-width: 70vw; padding: 0 20px; line-height: 1.6;
}
.rec-text .interim { color: var(--text-dim); font-style: italic; }
.rec-hint { font-size: 12px; color: var(--text-sub); }
.rec-actions { display: flex; gap: 14px; }
.rec-btn {
    width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
    font-size: 20px; display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
}
.rec-btn:hover { transform: scale(1.1); }
.rec-cancel { background: rgba(255, 255, 255, 0.14); color: #fff; }
.rec-send { background: var(--accent); color: #16161f; }

/* ========================= 聊天面板 ========================= */
.chat-panel {
    position: fixed; right: 26px; top: 76px; width: 350px;
    /* 用 --app-height 而非 100vh：移动端100vh 会把地址栏隐藏时的高度算进去，
       导致面板底部被截断。mobile.js 在不支持 dvh 的浏览器上用 JS 赋值兜底 */
    height: calc(var(--app-height, 100vh) - 190px);
    display: flex; flex-direction: column;
    z-index: 80; overflow: hidden;
}
.chat-head {
    display: flex; align-items: center; gap: 11px; padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07); flex-shrink: 0;
}
.chat-head .av {
    width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--accent);
}
.chat-head .info { flex: 1; line-height: 1.35; }
.chat-head .info b { font-size: 13.5px; }
.chat-head .info span { font-size: 10.5px; color: var(--text-dim); display: block; }
.chat-head .stat { font-size: 10px; color: var(--accent); }

.chat-body {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 16px;
}
.chat-body::-webkit-scrollbar { width: 5px; }
/* ========================= 聊天消息：角色在左 · 访客在右 ========================= */
/* 注意：访客消息在数据层的 role 是 'user'（engine/cloud/admin 都依赖这个值），
   而气泡的视觉位置类由 msgNode 统一映射为 left / right。
   这里同时兼容 'user'，防止任何路径漏映射时布局塌回左侧。 */
.msg-row {
    display: flex; gap: 9px; max-width: 82%;
    animation: msgIn 0.3s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg-row.left { align-self: flex-start; }        /* 角色靠左 */
.msg-row.right,
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }  /* 访客靠右 */

.msg-av {
    width: 34px; height: 34px; flex-shrink: 0;
    object-fit: cover; background: #222;
}
/* 角色：圆形头像 + 主色描边 */
.msg-row.left .msg-av {
    border-radius: 50%;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .16);
}
/* 访客：圆角方形头像 + 中性描边，形状本身就不同 */
.msg-row.right .msg-av,
.msg-row.user .msg-av {
    border-radius: 9px;
    border: 2px solid rgba(255, 255, 255, .4);
}

.msg-body { display: flex; flex-direction: column; min-width: 0; }
.msg-row.right .msg-body,
.msg-row.user .msg-body { align-items: flex-end; }

.msg-sender {
    font-size: 10.5px; color: var(--text-dim); margin: 0 2px 4px;
    display: flex; align-items: center; gap: 5px;
}
.msg-row.left .msg-sender i { color: var(--accent); }
.msg-row.right .msg-sender i,
.msg-row.user .msg-sender i { color: var(--info); }

.bubble {
    padding: 11px 14px; border-radius: 16px; font-size: 13px; line-height: 1.65;
    position: relative; word-break: break-word; white-space: pre-wrap;
}
.bubble.left {
    background: var(--msg-left-bg); color: var(--text-main);
    border-top-left-radius: 4px; border: 1px solid rgba(255,255,255,0.07);
}
.bubble.right,
.bubble.user {
    background: var(--msg-right-bg); color: #16161f; font-weight: 500;
    border-top-right-radius: 4px;
}
/* 气泡尖角指向发送者 */
.bubble.left::before, .bubble.right::before, .bubble.user::before {
    content: ''; position: absolute; top: 11px; border: 6px solid transparent;
}
.bubble.left::before { left: -11px; border-right-color: rgba(255,255,255,0.12); }
.bubble.right::before,
.bubble.user::before { right: -11px; border-left-color: var(--accent); }

.msg-meta {
    display: flex; align-items: center; gap: 5px; margin-top: 5px;
    font-size: 10px; color: var(--text-dim);
}
.msg-row.right .msg-meta,
.msg-row.user .msg-meta { justify-content: flex-end; }
.msg-meta .skill-tag {
    background: rgba(var(--accent-rgb), 0.2); color: var(--accent);
    padding: 1px 6px; border-radius: 6px; font-size: 9.5px;
}
.msg-meta .voice-tag { color: var(--info); }

/* --------- 微信式细节：连续同一方消息收紧间距、隐藏重复头像 --------- */
.chat-body > .msg-row + .msg-row.left,
.chat-body > .msg-row + .msg-row.right,
.chat-body > .msg-row + .msg-row.user {
    margin-top: -8px;
}
/* 连续同一方的第二条起，头像留白缩进，避免视觉重复 */
.chat-body > .msg-row.left + .msg-row.left,
.chat-body > .msg-row.right + .msg-row.right,
.chat-body > .msg-row.user + .msg-row.user {
    opacity: .96;
}
.chat-body > .msg-row.left + .msg-row.left .msg-av,
.chat-body > .msg-row.right + .msg-row.right .msg-av,
.chat-body > .msg-row.user + .msg-row.user .msg-av {
    transform: scale(.92);
    box-shadow: none;
}

/* 自己的气泡用主色（微信绿感），加深对比让左右一眼可辨 */
.bubble.right,
.bubble.user {
    background: linear-gradient(135deg, var(--accent), #ffb265);
    color: #1a1520;
}
.bubble.right::before,
.bubble.user::before { border-left-color: var(--accent); }

/* 移动端的气泡尺寸、聊天面板、输入区等适配统一放在 mobile.css，
   避免同一元素在两处用不同断点控制导致样式打架 */

.typing { display: flex; gap: 4px; padding: 14px 16px; align-items: center; }
.typing span {
    width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.5);
    animation: typingBounce 1.3s infinite ease-in-out both;
}
.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.chat-foot {
    padding: 10px 14px; border-top: 1px solid rgba(255,255,255,0.07);
    display: flex; gap: 8px; flex-shrink: 0;
}
.chat-foot .btn { flex: 1; justify-content: center; }

/* ========================= 模态框通用 ========================= */
.modal-mask {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(4, 4, 9, 0.72); backdrop-filter: blur(8px);
    display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-mask.show { display: flex; animation: fadeIn 0.22s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    width: 100%; max-width: 940px; max-height: 88vh;
    background: var(--glass-bg-strong); backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border); border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
    overflow: hidden; animation: modalIn 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-head {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 24px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.modal-head h3 { font-size: 16px; font-weight: 600; flex: 1; }
.modal-head .sub { font-size: 11px; color: var(--text-dim); display: block; margin-top: 2px; font-weight: 400; }
.modal-close {
    width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(255, 255, 255, 0.08); color: #fff; font-size: 14px;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.modal-close:hover { background: rgba(255, 71, 87, 0.3); }
.modal-body { flex: 1; overflow-y: auto; padding: 22px 24px; }
.modal-foot {
    padding: 14px 24px; border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0;
}

/* 标签页 */
.tabs {
    display: flex; gap: 4px; padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0; overflow-x: auto;
}
.tab {
    padding: 11px 16px; font-size: 13px; color: var(--text-sub);
    cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s;
    white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: #fff; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s; }

/* ========================= 角色管理 ========================= */
.char-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; }
.char-list { display: flex; flex-direction: column; gap: 9px; }
.char-item {
    display: flex; align-items: center; gap: 11px; padding: 10px;
    border-radius: var(--r-md); cursor: pointer; transition: all 0.2s;
    border: 1px solid transparent; background: rgba(255, 255, 255, 0.04);
}
.char-item:hover { background: rgba(255, 255, 255, 0.09); }
.char-item.active { background: rgba(var(--accent-rgb), 0.14); border-color: var(--accent); }
.char-item img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #222; }
.char-item .meta { flex: 1; min-width: 0; }
.char-item .meta b { font-size: 13px; display: block; }
.char-item .meta span {
    font-size: 10.5px; color: var(--text-dim); display: block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.char-item .del {
    opacity: 0; background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 12px; padding: 4px; transition: all 0.2s;
}
.char-item:hover .del { opacity: 1; }
.char-item .del:hover { color: var(--danger); }

.add-char {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px; border-radius: var(--r-md); cursor: pointer;
    border: 1px dashed rgba(255, 255, 255, 0.2); color: var(--text-sub);
    font-size: 12.5px; transition: all 0.2s; background: none;
}
.add-char:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }

.char-editor { display: flex; flex-direction: column; gap: 18px; }

.avatar-row { display: flex; gap: 16px; align-items: flex-start; }
.avatar-preview {
    width: 92px; height: 92px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--accent); background: #222; flex-shrink: 0;
}
.avatar-side { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.avatar-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.section-title {
    font-size: 12px; color: var(--text-sub); margin-bottom: 11px;
    display: flex; align-items: center; gap: 8px;
    padding-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.section-title i { color: var(--accent); }
.section-title .right { margin-left: auto; display: flex; gap: 7px; }

/* 视频配置行 */
.vid-row {
    display: grid; grid-template-columns: 78px 1fr 84px; gap: 10px;
    align-items: center; margin-bottom: 9px;
}
.vid-row .lbl {
    font-size: 12px; color: var(--text-sub);
    display: flex; align-items: center; gap: 6px;
}
.vid-row .lbl i { color: var(--accent); width: 14px; }
.vid-row .preview {
    height: 40px; border-radius: 8px; background: #111 center/cover no-repeat;
    border: 1px solid var(--glass-border); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-dim); font-size: 11px; overflow: hidden;
}
.vid-row .preview:hover { border-color: var(--accent); color: var(--accent); }

/* 标签输入 */
.tag-input {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 10px;
    background: rgba(255, 255, 255, 0.06); border: 1px solid var(--glass-border);
    border-radius: var(--r-md); min-height: 40px; align-items: center;
}
.tag-input:focus-within { border-color: var(--accent); }
.tag-input input {
    flex: 1; min-width: 90px; background: transparent; border: none;
    color: #fff; font-size: 12.5px; outline: none;
}
.tag-pill {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(var(--accent-rgb), 0.2); color: var(--accent);
    padding: 3px 9px; border-radius: 12px; font-size: 11.5px;
}
.tag-pill i { cursor: pointer; font-size: 9px; opacity: 0.75; }
.tag-pill i:hover { opacity: 1; color: #fff; }

/* 色板 */
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
    width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
    border: 2px solid transparent; transition: transform 0.2s;
}
.swatch:hover { transform: scale(1.18); }
.swatch.active { border-color: #fff; transform: scale(1.18); }

/* ========================= 技能面板 ========================= */
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 13px; }
.skill-card {
    background: rgba(255, 255, 255, 0.045); border: 1px solid var(--glass-border);
    border-radius: var(--r-md); padding: 14px; cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative; overflow: hidden;
}
.skill-card:hover { transform: translateY(-3px); background: rgba(255, 255, 255, 0.08); border-color: var(--accent); }
.skill-card.disabled { opacity: 0.45; }
.skill-card .ico {
    width: 38px; height: 38px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; margin-bottom: 10px;
}
.skill-card h4 { font-size: 13.5px; margin-bottom: 4px; display: flex; align-items: center; gap: 7px; }
.skill-card p { font-size: 11px; color: var(--text-dim); line-height: 1.55; min-height: 34px; }
.skill-card .foot {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,0.07);
}
.skill-card .uses { font-size: 10.5px; color: var(--text-dim); }
.skill-card .uses b { color: var(--accent); }

.skill-editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.trigger-opt {
    display: flex; align-items: flex-start; gap: 10px; padding: 11px;
    border: 1px solid var(--glass-border); border-radius: var(--r-md);
    cursor: pointer; transition: all 0.2s; background: rgba(255,255,255,0.03);
}
.trigger-opt:hover { border-color: var(--glass-border-hi); }
.trigger-opt.active { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.12); }
.trigger-opt input { display: none; }
.trigger-opt .dot {
    width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--text-dim);
    margin-top: 2px; flex-shrink: 0; transition: all 0.2s;
}
.trigger-opt.active .dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px #1a1a24; }
.trigger-opt b { font-size: 12.5px; display: block; }
.trigger-opt em { font-size: 10.5px; color: var(--text-dim); line-height: 1.5; display: block; margin-top: 2px; font-style: normal; }

/* 角色技能绑定列表 */
.char-skill-item {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px;
    border-radius: var(--r-md); cursor: pointer; transition: background 0.2s;
}
.char-skill-item:hover { background: rgba(255, 255, 255, 0.05); }
.char-skill-item .cs-ico {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.char-skill-item .cs-txt { flex: 1; line-height: 1.35; }
.char-skill-item .cs-txt b { font-size: 13px; font-weight: 500; }
.char-skill-item .cs-txt i { font-size: 10.5px; color: var(--text-dim); font-style: normal; }

/* 技能快捷触发面板 */
.skill-dock {
    position: fixed; right: 26px; bottom: 34px; width: 350px;
    z-index: 78; padding: 14px; display: none;
}
.skill-dock.show { display: block; animation: modalIn 0.25s; }
.skill-dock-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12.5px; margin-bottom: 11px; color: var(--text-sub);
}
.skill-dock-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.skill-dock-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 10px 4px; border-radius: var(--r-sm); cursor: pointer;
    background: rgba(255, 255, 255, 0.05); border: 1px solid transparent;
    transition: all 0.2s;
}
.skill-dock-item:hover { background: rgba(var(--accent-rgb), 0.16); border-color: var(--accent); transform: translateY(-2px); }
.skill-dock-item i { font-size: 17px; color: var(--accent); }
.skill-dock-item span { font-size: 10px; color: var(--text-sub); text-align: center; line-height: 1.3; }

/* ========================= 数据统计后台 ========================= */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 13px; margin-bottom: 22px; }
.kpi {
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border);
    border-radius: var(--r-md); padding: 16px; position: relative; overflow: hidden;
}
.kpi::after {
    content: ''; position: absolute; right: -20px; top: -20px;
    width: 78px; height: 78px; border-radius: 50%;
    background: var(--kpi-c, var(--accent)); opacity: 0.11;
}
.kpi .kpi-ico { font-size: 17px; color: var(--kpi-c, var(--accent)); margin-bottom: 9px; }
.kpi .val { font-size: 25px; font-weight: 700; line-height: 1.1; }
.kpi .val small { font-size: 13px; font-weight: 400; color: var(--text-sub); margin-left: 3px; }
.kpi .lbl { font-size: 11.5px; color: var(--text-sub); margin-top: 5px; }
.kpi .delta { font-size: 10.5px; margin-top: 6px; display: inline-flex; align-items: center; gap: 3px; }
.kpi .delta.up { color: var(--ok); } .kpi .delta.down { color: var(--danger); }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.chart-card {
    background: rgba(255, 255, 255, 0.04); border: 1px solid var(--glass-border);
    border-radius: var(--r-md); padding: 16px;
}
.chart-card.full { grid-column: 1 / -1; }
.chart-card h4 {
    font-size: 13px; margin-bottom: 14px; display: flex;
    align-items: center; gap: 8px; color: var(--text-sub); font-weight: 500;
}
.chart-card h4 i { color: var(--accent); }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th {
    text-align: left; padding: 9px 11px; color: var(--text-dim);
    font-weight: 500; border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 11px; white-space: nowrap;
}
table.data td { padding: 10px 11px; border-bottom: 1px solid rgba(255,255,255,0.05); }
table.data tr:hover td { background: rgba(255,255,255,0.035); }
.rank-badge {
    width: 20px; height: 20px; border-radius: 6px; display: inline-flex;
    align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700;
    background: rgba(255,255,255,0.1);
}
.rank-badge.top { background: var(--accent); color: #16161f; }

.empty {
    text-align: center; padding: 44px 20px; color: var(--text-dim);
}
.empty i { font-size: 34px; margin-bottom: 12px; opacity: 0.35; display: block; }
.empty p { font-size: 12.5px; }

/* ========================= Toast ========================= */
#toastWrap {
    position: fixed; top: 78px; left: 50%; transform: translateX(-50%);
    z-index: 900; display: flex; flex-direction: column; gap: 9px; align-items: center;
    pointer-events: none;
}
.toast {
    background: rgba(20, 20, 30, 0.94); backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border); border-radius: 24px;
    padding: 10px 20px; font-size: 13px; display: flex; align-items: center; gap: 9px;
    box-shadow: var(--shadow); animation: toastIn 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
}
.toast.ok i { color: var(--ok); }
.toast.err i { color: var(--danger); }
.toast.info i { color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut 0.28s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(-14px); } }

/* ========================= 解锁遮罩 ========================= */
/* 浏览器要求用户手势后才能播视频/语音，所以这里必须有一次点击。
   但不应做成「登录墙」——做成底部悬浮胶囊，主页全程可见可读。 */
#unlock {
    position: fixed; left: 50%; bottom: 128px; transform: translateX(-50%);
    z-index: 300; display: flex; align-items: center; gap: 12px;
    padding: 10px 20px 10px 12px; border-radius: 40px;
    background: rgba(18, 18, 28, 0.82);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    cursor: pointer; transition: opacity 0.4s, transform 0.4s;
}
#unlock.hide { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(16px); }
#unlock .orb {
    width: 40px; height: 40px; border-radius: 50%;
    background: radial-gradient(circle at 34% 30%, #ffbe76, var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: #fff; flex-shrink: 0;
    animation: pulseOrb 2.2s infinite;
}
@keyframes pulseOrb {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5); }
    50% { box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0); }
}
#unlock .tip { line-height: 1.4; }
#unlock .tip b { font-size: 13px; display: block; }
#unlock .tip span { font-size: 10.5px; color: var(--text-sub); }

/* ========================= 记忆抽屉 ========================= */
#memoryPanel {
    position: fixed; left: 26px; top: 76px; width: 320px;
    max-height: 62vh; z-index: 82; padding: 16px;
    display: none; flex-direction: column;
}
#memoryPanel.show { display: flex; animation: modalIn 0.25s; }
.mem-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mem-head b { font-size: 13px; }
.mem-list { overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.mem-item {
    padding: 10px 12px; border-radius: var(--r-sm);
    background: rgba(255,255,255,0.045); border-left: 2px solid var(--accent);
    font-size: 12px; line-height: 1.6;
}
.mem-item .t { font-size: 10px; color: var(--text-dim); margin-bottom: 4px; }

/* ========================= 角色切换器 ========================= */
.switcher-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 13px;
    border-radius: var(--r-md); cursor: pointer; transition: all 0.22s;
    border: 1px solid var(--glass-border); background: rgba(255, 255, 255, 0.04);
}
.switcher-item:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--accent); }
.switcher-item.active { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.14); }
.switcher-item img {
    width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
    background: #222; flex-shrink: 0;
}
.switcher-item .sw-meta { flex: 1; min-width: 0; line-height: 1.4; }
.switcher-item .sw-meta b { font-size: 13.5px; display: block; }
.switcher-item .sw-meta span {
    font-size: 11px; color: var(--text-dim); display: block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.switcher-item .sw-check { color: var(--accent); opacity: 0; transition: opacity .2s; }
.switcher-item.active .sw-check { opacity: 1; }

/* ========================= 用户资料 ========================= */
.uid-card {
    text-align: center; padding: 18px; margin-bottom: 18px;
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, rgba(var(--accent-rgb), .16), rgba(var(--accent-rgb), .04));
    border: 1px solid rgba(var(--accent-rgb), .3);
}
.uid-label { font-size: 11px; color: var(--text-sub); }
.uid-value {
    font-size: 32px; font-weight: 700; letter-spacing: 3px; margin: 6px 0 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.uid-tip { font-size: 10.5px; color: var(--text-dim); }

.pf-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    margin: 16px 0; text-align: center;
}
.pf-stats > div {
    background: rgba(255,255,255,.045); border: 1px solid var(--glass-border);
    border-radius: var(--r-md); padding: 11px 6px;
}
.pf-stats b { display: block; font-size: 16px; }
.pf-stats span { font-size: 10px; color: var(--text-dim); }

/* ========================= 登录 / 同步遮罩 ========================= */
#authGate {
    position: fixed; inset: 0; z-index: 700;
    background: rgba(4, 4, 9, 0.72);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    overflow-y: auto;
}
#authGate.hide { display: none; }
.auth-close {
    position: absolute; top: 20px; right: 20px;
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.08); border: 1px solid var(--glass-border);
    color: #fff; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s; z-index: 5;
}
.auth-close:hover { background: rgba(255, 71, 87, 0.3); }
.auth-card {
    width: 100%; max-width: 400px; padding: 32px 28px;
    background: rgba(20, 20, 30, 0.72); backdrop-filter: blur(30px);
    display: flex; flex-direction: column; gap: 12px;
}
.auth-logo {
    width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 4px;
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: #16161f;
    box-shadow: 0 6px 24px rgba(var(--accent-rgb), 0.4);
}
.auth-card h2 { font-size: 19px; text-align: center; letter-spacing: 1px; }
.auth-sub {
    font-size: 11.5px; color: var(--text-sub); text-align: center;
    line-height: 1.7; margin-bottom: 8px;
}
.auth-tabs {
    display: flex; gap: 4px; padding: 4px; border-radius: 14px;
    background: rgba(255, 255, 255, 0.06); margin-bottom: 4px;
}
.auth-tab {
    flex: 1; padding: 8px; border-radius: 11px; border: none; cursor: pointer;
    background: transparent; color: var(--text-sub); font-size: 12.5px; transition: all 0.22s;
}
.auth-tab.active { background: var(--accent); color: #16161f; font-weight: 600; }
.auth-pane { display: none; flex-direction: column; gap: 10px; }
.auth-pane.active { display: flex; animation: fadeIn 0.22s; }
.code-row { display: flex; gap: 9px; }
.code-row .input { flex: 1; }
.code-row .btn { flex-shrink: 0; white-space: nowrap; }
.auth-err { font-size: 11.5px; color: var(--danger); min-height: 15px; line-height: 1.4; }
.auth-tip { font-size: 10.5px; color: var(--text-dim); text-align: center; line-height: 1.6; }
.auth-foot {
    text-align: center; font-size: 10.5px; color: var(--text-dim);
    padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.07); margin-top: 6px;
}
.auth-foot i { color: var(--ok); margin-right: 5px; }

/* 模型列表 */
.model-toolbar {
    display: flex; align-items: center; gap: 10px; margin: 16px 0 10px;
}
.model-toolbar .input { flex: 1; }

.model-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 13px;
    border-radius: var(--r-md); cursor: pointer; transition: all 0.2s;
    border: 1px solid var(--glass-border); background: rgba(255, 255, 255, 0.04);
}
.model-item:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--accent); }
.model-item.active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.2);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .5);
}
.model-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.model-item.disabled { opacity: 0.4; cursor: not-allowed; }
.model-item .mi-ico {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    background: rgba(var(--accent-rgb), 0.18); color: var(--accent);
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.model-item .mi-txt { flex: 1; min-width: 0; line-height: 1.45; }
.model-item .mi-txt b { font-size: 13px; display: block; }
.model-item .mi-txt span { font-size: 10.5px; color: var(--text-dim); display: block; margin-top: 1px; }
.model-item .mi-tags { display: flex; gap: 4px; margin-top: 4px; }
.model-tag {
    font-size: 9px; padding: 1px 6px; border-radius: 6px;
    background: rgba(255, 255, 255, 0.09); color: var(--text-sub);
}
.model-tag.star {
    background: rgba(var(--accent-rgb), 0.22); color: var(--accent); font-weight: 600;
}
.model-item .mi-check { color: var(--accent); opacity: 0; flex-shrink: 0; transition: opacity .2s; font-size: 13px; }
.model-item.active .mi-check { opacity: 1; }
.model-item.active .mi-ico { background: var(--accent); color: #16161f; }

/* 同步状态 */
#syncBadge.syncing #syncIcon { animation: spin 1s linear infinite; }
#syncBadge.synced #syncIcon { color: var(--ok); }
#syncBadge.error #syncIcon { color: var(--danger); }

/* 流式输出光标 */
.bubble.streaming::after {
    content: '▍'; color: var(--accent);
    animation: caret 1s steps(2) infinite; margin-left: 1px;
}
@keyframes caret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* 登录态下的离线提示条 */
#offlineBar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 400;
    background: linear-gradient(90deg, #f39c12, #e67e22);
    color: #fff; font-size: 11.5px; text-align: center; padding: 5px 0;
    display: none;
}
#offlineBar.show { display: block; }

/* ========================= 响应式 ========================= */
@media (max-width: 1180px) {
    .chat-panel { width: 300px; }
    .skill-dock { width: 300px; }
    .bottom-left { left: 92px; }
    .games-card { min-width: 210px; }
}
@media (max-width: 900px) {
    .floating-nav { left: 12px; gap: 12px; }
    .fab { width: 44px; height: 44px; }
    .fab i { font-size: 15px; }
    .fab-label { left: 54px; font-size: 11.5px; }
    .chat-panel {
        right: 10px; left: 10px; width: auto; top: auto; bottom: 96px;
        height: 46vh;
    }
    .chat-panel.collapsed { display: none; }
    .emotion-console { padding: 5px 9px; gap: 5px; }
    .emo-btn { padding: 5px 10px; font-size: 11px; }
    .emo-btn span { display: none; }
    .bottom-left { display: none; }
    .skill-dock { right: 10px; left: 10px; width: auto; bottom: 96px; }
    .input-dock { bottom: 14px; width: 96vw; gap: 7px; }
    #charBadge .name { font-size: 17px; }
    .char-layout, .grid-2, .grid-3, .chart-grid, .skill-editor-grid { grid-template-columns: 1fr; }
    .modal { max-height: 92vh; }
    .modal-body { padding: 16px; }
    .vid-row { grid-template-columns: 68px 1fr 70px; }
    #memoryPanel { left: 10px; right: 10px; width: auto; }
}
@media (max-width: 600px) {
    .top-bar { padding: 12px 14px; }
    .brand .txt { display: none; }
    .resource-item { padding: 5px 10px; font-size: 11.5px; }
}

/* ========================= 语音诊断结果 ========================= */
.voice-diag-result {
    margin-top: 10px; padding: 11px 13px; border-radius: 11px;
    font-size: 11.5px; line-height: 1.75;
    border: 1px solid transparent;
}
.voice-diag-result.running {
    background: rgba(84, 160, 255, .1);
    border-color: rgba(84, 160, 255, .3);
    color: #9ecbff;
}
.voice-diag-result.ok {
    background: rgba(46, 204, 113, .1);
    border-color: rgba(46, 204, 113, .32);
    color: #7ee8ac;
}
.voice-diag-result.err {
    background: rgba(255, 107, 107, .1);
    border-color: rgba(255, 107, 107, .32);
    color: #ff9aa4;
}
.voice-diag-result i { margin-right: 6px; }

/* ==========================================================================
   语音包选择器
   ========================================================================== */
.voice-pack-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 9px;
}
.voice-pack-empty {
    grid-column: 1 / -1;
    padding: 16px; text-align: center;
    font-size: 11.5px; color: var(--text-dim);
}
.voice-pack-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .08);
    cursor: pointer;
    transition: border-color .2s, background .2s, transform .12s;
    position: relative;
    overflow: hidden;
}
.voice-pack-item:hover {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .14);
}
.voice-pack-item:active { transform: scale(.985); }
.voice-pack-item.active {
    background: rgba(var(--accent-rgb), .13);
    border-color: rgba(var(--accent-rgb), .55);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .25);
}
.voice-pack-item .vp-ico {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .07);
    color: var(--text-sub);
    font-size: 14px;
    transition: background .2s, color .2s;
}
.voice-pack-item.active .vp-ico {
    background: rgba(var(--accent-rgb), .9);
    color: #16161f;
}
.voice-pack-item .vp-txt { min-width: 0; flex: 1; }
.voice-pack-item .vp-name {
    font-size: 12.5px; color: var(--text); font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.voice-pack-item .vp-sub {
    font-size: 10px; color: var(--text-dim); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.voice-pack-item .vp-check {
    position: absolute; top: 7px; right: 8px;
    color: var(--accent); font-size: 11px; opacity: 0;
    transition: opacity .2s;
}
.voice-pack-item.active .vp-check { opacity: 1; }
/* 本机没有精确命中的系统音色时给出提示角标 */
.voice-pack-item.fallback .vp-sub { color: #e8a33d; }

@media (max-width: 560px) {
    .voice-pack-list { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .voice-pack-item { padding: 9px 10px; gap: 8px; }
    .voice-pack-item .vp-ico { width: 28px; height: 28px; font-size: 12px; }
    .voice-pack-item .vp-name { font-size: 11.5px; }
    .voice-pack-item .vp-sub { font-size: 9.5px; }
}



/* ==========================================================================
   悬浮音乐播放器
   ========================================================================== */
.music-panel {
    position: fixed;
    left: 26px;
    top: 200px;
    width: 320px;
    z-index: 120;
    padding: 14px;
    border-radius: 18px;
    display: none;
    flex-direction: column;
    gap: 12px;
}
.music-panel.show { display: flex; }

.music-head { display: flex; align-items: center; gap: 11px; }
.music-cover {
    width: 46px; height: 46px; border-radius: 12px;
  object-fit: cover; flex-shrink: 0;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), .35), rgba(255, 107, 107, .3));
    border: 1px solid rgba(255, 255, 255, .08);
}
.music-meta { min-width: 0; flex: 1; }
.music-meta b {
    display: block; font-size: 13px; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-meta span {
    display: block; font-size: 11px; color: var(--text-dim); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.music-progress {
    display: flex; align-items: center; gap: 8px;
    font-size: 10px; color: var(--text-dim);
}
.music-progress input[type=range],
.mc-vol input[type=range] {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .14);
    outline: none; cursor: pointer;
}
.music-progress input[type=range]::-webkit-slider-thumb,
.mc-vol input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
    box-shadow: 0 0 8px rgba(var(--accent-rgb), .55);
}
.music-progress input[type=range]::-moz-range-thumb,
.mc-vol input[type=range]::-moz-range-thumb {
 width: 11px; height: 11px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

.music-ctrl { display: flex; align-items: center; gap: 8px; }
.mc-btn {
    width: 32px; height: 32px; border: none; border-radius: 10px;
    background: rgba(255, 255, 255, .07); color: var(--text);
    cursor: pointer; font-size: 12px; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, color .2s, transform .12s;
}
.mc-btn:hover { background: rgba(255, 255, 255, .12); }
.mc-btn:active { transform: scale(.93); }
.mc-main {
  width: 40px; height: 40px; border-radius: 13px; font-size: 15px;
    background: linear-gradient(135deg, var(--accent), #ffb265);
    color: #16161f;
}
.mc-main:hover { background: linear-gradient(135deg, var(--accent), #ffb265); opacity: .9; }

.mc-vol { display: flex; align-items: center; gap: 6px; margin-left: auto; min-width: 96px; }
.mc-vol i { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.mc-vol span { font-size: 10px; color: var(--text-dim); width: 30px; text-align: right; flex-shrink: 0; }

.music-hint {
    margin: 0; font-size: 10.5px; color: #ffbe7d; line-height: 1.6;
    opacity: 0; transition: opacity .3s; min-height: 0;
}

.music-list {
    max-height: 168px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 2px;
    overscroll-behavior: contain;
}
.music-row {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 8px; border-radius: 9px; cursor: pointer;
    transition: background .18s;
}
.music-row:hover { background: rgba(255, 255, 255, .06); }
.music-row.active { background: rgba(var(--accent-rgb), .14); }
.mr-idx {
    width: 18px; font-size: 10px; color: var(--text-dim);
    text-align: center; flex-shrink: 0;
}
.music-row.active .mr-idx { color: var(--accent); }
.mr-title {
    font-size: 12px; color: var(--text); flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mr-artist {
    font-size: 10px; color: var(--text-dim); flex-shrink: 0; max-width: 40%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-empty { padding: 16px; text-align: center; font-size: 11.5px; color: var(--text-dim); }

/* 移动端：面板贴底居中，避开输入区 */
@media (max-width: 768px) {
    .music-panel {
        left: calc(8px + var(--safe-l));
        right: calc(8px + var(--safe-r));
        top: auto;
        bottom: calc(84px + var(--safe-b));
        width: auto;
        max-height: 66dvh;
        z-index: 130;
    }
    .music-list { max-height: 30dvh; }
}

/* ==========================================================================
   音乐播放器总开关
   --------------------------------------------------------------------------
   需求：隐藏音乐播放器。
   实现：用 <body class="no-music"> 统一关闭，而不是直接删除 DOM ——
        移动端 CSS 里有 `#fabMusic { display:flex !important }` 的强制显示规则，
     单纯删掉按钮元素会被这条规则"复活"，且不方便日后恢复。

   关闭后：
     · 左侧「音乐」按钮不显示
     · 播放面板与迷你播放器不显示
     · JS 侧停止歌单轮询与音频初始化，不再产生网络请求
   ========================================================================== */
body.no-music #fabMusic,
body.no-music .music-panel,
body.no-music .mini-player {
    display: none !important;
}
