/* =========================
   风月 -> Rili 转换版
   西幻纯爱黄油风
   仅转换聊天相关与可映射界面部分
   ========================= */

/* ---------- 基础变量 ---------- */
:root {
    --plf-bg: rgba(255, 252, 248, 0.95);
    --plf-text: #5a4a42;
    --plf-gold: #e6c288;
    --plf-gold-deep: #d4af37;
    --plf-pink: #ffb7b2;
    --plf-rose: #d65a68;
    --plf-cream: #fff0f5;
    --plf-soft-yellow: #FFF3B8;
    --plf-soft-yellow-focus: #ebeccc;
    --plf-shadow-pink: rgba(255, 182, 193, 0.4);
    --plf-shadow-rose: rgba(214, 90, 104, 0.15);
}

/* ---------- 页面背景（按你原规则迁移） ---------- */
div[class="relative h-full undefined"] {
    background-image: url('https://imgtolinkx.com/i/v1Wvfvtq') !important;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-attachment: fixed !important;
}

/* ---------- 统一聊天气泡基础样式 ----------
   A: .bg-gray-100/90.relative.inline-block
   B: .group.is-user/.group.is-assistant > 第一个内容卡片
*/
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-user > div:first-child,
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-assistant > div:first-child {
    background: var(--plf-bg) !important;
    backdrop-filter: blur(12px) !important;
    border-radius: 8px !important;
    padding: 16px !important;
    position: relative !important;
    overflow: visible !important;
    border: 2px solid var(--plf-gold) !important;
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, 0.8),
        0 4px 20px var(--plf-shadow-pink) !important;
    transition: all 0.3s ease !important;
}

/* 装饰性内边框 */
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-user > div:first-child::before,
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-assistant > div:first-child::before {
    content: '' !important;
    position: absolute !important;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border: 1px dashed rgba(212, 175, 55, 0.3) !important;
    border-radius: 4px !important;
    z-index: 0 !important;
    pointer-events: none !important;
}

/* 输入框专属：嫩粉描边 */
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-user > div:first-child {
    border-color: var(--plf-pink) !important;
    box-shadow: 0 0 15px 2px rgba(255, 183, 178, 0.5) !important;
}

/* 输入框右上角装饰 */
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-user > div:first-child::after {
    content: '☪' !important;
    position: absolute !important;
    top: -12px !important;
    right: -5px !important;
    font-size: 27px !important;
    opacity: 0.9 !important;
    z-index: 3 !important;
    color: var(--plf-gold-deep) !important;
    text-shadow: 0 0 5px #fff, 0 0 10px #ffc0cb;
    animation: wing-float 3s ease-in-out infinite !important;
}

@keyframes wing-float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-3px) scale(1.1); }
}

/* ---------- 文本区 ----------
   A: .markdown-body
   B: .rili-markdown-renderer
*/
.rili-markdown-renderer {
    font-size: 17px !important;
    line-height: 1.8 !important;
    color: var(--plf-text) !important;
    text-shadow: 0 0 1px rgba(255,255,255,0.5) !important;
    position: relative !important;
    z-index: 2 !important;
}

.rili-markdown-renderer p,
.rili-markdown-renderer li,
.rili-markdown-renderer blockquote,
.rili-markdown-renderer span,
.rili-markdown-renderer div {
    color: var(--plf-text) !important;
}

/* 粗体 */
.rili-markdown-renderer strong,
.rili-markdown-renderer b {
    font-weight: bold !important;
    color: var(--plf-rose) !important;
    background: linear-gradient(to top, rgba(255, 192, 203, 0.3) 0%, transparent 40%) !important;
}

/* em / i 标签 */
.rili-markdown-renderer em,
.rili-markdown-renderer i {
    font-style: normal !important;
    display: inline-block !important;
    padding: 2px 10px !important;
    margin: 0 4px !important;
    border: 1px solid var(--plf-pink) !important;
    background-color: #fff5f7 !important;
    color: var(--plf-rose) !important;
    border-radius: 12px !important;
    font-size: 0.9em !important;
    font-family: sans-serif !important;
}

.rili-markdown-renderer em::before,
.rili-markdown-renderer i::before {
    content: '#' !important;
    color: var(--plf-gold) !important;
    margin-right: 2px !important;
}

/* li */
.rili-markdown-renderer li {
    list-style: none !important;
    margin-bottom: 3px !important;
    padding-left: 22px !important;
    position: relative !important;
}

/* ---------- details/summary 折叠栏 ---------- */
.rili-markdown-renderer summary {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 8px 15px !important;
    margin-bottom: 5px !important;
    cursor: pointer !important;
    background: linear-gradient(90deg, #fffbf0, #fff) !important;
    color: #8b5a2b !important;
    font-weight: bold !important;
    font-size: 1.05em !important;
    border: 1px solid var(--plf-gold) !important;
    border-left: 4px solid var(--plf-rose) !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 5px rgba(214, 90, 104, 0.1) !important;
    list-style: none !important;
    transition: all 0.3s ease !important;
}

.rili-markdown-renderer summary::-webkit-details-marker {
    display: none !important;
}

.rili-markdown-renderer summary:hover {
    background: #fff0f5 !important;
    transform: translateX(3px) !important;
}

.rili-markdown-renderer summary::before {
    content: '❦' !important;
    margin-right: 10px !important;
    font-size: 1.3em !important;
    color: var(--plf-rose) !important;
    transition: transform 0.3s ease !important;
}

.rili-markdown-renderer details[open] > summary::before {
    transform: rotate(180deg) !important;
}

.rili-markdown-renderer details > *:not(summary) {
    background: rgba(255, 255, 255, 0.6) !important;
    border: 1px solid rgba(230, 194, 136, 0.5) !important;
    padding: 15px !important;
    margin-top: 0 !important;
    color: #665 !important;
    border-radius: 0 0 4px 4px !important;
    font-size: 14px !important;
}

/* ---------- 表格 ---------- */
.rili-markdown-renderer table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    border-collapse: collapse !important;
    margin: 1em 0 !important;
    background-color: #fff !important;
    border: 2px solid var(--plf-gold) !important;
    border-radius: 4px !important;
}

.rili-markdown-renderer th {
    background-color: #fff0f5 !important;
    color: #8b5a2b !important;
    font-weight: bold !important;
    text-align: center !important;
    border: 1px solid var(--plf-gold) !important;
    font-family: "Cinzel", serif !important;
}

.rili-markdown-renderer td {
    padding: 10px 15px !important;
    border: 1px solid #f0e6d2 !important;
    color: var(--plf-text) !important;
}

.rili-markdown-renderer tr:nth-child(even) {
    background-color: #fafafa !important;
}

/* ---------- 回复底部按钮区 ----------
   A: .MuiButtonBase-root...
   B: 右侧按钮组里的 button
*/
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors .ml-auto.md\:opacity-0.group-hover\:opacity-100 .bg-muted.rounded.flex.p-0\.5 {
    background: rgba(255, 240, 245, 0.45) !important;
    border: 1px solid rgba(255, 183, 178, 0.45) !important;
    border-radius: 18px !important;
    padding: 4px !important;
    box-shadow: 0 2px 8px rgba(214, 90, 104, 0.08) !important;
}

.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors .ml-auto.md\:opacity-0.group-hover\:opacity-100 .bg-muted.rounded.flex.p-0\.5 > button {
    background: linear-gradient(180deg, #fff0f5, #ffe4e1) !important;
    color: var(--plf-rose) !important;
    border: 1px solid var(--plf-pink) !important;
    border-radius: 15px !important;
    padding: 4px 15px !important;
    font-size: 0.85em !important;
    font-family: "Cinzel", serif !important;
    box-shadow: 0 2px 5px var(--plf-shadow-rose) !important;
    transition: all 0.2s ease !important;
    width: auto !important;
    min-width: 30px !important;
    height: 30px !important;
}

.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors .ml-auto.md\:opacity-0.group-hover\:opacity-100 .bg-muted.rounded.flex.p-0\.5 > button:hover {
    background: #fff !important;
    color: var(--plf-gold) !important;
    border-color: var(--plf-gold) !important;
    transform: translateY(-2px) !important;
}

.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors .ml-auto.md\:opacity-0.group-hover\:opacity-100 .bg-muted.rounded.flex.p-0\.5 > button svg {
    color: var(--plf-gold-deep) !important;
    stroke: var(--plf-gold-deep) !important;
}

/* 保留 sr-only 文本，不强行显示 */

/* ---------- token / 信息栏 ----------
   A: 模型与消耗在 .MuiTypography-root
   B: 左侧小信息块
*/
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors .flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground.px-2.py-1.rounded {
    background: linear-gradient(90deg, #fffbf0, #fff) !important;
    border: 1px solid var(--plf-gold) !important;
    color: #a89f91 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 5px rgba(214, 90, 104, 0.08) !important;
    font-style: italic !important;
}

/* ---------- 用户/AI 气泡宽度微调 ---------- */
.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-assistant {
    width: 100% !important;
}

.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-assistant > div:first-child {
    width: 100% !important;
}

.w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-user {
    width: fit-content !important;
    max-width: 100% !important;
}

/* ---------- 加载动画 ----------
   A: 用 .flex.items-center.justify-center.w-6.h-5 替换
   B: 加载结构是 3 个 span 的容器
*/
.flex.gap-2.w-full.h-full.items-center.justify-center {
    position: relative !important;
    min-height: 60px !important;
    gap: 0 !important;
}

.flex.gap-2.w-full.h-full.items-center.justify-center > span {
    display: none !important;
}

.flex.gap-2.w-full.h-full.items-center.justify-center::before {
    content: '' !important;
    display: inline-block !important;
    width: 30px !important;
    height: 30px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='45' fill='none' stroke='%23daa520' stroke-width='3' opacity='0.3'/%3E%3Cpath d='M50 5 L53 20 L68 20 L56 30 L60 45 L50 37 L40 45 L44 30 L32 20 L47 20 Z' fill='%23ffd700' opacity='0.8'/%3E%3C/svg%3E") !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    animation: magic-spin 2s linear infinite !important;
    margin-right: 8px !important;
    vertical-align: middle !important;
}

.flex.gap-2.w-full.h-full.items-center.justify-center::after {
    content: '正在施展魔法...' !important;
    display: inline-block !important;
    font-size: 15px !important;
    color: var(--plf-gold-deep) !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    animation: text-pulse 2s ease-in-out infinite !important;
    vertical-align: middle !important;
}

@keyframes magic-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes text-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* ---------- 顶部信息栏类通配迁移 ----------
   原规则保留，但限制到 markdown 内避免误伤
*/
.rili-markdown-renderer .row time,
.rili-markdown-renderer .row moment,
.rili-markdown-renderer .row loc,
.rili-markdown-renderer .row around {
    background: #fff !important;
    border: 1px solid var(--plf-gold) !important;
    color: #8b5a2b !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
    font-family: "Cinzel", serif !important;
}

/* ---------- Rili输入框区美化 ----------
   由于你原CSS里 #ai-chat-bottom-input / #ai-chat-input 无法直接映射，
   这里按 Rili 常见底部 textarea / 输入容器做兼容选择器
*/
textarea,
textarea[class],
textarea[placeholder] {
    background: var(--plf-soft-yellow) !important;
    border-radius: 10px !important;
    color: var(--plf-text) !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
    border: 1px solid var(--plf-gold) !important;
}

textarea:focus {
    background: var(--plf-soft-yellow-focus) !important;
    border-color: #D3E086 !important;
    box-shadow: 0 0 0 3px rgba(252, 228, 126, 0.4) !important;
    outline: none !important;
}

textarea::placeholder {
    color: #8b7355 !important;
    opacity: 0.8 !important;
}

textarea::selection {
    background: var(--plf-rose) !important;
    color: #fff !important;
}

/* ---------- 发送按钮图标兼容 ---------- */
button svg,
div[role="button"] svg {
    transition: all 0.2s ease !important;
}

button:hover svg,
div[role="button"]:hover svg {
    transform: scale(1.06) !important;
}

/* ---------- 开场白/选择器类奶油风 ----------
   使用 :has 仅在支持时生效
*/
div.h-9.rounded-md.cursor-pointer.group:has(svg[data-icon="SlidersH"]),
div.flex.items-center.h-9.bg-white.rounded-md.cursor-pointer.group[class~="border-gray-200"] {
    background: #FFF8E7 !important;
    border: 1.5px solid #F5DEB3 !important;
    box-shadow:
        0 2px 8px rgba(255, 222, 173, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.8) !important;
    transition: all 0.3s ease !important;
}

div.h-9.rounded-md.cursor-pointer.group:has(svg[data-icon="SlidersH"]):hover,
div.flex.items-center.h-9.bg-white.rounded-md.cursor-pointer.group[class~="border-gray-200"]:hover {
    background: #FFF3D6 !important;
    border-color: #DEB887 !important;
    box-shadow: 0 4px 12px rgba(255, 222, 173, 0.5) !important;
    transform: translateY(-1px) !important;
}

div.h-9.rounded-md.cursor-pointer.group:has(svg[data-icon="SlidersH"])::before,
div.flex.items-center.h-9.bg-white.rounded-md.cursor-pointer.group[class~="border-gray-200"]::before {
    content: "🧈" !important;
    font-size: 15px !important;
    margin-left: 8px !important;
    margin-right: -2px !important;
    display: inline-flex !important;
    align-items: center !important;
    animation: butterWiggle 2s ease-in-out infinite !important;
}

div.h-9.rounded-md.cursor-pointer.group:has(svg[data-icon="SlidersH"]) span,
div.h-9.rounded-md.cursor-pointer.group:has(svg[data-icon="SlidersH"]) p,
div.flex.items-center.h-9.bg-white.rounded-md.cursor-pointer.group[class~="border-gray-200"] span,
div.flex.items-center.h-9.bg-white.rounded-md.cursor-pointer.group[class~="border-gray-200"] p,
div.flex.items-center.h-9.bg-white.rounded-md.cursor-pointer.group[class~="border-gray-200"] div {
    color: #DB7093 !important;
    font-weight: 500 !important;
    text-shadow: 0 1px 1px rgba(219, 112, 147, 0.1) !important;
}

div.h-9.rounded-md.cursor-pointer.group:has(svg[data-icon="SlidersH"]) svg[data-icon="ChevronDown"],
div.flex.items-center.h-9.cursor-pointer.group svg[data-icon="ChevronDown"] {
    color: #DB7093 !important;
    transition: transform 0.3s ease !important;
}

div.h-9.rounded-md.cursor-pointer.group:has(svg[data-icon="SlidersH"]):hover svg[data-icon="ChevronDown"],
div.flex.items-center.h-9.cursor-pointer.group:hover svg[data-icon="ChevronDown"] {
    transform: rotate(180deg) !important;
}

div.flex.items-center.h-9.bg-white.rounded-md.cursor-pointer.group[class~="border-gray-200"]:active {
    transform: scale(0.98) !important;
    box-shadow: 0 1px 4px rgba(255, 222, 173, 0.4) !important;
}

@keyframes butterWiggle {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-user > div:first-child,
    .w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-assistant > div:first-child {
        border-radius: 14px !important;
        padding: 14px 16px !important;
    }

    .w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors > .group.flex.flex-col.gap-2.is-user > div:first-child::after {
        font-size: 16px !important;
        top: 8px !important;
        right: 10px !important;
    }

    .rili-markdown-renderer {
        font-size: 16px !important;
    }

    textarea {
        border-radius: 8px !important;
    }

    .w-full.h-full.flex.group.scroll-mt-\[96px\].rounded-xl.transition-colors .ml-auto.md\:opacity-0.group-hover\:opacity-100 .bg-muted.rounded.flex.p-0\.5 > button {
        border-radius: 16px !important;
        padding: 4px 10px !important;
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    textarea {
        border-radius: 6px !important;
    }
}