/* ============ 聊天页 ============ */
.chat-view { display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%; position: relative; }

/* 桌面侧立绘区（窄屏隐藏） */
.chat-side { display: none; }
.chat-main { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* 封面沉浸背景 */
.chat-bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.chat-bg img {
    width: 100%; height: 100%; object-fit: cover;
    filter: blur(60px) brightness(.26) saturate(1.15);
    transform: scale(1.6);
}
.chat-bg::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(12,10,7,.6), rgba(12,10,7,.42) 30%, rgba(12,10,7,.78) 100%);
}
.chat-view > :not(.chat-bg) { position: relative; z-index: 1; }

/* 题材主题色（覆盖 --accent2，用于气泡/标记点缀） */
.chat-view[data-theme="era"]     { --accent2: #d8a24a; }
.chat-view[data-theme="haomen"]  { --accent2: #d4668f; }
.chat-view[data-theme="xianxia"] { --accent2: #63c9a2; }
.chat-view[data-theme="romance"] { --accent2: #e58ab2; }
.chat-view[data-theme="mystery"] { --accent2: #82a7f8; }

/* 顶栏：毛玻璃 */
.chat-top {
    display: flex; align-items: center; gap: 8px; padding: 10px 10px;
    background: rgba(20,17,12,.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(58,49,40,.6);
}
.chat-top .back {
    flex: none; width: 34px; height: 34px; border-radius: 50%; border: none;
    background: transparent; color: var(--text); font-size: 20px; line-height: 1; padding: 0;
}
.chat-top .peer { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 0 1 auto; }
.chat-top .avatar {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none;
    border: 1.5px solid rgba(224,180,106,.55); background: var(--panel2);
}
.chat-top .who-box { min-width: 0; }
.chat-top .title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-top .sub { font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-top .spacer { flex: 1; }
.chat-top .me-btn {
    flex: none; width: 34px; height: 34px; border-radius: 50%; padding: 0;
    background: var(--panel2); border: 1px solid var(--line); font-size: 13px; color: var(--dim);
}
/* 消息流 */
.chat-body {
    flex: 1; min-height: 0; overflow-y: auto; padding: 16px 12px 8px;
    display: flex; flex-direction: column; gap: 14px;
}
.msg-row { display: flex; gap: 8px; align-items: flex-end; animation: msgIn .25s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }
.msg-row .m-avatar {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none;
    border: 1px solid rgba(224,180,106,.4); background: var(--panel2);
}
.msg {
    max-width: 78%; padding: 11px 14px; border-radius: var(--radius-lg);
    white-space: pre-wrap; word-break: break-word; line-height: 1.85;
    font-size: 16.5px;
}
.msg.assistant {
    background: rgba(48,39,29,.94); border: 1px solid rgba(96,80,58,.55);
    border-bottom-left-radius: 6px;
    font-family: var(--font-story); letter-spacing: .4px;
    text-shadow: 0 0 1px rgba(242,234,217,.14);
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.msg.user {
    background: linear-gradient(180deg, #e8c284, var(--accent)); color: var(--accent-ink);
    border-bottom-right-radius: 6px; margin-left: auto;
    box-shadow: 0 4px 14px rgba(224,180,106,.18);
}
.msg-row.user-row { justify-content: flex-end; }
.msg.system { align-self: center; color: var(--dim); font-size: 12px; background: transparent; max-width: 100%; }
.msg .who { font-size: 11px; color: var(--faint); margin-bottom: 3px; display: block; font-family: var(--font-ui); }
.msg .cursor { display: inline-block; width: 8px; height: 15px; background: var(--accent); vertical-align: -2px; animation: blink 1s steps(2) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* 叙事标记高亮：【旁白】【xxx】 */
.narr-tag { color: var(--accent2); font-weight: 700; font-family: var(--font-ui); font-size: .86em; letter-spacing: .5px; }


/* 输入条 */
.chat-input {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom, 0px));
    background: rgba(20,17,12,.8); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(58,49,40,.6);
}
.chat-input .tool-btn {
    flex: none; width: 40px; height: 40px; border-radius: 50%; padding: 0;
    background: var(--panel2); border: 1px solid var(--line); color: var(--dim); font-size: 13px;
}
.chat-input textarea {
    flex: 1; resize: none; min-height: 40px; max-height: 120px;
    border-radius: 20px; padding: 9px 14px; background: var(--panel2);
    line-height: 1.45;
}
.chat-input .send-btn {
    flex: none; width: 40px; height: 40px; border-radius: 50%; padding: 0; border: none;
    background: linear-gradient(180deg, #ecc27f, var(--accent)); color: var(--accent-ink);
    font-size: 17px; font-weight: 800; line-height: 1;
    box-shadow: 0 4px 14px rgba(224,180,106,.28);
}
.chat-input .send-btn:disabled { opacity: .4; box-shadow: none; }


/* 表情面板 */
img.gg-emoji { height: 1.6em; vertical-align: -0.4em; margin: 0 1px; }
.gg-ep-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 4px; }
.gg-ep-item { cursor: pointer; text-align: center; padding: 6px 2px; border-radius: var(--radius-sm); font-size: 22px; line-height: 1.2; }
.gg-ep-item:hover { background: rgba(255,255,255,.07); }
.gg-ep-item:active { background: var(--panel2); }
#emojiMask h3 { display: flex; align-items: center; justify-content: space-between; }
.gg-ep-close { background: none; border: none; color: var(--sub); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
.gg-ep-close:hover { color: var(--text); }
.gg-ep-item img { width: 46px; height: 46px; object-fit: contain; }
.gg-ep-sep { margin: 12px 0 6px; font-size: 12px; color: var(--faint); }


/* ============ 宽屏桌面（≥900px）：左立绘 + 右对话 ============ */
@media (min-width: 900px) {
    .chat-view { flex-direction: row; }
    .chat-side {
        display: block; flex: none; width: 44%; max-width: 620px;
        position: relative; overflow: hidden;
    }
    .chat-side img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
    .chat-side .side-veil {
        position: absolute; inset: 0;
        background:
            linear-gradient(90deg, rgba(12,10,7,.18), transparent 35%, transparent 62%, rgba(20,17,12,.95) 100%),
            linear-gradient(0deg, rgba(12,10,7,.88), transparent 32%);
    }
    .chat-side .side-info { position: absolute; left: 30px; bottom: 30px; right: 60px; }
    .chat-side .side-genre {
        display: inline-block; font-size: 12px; padding: 4px 10px; border-radius: 999px;
        background: rgba(20,16,10,.72); border: 1px solid rgba(224,180,106,.4); color: var(--accent);
        margin-bottom: 10px;
    }
    .chat-side .side-name {
        font-family: var(--font-story); font-size: 34px; font-weight: 700; letter-spacing: 2px;
        text-shadow: 0 3px 14px rgba(0,0,0,.7);
    }
    .chat-side .side-sub { color: rgba(242,234,217,.75); font-size: 13px; margin-top: 6px; }
    .chat-main { min-width: 0; }
    .chat-top { padding-left: max(18px, calc((100% - 700px)/2)); padding-right: max(18px, calc((100% - 700px)/2)); }
    .chat-body { padding-left: max(18px, calc((100% - 700px)/2)); padding-right: max(18px, calc((100% - 700px)/2)); gap: 16px; }
    .chat-input { padding-left: max(18px, calc((100% - 700px)/2)); padding-right: max(18px, calc((100% - 700px)/2)); padding-top: 11px; padding-bottom: 11px; }
    .msg { font-size: 16px; }
}

/* 危机晕影：危机/倒计时存在时聊天区四边泛红光脉冲 */
.chat-view.crisis::after {
    content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
    box-shadow: inset 0 0 110px rgba(224,60,60,.30);
    animation: crisisPulse 2.4s ease-in-out infinite;
}
@keyframes crisisPulse { 50% { box-shadow: inset 0 0 130px rgba(224,60,60,.14); } }

/* 掷骰检定浮层 */
.chat-view > .ggd-dice-roll {
    position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
    background: rgba(10,8,5,.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    animation: fadeIn .18s ease;
}
.ggd-dice-roll .dice-box {
    text-align: center; background: rgba(24,19,13,.95); border: 1px solid var(--accent);
    border-radius: 20px; padding: 26px 40px; box-shadow: 0 16px 50px rgba(0,0,0,.6);
}
.ggd-dice-roll .dice-num {
    font-size: 54px; font-weight: 800; font-family: var(--font-story); color: var(--accent);
    min-width: 90px; text-shadow: 0 0 18px rgba(224,180,106,.5);
}
.ggd-dice-roll .dice-label { font-size: 14px; color: var(--dim); margin-top: 6px; letter-spacing: 2px; }
.ggd-dice-roll.win .dice-box { border-color: #8fe6a8; box-shadow: 0 0 30px rgba(143,230,168,.25); }
.ggd-dice-roll.win .dice-num { color: #8fe6a8; text-shadow: 0 0 18px rgba(143,230,168,.6); }
.ggd-dice-roll.win .dice-label { color: #8fe6a8; }
.ggd-dice-roll.lose .dice-box { border-color: #ff8484; box-shadow: 0 0 30px rgba(255,132,132,.25); }
.ggd-dice-roll.lose .dice-num { color: #ff8484; text-shadow: 0 0 18px rgba(255,132,132,.6); }
.ggd-dice-roll.lose .dice-label { color: #ff8484; }

/* ============ 手机端画卷头图（宽屏隐藏，侧立绘已承担） ============ */
.chat-hero { display: none; }
@media (max-width: 899px) {
    .chat-hero {
        display: block; position: relative; flex: none;
        height: 32vh; min-height: 170px; margin: -2px -12px 6px;
        overflow: hidden; cursor: pointer;
        border-radius: 0 0 22px 22px;
    }
    .chat-hero img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; display: block; }
    .chat-hero .hero-veil {
        position: absolute; inset: 0; pointer-events: none;
        background: linear-gradient(180deg, rgba(14,12,9,.25), transparent 30%, transparent 62%, rgba(14,12,9,.92));
    }
}

/* 全屏看图 */
.art-lightbox {
    position: fixed; inset: 0; z-index: 60; background: rgba(8,6,4,.94);
    display: flex; align-items: center; justify-content: center; cursor: zoom-out;
    animation: fadeIn .2s ease;
}
.art-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 小灵系统推送（正文顶部的手机通知感 toast） */
.xl-toast {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%) translateY(-120%);
    z-index: 50; max-width: 92%; display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 12px; border-radius: 12px; cursor: pointer;
    background: rgba(20,16,10,.92); border: 1px solid rgba(99,201,162,.45);
    box-shadow: 0 4px 18px rgba(0,0,0,.5); backdrop-filter: blur(6px);
    transition: transform .25s ease, opacity .25s ease; opacity: 0;
}
.xl-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.xl-toast .xl-badge {
    flex: none; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
    background: rgba(99,201,162,.18); color: #63c9a2; letter-spacing: 1px; margin-top: 1px;
}
.xl-toast .xl-body { font-size: 12px; color: #d8efe2; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.xl-toast.xl-full .xl-body { -webkit-line-clamp: unset; display: block; }

/* 生成中动画（打字机关闭后，流式期间转这个） */
.ggd-thinking { display: flex; gap: 5px; padding: 6px 2px; }
.ggd-thinking .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: ggdthink 1.2s ease-in-out infinite; }
.ggd-thinking .dot:nth-child(2) { animation-delay: .18s; }
.ggd-thinking .dot:nth-child(3) { animation-delay: .36s; }
@keyframes ggdthink { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* 群聊化：旁白=氛围块（左侧主题色细条），角色=立绘头像+名字牌+正文 */
.msg.narr {
    background: rgba(255,255,255,.03);
    border-left: 3px solid var(--accent2, #63c9a2);
    border-radius: 8px;
    color: #b9c4bd;
    font-size: 14px;
    line-height: 1.75;
    padding: 8px 12px;
    margin-left: 46px;
}
.char-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent2, #63c9a2);
    margin: 0 0 3px 2px;
    cursor: pointer;
}
.char-body { font-size: 15px; line-height: 1.75; }
.gg-act { color: #98a29c; font-size: .88em; }

/* ===== 微信式对话窗（2026-08-30 稳定版） ===== */
.wx-narr{
  text-align:center;
  color:#b5bcb4;
  font-size:15.5px;
  line-height:1.8;
  padding:8px 14px;
  margin:10px auto;
  max-width:82%;
}
.wx-msg{
  display:flex;
  align-items:flex-start;
  gap:12px;
  margin:12px 0;
}
.wx-avatar{
  width:40px;height:40px;
  border-radius:8px;
  object-fit:cover;
  flex:none;
  background:#2a2620;
}
.wx-col{
  display:flex;flex-direction:column;
  align-items:flex-start;
  max-width:75%;
}
.wx-name{
  font-size:13px;
  color:#c9a96a;
  margin:0 0 5px 4px;
}
.wx-bubble{
  background:#241f18;
  border:1px solid rgba(255,255,255,.08);
  border-radius:4px 12px 12px 12px;
  padding:12px 16px;
  font-size:15.5px;
  line-height:1.75;
  color:#f0e6d2;
  word-break:break-word;
}
.wx-act{
  color:#9aa098;
  font-size:.9em;
  display:block;
  margin-bottom:2px;
}
/* 玩家消息（已有 .msg.user）微调对齐微信绿 */
.msg-row.user-row{ justify-content:flex-end; }

/* 场景分隔符（模型输出 --- 时） */
.wx-scene-break{
  text-align:center;
  color:#5a5248;
  font-size:16px;
  letter-spacing:8px;
  padding:4px 0;
  margin:6px auto;
}

/* ===== 场景卡（NPC 互交舞台卡） ===== */
.msg-row.scene-row{ display:flex; justify-content:center; }
.scene-card{
  width:88%; max-width:560px;
  background:rgba(26,22,16,.85);
  border:1px solid rgba(201,169,106,.25);
  border-radius:12px;
  padding:12px 16px;
  margin:10px 0;
}
.scene-head{
  font-size:13px; font-weight:700; letter-spacing:2px;
  color:#c9a96a; text-align:center;
  padding-bottom:6px; margin-bottom:8px;
  border-bottom:1px dashed rgba(201,169,106,.25);
}
.scene-line{ font-size:14px; line-height:1.7; color:#b5bcb4; margin:4px 0; }
.scene-line b{ color:#e0b46a; font-weight:700; }

/* ===== 托管时间卡（时间·托管 N天 分隔条 + 微信分段正文） ===== */
.msg-row.auto-row{ display:flex; justify-content:center; }
.auto-card{
  font-size:12.5px; font-weight:700; letter-spacing:3px;
  color:#e8c25a; background:rgba(232,194,90,.08);
  border:1px solid rgba(232,194,90,.35);
  border-radius:999px; padding:6px 22px;
  margin:10px 0 4px;
}

/* ===== 托管弹窗 ===== */
#apPop{
  position:absolute;bottom:70px;left:50%;transform:translateX(-50%);
  z-index:55;width:280px;background:rgba(14,11,7,.97);border:1px solid var(--accent2,#63c9a2);
  border-radius:14px;padding:16px;box-shadow:0 -4px 30px rgba(0,0,0,.6);
  text-align:center;color:var(--text,#f0e6d2);
}
.ap-title{font-size:15px;font-weight:800;margin-bottom:6px}
.ap-desc{font-size:12px;color:#9a8f7a;margin-bottom:10px}
.ap-slider-row{display:flex;align-items:center;gap:8px;margin:8px 0}
.ap-slider-row span{font-size:11px;color:#9a8f7a;flex:none}
.ap-slider-row input[type=range]{flex:1;accent-color:var(--accent2,#63c9a2)}
.ap-val{font-size:20px;font-weight:800;color:var(--accent2,#63c9a2);margin:6px 0}
.ap-go{width:100%;padding:10px;border:none;border-radius:8px;background:var(--accent2,#63c9a2);color:#0a0805;font-size:14px;font-weight:700;cursor:pointer;margin:6px 0}
.ap-go:disabled{opacity:.5}
.ap-note{font-size:10px;color:#6a6258;margin-top:6px}
