@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* === 核心变量 (深色默认 - From Chat) === */
    --bg-base: #050b14;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-color: #00f0ff;

    /* 玻璃质感 (From Chat) */
    --glass-panel: rgba(15, 23, 42, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --sidebar-glass: rgba(10, 15, 30, 0.5);

    --glass-noise-pattern: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.07'/%3E%3C/svg%3E");

    --bot-bubble: rgba(30, 41, 59, 0.6);
    --user-bubble: linear-gradient(135deg, #0061ff 0%, #60efff 100%);
    --user-text: #ffffff;

    --shadow-depth: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    --glass-blur: blur(40px);

    /* 安全区域 */
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);

    /* === MathSpace 独有变量 (保留) === */
    /* 冰雪主题色 */
    --ice-primary: #87CEEB;
    --ice-secondary: #00CED1;
    --ice-accent: #7FFFD4;
    --ice-glow: rgba(135, 206, 250, 0.5);
    --ice-track-bg: rgba(135, 206, 250, 0.15);
}

body.light-mode {
    /* === 浅色模式变量 (From Chat) === */
    --bg-base: #f0f4f8;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #0ea5e9;

    --glass-panel: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.6);
    --sidebar-glass: rgba(240, 245, 250, 0.5);

    --bot-bubble: rgba(255, 255, 255, 0.7);
    --user-bubble: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
    --user-text: #ffffff;

    --shadow-depth: 0 20px 50px -12px rgba(0, 0, 0, 0.1);

    /* MathSpace 浅色扩展 */
    --ice-primary: #0284c7;
    --ice-secondary: #0891b2;
    --ice-accent: #06b6d4;
    --ice-glow: rgba(2, 132, 199, 0.25);
    --ice-track-bg: rgba(14, 165, 233, 0.2);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* 全局移除 Focus 样式 */
button:focus,
button:focus-visible,
input:focus,
input:focus-visible {
    outline: none;
    box-shadow: none;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-base);
    transition: background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.4s ease;
    -webkit-text-size-adjust: 100%;
}

/* 主题切换过渡动画 */
.theme-transitioning,
.theme-transitioning * {
    transition: background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.5s ease,
        color 0.4s ease,
        box-shadow 0.5s ease,
        opacity 0.4s ease !important;
}

.theme-transitioning .app-layout {
    animation: themeBreath 0.6s ease-out;
}

@keyframes themeBreath {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(0.995);
        opacity: 0.95;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 背景粒子画布 */
#math-canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: radial-gradient(circle at center, transparent 0%, var(--bg-base) 90%);
    pointer-events: none;
}

#math-canvas-container canvas {
    display: block;
}

.math-particle-dom {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    font-size: 20px;
    animation: particleFly 1s forwards cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes particleFly {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }

    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(1.5) rotate(var(--rot));
    }
}

/* === 布局容器 === */
.glass-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding: 4vh 4vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-layout {
    width: 100%;
    height: 100%;
    max-width: 1400px;
    display: flex;
    background: var(--glass-panel);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--shadow-depth);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    overflow: hidden;
    transition: background 0.3s ease;
}

/* 侧边栏 */
.sidebar {
    width: 280px;
    background: var(--sidebar-glass);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 25px 20px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    transition: 0.3s;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.history-item {
    padding: 12px;
    margin-bottom: 5px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    transition: 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.history-item.active {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-color);
    font-weight: 600;
    border-left: 3px solid var(--accent-color);
}

.delete-chat {
    opacity: 0;
    color: #ff5252;
    transition: 0.2s;
}

.history-item:hover .delete-chat {
    opacity: 1;
}

/* 修改点：优化侧边栏底部布局 */
.sidebar-footer {
    padding: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--glass-border);
    display: flex;
    /* 启用 Flexbox */
    flex-direction: column;
    /* 垂直排列 */
    align-items: center;
    /* 水平居中 */
    gap: 8px;
    /* 间距 */
}

/* 修改点：新增备案号样式 */
.icp-link {
    font-size: 10px;
    /* 小字号 */
    text-decoration: none;
    /* 去掉默认下划线 */
    color: inherit;
    /* 继承父颜色，适配日夜模式 */
    opacity: 0.4;
    /* 默认低调半透明 */
    font-family: 'Inter', sans-serif;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    /* 防止换行 */
}

.icp-link:hover {
    opacity: 0.8;
    /* 悬停变亮 */
    text-decoration: underline;
    /* 悬停出现下划线 */
}

/* 主区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    min-width: 0;
}

/* 顶部栏 */
.header-bar {
    padding: 0 25px;
    border-bottom: 1px solid var(--glass-border);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1)), var(--glass-noise-pattern);
    backdrop-filter: var(--glass-blur);
    height: 60px;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

/* 图标容器 */
.glass-snowflake {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    opacity: 0.9;
    cursor: pointer;
    user-select: none;
    transition: all 0.5s ease;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.01));
    box-shadow: -3px -3px 8px rgba(255, 255, 255, 0.1), 4px 4px 10px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

body.light-mode .glass-snowflake {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.2));
    box-shadow: -4px -4px 10px rgba(255, 255, 255, 1), 4px 4px 10px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.icon-svg {
    position: absolute;
    width: 26px;
    height: 26px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-snow {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
}

.icon-cream {
    opacity: 0;
    transform: rotate(-15deg) scale(0.5);
}

body.light-mode .icon-snow {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

body.light-mode .icon-cream {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    color: var(--accent-color);
}

.glass-snowflake:hover {
    transform: translateY(-1px);
    opacity: 1;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-color);
}

/* 消息列表 */
.messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 8%;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding-bottom: 20px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    max-width: 80%;
    width: fit-content;
    animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    margin-right: auto;
}

.message.bot .message-content {
    background: var(--bot-bubble);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-top-left-radius: 4px;
}

.message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message.user .message-content {
    background: var(--user-bubble);
    color: var(--user-text);
    border-top-right-radius: 4px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.message img {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: breath 4s ease-in-out infinite;
}

.message img:hover {
    transform: scale(1.5);
    z-index: 50;
    border-color: var(--accent-color);
}

@keyframes breath {

    0%,
    100% {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }

    50% {
        box-shadow: 0 4px 20px rgba(0, 240, 255, 0.4);
    }
}

.message-content {
    padding: 14px 20px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
}

/* 输入区域 */
.input-area {
    padding: 20px 30px;
    display: flex;
    gap: 12px;
    border-top: 1px solid var(--glass-border);
    background: linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05)), var(--glass-noise-pattern);
    backdrop-filter: var(--glass-blur);
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.input-container {
    flex: 1;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 6px 16px;
    transition: 0.3s;
}

.input-container:focus-within {
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.1);
}

/* Ghost 输入法 */
.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    overflow: hidden;
}

.input-container input {
    position: relative;
    z-index: 2;
    background: transparent !important;
    width: 100%;
    padding: 10px;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    outline: none;
    min-width: 0;
}

#ghost-input {
    position: absolute;
    top: 50%;
    padding: 0;
    margin: 0;
    transform: translateY(-50%);
    z-index: 1;
    pointer-events: none;
    font-size: 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: normal;
    color: var(--text-secondary);
    opacity: 0.5;
    white-space: pre;
    transition: opacity 0.3s ease, left 0.1s linear;
}

.ghost-cycle-anim {
    animation: ghostCycle 0.5s ease-in-out;
}

@keyframes ghostCycle {
    0% {
        transform: translateY(-50%) translateY(0);
        opacity: 0.5;
    }

    50% {
        transform: translateY(-50%) translateY(-5px);
        opacity: 0;
    }

    51% {
        transform: translateY(-50%) translateY(5px);
        opacity: 0;
    }

    100% {
        transform: translateY(-50%) translateY(0);
        opacity: 0.5;
    }
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
    outline: none;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

.mic-btn.recording {
    color: #ff5252;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.dropdown-content {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 0;
    background: var(--sidebar-glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px;
    min-width: 160px;
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.dropdown-content.show {
    display: block;
    animation: pop 0.2s ease;
}

@keyframes pop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dropdown-item {
    padding: 10px;
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    color: var(--text-primary);
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* 移动端菜单按钮 */
#mobile-menu-btn {
    position: fixed;
    z-index: 200;
    background: var(--sidebar-glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    width: 40px;
    height: 40px;
    display: none;
    border-radius: 8px;
    color: var(--text-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: background 0.3s ease, color 0.3s ease;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    display: none;
}

.overlay.active {
    display: block;
}

.katex {
    font-size: 1.1em;
}

/* Video Container (保留视频样式，虽然 Chat 暂无) */
.video-container {
    margin-top: 12px;
    background: linear-gradient(145deg, #0a0f1a 0%, #000 100%);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(0, 240, 255, 0.15);
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 0 30px rgba(0, 240, 255, 0.05);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* 防止移动端越界 */
    max-width: 100%;
    box-sizing: border-box;
}

.video-container:hover {
    transform: translateY(-4px);
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(0, 240, 255, 0.2) inset,
        0 0 40px rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.3);
}

.video-container video {
    width: 100%;
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.video-info {
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.9) 100%);
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--accent-color);
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* 输入区 (保证能点击) */
.input-area {
    padding: 20px 30px;
    display: flex;
    gap: 12px;
    border-top: 1px solid var(--glass-border);
    background: linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05)), var(--glass-noise-pattern);
    backdrop-filter: var(--glass-blur);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    /* 确保在最上层 */
}

.input-container {
    flex: 1;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 6px 16px;
    transition: 0.3s;
}

.input-container:focus-within {
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.1);
    box-shadow:
        0 0 0 3px rgba(0, 240, 255, 0.1),
        0 0 30px rgba(0, 240, 255, 0.1);
}

/* Ghost 输入法 */
.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    overflow: hidden;
}

.input-container input {
    flex: 1;
    padding: 10px;
    background: transparent !important;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    min-width: 0;
    position: relative;
    z-index: 2;
    width: 100%;
}

#ghost-input {
    position: absolute;
    top: 50%;
    padding: 0;
    margin: 0;
    transform: translateY(-50%);
    z-index: 1;
    pointer-events: none;
    font-size: 16px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: normal;
    color: var(--text-secondary);
    opacity: 0.5;
    white-space: pre;
    transition: opacity 0.3s ease, left 0.1s linear;
}

.ghost-cycle-anim {
    animation: ghostCycle 0.5s ease-in-out;
}

@keyframes ghostCycle {
    0% {
        transform: translateY(-50%) translateY(0);
        opacity: 0.5;
    }

    50% {
        transform: translateY(-50%) translateY(-5px);
        opacity: 0;
    }

    51% {
        transform: translateY(-50%) translateY(5px);
        opacity: 0;
    }

    100% {
        transform: translateY(-50%) translateY(0);
        opacity: 0.5;
    }
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    font-size: 20px;
    color: var(--text-secondary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    border: 1px solid transparent;
}

.icon-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-color);
    border-color: rgba(0, 240, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.15);
}

.icon-btn:active {
    transform: translateY(0) scale(0.95);
}

.mic-btn.recording {
    color: #ff5252;
    background: rgba(255, 82, 82, 0.1);
    border-color: rgba(255, 82, 82, 0.3);
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.4);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(255, 82, 82, 0);
    }
}

.dropdown-content {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 0;
    background: var(--sidebar-glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px;
    min-width: 160px;
    backdrop-filter: blur(20px);
    z-index: 200;
}

.dropdown-content.show {
    display: block;
    animation: pop 0.2s ease;
}

.dropdown-item {
    padding: 10px;
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    color: var(--text-primary);
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

@keyframes pop {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading {
    text-align: center;
    color: var(--accent-color);
    font-size: 14px;
    margin: 0;
    padding: 20px 25px;
    background: linear-gradient(135deg, rgba(135, 206, 250, 0.08) 0%, rgba(70, 130, 180, 0.05) 100%);
    border-radius: 16px 16px 0 0;
    border: 1px solid rgba(135, 206, 250, 0.2);
    border-bottom: none;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    cursor: progress;
}

/* ❄️ Snowflake Loading Theme */
.snowflake-loading {
    background: linear-gradient(145deg,
            rgba(135, 206, 250, 0.1) 0%,
            rgba(176, 224, 230, 0.08) 50%,
            rgba(70, 130, 180, 0.05) 100%);
    border: 1px solid rgba(135, 206, 250, 0.25);
    box-shadow:
        0 0 40px rgba(135, 206, 250, 0.1),
        inset 0 0 30px rgba(255, 255, 255, 0.03);
}

/* Floating Snowflakes Container */
.snowflakes-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    color: rgba(135, 206, 250, 0.6);
    font-size: 18px;
    animation: snowfall linear infinite;
    text-shadow: 0 0 10px rgba(135, 206, 250, 0.8);
}

.snowflake.sf1 {
    left: 10%;
    animation-duration: 3s;
    animation-delay: 0s;
    font-size: 16px;
}

.snowflake.sf2 {
    left: 30%;
    animation-duration: 4s;
    animation-delay: 0.5s;
    font-size: 20px;
}

.snowflake.sf3 {
    left: 50%;
    animation-duration: 3.5s;
    animation-delay: 1s;
    font-size: 14px;
}

.snowflake.sf4 {
    left: 70%;
    animation-duration: 4.5s;
    animation-delay: 1.5s;
    font-size: 18px;
}

.snowflake.sf5 {
    left: 90%;
    animation-duration: 3s;
    animation-delay: 2s;
    font-size: 22px;
}

@keyframes snowfall {
    0% {
        top: -20px;
        opacity: 0;
        transform: translateX(0) rotate(0deg);
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
        transform: translateX(20px) rotate(360deg);
    }
}

/* Ice Crystal Progress Bar */
.ice-progress-container {
    width: 100%;
    max-width: 450px;
    margin: 20px auto 10px;
    position: relative;
    z-index: 1;
}

.ice-track {
    width: 100%;
    height: 8px;
    background: var(--ice-track-bg);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(135, 206, 250, 0.2);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ice-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg,
            var(--ice-primary) 0%,
            var(--ice-secondary) 50%,
            var(--ice-accent) 100%);
    border-radius: 20px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow:
        0 0 15px var(--ice-glow),
        0 0 30px var(--ice-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.ice-shimmer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.6) 50%,
            transparent 100%);
    animation: iceShimmer 2s infinite;
}

@keyframes iceShimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(200%);
    }
}

/* Ice Crystal Step Indicators */
.ice-steps {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    font-size: 11px;
    color: var(--text-secondary);
}

.ice-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.4;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ice-crystal {
    font-size: 20px;
    transition: all 0.4s ease;
    filter: grayscale(1);
    /* 确保旋转中心稳定 */
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
}

.ice-step.active {
    opacity: 1;
    color: var(--ice-secondary);
}

.ice-step.active .ice-crystal {
    filter: grayscale(0) drop-shadow(0 0 8px var(--ice-glow));
    animation: crystalSpin 1.5s linear infinite;
}

.ice-step.completed {
    opacity: 1;
    color: var(--ice-accent);
}

.ice-step.completed .ice-crystal {
    filter: grayscale(0) drop-shadow(0 0 6px var(--ice-glow));
}

@keyframes crystalSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.loading-status {
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    font-size: 15px;
    color: var(--ice-primary);
    position: relative;
    z-index: 1;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    display: none;
}

.overlay.active {
    display: block;
}

/* 点击特效 */
.math-particle-dom {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    font-family: monospace;
    font-weight: bold;
    font-size: 20px;
    animation: particleFly 1s forwards;
}

@keyframes particleFly {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }

    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(1.5) rotate(var(--rot));
    }
}

@media (max-width: 768px) {
    .glass-wrapper {
        padding: 0;
        width: 100%;
        height: 100dvh;
    }

    .app-layout {
        border-radius: 0;
        border: none;
        /* 默认深色 (Fallback) */
        background: #050b14;
        background: var(--bg-base);
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 80%;
        max-width: 300px;
        background: var(--sidebar-glass);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        padding-top: calc(80px + var(--safe-top));
    }

    #mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        top: calc(10px + var(--safe-top));
        left: 15px;
    }

    .header-bar {
        height: calc(60px + var(--safe-top));
        padding-top: var(--safe-top);
        padding-left: 70px;
        padding-right: 15px;
        background: linear-gradient(to bottom, var(--bg-base), transparent);
        border-bottom: 1px solid var(--glass-border);
    }

    .messages {
        padding: 10px 15px;
    }

    .message {
        max-width: 92%;
    }

    .input-area {
        padding: 10px 12px;
        gap: 8px;
        padding-bottom: calc(10px + var(--safe-bottom));
        background: var(--bg-base);
        border-top: 1px solid var(--glass-border);
    }

    .input-container input {
        font-size: 16px !important;
    }

    #ghost-input {
        font-size: 16px !important;
    }

    .status-dot {
        width: 6px;
        height: 6px;
    }

    .message img {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .message-content {
        padding: 12px 16px;
        font-size: 14px;
        line-height: 1.6;
    }

    .message {
        gap: 10px;
    }

    /* Phase 2: 组件适配 */
    .input-container {
        border-radius: 20px;
        padding: 4px 12px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .video-container {
        border-radius: 12px;
    }

    .video-info {
        padding: 8px 12px;
        font-size: 10px;
    }

    .video-actions {
        padding: 10px 12px;
        gap: 8px;
    }

    .video-action-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* 进度条步骤简化 */
    .ice-progress-container {
        max-width: 100%;
        margin: 15px auto 8px;
    }

    .ice-steps {
        gap: 4px;
    }

    .ice-step span {
        font-size: 10px;
    }

    .ice-crystal {
        font-size: 16px;
    }

    .loading-status {
        font-size: 13px;
    }

    /* 代码面板纵向布局 */
    .code-panel-body {
        flex-direction: column;
    }

    .video-preview-container {
        width: 100%;
        max-width: none;
        min-width: unset;
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .code-panel-header {
        padding: 12px 16px;
        font-size: 14px;
    }

    .code-action-btn {
        padding: 8px 14px;
        font-size: 12px;
    }

    .ai-input-area {
        flex-direction: column;
        padding: 12px 16px;
        gap: 10px;
    }

    .ai-input-area input {
        font-size: 14px;
        padding: 10px 14px;
    }

    .code-action-btn.ai-btn {
        width: 100%;
        justify-content: center;
    }

    /* === 视频容器移动端适配 === */
    .video-container {
        max-width: 100%;
        border-radius: 12px;
    }

    .message-content {
        max-width: 100%;
        overflow: hidden;
    }

    /* === 代码面板移动端全屏模式 === */
    .code-panel {
        width: 100%;
        min-width: 0;
        border-radius: 0;
        border-left: none;
    }

    .code-panel-header {
        padding: 12px 16px;
        padding-top: calc(12px + var(--safe-top));
    }

    .code-panel-actions {
        gap: 8px;
    }

    .code-action-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .code-action-btn.close-btn {
        width: 36px;
        height: 36px;
        padding: 0;
    }

    /* 移动端 Tab 切换显示 */
    .mobile-tabs {
        display: flex;
    }

    /* 隐藏桌面端代码编辑器 */
    #monaco-container {
        display: none;
    }

    /* 显示移动端代码视图 */
    .mobile-code-view {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }

    .mobile-code-view.tab-hidden {
        display: none;
    }

    .video-preview-container.tab-hidden {
        display: none;
    }

    .video-preview-container {
        flex: 1;
        max-height: none;
        border-right: none;
        border-bottom: none;
    }

    .ai-input-area {
        flex-direction: column;
        padding: 12px;
        padding-bottom: calc(12px + var(--safe-bottom));
        gap: 10px;
    }

    .ai-input-area input {
        font-size: 16px;
    }

    .code-action-btn.ai-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Phase 3: 超小屏幕适配 (< 480px) */
@media (max-width: 480px) {
    .ice-step span {
        display: none;
        /* 隐藏文字，只显示图标 */
    }

    .ice-steps {
        justify-content: center;
        gap: 16px;
    }

    .ice-crystal {
        font-size: 20px;
    }

    .message {
        max-width: 92%;
    }

    .header-bar {
        padding-left: 55px;
        font-size: 10px;
    }

    .glass-snowflake {
        width: 32px;
        height: 32px;
    }

    .icon-svg {
        width: 20px;
        height: 20px;
    }

    .input-area {
        padding: 10px 12px;
    }
}

/* =======================================================
   >>> 暴力强制规则 (防止变量在移动端不生效) <<<
   ======================================================= */
@media (max-width: 768px) {
    body.light-mode .app-layout {
        background: #f0f4f8 !important;
        /* 强制浅色背景 */
    }

    body.light-mode .input-area {
        background: #ffffff !important;
        /* 强制白色输入区 */
    }

    body.light-mode .header-bar {
        background: rgba(240, 244, 248, 0.95) !important;
    }

    body.light-mode .sidebar {
        background: #f8fafc !important;
    }
}

/* 呼吸灯文字效果 */
.breathing-text {
    animation: textBreath 1.5s infinite ease-in-out;
    display: inline-block;
    font-weight: 500;
}

@keyframes textBreath {

    0%,
    100% {
        opacity: 1;
        text-shadow: 0 0 3px var(--ice-glow);
    }

    50% {
        opacity: 0.7;
        text-shadow: none;
    }
}

/* 2. 动态点点点动画 */
.animated-dots::after {
    content: '';
    animation: dots 1.5s infinite;
    display: inline-block;
    width: 24px;
    /* 预留足够空间 */
    text-align: left;
}

@keyframes dots {
    0% {
        content: '';
    }

    25% {
        content: '.';
    }

    50% {
        content: '..';
    }

    75% {
        content: '...';
    }

    100% {
        content: '';
    }
}

/* ========== Code Panel Styles (Premium Aurora Theme) ========== */
.code-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 11, 20, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.code-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

.code-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 1400px;
    min-width: 600px;
    height: 100%;
    /* Glass morphism - matching main UI */
    background: var(--glass-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-left: 1px solid var(--glass-border);
    box-shadow: var(--shadow-depth);
    z-index: 600;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

/* Subtle side accent */
.code-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg,
            transparent 0%,
            var(--ice-primary) 30%,
            var(--ice-secondary) 50%,
            var(--ice-accent) 70%,
            transparent 100%);
    opacity: 0.5;
}

@keyframes auroraBorder {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.6;
    }
}

.code-panel.open {
    transform: translateX(0);
}

.code-panel-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
    font-weight: 600;
    font-size: 15px;
    color: var(--ice-primary);
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.code-panel-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* === 移动端 Tab 切换器 === */
.mobile-tabs {
    display: none;
    /* 默认桌面端隐藏 */
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    padding: 0;
}

.mobile-tab-btn {
    flex: 1;
    padding: 14px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.mobile-tab-btn.active {
    color: var(--accent-color);
    background: rgba(0, 240, 255, 0.08);
}

.mobile-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--accent-color);
    border-radius: 2px 2px 0 0;
}

/* === 移动端代码视图 (只读) === */
.mobile-code-view {
    display: none;
    /* 默认桌面端隐藏 */
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
}

.mobile-code-view.tab-hidden {
    display: none !important;
}

.mobile-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid var(--glass-border);
    font-size: 12px;
    color: var(--text-secondary);
}

.copy-code-btn {
    padding: 6px 12px;
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 6px;
    color: var(--accent-color);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-code-btn:hover {
    background: rgba(0, 240, 255, 0.2);
}

.mobile-code-content {
    flex: 1;
    overflow: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.mobile-code-content pre {
    margin: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Split View Body */
.code-panel-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    background: var(--glass-noise-pattern);
}

/* Video Preview Container (Left Side) */
.video-preview-container {
    width: 40%;
    min-width: 280px;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--glass-border);
    overflow: hidden;
}

.video-preview-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    gap: 12px;
}

.video-preview-placeholder span {
    font-size: 40px;
    opacity: 0.4;
}

.video-preview-placeholder p {
    margin: 0;
    opacity: 0.6;
}

/* Video player inside preview */
.video-preview-container video {
    width: 100%;
    height: auto;
    max-height: 45%;
    object-fit: contain;
    background: #000;
    flex-shrink: 0;
}

.video-preview-container .video-info {
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--accent-color);
    flex-shrink: 0;
}

/* === 版本指示器 === */
.version-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', monospace;
}

.version-label {
    color: var(--text-secondary);
    opacity: 0.7;
}

.version-tag {
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.version-tag:hover {
    background: rgba(0, 240, 255, 0.2);
    color: var(--accent-color);
}

.version-tag.current {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.3) 0%, rgba(0, 200, 255, 0.2) 100%);
    color: var(--accent-color);
    font-weight: 600;
}

.revert-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.revert-btn:hover {
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.video-preview-container .video-controls {
    padding: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--glass-border);
}

/* ========== 详细历史列表 ========== */
.history-list-container {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.25);
    flex: 1;
    /* 自动填充剩余空间，延伸到输入框 */
    min-height: 80px;
    overflow: hidden;
}

.history-list-header {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ice-primary);
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.history-list-container .history-list {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
    /* 填充 history-list-container 剩余空间 */
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-list-container .history-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 11px;
    padding: 16px;
    opacity: 0.6;
}

.history-list-container .history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 4px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    cursor: pointer;
}

.history-list-container .history-item:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.2);
}

.history-list-container .history-item.current {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.15) 0%, rgba(0, 200, 255, 0.1) 100%);
    border-color: rgba(0, 240, 255, 0.25);
}

.history-list-container .history-version {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-color);
    padding: 2px 6px;
    background: rgba(0, 240, 255, 0.1);
    border-radius: 4px;
    flex-shrink: 0;
}

.history-list-container .history-desc {
    flex: 1;
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-list-container .history-revert-btn {
    padding: 4px 8px;
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.history-list-container .history-revert-btn:hover {
    background: rgba(0, 240, 255, 0.15);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.history-list-container .history-current-tag {
    font-size: 10px;
    color: var(--accent-color);
    padding: 2px 6px;
    background: rgba(0, 240, 255, 0.1);
    border-radius: 4px;
    flex-shrink: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.history-header span {
    font-size: 12px;
    font-weight: 600;
    color: var(--ice-primary);
}

.rebuild-btn {
    padding: 6px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rebuild-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* 历史列表辅助样式 (保留唯一定义) */
.history-list-container .history-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
    flex-shrink: 0;
}

.history-list-container .history-item.current .history-dot {
    background: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-color);
}

.history-list-container .history-item.original .history-dot {
    background: #10b981;
}

.history-list-container .history-info {
    flex: 1;
    min-width: 0;
}

.history-list-container .history-time {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Monaco Editor Container (Right Side) */
#monaco-container {
    flex: 1;
    overflow: hidden;
}

.code-panel-actions {
    display: flex;
    gap: 12px;
}

.code-action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-action-btn.render-btn {
    background: linear-gradient(135deg, #0061ff 0%, #60efff 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 97, 255, 0.3);
}

.code-action-btn.render-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 97, 255, 0.45);
}

.code-action-btn.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.code-action-btn.close-btn:hover {
    background: rgba(255, 82, 82, 0.15);
    border-color: rgba(255, 82, 82, 0.4);
    color: #ff5252;
    transform: rotate(90deg);
}

/* Video action buttons */
.video-actions {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.9) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.video-action-btn {
    padding: 8px 14px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.video-action-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-color);
    border-color: rgba(0, 240, 255, 0.35);
    transform: translateY(-1px);
}

/* ========== Mobile Code Panel - Complete Refactor ========== */
@media (max-width: 768px) {

    /* 面板从底部滑出 */
    .code-panel {
        width: 100%;
        min-width: unset;
        max-width: unset;
        top: auto;
        bottom: 0;
        height: 90vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        border-left: none;
        border-top: 1px solid var(--glass-border);
    }

    .code-panel.open {
        transform: translateY(0);
    }

    /* 面板顶部装饰条 */
    .code-panel::before {
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        border-radius: 2px;
        background: var(--glass-border);
    }

    .code-panel-header {
        padding: 20px 16px 12px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .code-panel-header>span {
        width: 100%;
        text-align: center;
        font-size: 16px;
    }

    .code-panel-actions {
        width: 100%;
        justify-content: center;
        gap: 10px;
    }

    .code-action-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }

    .code-action-btn.close-btn {
        flex: 0;
        width: 44px;
    }

    /* Tab 切换按钮 */
    .mobile-tabs {
        display: flex !important;
        padding: 0 16px 12px;
        gap: 8px;
        border-bottom: 1px solid var(--glass-border);
    }

    .mobile-tab-btn {
        flex: 1;
        padding: 10px 16px;
        border: 1px solid var(--glass-border);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.03);
        color: var(--text-secondary);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .mobile-tab-btn.active {
        background: linear-gradient(135deg, rgba(0, 240, 255, 0.15) 0%, rgba(0, 200, 255, 0.1) 100%);
        color: var(--accent-color);
        border-color: rgba(0, 240, 255, 0.3);
    }

    /* Tab 内容区域 */
    .code-panel-body {
        flex-direction: column;
        position: relative;
    }

    .video-preview-container,
    #monaco-container,
    .mobile-code-view {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .video-preview-container {
        max-width: none;
        min-width: unset;
        max-height: none;
        border-right: none;
        border-bottom: none;
    }

    .tab-hidden {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    /* Monaco 在移动端隐藏，用只读视图替代 */
    #monaco-container {
        display: none;
    }

    /* 移动端代码只读视图 */
    .mobile-code-view {
        display: flex !important;
        flex-direction: column;
        background: rgba(0, 0, 0, 0.3);
        overflow: hidden;
    }

    .mobile-code-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        background: rgba(0, 0, 0, 0.4);
        border-bottom: 1px solid var(--glass-border);
        flex-shrink: 0;
    }

    .mobile-code-header span {
        font-size: 12px;
        color: var(--text-secondary);
    }

    .copy-code-btn {
        padding: 8px 16px;
        border: 1px solid var(--glass-border);
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.05);
        color: var(--text-primary);
        font-size: 12px;
        cursor: pointer;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .copy-code-btn:hover {
        background: rgba(0, 240, 255, 0.1);
        border-color: var(--accent-color);
    }

    .copy-code-btn.copied {
        background: rgba(16, 185, 129, 0.2);
        border-color: #10b981;
        color: #10b981;
    }

    .mobile-code-content {
        flex: 1;
        overflow: auto;
        padding: 16px;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-code-content pre {
        margin: 0;
        font-family: 'JetBrains Mono', monospace;
        font-size: 12px;
        line-height: 1.6;
        color: var(--text-primary);
        white-space: pre-wrap;
        word-break: break-all;
    }

    /* AI 输入区 */
    .ai-input-area {
        flex-direction: column;
        padding: 12px 16px;
        gap: 10px;
    }

    .ai-input-area input {
        font-size: 14px;
        padding: 12px 14px;
    }

    .code-action-btn.ai-btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    /* 视频预览优化 */
    .video-preview-container video {
        max-height: 50%;
    }

    .video-preview-placeholder {
        padding: 40px 20px;
    }

    .video-preview-placeholder span {
        font-size: 48px;
    }
}

/* 桌面端隐藏移动端专属元素 */
.mobile-tabs {
    display: none;
}

.mobile-code-view {
    display: none;
}

@media (min-width: 769px) {

    .mobile-tabs,
    .mobile-code-view {
        display: none !important;
    }
}

/* AI Input Area (Enhanced) */
.ai-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.02) 0%, rgba(16, 185, 129, 0.02) 100%);
    border-top: 1px solid var(--glass-border);
}

.ai-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.3s ease;
}

.ai-input-area input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
    background: rgba(0, 0, 0, 0.45);
}

.ai-input-area input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.code-action-btn.ai-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    min-width: 120px;
    justify-content: center;
}

.code-action-btn.ai-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.45);
}

.code-action-btn.ai-btn:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
    animation: pulse 1.5s infinite;
}

/* Light mode adjustments */
body.light-mode .code-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.98) 100%);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.1);
}

body.light-mode .code-panel-header {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.05) 0%, rgba(56, 189, 248, 0.05) 100%);
}

body.light-mode .ai-input-area input {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .ai-input-area input:focus {
    border-color: var(--accent-color);
    background: white;
}

/* Light mode - Mobile Code View */
body.light-mode .mobile-code-view {
    background: rgba(248, 250, 252, 0.95);
}

body.light-mode .mobile-code-header {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .mobile-code-content {
    background: #f8fafc;
}

body.light-mode .mobile-code-content pre {
    color: #1e293b;
}

body.light-mode .copy-code-btn {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
    color: #334155;
}