/* ==============================================
   苍穹·起源 — AI 回复渲染 CSS（暖白轻奢主题）
   ============================================== */

.max-w-\[720px\] {
    --bg: #f8f5f0;
    --bg-warm: #f0ece4;
    --bg-card: #ffffff;
    --text: #2c2416;
    --text-soft: #6b5d4d;
    --text-muted: #9a8a7a;
    --text-faint: #c0b4a4;
    --gold: #c4a35a;
    --gold-soft: #d4b87a;
    --gold-light: rgba(196,163,90,0.06);
    --gold-mid: rgba(196,163,90,0.1);
    --gold-border: rgba(196,163,90,0.15);
    --gold-line: rgba(196,163,90,0.08);
    --green: #5a9a6a;
    --blue: #4a8aba;
    --purple: #8a5aaa;
    --red: #b85a5a;
    --shadow: 0 1px 3px rgba(44,36,22,0.02), 0 1px 2px rgba(44,36,22,0.02);
    --shadow-sm: 0 2px 8px rgba(44,36,22,0.03);
    --shadow-md: 0 4px 20px rgba(44,36,22,0.05);
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --font-body: 'Noto Serif SC', 'Source Han Serif SC', 'STSong', Georgia, serif;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --ease: cubic-bezier(0.34, 0.54, 0.2, 1);
}

/* ========== 对话气泡 — 暖白底 + 细金边 ========== */
.chat-container .group .relative.inline-block {
    background: var(--bg-card);
    border: 1px solid var(--gold-line);
    box-shadow: var(--shadow);
    border-radius: var(--radius-xl);
    padding: 20px 24px;
    position: relative;
    transition: all 0.3s var(--ease);
    max-width: 720px;
}
.chat-container .group .relative.inline-block:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gold-border);
}

/* 顶部金线装饰 */
.chat-container .group .relative.inline-block::before {
    content: '';
    position: absolute;
    top: 0; left: 20px; right: 20px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.1;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* 星标装饰 */
.chat-container .group .relative.inline-block::after {
    content: '✦ ✦';
    position: absolute;
    bottom: -4px; right: -2px;
    font-size: 7px;
    color: var(--gold);
    opacity: 0.05;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 3px;
}
.chat-container .group .relative.inline-block:hover::after { opacity: 0.12; }

/* 隐藏多余元素 */
.chat-container .group .relative.inline-block > .MuiBox-root.css-0 { display: none; }

/* ========== 用户输入框装饰 ========== */
#ai-chat-input textarea,
.chat-container textarea,
.chat-input textarea,
[placeholder*="输入"] {
    background: linear-gradient(135deg, rgba(248,245,240,0.8), rgba(245,240,232,0.5)) !important;
    border: 1px solid var(--gold-line) !important;
    border-radius: 16px !important;
    padding: 16px 20px !important;
    font-family: var(--font-body) !important;
    color: var(--text) !important;
    font-size: 0.9rem !important;
    line-height: 1.7 !important;
    transition: all 0.3s ease !important;
    box-shadow: inset 0 2px 6px rgba(44,36,22,0.02) !important;
}
#ai-chat-input textarea:focus,
.chat-container textarea:focus,
.chat-input textarea:focus,
[placeholder*="输入"]:focus {
    outline: none !important;
    border-color: var(--gold) !important;
    box-shadow: 0 0 0 3px var(--gold-light), inset 0 2px 6px rgba(44,36,22,0.02) !important;
}

/* 发送按钮 */
#ai-chat-input button[type="submit"],
.chat-container button[type="submit"],
.chat-input button[type="submit"],
.send-btn,
button:has(> svg) {
    background: linear-gradient(135deg, var(--gold), #a8883a) !important;
    border: none !important;
    border-radius: 100px !important;
    color: #fff !important;
    box-shadow: 0 4px 16px var(--gold-light) !important;
    transition: all 0.3s ease !important;
    min-width: 40px !important;
    min-height: 40px !important;
}
#ai-chat-input button[type="submit"]:hover,
.chat-container button[type="submit"]:hover,
.send-btn:hover,
button:has(> svg):hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 24px var(--gold-mid) !important;
}

/* ========== 折叠块 ========== */
.markdown-body details {
    border: none;
    margin: 18px 0;
    background: transparent;
    overflow: visible;
}
.markdown-body summary {
    display: inline-flex;
    align-items: center;
    padding: 8px 20px;
    cursor: pointer;
    background: var(--gold-light);
    color: var(--gold);
    font-weight: 600;
    font-family: var(--font-body);
    transition: all 0.3s var(--ease);
    outline: none;
    border: 1px solid var(--gold-line);
    border-radius: 9999px;
    box-shadow: var(--shadow);
    list-style: none;
    letter-spacing: 0.03em;
    font-size: 0.82rem;
}
.markdown-body summary::-webkit-details-marker { display: none; }
.markdown-body summary:hover {
    background: var(--gold-mid);
    border-color: var(--gold-border);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.markdown-body summary::before {
    content: '✦';
    display: inline-block;
    margin-right: 8px;
    font-size: 0.82rem;
    opacity: 0.5;
    transition: transform 0.3s var(--ease);
}
.markdown-body details[open] > summary::before { transform: rotate(90deg); }

.markdown-body details > pre,
.markdown-body details > table {
    margin-top: 12px;
    border: 1px solid var(--gold-line);
    border-radius: var(--radius);
    background: var(--bg);
    overflow-x: auto;
    box-shadow: var(--shadow);
}
.markdown-body details pre > div[nod] {
    padding: 14px;
    color: var(--text-soft);
    background: var(--bg) !important;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.76rem;
}
.markdown-body details code.language-markdown {
    font-size: 12px;
    line-height: 1.5;
    color: var(--gold);
    background: transparent !important;
}

/* 表格 */
.markdown-body details table { border-collapse: collapse; width: 100%; }
.markdown-body details table th,
.markdown-body details table td {
    font-size: 12px;
    padding: 6px 10px;
    line-height: 1.5;
    border: 1px solid var(--gold-line);
    color: var(--text-soft);
}
.markdown-body details table th {
    background: var(--gold-light);
    font-weight: 600;
    color: var(--gold);
}
.markdown-body details table tr:nth-child(even) { background: rgba(240,236,230,0.3); }

/* ========== 叙事段落 ========== */
.narration {
    background: var(--bg-warm);
    border-left: 3px solid var(--gold-line);
    border-radius: var(--radius);
    padding: 12px 16px 12px 20px;
    margin: 10px 0;
    position: relative;
    transition: all 0.25s var(--ease);
    line-height: 2;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text);
}
.narration:hover {
    border-left-color: var(--gold);
    background: #ece8e0;
}
.narration::before {
    content: attr(data-icon);
    position: absolute;
    top: -6px;
    right: 10px;
    font-size: 13px;
    opacity: 0.1;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.narration:hover::before { opacity: 0.2; }
.narration p {
    margin: 0;
    text-indent: 2em;
    color: var(--text);
    line-height: 2;
    font-size: 0.9rem;
}

/* ========== 环境氛围块 ========== */
.atmosphere-block {
    background: linear-gradient(135deg, var(--bg), var(--bg-warm));
    border-radius: var(--radius);
    padding: 10px 16px;
    margin: 8px 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-soft);
    letter-spacing: 0.02em;
    line-height: 1.9;
    border: 1px solid var(--gold-line);
}
.atmosphere-block .atmo-icon { font-size: 17px; display: block; margin-bottom: 2px; opacity: 0.4; }

/* ========== 动作效果块 ========== */
.action-highlight {
    background: linear-gradient(135deg, var(--gold-light), rgba(90,154,106,0.03));
    border-radius: var(--radius);
    padding: 12px 18px;
    margin: 10px 0;
    text-align: center;
    font-size: 0.88rem;
    color: var(--gold);
    border: 1px solid var(--gold-border);
    letter-spacing: 0.02em;
}
.action-highlight .action-icon { font-size: 22px; display: block; margin-bottom: 3px; }

/* ========== 内心独白 ========== */
.inner-thought {
    background: rgba(245,240,232,0.3);
    border: 1px dashed var(--gold-line);
    border-radius: var(--radius);
    padding: 8px 14px;
    margin: 6px 0 6px 16px;
    font-style: italic;
    color: var(--text-soft);
    font-size: 0.84rem;
    line-height: 1.8;
    position: relative;
}
.inner-thought::before {
    content: '💭';
    position: absolute;
    left: -18px;
    top: 6px;
    font-size: 13px;
    opacity: 0.25;
}

/* ========== 游戏通知 ========== */
.game-notify {
    background: linear-gradient(135deg, var(--gold-light), rgba(138,90,170,0.03));
    border: 1px solid var(--gold-border);
    border-radius: var(--radius);
    padding: 6px 14px;
    margin: 6px 0;
    text-align: center;
    font-size: 0.74rem;
    color: var(--gold);
    letter-spacing: 0.03em;
    font-family: var(--font-ui);
}
.game-notify .gn-icon { font-size: 14px; display: block; margin-bottom: 1px; }

/* ========== 对话行（无头像，角色色标） ========== */
.dialogue-line {
    margin: 8px 0;
    padding: 8px 14px 8px 18px;
    border-radius: var(--radius);
    position: relative;
    font-size: 0.9rem;
    line-height: 1.8;
    transition: all 0.2s var(--ease);
    border-left: 3px solid transparent;
}
.dialogue-line .speaker-tag {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 2px 8px 2px 0;
    margin-bottom: 2px;
    opacity: 0.65;
    font-family: var(--font-ui);
    border-radius: 4px;
}
.dialogue-line.user {
    background: rgba(44,36,22,0.02);
    border-left-color: var(--text-muted);
}
.dialogue-line.user .speaker-tag { color: var(--text-muted); }
.dialogue-line.user:hover { background: rgba(44,36,22,0.04); }

.dialogue-line.npc-a {
    background: var(--gold-light);
    border-left-color: var(--gold);
}
.dialogue-line.npc-a .speaker-tag { color: var(--gold); }
.dialogue-line.npc-a:hover { background: var(--gold-mid); }

.dialogue-line.npc-b {
    background: rgba(90,154,106,0.04);
    border-left-color: var(--green);
}
.dialogue-line.npc-b .speaker-tag { color: var(--green); }
.dialogue-line.npc-b:hover { background: rgba(90,154,106,0.08); }

.dialogue-line.npc-c {
    background: rgba(138,90,170,0.04);
    border-left-color: var(--purple);
}
.dialogue-line.npc-c .speaker-tag { color: var(--purple); }
.dialogue-line.npc-c:hover { background: rgba(138,90,170,0.08); }

.dialogue-line.npc {
    background: rgba(44,36,22,0.02);
    border-left-color: var(--gold-line);
}
.dialogue-line.npc .speaker-tag { color: var(--text-muted); }
.dialogue-line.npc:hover { background: rgba(44,36,22,0.04); }

.dialogue-line .action-text {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-style: italic;
    margin-top: 2px;
}

/* ========== ★ RPG状态面板（完整版） ========== */
.rpg-panel {
    background: var(--bg-card);
    border: 2px solid var(--gold-line);
    border-radius: var(--radius-xl);
    padding: 20px 22px;
    margin: 14px 0;
    box-shadow: var(--shadow);
    position: relative;
    font-family: var(--font-ui), 'Noto Serif SC', sans-serif;
}
.rpg-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--green), var(--purple));
    opacity: 0.12;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.rpg-panel::after {
    content: '✦ ✦ ✦';
    position: absolute;
    bottom: 4px; right: 10px;
    font-size: 7px;
    opacity: 0.04;
    pointer-events: none;
    letter-spacing: 4px;
    color: var(--gold);
}

.rpg-panel .panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 12px;
    font-family: var(--font-ui);
    display: flex;
    align-items: center;
    gap: 8px;
}
.rpg-panel .panel-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gold-line);
}

.rpg-panel .panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
}
@media (max-width: 480px) { .rpg-panel .panel-grid { grid-template-columns: 1fr; } }

.rpg-panel .p-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.2s ease;
    cursor: default;
    position: relative;
}
.rpg-panel .p-item:hover { background: var(--bg-warm); }
.rpg-panel .p-item .pi-icon { font-size: 13px; opacity: 0.5; width: 18px; text-align: center; flex-shrink: 0; margin-top: 2px; }
.rpg-panel .p-item .pi-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 36px;
    font-family: var(--font-ui);
    flex-shrink: 0;
}
.rpg-panel .p-item .pi-value {
    font-size: 0.74rem;
    color: var(--text);
    font-weight: 400;
    line-height: 1.5;
}
.rpg-panel .p-item .pi-value.gold { font-weight: 600; color: var(--gold); }
.rpg-panel .p-item.full { grid-column: 1 / -1; }

/* ========== Tooltip悬浮提示 ========== */
.tooltip-trigger {
    position: relative;
    cursor: help;
    border-bottom: 1px dashed var(--gold-border);
    color: var(--gold);
    font-weight: 500;
}
.tooltip-trigger .tooltip-box {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #2c2416;
    color: #faf7f2;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.68rem;
    line-height: 1.4;
    white-space: nowrap;
    font-family: var(--font-ui);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s var(--ease);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    z-index: 10;
}
.tooltip-trigger .tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%; left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #2c2416;
}
.tooltip-trigger:hover .tooltip-box {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========== 加载动画 ========== */
@keyframes ai-answer-spinner-rotation { to { transform: rotate(360deg); } }

#ai-chat-answer .chat-answer-container div:has(> .style_dot-flashing__8L91Q) {
    justify-content: flex-start; width: auto; height: auto; gap: 12px;
}
#ai-chat-answer .chat-answer-container div:has(> .style_dot-flashing__8L91Q)::after {
    content: '✦ 苍穹正在编织故事 ✦';
    font-size: 13px;
    color: var(--gold);
    margin-left: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    font-family: var(--font-body);
}
#ai-chat-answer .chat-answer-container .style_dot-flashing__8L91Q::before,
#ai-chat-answer .chat-answer-container .style_dot-flashing__8L91Q::after { content: none; display: none; }
#ai-chat-answer .chat-answer-container .style_dot-flashing__8L91Q {
    background: transparent;
    width: 18px; height: 18px;
    box-sizing: border-box; flex-shrink: 0;
    border: 2px solid var(--gold-line);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: ai-answer-spinner-rotation 0.8s linear infinite;
    box-shadow: 0 0 8px var(--gold-light);
}

.markdown-body details[open]::after {
    content: '✦';
    position: absolute;
    bottom: -8px; right: 4px;
    font-size: 9px;
    opacity: 0.1;
    pointer-events: none;
    color: var(--gold);
}

.max-w-\[720px\] { background: transparent; }