/* --- 异世界·古旧卷轴 主题 --- */
/* 1. 移除顶部默认颜色条，保持卷轴风格的完整性 */
[class="bg-[#F1CBCB]"],
[class*="bg-[#c9e1e9]"] {
    display: none !important;
}

/* 2. 聊天框主体样式 (输入与输出框通用) - 魔法羊皮卷效果 */
.bg-gray-100\/90.relative.inline-block {
    /* 使用渐变模拟羊皮卷的自然色泽 */
    background: linear-gradient(145deg, #fdf4d8, #e9dcb9) !important;
    border: 8px solid !important;
    /* 使用边框图片创建华丽的金属/魔法边框 */
    border-image-slice: 1 !important;
    border-image-source: linear-gradient(to bottom right, #c5a059, #e7d5a5, #c5a059) !important;
    border-radius: 10px !important;
    /* 增加立体感的阴影 */
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3), 0 0 3px rgba(212, 175, 55, 0.5) !important;
    padding: 12px 18px !important;
    /* 创建层叠上下文，为背景动效预留 */
    isolation: isolate !important;
}

/* 3. 聊天框内的主要文本样式 - 旧墨迹效果 */
.markdown-body {
    /* 确保在羊皮卷背景上绝对清晰可读 */
    color: #3A2F2F !important;
    /* 优先使用更具古典感的衬线字体 */
    font-family: Georgia, 'Times New Roman', serif !important;
    /* 严禁使用文本阴影，保证最高可读性 */
    text-shadow: none !important;
    /* 为可能的背景动效设置 */
    background: transparent !important;
    position: relative !important;
    z-index: 1 !important;
}

/* 4. 底部附加元素样式 (按钮, 模型名, Token) */
.MuiButtonBase-root.MuiButton-root.MuiButton-text.MuiButton-textPrimary,
.MuiTypography-root.MuiTypography-body2.css-6c0gf2,
.text-orange-500 {
    /* 使用稍浅的颜色与主文本区分，但仍保持高对比度 */
    color: #6a5a4a !important;
    font-family: Georgia, 'Times New Roman', serif !important;
    font-size: 0.8rem !important;
    opacity: 0.8 !important;
    transition: all 0.2s ease-in-out !important;
}

/* 5. 底部按钮交互效果 - 魔法微光 */
.MuiButtonBase-root.MuiButton-root.MuiButton-text.MuiButton-textPrimary:hover {
    color: #B8860B !important; /* 悬停时变为亮金色 */
    opacity: 1 !important;
    background-color: transparent !important;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.8) !important;
}

/* 6. 自定义加载动画 - 魔法光球脉动效果 */

/* 6.1 隐藏默认的加载点 */
.style_dot-flashing__8L91Q.style_text__zGhNq {
    display: none !important;
}

/* 6.2 设置加载动画容器 */
.flex.items-center.justify-center.w-6.h-5 {
    position: relative !important;
    height: 30px !important; /* 确保动画完整显示 */
}

/* 6.3 使用伪元素插入SVG动画 */
.flex.items-center.justify-center.w-6.h-5::before {
    content: '';
    position: absolute !important;
    left: 0;
    top: 0;
    width: 100% !important;
    height: 100% !important;
    /* 核心：内联SVG与SMIL动画，确保在任何环境下都能播放 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='50%25' r='50%25'%3E%3Cstop offset='0%25' stop-color='%23FFD700' stop-opacity='1'/%3E%3Cstop offset='100%25' stop-color='%23B8860B' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='50' cy='50' r='30' fill='url(%23g)'%3E%3Canimate attributeName='r' from='20' to='35' dur='1.5s' repeatCount='indefinite' begin='0s' calcMode='spline' keySplines='0.42 0 0.58 1; 0.42 0 0.58 1'/%3E%3Canimate attributeName='opacity' from='0.7' to='1' dur='1.5s' repeatCount='indefinite' begin='0s' calcMode='spline' keySplines='0.42 0 0.58 1; 0.42 0 0.58 1'/%3E%3C/circle%3E%3C/svg%3E") !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

/* 7. 移动端适配与低动效模式 */
@media (max-width: 480px) {
    .bg-gray-100\/90.relative.inline-block {
        border-width: 6px !important;
        padding: 10px 14px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* 在低动效模式下，减缓动画，但不完全停止 */
    .flex.items-center.justify-center.w-6.h-5::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='50%25' r='50%25'%3E%3Cstop offset='0%25' stop-color='%23FFD700' stop-opacity='1'/%3E%3Cstop offset='100%25' stop-color='%23B8860B' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='50' cy='50' r='30' fill='url(%23g)'%3E%3Canimate attributeName='r' from='25' to='30' dur='3s' repeatCount='indefinite' begin='0s' calcMode='spline' keySplines='0.42 0 0.58 1; 0.42 0 0.58 1'/%3E%3Canimate attributeName='opacity' from='0.8' to='1' dur='3s' repeatCount='indefinite' begin='0s' calcMode='spline' keySplines='0.42 0 0.58 1; 0.42 0 0.58 1'/%3E%3C/circle%3E%3C/svg%3E") !important;
    }
}


/* --- 黑暗幻想RPG主题美化方案 (兴趣使然的修正版) --- */

/* 1. 主容器：设定整体的“画框”与基础字体 */
.rpg-reply-container {
    background-color: #1e1e2e; /* Catppuccin Mocha 暗色背景 */
    border: 1px solid #45475a;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    overflow: hidden; /* 确保圆角和内边距正常工作 */
    font-family: 'Times New Roman', Georgia, serif; /* 优先使用更广泛支持的衬线字体 */
    color: #cdd6f4;
}

/* 2. 顶部状态栏：精准定位并美化 */
/* 核心修正：使用直接子选择器 > 和 :first-of-type 确保只选中第一个p元素 */
.rpg-reply-container > p:first-of-type {
    background: linear-gradient(90deg, rgba(58, 58, 77, 0.9) 0%, rgba(30, 30, 46, 0.6) 100%);
    border-left: 4px solid #f9e2af; /* 左侧金色高亮条 */
    padding: 12px 18px;
    margin: -24px -24px 24px -24px; /* 撑满容器顶部 */
    border-radius: 11px 11px 0 0;
    font-family: 'Lucida Console', Monaco, monospace; /* 等宽字体，模拟终端或UI */
    font-size: 0.9em;
    color: #cdd6f4;
    border-bottom: 1px solid #45475a;
}

.rpg-reply-container > p:first-of-type b {
    color: #f9e2af; /* 金色，与左侧高亮条呼应 */
    font-weight: normal; /* b标签只用来定位，不加粗 */
}

/* 3. 主要叙事文本区 */
/* 核心修正：定位到第一个div容器内的p标签 */
.rpg-reply-container > div:nth-of-type(1) p {
    line-height: 1.75;
    margin-bottom: 1.5em; /* 增加与下方模块的间距 */
    color: #cdd6f4; /* 确保正文颜色 */
}

/* 4. 可折叠信息面板 (details/summary) - 位于第二个div容器内 */
/* 核心修正：所有面板相关的选择器都基于 .rpg-reply-container > div:nth-of-type(2) */
.rpg-reply-container > div:nth-of-type(2) details {
    background-color: rgba(69, 71, 90, 0.3);
    border: 1px solid #585b70;
    border-radius: 8px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.rpg-reply-container > div:nth-of-type(2) details[open] {
    background-color: #181825;
    box-shadow: 0 0 15px rgba(137, 180, 250, 0.15);
}

.rpg-reply-container > div:nth-of-type(2) summary {
    padding: 14px 20px;
    cursor: pointer;
    font-weight: bold;
    color: #cba6f7; /* 薰衣草紫色标题 */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    outline: none;
    position: relative;
    list-style: none; /* 移除默认的三角箭头 */
    transition: background-color 0.2s;
}
.rpg-reply-container > div:nth-of-type(2) summary:hover {
    background-color: rgba(88, 91, 112, 0.2);
}
.rpg-reply-container > div:nth-of-type(2) summary::-webkit-details-marker {
    display: none;
}

.rpg-reply-container > div:nth-of-type(2) summary::before {
    content: '❖';
    color: #f9e2af;
    margin-right: 12px;
    display: inline-block;
    transition: transform 0.3s ease-out;
    font-size: 1.1em;
    vertical-align: middle;
}

.rpg-reply-container > div:nth-of-type(2) details[open] > summary::before {
    transform: rotate(90deg);
}

/* 适配核心：为展开的面板内容区创建内边距 */
.rpg-reply-container > div:nth-of-type(2) details > *:not(summary) {
    padding: 0 20px 20px 20px;
}
/* 为紧跟在summary后的第一个元素添加上边距，拉开距离 */
.rpg-reply-container > div:nth-of-type(2) details > summary + * {
    padding-top: 20px;
}

/* 5. 嵌套的Details面板样式 (例如NPC生理细节) */
.rpg-reply-container > div:nth-of-type(2) details details {
    margin-top: 15px;
    border-color: #313244;
    background-color: rgba(30, 30, 46, 0.3);
}
.rpg-reply-container > div:nth-of-type(2) details details[open] {
    background-color: #11111b; /* 更深的嵌套背景 */
    box-shadow: 0 0 10px rgba(203, 166, 247, 0.1);
}
.rpg-reply-container > div:nth-of-type(2) details details summary {
    color: #a6e3a1; /* 绿色作为子标题 */
    font-size: 0.9em;
    padding: 10px 15px;
}
.rpg-reply-container > div:nth-of-type(2) details details summary::before {
    content: '›'; /* 使用更简单的箭头符号 */
    font-size: 1.2em;
}
/* 嵌套面板内容区的边距调整 */
.rpg-reply-container > div:nth-of-type(2) details details > *:not(summary) {
    padding: 0 15px 15px 15px;
}
.rpg-reply-container > div:nth-of-type(2) details details > summary + * {
    padding-top: 15px;
}

/* 6. 通用内容样式 (段落、表格等) */
.rpg-reply-container p {
    margin: 0.6em 0;
    line-height: 1.6;
}
.rpg-reply-container details p > b {
    color: #fab387; /* 桃色，用于高亮关键信息 */
    font-weight: 600;
    margin-right: 8px;
}
.rpg-reply-container table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1em;
    font-size: 0.95em;
}
.rpg-reply-container th, .rpg-reply-container td {
    padding: 10px 12px;
    border: 1px solid #313244;
    text-align: left;
    vertical-align: top;
}
.rpg-reply-container thead {
    background-color: #313244;
}
.rpg-reply-container th {
    color: #cba6f7;
    font-weight: bold;
}
.rpg-reply-container tbody tr:nth-child(even) {
    background-color: rgba(49, 50, 68, 0.5);
}

/* 7. 装饰性分割线 (hr) */
.rpg-reply-container hr {
    border: none;
    height: 1px;
    background-image: linear-gradient(to right, rgba(88, 91, 112, 0), #585b72, rgba(88, 91, 112, 0));
    margin: 24px 0;
}

/* 8. “行动推荐”选项特殊样式 */
.rpg-reply-container details:has(summary:contains("行动推荐")) p {
    background: rgba(137, 180, 250, 0.1);
    border-left: 3px solid #89b4fa;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 4px;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
    cursor: pointer;
}
.rpg-reply-container details:has(summary:contains("行动推荐")) p:hover {
    background: rgba(137, 180, 250, 0.2);
    border-left-color: #a6e3a1;
    transform: translateX(5px); /* 增加一个悬浮微动效 */
}