/*
Theme Name: BenjiyunAI
Author: JeyooZ
Description: 一个极简风格的AI对话主题，灵感源自 Apple 设计风格。
Version: 1.0
*/

/* * ==============================
 * 全局变量定义 (CSS Variables)
 * ==============================
 * 这里定义了主题的主色调、背景色、边框色等，方便一键换肤。
 */
:root {
    --primary: #0071e3;
    /* 主色调 (Apple Blue) */
    --primary-hover: #0077ed;
    /* 悬停时的深蓝色 */
    --bg: #ffffff;
    /* 全局背景白 */
    --sidebar: #f5f5f7;
    /* 侧边栏浅灰 (Apple Light Gray) */
    --border: #e5e5e5;
    /* 边框颜色 */
    --text: #1d1d1f;
    /* 主文字颜色 (Apple Black) */
    --text-sub: #86868b;
    /* 次要文字颜色 (灰色) */
    --glass: rgba(255, 255, 255, 0.8);
    /* 毛玻璃背景基色 */
    --glass-blur: 20px;
    /* 毛玻璃模糊度 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    /* 小阴影 */
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* 中阴影 */
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
    /* 大阴影 (用于弹窗) */
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    /* 系统字体栈 */
    /* 深色模式专用变量（默认浅色值，深色时覆盖） */
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --hover-bg: rgba(0, 0, 0, 0.05);
    --user-bubble: #eef5ff;
    --code-bg: #1e1e1e;
    --modal-bg: #ffffff;
    --modal-overlay: rgba(255, 255, 255, 0.5);
    --notice-bg: #eef5ff;
    --tag-bg: #f2f2f7;
    --stat-bg: #f5f5f7;
    --gradient-bottom: linear-gradient(to top, #fff 60%, rgba(255, 255, 255, 0) 100%);
}

/* 深色模式 */
[data-theme="dark"] {
    --bg: #1a1a1d;
    --sidebar: #222225;
    --border: #3a3a3d;
    --text: #e5e5e7;
    --text-sub: #98989d;
    --glass: rgba(30, 30, 32, 0.85);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --card-bg: #2a2a2d;
    --input-bg: #2a2a2d;
    --hover-bg: rgba(255, 255, 255, 0.06);
    --user-bubble: #1c3a5e;
    --code-bg: #0d0d0d;
    --modal-bg: #2a2a2d;
    --modal-overlay: rgba(0, 0, 0, 0.6);
    --notice-bg: #1c2d42;
    --tag-bg: #333336;
    --stat-bg: #333336;
    --gradient-bottom: linear-gradient(to top, #1a1a1d 60%, rgba(26, 26, 29, 0) 100%);
}

/* 深色模式下侧边栏 Logo 反色（适配位图 logo） */
[data-theme="dark"] .sidebar-logo {
    filter: invert(1) brightness(1.8);
}

/* 基础重置 */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* 防止页面整体滚动，只允许聊天区域滚动 */
    font-family: var(--font-stack);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    /* 字体抗锯齿 */
}

/* * ==============================
 * 布局结构 (Layout)
 * ==============================
 */
#app {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* * ==============================
 * 侧边栏样式 (Sidebar)
 * ==============================
 */
aside {
    width: 260px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* 移动端滑出动画 */
    z-index: 100;
    flex-shrink: 0;
}

/* Logo 区域 */
.sidebar-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 17px;
}

.sidebar-logo {
    height: 24px;
    width: auto;
}

/* "新对话" 按钮 */
.new-chat-btn {
    margin: 10px 15px;
    padding: 10px 16px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    color: var(--text);
}

.new-chat-btn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* 历史记录列表 */
.history-list {
    flex: 1;
    /* 占据剩余空间 */
    overflow-y: auto;
    /* 内容过多时滚动 */
    padding: 10px;
}

.h-item {
    padding: 10px 14px;
    margin-bottom: 2px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.h-item:hover {
    background: var(--hover-bg);
}

.h-item.active {
    background: var(--hover-bg);
    font-weight: 600;
}

.h-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 操作按钮（悬停时显示） */
.h-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    margin-left: 4px;
}

.h-item:hover .h-actions {
    opacity: 1;
}

.h-action-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.h-action-btn:hover {
    background: var(--border);
}

/* 行内重命名输入框 */
.h-rename-input {
    width: 100%;
    border: 1px solid var(--primary) !important;
    border-radius: 6px !important;
    padding: 2px 6px !important;
    font-size: 13px;
    outline: none;
    margin: 0 !important;
    background: var(--input-bg) !important;
    color: var(--text) !important;
}

/* 用户信息栏 (左下角) */
.user-bar {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.user-bar:hover {
    background: var(--hover-bg);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.user-status {
    font-size: 12px;
    color: var(--text-sub);
}

.settings-icon {
    width: 20px;
    height: 20px;
    color: var(--text-sub);
    transition: color 0.2s;
}

.user-bar:hover .settings-icon {
    color: var(--text);
}

/* * ==============================
 * 主内容区域 (Main Content)
 * ==============================
 */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

/* 顶部导航栏 (Header) */
header {
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass);
    backdrop-filter: blur(20px);
    /* 毛玻璃效果 */
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

/* 移动端菜单按钮 */
.mobile-menu {
    display: none;
    /* 默认隐藏，小屏幕显示 */
    background: none;
    border: none;
    font-size: 20px;
    padding: 0;
    cursor: pointer;
}

/* 余额显示胶囊 */
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.balance-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--tag-bg);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
    font-family: var(--font-stack);
}

.balance-pill:hover {
    background: var(--hover-bg);
    border-color: var(--border);
}

.balance-icon {
    font-size: 14px;
}

/* * ==============================
 * 聊天窗口 (Chat Window)
 * ==============================
 */
#chat-window {
    flex: 1;
    overflow-y: auto;
    /* 允许垂直滚动 */
    padding: 80px 20px 140px 20px;
    /* 留出顶部 Header 和底部输入框的空间 */
    scroll-behavior: smooth;
}

/* 欢迎屏幕 */
.welcome {
    margin-top: 8vh;
    text-align: center;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.welcome h1 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.welcome p {
    color: var(--text-sub);
    font-size: 16px;
    margin-bottom: 40px;
}

/* 公告胶囊 */
.notice-capsule {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--notice-bg);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 30px;
    transition: 0.2s;
}

.notice-capsule:hover {
    background: var(--notice-bg);
    transform: scale(1.02);
    filter: brightness(0.95);
}

/* 提示词 (Prompts) */
.prompt-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 18px;
    background: var(--tag-bg);
    color: var(--text-sub);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
}

.prompt-grid {
    display: none;
    /* 默认隐藏，通过 JS 切换 active 显示 */
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    /* 自适应网格布局 */
    gap: 16px;
}

.prompt-grid.active {
    display: grid;
}

.p-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    position: relative;
}

.p-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.p-icon img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.p-title {
    font-weight: 600;
    font-size: 15px;
}

.p-desc {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* 限制显示2行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 换一批按钮 */
.refresh-container {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid #d2d2d7;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
    cursor: pointer;
    transition: 0.2s;
    font-family: var(--font-stack);
}

.btn-refresh:hover {
    background: var(--hover-bg);
    color: var(--text);
    border-color: var(--border);
}

.btn-refresh:active {
    transform: scale(0.98);
}

/* * ==============================
 * 输入区域 (Input Area)
 * ==============================
 */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    z-index: 20;
    background: var(--gradient-bottom);
    /* 渐变遮罩 */
}

.input-box {
    width: 100%;
    max-width: 760px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 12px 16px 12px 20px;
    transition: 0.3s;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.input-box:focus-within {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    /* 聚焦时阴影加深 */
    border-color: rgba(0, 0, 0, 0.15);
}

textarea {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    /* 禁止手动拉伸 */
    font-size: 16px;
    line-height: 1.5;
    max-height: 200px;
    min-height: 24px;
    padding: 0;
    font-family: inherit;
    color: var(--text);
}

.tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.tool-left {
    display: flex;
    align-items: center;
}

.tool-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 附件按钮 (+) */
.attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text);
    margin-right: 5px;
}

.attach-btn:hover {
    background: #f5f5f7;
}

/* 自定义模型选择器 */
.model-selector-custom {
    position: relative;
    display: inline-block;
    z-index: 100;
}

.model-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--tag-bg);
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    height: 32px;
}

.model-trigger:hover,
.model-selector-custom.active .model-trigger {
    background-color: var(--hover-bg);
}

.model-popup {
    display: none;
    /* 默认隐藏 */
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 10px;
    width: 220px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 6px;
    flex-direction: column;
    gap: 2px;
    animation: popupScale 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
    transform-origin: bottom left;
}

.model-selector-custom.active .model-popup {
    display: flex;
}

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

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

.model-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: background 0.1s;
}

.model-option:hover {
    background-color: var(--hover-bg);
}

.model-option.selected {
    background-color: var(--notice-bg);
    font-weight: 600;
}

.check-icon {
    width: 16px;
    height: 16px;
    color: var(--primary);
    opacity: 0;
}

.model-option.selected .check-icon {
    opacity: 1;
}

@media (max-width: 480px) {
    .model-popup {
        width: 200px;
    }
}

/* 发送按钮 */
.send-btn {
    border: none;
    background: transparent;
    color: var(--primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.send-btn:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
}

.send-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    margin-left: 2px;
}

/* 深色/浅色模式切换按钮 */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--tag-bg);
    border: none;
    cursor: pointer;
    transition: 0.2s;
    font-size: 16px;
    color: var(--text);
}

.theme-toggle:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
}

/* 图片预览区 */
#img-preview {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.img-thumb-box {
    position: relative;
    width: 50px;
    height: 50px;
    transition: transform 0.2s;
}

.img-thumb-box:hover {
    transform: scale(1.05);
}

.img-thumb-box img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #eee;
}

.img-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: #ff3b30;
    color: #fff;
    border-radius: 50%;
    text-align: center;
    line-height: 16px;
    font-size: 12px;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

/* * ==============================
 * 消息气泡 (Messages)
 * ==============================
 */
.msg {
    max-width: 760px;
    margin: 0 auto 32px;
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s ease;
}

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

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

/* 用户消息 (右侧) */
.msg.user {
    justify-content: flex-end;
}

.msg.user .bubble {
    background: var(--user-bubble);
    color: var(--text);
    border-radius: 20px 20px 4px 20px;
}

/* AI 消息 (左侧) */
.msg.assistant .bubble {
    background: transparent;
    padding: 0;
    width: 100%;
    color: var(--text);
}

.bubble {
    padding: 12px 18px;
    font-size: 16px;
    line-height: 1.6;
    max-width: 85%;
}

.bubble img {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
}

.bubble pre {
    background: var(--code-bg);
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    color: #fff;
    font-size: 14px;
    margin: 12px 0;
}

.msg .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: #f2f2f7;
    object-fit: cover;
}

.msg.assistant .avatar {
    background: linear-gradient(135deg, #00C6FB 0%, #005BEA 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 91, 234, 0.2);
}

.msg.user .avatar {
    display: none;
}

/* 思考中状态 */
.thinking-container {
    display: inline-flex;
    align-items: center;
    background: var(--card-bg);
    padding: 10px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    color: var(--text-sub);
    font-size: 14px;
}

.pulse-ring {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-right: 12px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.4);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(0, 113, 227, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 113, 227, 0);
    }
}

/* * ==============================
 * 弹窗组件 (Modals)
 * ==============================
 */
.modal-overlay {
    display: none;
    /* 默认隐藏 */
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--modal-overlay);
    backdrop-filter: blur(15px);
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--modal-bg);
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    color: var(--text);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
    font-size: 24px;
    color: #ccc;
}

/* 遮罩层 - 用于移动端侧边栏等 */
#overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    backdrop-filter: blur(2px);
}

/* 弹窗表单元素 */
.modal-box input {
    width: 100%;
    padding: 14px;
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: 0.2s;
    font-family: var(--font-stack);
    color: var(--text);
    background: var(--input-bg);
    -webkit-appearance: none;
    appearance: none;
}

.modal-box input::placeholder {
    font-family: var(--font-stack);
    color: #999;
}

.modal-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.modal-box button {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-family: var(--font-stack);
}

.modal-box button:hover {
    background: var(--primary-hover);
    transform: scale(1.01);
}

.modal-box button:active {
    transform: scale(0.98);
}

/* 用户资料弹窗特有样式 */
.ac-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 15px;
    object-fit: cover;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.ac-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 5px;
}

.ac-role {
    font-size: 13px;
    color: var(--primary);
    background: rgba(0, 113, 227, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 20px;
    font-weight: 600;
}

.ac-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    padding: 15px;
    background: var(--stat-bg);
    border-radius: 16px;
}

.ac-stat-item {
    flex: 1;
    text-align: center;
}

.ac-stat-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    display: block;
}

.ac-stat-label {
    font-size: 12px;
    color: var(--text-sub);
}

.ac-divider {
    height: 40px;
    width: 1px;
    background: #e5e5e5;
}

.ac-logout {
    margin-top: 15px;
    display: block;
    font-size: 14px;
    color: #ff3b30;
    text-decoration: none;
    cursor: pointer;
}

/* * ==============================
 * 响应式适配 (Mobile Responsive)
 * ==============================
 */
@media (max-width: 768px) {
    aside {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
        /* 默认移出屏幕 */
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }

    aside.active {
        transform: translateX(0);
        /* 激活时滑入 */
    }

    .mobile-menu {
        display: block;
    }

    .header-right {
        margin-right: 5px;
    }

    .balance-pill span {
        display: inline-block;
    }
}

/* ========================================
   Apple 风格 Toast 通知
   ======================================== */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 14px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 400px;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.hide {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s ease-in;
}

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast-text {
    flex: 1;
}

/* 左侧彩色指示条 */
.toast-success {
    border-left: 3px solid #34c759;
}

.toast-error {
    border-left: 3px solid #ff3b30;
}

.toast-warning {
    border-left: 3px solid #ff9f0a;
}

.toast-info {
    border-left: 3px solid #007aff;
}


/* ========================================
   Apple 风格 Confirm 确认弹窗
   ======================================== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--modal-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.confirm-overlay.active {
    opacity: 1;
}

.confirm-card {
    background: var(--modal-bg);
    border-radius: 16px;
    padding: 28px 32px 20px;
    width: 320px;
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.confirm-overlay.active .confirm-card {
    transform: scale(1);
}

.confirm-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.confirm-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.confirm-msg {
    font-size: 14px;
    color: var(--text-sub);
    line-height: 1.5;
    margin-bottom: 20px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
}

.confirm-btn {
    flex: 1;
    padding: 10px 0;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.confirm-btn.cancel {
    background: var(--tag-bg);
    color: var(--text);
}

.confirm-btn.cancel:hover {
    background: var(--border);
}

.confirm-btn.danger {
    background: #ff3b30;
    color: #fff;
}

.confirm-btn.danger:hover {
    background: #e0332b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

/* ========================================
   消息操作栏（复制 / 重新生成）
   ======================================== */
/* ========================================
   消息操作栏 — Gemini 风格小图标
   ======================================== */
.msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    opacity: 0;
    transition: opacity 0.2s;
}

.msg:hover .msg-actions,
.msg-actions.show {
    opacity: 1;
}

.msg-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.msg-action-btn:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.msg-action-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
}

.msg-action-btn.copied {
    color: #34c759;
    border-color: #34c759;
}

/* ========================================
   打字机闪烁光标
   ======================================== */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: cursor-blink 0.8s step-end infinite;
}

@keyframes cursor-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ========================================
   侧边栏搜索框
   ======================================== */
.search-box {
    margin: 0 15px 8px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
}

.search-box input::placeholder {
    color: var(--text-sub);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--text-sub);
    pointer-events: none;
}

/* ========================================
   Prompt 收藏星标
   ======================================== */
.prompt-fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 2;
}

.prompt-card {
    position: relative;
}

.p-card:hover .prompt-fav-btn,
.prompt-card:hover .prompt-fav-btn {
    opacity: 1;
}

.prompt-fav-btn:hover {
    opacity: 1 !important;
    transform: scale(1.2);
}

.prompt-fav-btn.saved {
    opacity: 1 !important;
    color: #ff9f0a;
}

/* 收藏夹分类按钮 */
.fav-tab {
    position: relative;
}

/* ========================================
   移动端增强
   ======================================== */
@media (max-width: 768px) {

    /* 优化触摸目标大小 */
    .h-item {
        padding: 12px 14px;
        min-height: 44px;
    }

    .h-action-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .tab-btn {
        min-height: 36px;
        padding: 6px 14px;
    }

    .prompt-tabs {
        justify-content: center;
        padding: 0 16px;
    }

    .prompt-card {
        min-height: 60px;
    }

    /* 消息操作栏在移动端始终显示 */
    .msg-actions {
        opacity: 1;
    }

    /* 输入栏安全区适配 */
    .input-bar {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* 侧边栏滑出动画增强 */
    aside {
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    }

    /* 搜索框移动端自适应 */
    .search-box {
        margin: 0 10px 6px;
    }

    .search-box input {
        font-size: 16px;
        /* 防止 iOS 自动缩放 */
    }

    /* 遮罩层优化 */
    #overlay {
        -webkit-tap-highlight-color: transparent;
    }

    /* 消息气泡允许代码块水平滚动 */
    .bubble pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}