/* ═══════════════════════════════════════════════════════════════════
   📑 style.css 结构总目录
   ─────────────────────────────────────────────────────────────────
   [A] 全局变量 + 布局骨架         :root / body.dark-mode / .app-*
   [B] 聊天 / 翻译 / Vision 通用   .message-* / .translation-* / .vision-*
   [H] 图片 Modal + Toast          .modal / .toast-message
   [I] 伙伴系统                    .companion-* / .buddy-*
   ─────────────────────────────────────────────────────────────────
   📦 已拆分到独立文件（见 index.html）：
       [C] chess.css          国际象棋棋盘
       [D] file-manager.css   文件管理器
       [E] [F] financial.css  财务图表 + 电话会卡片
       [G] skill-toggle.css   技能开关
   ─────────────────────────────────────────────────────────────────
   📌 修改约定：
      1. 加新样式时，请放入对应区块
      2. 修改此文件前请先 git commit
      3. 区块间用 ══ 横幅分隔
   ═══════════════════════════════════════════════════════════════════ */

/* style.css */

/* ═══════════════════════════════════════════════════════
   [A] 全局变量 + 布局骨架
       :root / body.dark-mode / body / .app-* / .control-panel
   ═══════════════════════════════════════════════════════ */

/* 全局变量 */
:root {
  /* 亮色模式变量 */
  --bg-color: #f5f7fa;
  --surface-color: #ffffff;
  --text-color: #202124;
  --text-secondary-color: #5f6368;
  --border-color: #dadce0;
  --shadow-color: rgba(0, 0, 0, 0.08);
  --primary-color: #4285f4; /* Google Blue */
  --secondary-color: #34a853; /* Google Green */
  --danger-color: #ea4335; /* Google Red */
  --modal-backdrop-color: rgba(0, 0, 0, 0.6);

  /* ═══════════════════════════════════════════════════════
     🆕 财务模块命名空间（此前未定义，靠 var() fallback 工作）
     亮色值 = 现有 fallback 值，保证零视觉变化
     ═══════════════════════════════════════════════════════ */
  --bg-primary: #f9fafb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border-color-light: #f0f0f0;

  /* ═══════════════════════════════════════════════════════
     🆕 技能开关命名空间
     ═══════════════════════════════════════════════════════ */
  --accent-color: #007acc;
  --bg-hover: #f5f5f5;
}

body.dark-mode {
  /* 暗色模式变量 */
  --bg-color: #1a1a1a;
  --surface-color: #2d2d2d;
  --text-color: #f8fafc;
  --text-secondary-color: #a0a0a0;
  --border-color: #374151;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --primary-color: #6366f1; /* 紫色系 */
  --secondary-color: #8b5cf6; /* 浅紫色系 */
  --danger-color: #ef4444;
  --modal-backdrop-color: rgba(0, 0, 0, 0.85);

  /* ═══════════════════════════════════════════════════════
     🆕 财务模块暗色值
     ═══════════════════════════════════════════════════════ */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #363636;
  --text-primary: #f8fafc;
  --text-secondary: #a0a0a0;
  --border-color-light: #374151;

  /* ═══════════════════════════════════════════════════════
     🆕 技能开关暗色值
     ═══════════════════════════════════════════════════════ */
  --accent-color: #4dabf7;
  --bg-hover: #2a2a2a;
}

/* 通用样式 */
body {
    margin: 0;
    font-family: 'Roboto', sans-serif; /* 建议使用更现代的字体 */
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: auto; /* 允许页面滚动 */
}

/* 添加 iOS 安全区域适配 */
@supports (padding: max(0px)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-color);
}

/* 顶部导航栏 */
.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background-color: var(--surface-color);
    box-shadow: 0 2px 8px var(--shadow-color);
    z-index: 100;
}

.app-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-left: 15px; /* 与模式按钮的间距 */
}

/* 新增模式切换容器样式 */
.mode-switcher {
    display: flex;
    align-items: center;
    gap: 10px; /* 按钮和标题之间的间距 */
}

/* 新增模式切换按钮样式 */
.mode-button {
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
    padding: 5px 10px; /* 增加点击区域 */
    border-radius: 8px;
}

.mode-button:hover {
    color: var(--primary-color);
    background-color: rgba(var(--primary-color-rgb), 0.1);
    transform: scale(1.05);
}

.mode-button.active {
    color: var(--primary-color);
    background-color: rgba(var(--primary-color-rgb), 0.15);
    font-weight: 600;
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: 15px; /* 调整按钮间距 */
}

.nav-tools button {
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 24px;
    cursor: pointer;
    /* margin-left: 15px; */ /* 移除，由 gap 控制 */
    transition: color 0.3s ease, transform 0.2s ease;
}

.nav-tools button:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

/* 主容器：左右分栏 */
.main-container {
    display: grid;
    grid-template-columns: 300px 1fr; /* 左侧固定宽度，右侧主内容区自适应 */
    gap: 20px;
    padding: 20px;
    flex-grow: 1;
    overflow: hidden; /* 防止内部元素溢出导致滚动条 */
    box-sizing: border-box; /* 新增：确保 padding 不会撑大容器 */
}

/* 左侧控制面板 */
.control-panel {
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto; /* 允许内部滚动 */
}

.settings-card {
    background-color: var(--bg-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.settings-card h3 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.setting-item {
    margin-bottom: 10px;
}

.setting-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-secondary-color);
}

.setting-item input[type="password"],
.setting-item input[type="number"],
.setting-item select,
.setting-item textarea {
    width: calc(100% - 20px);
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.3s ease;
}

.setting-item input:focus,
.setting-item select:focus,
.setting-item textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}

.setting-item textarea {
    resize: vertical;
    min-height: 80px;
}

.fps-help {
    font-size: 12px;
    color: var(--text-secondary-color);
    margin-top: 5px;
    display: block;
}

.action-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: flex; /* 使按钮成为 flex 容器 */
    align-items: center; /* 垂直居中内容 */
    justify-content: center; /* 水平居中内容 */
}

.action-button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.action-button.primary {
    background-color: var(--primary-color);
}

.action-button.primary:hover {
    background-color: var(--secondary-color);
}

.button-group {
    display: flex;
    justify-content: flex-start; /* 修改为左对齐 */
    gap: 10px;
    margin-top: 15px;
}

/* 右侧主内容区 */
.content-area {
    display: grid;
    grid-template-rows: auto 1fr; /* 顶部选项卡，下方聊天区自适应 */
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow-color);
    overflow: hidden;
}

/* 模式切换选项卡 */
.mode-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    background-color: var(--surface-color);
}

.tab {
    background: none;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary-color);
    position: relative;
    transition: color 0.3s ease;
}

.tab.active {
    color: var(--primary-color);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 2px 2px 0 0;
}

/* 聊天容器 */
.chat-container {
    display: none; /* 默认隐藏 */
    padding: 20px;
    height: 100%;
    box-sizing: border-box;
    flex-direction: column; /* 内部使用 flex 布局 */
    position: relative; /* 确保内部元素可以相对定位 */
    min-height: 0; /* 关键修复：允许内部内容滚动 */
    /* display: flex;  移除重复且错误的样式 */
}

/* 翻译功能区样式 */

/* ═══════════════════════════════════════════════════════
   [B] 聊天 / 翻译 / Vision 通用
       .chat-container / .translation-* / .vision-* / .message-*
       .input-area / #message-input / #send-button
   ═══════════════════════════════════════════════════════ */

.translation-container {
    display: none;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    padding: 20px;
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow-color);
    overflow: auto; /* 允许翻译容器内部滚动 */
}

.translation-container.active {
    display: flex;
}

.translation-input-area,
.translation-output-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    border-radius: 8px;
    background-color: var(--bg-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    position: relative;
}

.translation-output-area {
    flex-grow: 1;
    margin-bottom: 0;
}

.translation-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.translation-controls select {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 15px;
}

.translation-input-area textarea {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 16px;
    resize: vertical;
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
}

.translation-action-buttons {
    display: flex;
    justify-content: flex-end; /* 桌面端右对齐 */
    gap: 10px; /* 按钮之间的间距 */
    width: 100%; /* 确保宽度与父容器一致 */
    margin-top: 10px; /* 与上方输入框的间距 */
}

.translation-output-display {
    flex-grow: 1;
    padding: 12px;
    padding-bottom: 40px; /* 增加底部内边距，为复制按钮留出空间 */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 16px;
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.translation-output-area .copy-button {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: transparent; /* 默认透明背景 */
    color: var(--text-secondary-color); /* 默认颜色 */
    border: none;
    border-radius: 4px; /* 调整圆角 */
    padding: 5px; /* 调整内边距 */
    cursor: pointer;
    font-size: 20px; /* 调整图标大小 */
    opacity: 0; /* 桌面端默认隐藏 */
    transition: opacity 0.3s ease, background-color 0.3s ease, color 0.3s ease; /* 添加过渡效果 */
    z-index: 1; /* 确保按钮在文本内容之上 */
}

.translation-output-area:hover .copy-button {
    opacity: 1; /* 悬停显示 */
    background-color: rgba(var(--primary-color-rgb), 0.1); /* 悬停背景色 */
    color: var(--primary-color); /* 悬停颜色 */
}

/* 移动端适配 */
@media (max-width: 768px) {
    .translation-container {
        padding: 15px;
    }

    .translation-input-area,
    .translation-output-area {
        padding: 10px;
        margin-bottom: 15px;
    }

    .translation-controls {
        flex-direction: column;
        gap: 8px;
    }

    .translation-input-area textarea,
    .translation-output-display {
        min-height: 100px;
        /* 移除 max-height，允许内容自适应高度 */
        font-size: 14px;
    }

    .translation-action-buttons {
        justify-content: center; /* 移动端居中 */
    }

    .translation-input-area .action-button {
        width: 100%;
        text-align: center;
    }

    .translation-output-area .copy-button {
        opacity: 1; /* 移动端始终显示 */
        background-color: rgba(var(--primary-color-rgb), 0.1); /* 移动端默认背景色 */
        color: var(--primary-color); /* 移动端默认颜色 */
        position: absolute; /* 保持绝对定位 */
        bottom: 8px;
        right: 8px;
        width: auto; /* 取消 100% 宽度 */
        margin-top: 0; /* 移除顶部外边距 */
        text-align: center; /* 保持居中 */
        justify-content: center; /* 保持居中 */
    }
}

/* 移动端导航栏布局优化 */
@media (max-width: 768px) {
  .app-nav {
    flex-direction: column;
    align-items: stretch;
  }
  
  .nav-tools {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 10px;
  }
  
  
  /* 调整图标按钮大小 */
  .nav-tools > button {
    width: 100%;
    height: 40px;
    font-size: 20px;
  }
}

.setting-item.setting-item-horizontal {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.setting-item.setting-item-horizontal label:first-child {
    margin-bottom: 0;
}

/* 优化移动端输入区域和媒体预览位置 */
@media (max-width: 768px) {
    .input-area {
        /* 确保输入区域在底部，并考虑安全区域 */
        padding-bottom: calc(15px + env(safe-area-inset-bottom)); /* 15px 是原有 padding-top */
        bottom: 20px; /* 新增：向上移动10px */
    }
}

.chat-container.active {
    display: flex; /* 激活时显示为 flex 容器 */
}

/* 文字聊天区 */
.text-mode .message-history {
    flex-grow: 1; /* 允许其在 flex 容器中占据可用空间 */
    overflow-y: auto; /* 确保垂直滚动 */
    min-height: 0; /* 关键：允许内部内容滚动 */
    display: flex;
    flex-direction: column; /* 确保消息从顶部到底部排列 */
    padding-bottom: 10px; /* 底部留白，防止消息紧贴底部 */
}

/* ... (保留原有 message, avatar, content 样式) ... */

.message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 15px; /* 保持底部间距 */
    max-width: 85%; /* 调整最大宽度，留出更多空白 */
}

.message.user {
    flex-direction: row-reverse;
    margin-left: auto; /* 靠右对齐 */
    margin-right: 45px; /* 新增：为用户消息提供右边距，防止头像被遮挡 */
}

.message.ai {
    margin-right: auto; /* 靠左对齐 */
    margin-left: 2px;  /* 新增：为AI消息提供左边距 */
}

.message .avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    margin: 0 10px;
    background-color: var(--primary-color);
    color: white;
    overflow: hidden;   /* 🔥 新增这一行 */
}

.message.ai .avatar {
    background-color: var(--secondary-color);
}

/* 🔥 新增：让头像图片完美适应容器 */
.message .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* 新增复制按钮样式 */
.message .content {
    position: relative; /* 确保复制按钮可以相对定位 */
    padding-right: 18px; /* 恢复默认内边距，因为复制按钮移到外部 */
    overflow-wrap: break-word; /* 允许长单词或URL内部换行 */
    word-break: break-word; /* 备用属性，增强兼容性 */
}

/* 原有的复制按钮 - 调整位置 */
.copy-button {
    position: absolute;
    bottom: -5px; /* 调整到底部外侧 */
    right: -55px; /* 调整到右侧外侧，为第二个按钮腾出空间 */
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, color 0.3s ease;
    padding: 5px;
    border-radius: 4px;
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* 新增：复制原始Markdown按钮 */
.copy-raw-button {
    position: absolute;
    bottom: -5px; /* 与复制按钮对齐 */
    right: -30px; /* 放在复制按钮的左侧 */
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, color 0.3s ease;
    padding: 5px;
    border-radius: 4px;
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* 悬停时显示两个按钮 */
.message .content:hover .copy-button,
.message .content:hover .copy-raw-button {
    opacity: 1;
}

/* 悬停效果 */
.copy-button:hover,
.copy-raw-button:hover {
    color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.1);
}

/* 用户消息中的按钮 */
.message.user .copy-button,
.message.user .copy-raw-button {
    color: rgba(255, 255, 255, 0.7);
}
.message.user .copy-button:hover,
.message.user .copy-raw-button:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.2);
}

/* 可选：工具提示 */
.copy-button::after,
.copy-raw-button::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 1000;
    margin-bottom: 5px;
}

.copy-button:hover::after,
.copy-raw-button:hover::after {
    opacity: 1;
}

.message.user .content {
    background-color: var(--primary-color);
    color: white;
    border-radius: 18px;
    padding: 12px 12px 12px 20px; /* 调整右侧内边距，使其向左移动 */
}

.message.ai .content {
    background-color: var(--bg-color); /* 新增：恢复灰色底色 */
    border-radius: 18px; /* 新增：确保圆形 */
    /* border-bottom-left-radius: 4px; */ /* 删除：恢复圆形 */
    margin-top: 5px; /* 新增：使消息顶部与头像中线对齐 */
}

.text-mode .input-area {
    display: flex;
    align-items: center; /* 垂直居中对齐 */
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
    padding: 15px 40px;
    box-sizing: border-box;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.text-mode #message-input {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    resize: vertical; /* 允许垂直方向调整大小 */
    max-height: 180px; /* 新增：限制最大高度 */
    overflow-y: auto; /* 新增：内容溢出时显示滚动条 */
}

.text-mode #send-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: background-color 0.3s ease;
}

.text-mode #send-button:hover {
    background-color: var(--secondary-color);
}

/* 确保输入区域内的按钮不会被压缩 */
.text-mode .input-area > button {
    flex-shrink: 0;
}

/* 新增：附件按钮样式 */
#attachment-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%; /* 改为圆形 */
    width: 48px; /* 确保是圆形 */
    height: 48px; /* 确保是圆形 */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    flex-shrink: 0; /* 防止被压缩 */
}

#attachment-button:hover {
    background-color: var(--secondary-color);
    transform: scale(1.05);
}

/* 新增：文件附件预览容器样式 */
.file-attachment-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 20px 10px; /* 左右和底部留出间距 */
    max-height: 120px; /* 限制最大高度，超出则滚动 */
    overflow-y: auto;
    overflow-x: hidden;
}

/* 新增：单个文件预览卡片样式 */
.file-preview-card {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    flex-shrink: 0; /* 防止被压缩 */
}

.file-preview-card img,
.file-preview-card canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 新增：预览卡片上的关闭按钮 */
.file-preview-card .close-button {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    z-index: 1;
}

.file-preview-card .close-button:hover {
    background: var(--danger-color);
}

/* 新增：文件占位符样式（用于PDF、音频等） */
.file-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
    padding: 10px;
    box-sizing: border-box;
}

.file-placeholder i {
    font-size: 40px; /* 调整图标大小 */
    color: var(--text-secondary-color);
    margin-bottom: 8px;
}

.file-placeholder p {
    font-size: 12px;
    color: var(--text-secondary-color);
    margin: 0;
    white-space: nowrap;
}

.close-button {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.close-button:hover {
    background: var(--danger-color);
}

/* 删除音频聊天区相关样式 */
/* .audio-mode .audio-visualization { ... } */
/* .audio-mode .media-display-area { ... } */
/* .audio-mode .media-preview-box { ... } */
/* .audio-mode .video-controls { ... } */
/* .audio-mode .close-button { ... } */
/* .audio-mode .audio-controls { ... } */
/* .audio-mode #mic-button.active { ... } */

/* 新增日志模式样式 */
.log-mode {
    display: none; /* 默认隐藏 */
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow-color);
    overflow: hidden;
}

.log-mode.active {
    display: flex; /* 激活时显示 */
}

.log-mode .log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
}

.log-mode .log-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-color);
}

.log-mode .log-header .action-button {
    padding: 5px 10px;
    font-size: 14px;
    margin-left: 10px;
}

.log-mode .log-content {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    font-family: 'SF Mono', monospace;
    font-size: 13px;
    color: var(--text-color);
    white-space: pre-wrap;
    word-break: break-all;
}

/* 响应式设计 */
@media (min-width: 1201px) {
    /* 桌面端显示连接按钮 */
    #connect-button {
        display: block;
    }
}

@media (max-width: 1200px) {
    /* 移动端和iPad端布局调整 */
    .main-container {
           grid-template-columns: 1fr; /* 单列布局 */
    }
    .control-panel {
        display: none; /* 默认隐藏 */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
        background-color: rgba(0, 0, 0, 0.5);
        padding: 0;
        border-radius: 0;
        box-shadow: none;
        flex-direction: row;
        justify-content: flex-end;
        transition: background-color 0.3s ease;
    }
    .control-panel.active {
        display: flex;
        justify-content: flex-end;
    }
    .control-panel .settings-wrapper {
        width: 85%;
        max-width: 400px;
        height: 100%;
        background-color: var(--surface-color);
        box-shadow: -4px 0 16px var(--shadow-color);
        padding: 20px;
        display: flex;
        flex-direction: column;
        gap: 15px;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.3s ease-out;
    }
    .control-panel.active .settings-wrapper {
        transform: translateX(0);
    }

    .content-area {
        order: 1;
    }
    .log-mode {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        width: auto;
        height: 100%;
        padding-bottom: 0;
    }
    /* 确保在移动端和iPad端，设置面板内的连接按钮可见 */
    .button-group #connect-button {
        display: block;
    }
}

/* 针对iPad尺寸范围的特定调整 */
@media (min-width: 769px) and (max-width: 1200px) {
    /* 确保在iPad尺寸下，设置面板内的连接按钮可见 */
    .button-group #connect-button {
        display: block;
        width: auto; /* 恢复自动宽度 */
        margin-top: 0; /* 移除顶部外边距 */
    }
}

@media (max-width: 768px) {
    .app-nav {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }
    .app-title {
        font-size: 20px;
    }
    .nav-tools {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        margin-top: 10px;
    }
    .nav-tools > button {
        width: 100%;
        height: 40px;
        font-size: 20px;
    }
    .main-container {
        padding: 15px;
        gap: 15px;
    }
    .control-panel {
        padding: 15px;
    }
    .settings-card {
        padding: 10px;
    }
    .tab {
        padding: 10px 12px;
        font-size: 13px;
    }
    .chat-container {
        padding: 15px;
    }
    .message .avatar {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
    .message .content {
        padding: 10px 15px;
        font-size: 14px;
    }

    .message {
        padding: 0 5px; /* 为消息本身添加水平内边距，增加左右间距 */
        max-width: 85%;   /* 调整最大宽度 */
    }
    .message.ai {
        margin-left: -5px; /* 移动端AI消息左边距调整 */
    }
    .text-mode #message-input {
        padding: 10px;
        font-size: 14px;
    }
    .text-mode #send-button { /* 发送按钮单独设置 */
        width: 32px;
        height: 32px;
        font-size: 16px;
        border-radius: 8px; /* 确保是圆角矩形 */
    }
    .text-mode #attachment-button, /* 附件按钮 */
    .text-mode #chat-voice-input-button /* 聊天语音输入按钮 */{
        width: 28px; /* 调整为与发送按钮一致 */
        height: 28px; /* 调整为与发送按钮一致 */
        font-size: 12px; /* 稍微调小字体大小 */
        border-radius: 8px; /* 确保是圆角矩形 */
    }

    .text-mode .input-area {
        padding-left: 0px; /* 调整左侧内边距 */
        padding-right: 10px; /* 减小右侧内边距，为图标腾出空间 */
        gap: 5px; /* 调整按钮间距以适应新按钮 */
        flex-wrap: nowrap; /* 防止换行 */
    }
}

@supports (-webkit-overflow-scrolling: touch) {
    .message-history {
        -webkit-overflow-scrolling: touch;
    }
    
    input, button, textarea {
        -webkit-appearance: none;
        appearance: none;
        border-radius: 0;
    }
}

/* Markdown 渲染内容通用样式 */
.message .content p {
    margin-bottom: 1em;
    line-height: 1.6;
}

.message .content h1,
.message .content h2,
.message .content h3,
.message .content h4,
.message .content h5,
.message .content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    font-weight: bold;
    line-height: 1.2;
    color: var(--text-color);
}

.message .content h1 { font-size: 1.8em; }
.message .content h2 { font-size: 1.6em; }
.message .content h3 { font-size: 1.4em; }
.message .content h4 { font-size: 1.2em; }
.message .content h5 { font-size: 1.1em; }
.message .content h6 { font-size: 1em; }

.message .content ul,
.message .content ol {
    margin-left: 20px;
    padding-left: 1.5em; /* 调整 */
    margin-bottom: 1em;
}

.message .content li {
    margin-bottom: 0.5em;
}

.message .content ul li {
    list-style-type: disc;
}

.message .content ol li {
    list-style-type: decimal;
}

/* 代码块样式 */
.message .content pre {
    background-color: var(--bg-color);
    padding: 12px; /* 调整 */
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 10px; /* 调整 */
    border: 1px solid var(--border-color);
    max-height: 300px; /* 新增 */
    overflow-y: auto; /* 新增 */
}

.message .content pre code {
    display: block;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'SF Mono', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

/* 行内代码样式 */
.message .content code {
    background-color: rgba(128, 128, 128, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'SF Mono', monospace;
    font-size: 0.9em;
    color: var(--text-color);
}

/* 引用块样式 */
.message .content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1em;
    margin: 1em 0;
    color: var(--text-secondary-color);
    background-color: rgba(var(--primary-color-rgb, 66, 133, 244), 0.05);
    border-radius: 4px;
}

/* 表格样式 */
.message .content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    overflow-x: auto;
    display: block;
}

.message .content th,
.message .content td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
}

.message .content th {
    background-color: var(--bg-color);
    font-weight: bold;
}

.message .content tr:nth-child(even) {
    background-color: var(--bg-color);
}

/* 链接样式 */
.message .content a {
    color: var(--primary-color);
    text-decoration: underline;
}

.message .content a:hover {
    text-decoration: none;
}

/* 图片样式 */
.message .content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em 0;
    border-radius: 8px;
}

/* 暗色模式下代码块和行内代码的背景调整 */
body.dark-mode .message .content pre {
    background-color: #333;
    border-color: #444;
}

body.dark-mode .message .content code {
    background-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .message .content blockquote {
    background-color: rgba(var(--primary-color-rgb, 99, 102, 241), 0.1);
}

/* 辅助变量，用于 rgba() */
:root {
    --primary-color-rgb: 66, 133, 244; /* Google Blue 的 RGB 值 */
}

body.dark-mode {
    --primary-color-rgb: 99, 102, 241; /* 暗色模式下 primary-color 的 RGB 值 */
/* 确保Markdown容器正确显示 */
.markdown-container {
  overflow-x: auto;
  word-wrap: break-word;
}
}

/* 翻译模式语音输入按钮的录音状态样式 */
#translation-voice-input-button.recording-active {
    background-color: var(--danger-color); /* 录音时变为红色 */
    color: white;
    animation: pulse 1.5s infinite; /* 添加脉冲动画 */
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--danger-color-rgb), 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(var(--danger-color-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--danger-color-rgb), 0);
    }
}

/* 定义 --danger-color-rgb 变量 */
:root {
    --danger-color-rgb: 234, 67, 53; /* 亮色模式下的 Google Red RGB 值 */
}

body.dark-mode {
    --danger-color-rgb: 239, 68, 68; /* 暗色模式下的 danger-color RGB 值 */
}

/* Toast 通知样式 */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.toast-message {
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 15px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(-20px);
}

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

/* 聊天语音输入按钮样式调整为圆形 */
#chat-voice-input-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%; /* 改为圆形 */
    width: 48px; /* 确保是圆形 */
    height: 48px; /* 确保是圆形 */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    flex-shrink: 0; /* 防止被压缩 */
}

#chat-voice-input-button:hover {
    background-color: var(--secondary-color);
    transform: scale(1.05);
}

/* 聊天语音输入按钮录音状态 */
#chat-voice-input-button.recording {
    background-color: var(--danger-color);
    color: white;
    animation: pulse 1.5s infinite;
}

/* 系统信息消息样式 */
.message.system-info {
    justify-content: center;
    align-items: center;
    margin: 10px 0;
    color: var(--text-secondary-color);
    font-size: 14px;
    font-style: italic;
}

.message.system-info .content {
    background-color: transparent;
    padding: 5px 15px;
    border-radius: 15px;
    background-color: var(--bg-color);
}

/* 视觉模型功能区样式 (重构为聊天样式) */
.vision-container {
    display: none; /* 默认隐藏 */
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    padding: 20px;
    overflow: hidden; /* 父容器隐藏溢出 */
}

.vision-container.active {
    display: flex;
}

/* 视觉模式下的消息历史记录 */
.vision-container .message-history {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
}

/* 视觉模式下的附件预览 */
.vision-container .file-attachment-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 20px 10px;
    max-height: 120px;
    overflow-y: auto;
}

/* 视觉模式下的输入区域 */
.vision-container .input-area {
    display: flex;
    flex-wrap: wrap; /* 允许换行 */
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
    flex-shrink: 0;
}

.vision-container .vision-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-bottom: 10px;
}

.vision-container .vision-control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    flex-wrap: wrap;
}

.vision-container .vision-control-row label {
    font-weight: 500;
    color: var(--text-secondary-color);
    min-width: 40px;
    flex-shrink: 0;
}

.vision-container .vision-control-row select {
    flex: 1 1 150px;
    min-width: 120px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.vision-container .vision-control-row select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* 对局总结按钮样式 */
.vision-container .vision-control-row .action-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 8px;
}

.vision-container .vision-control-row .action-button:hover:not(:disabled) {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
}

.vision-container .vision-control-row .action-button:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

.vision-container .input-area textarea {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    resize: vertical;
    max-height: 150px;
    overflow-y: auto;
}

.vision-container .input-area .action-button,
.vision-container .input-area .send-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.vision-container .input-area .action-button:hover,
.vision-container .input-area .send-button:hover {
    background-color: var(--secondary-color);
}

/* 视觉模型响应式调整 */
@media (max-width: 768px) {
    .vision-container {
        padding: 15px;
    }

    .vision-container .input-area {
        padding: 10px;
        gap: 8px;
    }

    .vision-container .input-area textarea {
        font-size: 14px;
    }

    .vision-container .input-area .action-button,
    .vision-container .input-area .send-button {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .vision-container .vision-control-row {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* 在 vision-container 相关样式后添加以下内容 */

/* 视觉模式全屏样式 */
.vision-container.full-screen {
  padding: 0;
  overflow: hidden;
}

/* 视觉聊天全屏 */
.vision-chat-fullscreen {
  display: none; /* 默认隐藏 */
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.vision-chat-fullscreen.active {
  display: flex;
}

/* 高亮答案内容的样式 */
.highlight-box {
    background-color: #fff3cd; /* 浅黄色背景 */
    color: #664d03; /* 深色文本 */
    padding: 0.2em 0.5em;
    border-radius: 4px;
    font-weight: bold;
    border: 1px solid #ffeeba;
}

body.dark-mode .highlight-box {
    background-color: #4a4a00; /* 暗色模式下的深色背景 */
    color: #ffeb3b; /* 暗色模式下的亮色文本 */
    border-color: #808000;
}
/* Prompt Select Styles */
#prompt-select {
    width: 90%;
    max-width: 90%;
    box-sizing: border-box;   /* 关键：让 padding 和 border 算进 100% 内，解决右侧截断 */
    padding: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg-color);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 14px;
}

#prompt-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* 历史记录区样式 */
.history-mode {
    display: none; /* 默认隐藏 */
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    overflow-y: auto; /* 允许垂直滚动 */
}

.history-mode.active {
    display: flex; /* 激活时显示 */
}

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

.history-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

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

.history-item-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 5px;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-time {
    font-size: 12px;
    color: var(--text-secondary-color);
}

/* 历史记录列表项的布局 */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.3s ease;
    position: relative; /* 用于定位操作菜单 */
}

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

.history-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 确保标题和日期不会溢出 */
}

.history-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 5px;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-date {
    font-size: 12px;
    color: var(--text-secondary-color);
}

/* 历史记录操作区域 */
.history-actions {
    display: flex;
    align-items: center;
    gap: 5px; /* 图标和按钮之间的间距 */
    position: relative; /* 用于定位下拉菜单 */
    flex-shrink: 0; /* 防止被压缩 */
}

/* 置顶图标 */
.pinned-icon {
    color: var(--primary-color); /* 置顶图标颜色 */
    font-size: 20px;
    margin-right: 5px;
}

/* 置顶的历史项的特殊样式 */
.history-item.is-pinned {
    background-color: rgba(var(--primary-color-rgb), 0.1); /* 浅色背景 */
    border-left: 4px solid var(--primary-color); /* 左侧强调边框 */
    padding-left: 11px; /* 调整内边距以适应边框 */
}

/* 历史记录操作按钮 (more_vert) */
.history-options-button {
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-options-button:hover {
    background-color: rgba(var(--primary-color-rgb), 0.1);
    color: var(--primary-color);
}

/* 历史记录操作菜单 */
.history-options-menu {
    position: absolute;
    top: 100%; /* 位于按钮下方 */
    right: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
    min-width: 120px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    /* overflow: hidden; */ /* 暂时移除，排查底部选项显示不全的问题 */
}

.history-options-menu .menu-item {
    background: none;
    border: none;
    padding: 10px 15px;
    text-align: left;
    width: 100%;
    cursor: pointer;
    color: var(--text-color);
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.history-options-menu .menu-item:hover {
    background-color: var(--bg-color);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .history-item {
        padding: 10px;
    }

    .history-title {
        font-size: 14px;
    }

    .history-date {
        font-size: 11px;
    }

    .history-options-button {
        font-size: 18px;
        padding: 3px;
    }

    .pinned-icon {
        font-size: 18px;
    }

    .history-options-menu {
        min-width: 100px;
    }

    .history-options-menu .menu-item {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* 任务T7: 工具调用状态UI样式 */
.tool-call-status {
    background-color: var(--bg-color);
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-family: var(--font-family);
    color: var(--text-secondary-color);
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border-color);
}


/* =================================
   Image Modal Styles
   ================================= */

/* ═══════════════════════════════════════════════════════
   [H] 图片 Modal + Toast
       .modal / .modal-content / .toast-message
   ═══════════════════════════════════════════════════════ */

.modal {
    display: none; /* 由 JS 直接控制 display: flex 来显示 */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-backdrop-color);
    justify-content: center;
    align-items: center;
    /* 备注: 平滑过渡效果(opacity)需要JS配合.
       当前JS直接修改display, 无法触发CSS transition.
       为确保功能正常, 暂时移除过渡效果. */
}

.modal-content {
    background-color: var(--surface-color);
    color: var(--text-color);
    border-radius: 12px;
    box-shadow: 0 8px 30px var(--shadow-color);
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content .close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    color: var(--text-secondary-color);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 10;
}

.modal-content .close-button:hover {
    color: var(--danger-color);
}

.modal-title {
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-color);
    text-align: center;
    font-size: 22px;
}

.modal-image-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* 确保图片不会溢出此容器 */
    position: relative;
    background-color: var(--bg-color);
    border-radius: 8px;
}

#modal-image-display {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* 核心：确保图片完整显示且不变形 */
    border-radius: 4px;
    transition: transform 0.3s ease;
    /* 为移动端手势操作提供更好的体验 */
    touch-action: manipulation;
}

.modal-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary-color);
}

.modal-info p {
    margin: 5px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-info i {
    color: var(--primary-color);
}

.modal-info a {
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-all;
}

.modal-info a:hover {
    text-decoration: underline;
}

.modal-actions {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.modal-actions .action-button {
    padding: 10px 15px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        height: 85vh;
        padding: 15px;
    }
    
    @media (max-width: 768px) {
        /* 在手机端隐藏图片模态框中的“原始链接”信息行 */
        .modal-info p:has(#modal-image-info-url) {
            display: none;
        }
    }

    .modal-title {
        font-size: 18px;
    }


    .modal-actions {
        bottom: 15px;
        right: 15px;
    }

    .modal-actions .action-button.copy-button {
        display: none; /* 在小屏幕上隐藏复制链接按钮 */
    }
}

/* =================================
   History Panel Controls
   ================================= */

/* 更新日志/历史记录头部以支持 flex 布局 */
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 通用图标按钮样式 */
.icon-button {
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background-color: rgba(var(--primary-color-rgb), 0.1);
    color: var(--primary-color);
}

/* 滑动开关样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

/* 圆形滑块 */
.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* =================================
   Batch History Deletion Styles
   ================================= */

/* Style for the danger button (e.g., delete) */
.icon-button.danger:hover {
    background-color: rgba(var(--danger-color-rgb), 0.1);
    color: var(--danger-color);
}


/* When in select mode, prevent the main click from loading the session */
.history-list-container.select-mode .history-item {
    cursor: default;
}

/* 数据文件预览特殊样式 */
.file-preview-card.data-file {
    border: 2px solid #4CAF50;
    background: #f8fff8;
}

.data-file-preview {
    text-align: center;
    padding: 10px;
}

.data-file-preview i {
    font-size: 24px;
    margin-bottom: 5px;
}

.data-file-preview p {
    margin: 0;
    font-size: 12px;
    word-break: break-all;
}

/* style.css (最终的、带完整颜色定义的美学方案) */

/* ═══════════════════════════════════════════════════════
   [I] 伙伴系统（浮动可拖拽版）
       .companion-* / .buddy-* / .stats-*
   ═══════════════════════════════════════════════════════ */

/* ========== 伙伴系统（浮动可拖拽版） ========== */
.companion-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    background: transparent;
    min-width: 120px;
    text-align: center;
    transition: none;
    touch-action: none;            /* 🔥 移动端：禁止浏览器默认手势 */
}

.companion-container:active {
    cursor: grabbing;
}

.companion-sprite {
    display: inline-block;
    position: relative;
}

.companion-sprite pre {
    margin: 0;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    line-height: 1.2;
    color: #c7d92d;                  /* 被内联 style 覆盖，仅作备选 */
    text-shadow: 0 0 6px rgba(199, 217, 45, 0.4);
    white-space: pre;
    pointer-events: none;
}

.companion-name {
    margin-top: 5px;
    font-size: 14px;
    font-style: italic;
    color: var(--text-secondary-color, #6c757d);
}

.companion-holding-side {
    position: absolute;
    left: -18px;        /* 向左偏移，放在左侧 */
    top: 38%;
    transform: translateY(-50%);
    font-size: 20px;
    pointer-events: none;
    z-index: 5;
}

/* 说话气泡（上方居中，不换行） */
.companion-bubble {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(199, 217, 45, 0.15);
    border: 1px solid rgba(199, 217, 45, 0.3);
    color: var(--text-color, #e0e0e0);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 13px;
    white-space: nowrap;
    max-width: 280px;
    word-break: keep-all;
    display: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* 宠物特效浮层 */
.companion-pet-overlay {
    pointer-events: none;
}

/* 🔥 属性面板/图鉴面板（右侧显示） */
.buddy-stats-bubble {
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-family: monospace;
    white-space: pre-wrap;
    max-width: 260px;
    width: 260px;
    z-index: 25;
    pointer-events: none;          /* 桌面端面板不拦截点击 */
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* 🔥 面板关闭按钮 */
.buddy-stats-close {
    position: absolute;
    top: 2px;
    right: 4px;
    color: #ccc;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    background: none;
    border: none;
    padding: 2px 6px;
    z-index: 26;
    pointer-events: auto;          /* 按钮需要响应点击 */
}
.buddy-stats-close:hover {
    color: #fff;
}

/* 🔥 右键菜单 */
.companion-context-menu {
    position: fixed;
    background: rgba(30, 30, 30, 0.92);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    color: #eee;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 6px 0;
    min-width: 140px;
    z-index: 10000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-user-select: none;
    user-select: none;
}

.menu-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

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

.menu-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    margin: 4px 8px;
}

/* 伙伴浮窗通用样式 */
.buddy-floating-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-height: 70vh;
    background: rgba(30, 30, 30, 0.92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    color: #eee;
}

.buddy-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.buddy-panel-header h3 {
    margin: 0;
    font-size: 16px;
}

.buddy-panel-close {
    background: none;
    border: none;
    color: #ccc;
    font-size: 20px;
    cursor: pointer;
}

.buddy-panel-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.chatlog-body .chatlog-item {
    margin-bottom: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
}

.chatlog-item .role-label {
    font-weight: bold;
    margin-right: 8px;
}
.chatlog-item.user .role-label { color: #4a9eff; }
.chatlog-item.buddy .role-label { color: #f39c12; }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: rgba(255,255,255,0.1);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.stat-card span {
    display: block;
    font-size: 12px;
    opacity: 0.7;
}

.stat-card strong {
    display: block;
    font-size: 24px;
    margin-top: 4px;
}

@media (max-width: 600px) {
    .buddy-stats-bubble {
        position: fixed;
        top: auto;
        bottom: 10px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        z-index: 10000;
        pointer-events: auto;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
        font-size: 14px;
    }

    .companion-context-menu {
        min-width: 160px;
        font-size: 15px;
    }

    .menu-item {
        padding: 10px 18px;
    }

    .buddy-floating-panel {
        width: 95vw;
        max-height: 80vh;
    }
}