/* ========== 基础重置与全局深色主题 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* 仅对常用交互元素启用过渡，避免大型文章 DOM 上的全局 transition 开销 */
button, a, input, textarea, select, .toc-item, .comment-toggle {
    transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .section-wrapper {
        content-visibility: visible !important;
        contain-intrinsic-size: none !important;
    }
}

html {
    scroll-behavior: smooth; /* ⭐ 让页面滚动丝滑 */
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #1e1e1e;
    color: #ccc;
    overflow: hidden;
    height: 100vh;
}
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ========== 侧边栏 - 深色 ========== */
#sidebar {
    width: 260px;
    background: #252525;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    user-select: none;
    padding-bottom: 3rem;
    /* ⭐ 新增：侧边栏自身平滑过渡（配合拖拽磁吸） */
    transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid #333;
    background: #1e1e1e;
    color: #ddd;
}
.sidebar-header button {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.3rem;
    color: #bbb;
    transition: background-color 0.2s ease, transform 0.15s ease; /* ⭐ */
}
.sidebar-header button:hover { background: #3a3a3a; border-radius: 3px; transform: scale(1.1); } /* ⭐ 加个微弹 */

#toc-tree { padding: 0.5rem 0 2rem; }

.toc-item {
    padding: 0.2rem 1rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    color: #bbb;
    border-radius: 4px;
    margin: 0.1rem 0.3rem;
    /* ⭐ 新增：目录项点击/悬停平滑 */
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease, padding-left 0.2s ease;
}
.toc-item:hover {
    background: #383838;
    transform: translateX(2px); /* ⭐ 微微右移，像被吸过去 */
}
.toc-h1 { font-weight: 600; padding-left: 0.8rem; }
.toc-h2 { padding-left: 1.8rem; font-size: 0.95rem; }
.toc-h3 { padding-left: 2.8rem; font-size: 0.9rem; color: #999; }
.toc-toggle {
    display: inline-block;
    width: 1rem;
    cursor: pointer;
    margin-right: 0.2rem;
    text-align: center;
    flex-shrink: 0;
}

/* 多级高亮 - ⭐ 增强高亮反馈 */
.toc-item.active {
    background-color: #ffffff;
    color: #111;
    font-weight: 600;
    transform: translateX(4px); /* ⭐ 高亮时再右移一点 */
    box-shadow: 0 2px 8px rgba(255,255,255,0.08);
}

/* ========== 分隔条 ========== */
#resizer {
    width: 4px;
    background: #444;
    cursor: col-resize;
    transition: background 0.15s ease, transform 0.15s ease;
}
#resizer:hover {
    background: #fff;
    transform: scaleX(1.5); /* ⭐ 悬停时变宽一点点，手感更清晰 */
}

/* ========== 正文区域 - 白底 (阅读器用) ========== */
#content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem 25px;
    line-height: 1.8;
    background: #ffffff;
    color: #1a1a1a;
    position: relative;
}
#version-info {
    background: #f0f0f0;
    padding: 0.5rem 1rem;
    border-left: 4px solid #333;
    margin-bottom: 2rem;
    font-size: 0.85rem;
    color: #555;
    display: none;
}

/* ========== 工具栏 ========== */
#toolbar {
    position: fixed;
    top: 10px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 10;
}
.toolbar-btn {
    background: #2d2d2d;
    border: 1px solid #555;
    color: #ddd;
    padding: 0.4rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    backdrop-filter: blur(5px);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease; /* ⭐ */
}
.toolbar-btn:hover {
    background: #3a3a3a;
    border-color: #888;
    transform: scale(1.03); /* ⭐ 微弹 */
}

/* ========== 面板通用（搜索/个人中心） ========== */
.panel-hidden {
    position: fixed;
    right: -360px;
    top: 0;
    width: 340px;
    height: 100vh;
    background: #2d2d2d;
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
    transition: right 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); /* ⭐ 果冻弹出 */
    z-index: 20;
    overflow-y: auto;
    color: #ccc;
}
.panel-visible { right: 0; }
.panel-content {
    padding: 2rem 2rem 3rem;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}
.close-btn {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: #aaa;
    align-self: flex-end;
    transition: transform 0.2s ease, color 0.2s ease; /* ⭐ */
}
.close-btn:hover {
    color: #fff;
    transform: rotate(90deg); /* ⭐ 优雅转一下 */
}

/* 搜索输入 */
#search-input {
    width: 100%;
    padding: 0.6rem;
    margin: 1rem 0;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 1rem;
    background: #1e1e1e;
    color: #ddd;
    transition: border-color 0.25s ease, box-shadow 0.25s ease; /* ⭐ */
}
#search-input:focus {
    border-color: #888;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
    outline: none;
}
#search-results { margin-top: 1rem; flex: 1; }
.search-result-item {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid #444;
    cursor: pointer;
    line-height: 1.3;
    transition: background 0.15s ease, transform 0.15s ease; /* ⭐ */
}
.search-result-item:hover {
    background: #3a3a3a;
    transform: translateX(3px);
}
.search-result-item .title { font-weight: 600; color: #fff; font-size: 0.85rem; }
.search-result-item .context { font-size: 0.75rem; color: #aaa; margin-top: 0.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 自动跟随开关 */
.auto-scroll-toggle {
    margin-top: auto;
    padding: 1rem 0 0.5rem;
    border-top: 1px solid #444;
    font-size: 0.85rem;
    color: #bbb;
}
.auto-scroll-toggle label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.auto-scroll-toggle input[type="checkbox"] { accent-color: #fff; width: 1rem; height: 1rem; }

/* ========== 文章标题与内容 (阅读器用) ========== */
#article-body h1 {
    font-size: 2rem;
    margin: 1.8rem 0 1rem;
    border-bottom: 2px solid #333;
    padding-bottom: 0.3rem;
    color: #111;
}
#article-body h2 { font-size: 1.5rem; margin: 1.5rem 0 0.8rem; color: #222; }
#article-body h3 { font-size: 1.2rem; margin: 1.2rem 0 0.6rem; color: #333; }
#article-body p { margin: 0.8rem 0; color: #333; }

pre {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1rem 0;
}
code { font-family: 'Consolas', 'Courier New', monospace; font-size: 0.9rem; }

/* ========== ⭐ 新增：章节入场淡入 ========== */
.section-wrapper {
    opacity: 0;
    transform: translateY(12px);
    animation: fadeUp 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}
@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}
/* 排队进场延迟（最多延迟 0.4s，避免等太久） */
.section-wrapper:nth-child(1) { animation-delay: 0.02s; }
.section-wrapper:nth-child(2) { animation-delay: 0.06s; }
.section-wrapper:nth-child(3) { animation-delay: 0.10s; }
.section-wrapper:nth-child(4) { animation-delay: 0.14s; }
.section-wrapper:nth-child(5) { animation-delay: 0.18s; }
.section-wrapper:nth-child(6) { animation-delay: 0.22s; }
.section-wrapper:nth-child(7) { animation-delay: 0.26s; }
.section-wrapper:nth-child(8) { animation-delay: 0.30s; }
.section-wrapper:nth-child(9) { animation-delay: 0.34s; }
.section-wrapper:nth-child(10) { animation-delay: 0.38s; }
.section-wrapper:nth-child(11) { animation-delay: 0.40s; }
.section-wrapper:nth-child(12) { animation-delay: 0.42s; }
.section-wrapper:nth-child(n+13) { animation-delay: 0.44s; }

/* ========== 渲染性能 / 截图兼容 ========== */
.section-wrapper.capture-mode,
#article-body.capture-mode .section-wrapper {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

.image-load-error {
    min-height: 1.5rem;
    opacity: 0.55;
}

@media print {
    #article-body .section-wrapper {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ========== 图片排版 ========== */

img { max-width: 100%; border-radius: 4px; }
img.iwp-img-center { display: block; margin: 1rem auto; }
img.iwp-img-left { float: left; margin: 0.5rem 1rem 0.5rem 0; max-width: 50%; }
img.iwp-img-right { float: right; margin: 0.5rem 0 0.5rem 1rem; max-width: 50%; }
img.iwp-img-around { float: left; margin: 0.5rem 1rem 0.5rem 0; max-width: 50%; shape-outside: margin-box; }

.figure-container { margin: 1rem 0; text-align: center; }
.figure-container.figure-left { float: left; margin: 0.5rem 1rem 0.5rem 0; max-width: 50%; }
.figure-container.figure-right { float: right; margin: 0.5rem 0 0.5rem 1rem; max-width: 50%; }
.figure-container .figure-caption { font-size: 0.85rem; color: #555; margin-top: 0.3rem; }

.clearfix::after { content: ""; display: table; clear: both; }

/* ========== 表格优化 (阅读器) ========== */
#article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
#article-body th, #article-body td {
    padding: 0.6rem 0.8rem;
    border: 1px solid #ddd;
    text-align: left;
    vertical-align: top;
}
#article-body th {
    background-color: #f2f2f2;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
}
#article-body tr:nth-child(even) td { background-color: #fafafa; }
#article-body tr:nth-child(odd) td { background-color: #fff; }
#article-body tr:hover td { background-color: #e6f0fa; transition: background-color 0.15s; }
#article-body td code { background-color: #f0f0f0; }

/* ========== 评论区样式 (阅读器) ========== */
.comment-section {
    margin: 2rem 0 1rem;
    border-top: 1px solid #ddd;
    padding-top: 1rem;
}

.comment-toggle {
    cursor: pointer;
    font-size: 0.95rem;
    color: #555;
    font-weight: 500;
    user-select: none;
    display: inline-block;
    transition: color 0.2s ease, transform 0.2s ease; /* ⭐ */
}
.comment-toggle:hover {
    color: #111;
    transform: translateX(2px);
}

.comment-count-badge {
    font-size: 0.85rem;
    color: #888;
    margin-left: 0.3rem;
}

.comment-body {
    margin-top: 1rem;
    padding: 1.2rem 1.5rem;
    background: #f8f8f8;
    border-radius: 6px;
    border: 1px solid #e8e8e8;
    /* ⭐ 新增：评论区展开/收起动画 */
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.comment-body[style*="display: none"] {
    opacity: 0;
    transform: scale(0.97);
}

.comment-list {
    margin-bottom: 1rem;
}

.comment-item {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #eee;
    /* ⭐ 新增：评论入场微动 */
    animation: commentSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform: translateY(6px);
}
@keyframes commentSlide {
    to { opacity: 1; transform: translateY(0); }
}
/* 评论排队延迟 */
.comment-item:nth-child(1) { animation-delay: 0.02s; }
.comment-item:nth-child(2) { animation-delay: 0.04s; }
.comment-item:nth-child(3) { animation-delay: 0.06s; }
.comment-item:nth-child(4) { animation-delay: 0.08s; }
.comment-item:nth-child(5) { animation-delay: 0.10s; }
.comment-item:nth-child(n+6) { animation-delay: 0.12s; }

.comment-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.comment-content {
    flex: 1;
}

.comment-user {
    font-weight: 600;
    color: #333;
    margin-right: 0.5rem;
}

.comment-time {
    font-size: 0.8rem;
    color: #999;
}

.comment-content p {
    margin: 0.3rem 0 0.2rem;
    color: #444;
    line-height: 1.5;
}

.comment-actions button {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
    margin-right: 0.8rem;
    transition: color 0.2s ease, transform 0.15s ease; /* ⭐ */
}
.comment-actions button:hover {
    color: #111;
    transform: scale(1.1); /* ⭐ 微弹 */
}

.comment-pagination {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 1rem;
}
.comment-pagination button {
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #333;
    transition: background 0.2s ease, transform 0.15s ease; /* ⭐ */
}
.comment-pagination button:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}
.comment-pagination button.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

.comment-form {
    border-top: 1px solid #eee;
    padding-top: 1rem;
}

.auth-panel {
    margin-bottom: 0.8rem;
}
.auth-panel button {
    margin-right: 0.5rem;
    padding: 0.25rem 0.8rem;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    transition: background 0.2s ease, transform 0.15s ease; /* ⭐ */
}
.auth-panel button:hover {
    background: #f0f0f0;
    transform: scale(1.03);
}
.auth-panel input {
    padding: 0.3rem 0.5rem;
    margin-right: 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 130px;
    transition: border-color 0.2s ease; /* ⭐ */
}
.auth-panel input:focus {
    border-color: #888;
    outline: none;
}

.input-area {
    margin-top: 0.5rem;
}
.input-area textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    font-size: 0.9rem;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease; /* ⭐ */
}
.input-area textarea:focus {
    border-color: #888;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
    outline: none;
}
.input-area button {
    padding: 0.3rem 1.2rem;
    margin-top: 0.4rem;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease, transform 0.15s ease; /* ⭐ */
}
.input-area button:hover {
    background: #111;
    transform: scale(1.04);
}

.quote-hint {
    font-size: 0.8rem;
    color: #888;
    margin-left: 0.5rem;
}

/* ========== 固定底部占位 ========== */
.bottom-spacer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 25px;
    pointer-events: none;
    background: transparent;
    z-index: 900;
}

/* ============================================================
   博客页面深色主题覆盖 (不影响阅读器)
   ============================================================ */
#blog-list-view,
#blog-read-view {
    background: #1a1a1a;
    color: #ddd;
}

#article-container {
    background: #1a1a1a !important;
    color: #ddd !important;
}

#article-container h1,
#article-container h2,
#article-container h3 {
    color: #eee !important;
    border-bottom: 1px solid #333;
}

#article-container p {
    color: #ccc !important;
}

#article-container pre,
#article-container code {
    background: #2d2d2d !important;
    color: #ccc !important;
}

#article-container table {
    background: #1a1a1a;
    border-collapse: collapse;
}
#article-container th,
#article-container td {
    border: 1px solid #444;
    padding: 0.5rem;
    color: #ccc;
    background: #1a1a1a !important;
}
#article-container th {
    background: #2a2a2a !important;
    font-weight: bold;
}
#article-container tr:nth-child(even) td {
    background: #1a1a1a !important;
}
#article-container tr:hover td {
    background: #2a2a2a !important;
}

#article-container a {
    color: #88b4e6 !important;
}

#blog-comments-area {
    background: #1a1a1a !important;
    color: #ddd !important;
}
#blog-comments-area .comment-body {
    background: #1a1a1a;
    border: 1px solid #333;
}

#blog-comment-list .comment-item {
    border-bottom: 1px solid #333;
}

/* ========== ⭐ 移动端侧边栏适配 ========== */
/* 汉堡按钮在宽屏下隐藏（由 JS 控制，但 CSS 保底） */
#btn-hamburger {
    display: none;
}

@media (max-width: 768px) {
    #btn-hamburger {
        display: inline-block !important;
    }

    /* 侧边栏改为固定定位，滑出屏幕 */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        min-width: 280px;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
        z-index: 1000;
        border-right: none;
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

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

    /* 遮罩层 */
    #app::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 999;
    }

    #app.sidebar-active::after {
        opacity: 1;
        pointer-events: auto;
    }

    /* 点击遮罩关闭侧边栏（光标反馈） */
    #app.sidebar-active::after {
        cursor: pointer;
    }

    /* 分隔条在移动端隐藏 */
    #resizer {
        display: none;
    }

    /* 正文内边距缩小 */
    #content {
        padding: 1.2rem 1rem 20px;
    }

    /* 文章标题字号缩小 */
    #article-body h1 {
        font-size: 1.6rem;
    }
    #article-body h2 {
        font-size: 1.3rem;
    }
    #article-body h3 {
        font-size: 1.1rem;
    }
    #article-body p {
        font-size: 0.95rem;
    }

    /* 表格字号缩小 */
    #article-body table {
        font-size: 0.8rem;
    }
    #article-body th,
    #article-body td {
        padding: 0.3rem 0.4rem;
    }

    /* 评论区内边距缩小 */
    .comment-body {
        padding: 0.8rem 1rem;
    }

    /* 工具栏按钮在移动端紧凑排列 */
    #toolbar {
        top: 6px;
        right: 8px;
        gap: 4px;
    }
    .toolbar-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    /* 个人中心面板在移动端全屏 */
    #profile-panel {
        width: 100%;
    }

    /* 搜索面板在移动端全屏 */
    .panel-hidden {
        width: 100%;
        right: -100%;
    }
    .panel-visible {
        right: 0;
    }
}

/* ========== ⭐ 搜索高亮（黑底白字，圆角） ========== */
/* 此样式已在 HTML head 中定义，但为防止 CSS 加载顺序问题，在这里也定义一次 */
.search-highlight {
    background: #000 !important;
    color: #fff !important;
    border-radius: 3px;
    padding: 0 4px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ============================================================
   Copilot 新增样式（全部追加在末尾，不修改任何原有样式）
   ============================================================ */

/* ----- Copilot 侧栏视图 ----- */
#sidebar-copilot-view {
    display: none;
    flex-direction: column;
    height: 100%;
    background: #252525;
}

/* ----- 消息区域（含轮次点定位） ----- */
#copilot-messages-wrapper {
    position: relative;
    overflow-y: auto;
    flex: 1;
}

/* ----- 轮次点 ----- */
#copilot-dots {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
    pointer-events: none;
}
.copilot-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #555;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.25s ease, transform 0.2s ease;
    flex-shrink: 0;
}
.copilot-dot:hover {
    background: #888;
    transform: scale(1.2);
}
.copilot-dot.active {
    background: #fff;
    transform: scale(1.3);
    box-shadow: 0 0 8px rgba(255,255,255,0.25);
}

/* ----- 消息气泡 ----- */
.copilot-msg {
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.5;
    background: #2a2a2a;
    align-self: flex-start;
    color: #ddd;
}
.copilot-msg-user {
    align-self: flex-end;
    background: #3a3a3a;
    color: #eee;
}
.copilot-msg-assistant {
    background: #1e1e1e;
    border: 1px solid #333;
}
.copilot-msg p {
    margin: 0;
}

/* ----- 思考过程折叠 ----- */
.copilot-thinking {
    margin-bottom: 6px;
    background: #1a1a1a;
    border-radius: 4px;
    padding: 4px 8px;
    border-left: 3px solid #555;
}
.thinking-toggle {
    color: #888;
    cursor: pointer;
    font-size: 0.8rem;
    user-select: none;
}
.thinking-toggle:hover {
    color: #ccc;
}
.thinking-content {
    margin-top: 4px;
    color: #999;
    font-style: italic;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ----- 占位文字 ----- */
.copilot-placeholder {
    color: #888;
    text-align: center;
    padding: 1rem 0;
    font-size: 0.9rem;
}

/* ----- 历史记录列表 ----- */
.copilot-history-item {
    padding: 4px 8px;
    cursor: pointer;
    color: #ccc;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    transition: background 0.1s;
}
.copilot-history-item:hover {
    background: #3a3a3a;
}
.copilot-history-delete {
    color: #888;
    cursor: pointer;
    padding: 0 4px;
}
.copilot-history-delete:hover {
    color: #fff;
}
.copilot-history-empty {
    color: #666;
    text-align: center;
    padding: 0.5rem 0;
    font-size: 0.8rem;
}

/* ----- 图片缩略图 ----- */
.copilot-image-thumb {
    margin-bottom: 4px;
}
.copilot-image-thumb img {
    max-width: 60px;
    max-height: 60px;
    border-radius: 4px;
}

/* ----- 模式上拉条 & 模型下拉 ----- */
#copilot-mode-display,
#copilot-model-display {
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #ddd;
    user-select: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}
#copilot-mode-display:hover,
#copilot-model-display:hover {
    border-color: #888;
    background: #3a3a3a;
}

#copilot-mode-options,
#copilot-model-options {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #2d2d2d;
    border: 1px solid #555;
    border-radius: 4px;
    min-width: 120px;
    display: none;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    overflow-y: auto;
    max-height: 200px;
}
#copilot-mode-options { min-width: 120px; }
#copilot-model-options { min-width: 180px; }

.copilot-mode-option {
    padding: 6px 12px;
    cursor: pointer;
    color: #ccc;
    border-bottom: 1px solid #3a3a3a;
    transition: background 0.15s;
    font-size: 0.8rem;
}
.copilot-mode-option:hover { background: #3a3a3a; }
.copilot-mode-option.active { background: #555; color: #fff; }

.copilot-model-option {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #ccc;
    border-bottom: 1px solid #3a3a3a;
    transition: background 0.15s;
    font-size: 0.8rem;
}
.copilot-model-option:hover { background: #3a3a3a; }
.copilot-model-option img {
    width: 20px;
    height: 20px;
    margin-right: 8px;
}
.copilot-model-option.active { background: #555; color: #fff; }
.copilot-model-divider {
    height: 1px;
    background: #444;
    margin: 4px 8px;
}

/* ----- 图片上传标签 ----- */
#copilot-image-label {
    cursor: pointer;
    font-size: 0.75rem;
    color: #888;
    opacity: 0.3;
    transition: opacity 0.2s ease;
    user-select: none;
}
#copilot-image-label:has(+ input:not([disabled])) {
    opacity: 1;
}
#copilot-image-label:has(+ input[disabled]) {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ----- 白板导入按钮 ----- */
#copilot-whiteboard-import {
    display: none;
    background: #333;
    border: 1px solid #555;
    color: #ddd;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}
#copilot-whiteboard-import:hover {
    background: #3a3a3a;
    border-color: #888;
}
#copilot-whiteboard-import.active {
    border-color: #88b4e6;
    background: #2a3a4a;
}

/* ----- 白板导入面板（浮层） ----- */
#copilot-whiteboard-panel {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #2d2d2d;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 4px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
#copilot-whiteboard-panel.open { display: block; }
#copilot-whiteboard-panel .wb-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
#copilot-whiteboard-panel .wb-actions button {
    background: #333;
    border: 1px solid #555;
    color: #ddd;
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
}
#copilot-whiteboard-panel .wb-actions button:hover { background: #3a3a3a; }
#copilot-whiteboard-panel .wb-actions button.primary {
    background: #555;
    border-color: #777;
}
#copilot-whiteboard-panel .wb-actions button.primary:hover { background: #666; }

/* ----- Toast 提示 ----- */
.copilot-toast {
    animation: copilotFadeUp 0.3s ease;
}
@keyframes copilotFadeUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ----- 移动端适配 ----- */
@media (max-width: 768px) {
    #sidebar-copilot-view {
        width: 100%;
    }
    .copilot-model-option {
        font-size: 0.8rem;
    }
    #copilot-model-dropdown {
        max-width: 120px;
    }
    #copilot-mode-dropdown {
        max-width: 100px;
    }
    .copilot-dot {
        width: 6px;
        height: 6px;
    }
    #copilot-dots {
        right: 4px;
        gap: 4px;
    }
}
/* ============================================================
 * Copilot 自适应布局
 * ============================================================ */

#sidebar {
    min-height: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#sidebar-copilot-view {
    display: none;
    flex: 1 1 0 !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* 消息区占据全部剩余空间 */
#copilot-messages-wrapper {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* 消息内容不要把 flex 父级撑爆 */
#copilot-messages {
    min-height: 0;
}

/* 模式 / 模型工具栏 */
#sidebar-copilot-view > div:not(#copilot-messages-wrapper):not(.copilot-input-wrap):not(#copilot-history-panel) {
    flex-shrink: 0 !important;
}

/* 输入框永远是底部区域 */
#sidebar-copilot-view .copilot-input-wrap {
    flex: 0 0 auto !important;
    min-height: 0;
    background: #252525;
}

/* 输入框本身 */
#copilot-input {
    min-height: 42px;
    max-height: 120px;
}

/* ============================================================
 * 历史记录
 * ============================================================ */

#copilot-history-panel {
    flex: 0 0 auto;
    min-height: 0;
    border-top: 1px solid #444;
    background: #252525;
}

/* 历史记录按钮 */
#copilot-history-toggle {
    width: 100%;
    height: 34px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #252525;
    border: 0;
    color: #aaa;
    cursor: pointer;
    font-size: 0.78rem;
    text-align: left;
}

#copilot-history-toggle:hover {
    background: #303030;
    color: #ddd;
}

#copilot-history-arrow {
    font-size: 9px;
    transition: transform 0.15s ease;
}

/* 历史记录默认关闭 */
#copilot-history-list {
    display: none;
    max-height: 150px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.3rem 0.7rem 0.5rem;
    -webkit-overflow-scrolling: touch;
}

/* 打开状态 */
#copilot-history-panel.open #copilot-history-list {
    display: block;
}

#copilot-history-panel.open #copilot-history-arrow {
    transform: rotate(180deg);
}

/* ============================================================
 * 模型 / 模式菜单
 * ============================================================ */

#copilot-mode-options,
#copilot-model-options {
    z-index: 1000 !important;
}

/* ============================================================
 * 手机 / Edge 动态视口
 * ============================================================ */

@media (max-width: 768px) {
    #sidebar {
        height: 100dvh;
        max-height: 100dvh;
    }

    #sidebar-copilot-view {
        flex: 1 1 0 !important;
        min-height: 0 !important;
    }

    #copilot-messages-wrapper {
        flex: 1 1 0 !important;
        min-height: 0 !important;
    }

    #copilot-history-list {
        max-height: 120px;
    }

    #copilot-input {
        min-height: 40px;
        max-height: 90px;
    }
}
