/* --- 1. 日常模式：让博客半透明 --- */
#recent-posts > .recent-post-item,
#aside-content .card-widget,
.layout > .recent-posts .pagination > *,
#page-header.nav-fixed #nav,
#footer,
#aplayer {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(8px);
}

[data-theme="dark"] #recent-posts > .recent-post-item,
[data-theme="dark"] #aside-content .card-widget,
[data-theme="dark"] #page-header.nav-fixed #nav,
[data-theme="dark"] #aplayer {
    background: rgba(0, 0, 0, 0.6) !important;
}

/* --- 2. AI 助手样式 --- */

/* ---- 悬浮按钮（右下角，避开 rightside 按钮） ---- */
#ai-ball {
    position: fixed;
    bottom: 30px;
    right: 60px;
    z-index: 10000;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35),
    0 0 0 0 rgba(139, 92, 246, 0.3);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    animation: ai-ball-pulse 2.5s ease-in-out infinite;
}

#ai-ball:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.45),
    0 0 0 0 rgba(139, 92, 246, 0);
    border-radius: 18px;
    animation: none;
}

#ai-ball:active {
    transform: translateY(0) scale(0.96);
}

#ai-ball svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

@keyframes ai-ball-pulse {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35),
        0 0 0 0 rgba(139, 92, 246, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45),
        0 0 0 8px rgba(139, 92, 246, 0);
    }
}

/* ---- 弹窗（右下角展开） ---- */
#ai-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 10000;
    width: 440px;
    height: 580px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.12),
    0 8px 20px rgba(0, 0, 0, 0.06);
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform-origin: bottom right;
}

#ai-window.ai-window-hidden {
    display: none;
}

#ai-window.ai-window-show {
    display: flex;
    animation: ai-window-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes ai-window-in {
    from {
        opacity: 0;
        transform: scale(0.4) translateY(40px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ---- 顶栏 ---- */
#ai-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    color: #fff;
    padding: 20px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

#ai-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 180px;
    height: 180px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
}

#ai-header::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: 10%;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 50%;
}

.ai-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}

.ai-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.5px;
}

.ai-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.2px;
}

.ai-subtitle {
    font-size: 12px;
    opacity: 0.75;
    margin-top: 2px;
    font-weight: 400;
}

.ai-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #34d399;
    border-radius: 50%;
    margin-right: 5px;
    animation: ai-dot-blink 2s ease-in-out infinite;
}

@keyframes ai-dot-blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

#ai-close {
    cursor: pointer;
    font-size: 24px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    line-height: 1;
    position: relative;
    z-index: 1;
}

#ai-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---- 消息区域 ---- */
#ai-content {
    padding: 20px;
    overflow-y: auto;
    font-size: 14px;
    color: #333;
    line-height: 1.6;
    flex: 1;
    scroll-behavior: smooth;
    background: #fafbfc;
}

#ai-content::-webkit-scrollbar {
    width: 5px;
}

#ai-content::-webkit-scrollbar-track {
    background: transparent;
}

#ai-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 5px;
}

#ai-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ---- 消息气泡 ---- */
.ai-msg {
    display: flex;
    margin-bottom: 16px;
    animation: ai-msg-in 0.3s ease-out;
}

@keyframes ai-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-msg-user {
    justify-content: flex-end;
}

.ai-msg-bot {
    justify-content: flex-start;
}

.ai-bubble {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
}

.ai-bubble-user {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.ai-bubble-bot {
    background: #fff;
    color: #374151;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.ai-bubble-bot.ai-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
}

.ai-loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ai-loading-dots span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: ai-dot-bounce 1.4s ease-in-out infinite;
}

.ai-loading-dots span:nth-child(2) {
    animation-delay: 0.16s;
}

.ai-loading-dots span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes ai-dot-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.ai-bubble-bot.ai-error {
    background: #fef2f2;
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.1);
}

/* ---- 输入区域 ---- */
#ai-footer {
    padding: 16px 18px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 10px;
    align-items: center;
    background: #fff;
}

#ai-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 26px;
    outline: none;
    font-size: 14px;
    background: #fafbfc;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#ai-input:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
    background: #fff;
}

#ai-input::placeholder {
    color: #9ca3af;
}

#ai-send {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

#ai-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}

#ai-send:active {
    transform: scale(0.93);
}

/* ---- 暗色模式 ---- */
[data-theme="dark"] #ai-window {
    background: #1e1e2e;
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] #ai-content {
    color: #e5e7eb;
    background: #181825;
}

[data-theme="dark"] .ai-bubble-bot {
    background: #2a2a3e;
    color: #e5e7eb;
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: none;
}

[data-theme="dark"] .ai-bubble-bot.ai-error {
    background: #3b1a1a;
    color: #fca5a5;
    border-color: rgba(252, 165, 165, 0.1);
}

[data-theme="dark"] #ai-footer {
    background: #1e1e2e;
    border-top-color: #2a2a3e;
}

[data-theme="dark"] #ai-input {
    background: #2a2a3e;
    border-color: #3f3f5e;
    color: #e5e7eb;
}

[data-theme="dark"] #ai-input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.15);
    background: #2a2a3e;
}

[data-theme="dark"] #ai-input::placeholder {
    color: #6b7280;
}

[data-theme="dark"] #ai-content::-webkit-scrollbar-thumb {
    background: #3f3f5e;
}

[data-theme="dark"] #ai-ball {
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5),
    0 0 0 0 rgba(139, 92, 246, 0.4);
}

/* ---- 移动端适配 ---- */
@media (max-width: 768px) {
    #ai-ball {
        bottom: 24px;
        right: 55px;
        width: 50px;
        height: 50px;
        border-radius: 14px;
    }

    #ai-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 160px);
        max-height: 580px;
        right: 12px;
        bottom: 90px;
        border-radius: 16px;
    }
}

/* --- 3. 寰宇模式 (沉浸状态) --- */

/* 把星空 Canvas 提到最前面 */
body.universe-mode #universe-bg {
    z-index: 9998 !important;
}

/* 核心：隐藏除了 Canvas 和 提示语 之外的所有元素 */
/* 这里特意把 #universe-btn 也包含了进去，所以它也会消失 */
body.universe-mode > *:not(#universe-bg):not(#universe-hint) {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.8s ease;
    filter: blur(10px);
}

/* 双重保险：强制隐藏寰宇按钮 */
body.universe-mode #universe-btn {
    opacity: 0 !important;
    pointer-events: none !important;
}