:root {
    --sb-w: 280px; --primary: #07c160;
    --bg-gray: #f2f3f5; --border-color: rgba(0,0,0,0.05);
    --paper-w: 800px; --content-w: 640px;
}
* { box-sizing: border-box; outline: none; }

.app-container { display: flex; height: 100vh; background: transparent; }

/* --- 侧边栏 --- */
.sidebar {
    width: var(--sb-w); display: flex; flex-direction: column; padding: 24px; flex-shrink: 0;
    background: transparent; border-right: 1px solid var(--border-color);
}
.logo-area { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: bold; font-size: 18px; color: #000; }
.logo-area span { background: #000; color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 14px; }

.article-card {
    width: 100%; border-radius: 6px; padding: 20px;
    margin-top: 0px;
    background: white; backdrop-filter: blur(10px);
}
.cover-box {
    width: 100%; aspect-ratio: 16 / 9; background: rgba(255,255,255,0.4); border: 1px dashed #ccc;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #888; cursor: pointer; position: relative; overflow: hidden; font-size: 12px;
}
.cover-box img { width: 100%; height: 100%; object-fit: cover; display: none; }
.card-title-sync { font-size: 13px; margin-top: 10px; color: #444; height: 2.8em; overflow: hidden; line-height: 1.4; }

/* --- 主阶段 --- */
.main-stage { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.top-nav { height: 50px; display: flex; align-items: center; padding: 0 24px; justify-content: space-between; border-bottom: 1px solid var(--border-color); flex-shrink: 0;}
.top-nav .path { font-size: 13px; color: #888; }
.top-nav .path b { color: #333; font-weight: normal; }

/* --- 工具栏 --- */
.toolbar { height: 52px;border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 20px; gap: 4px; position: relative; flex-shrink: 0; }
.plus-btn-wrap {
    width: 22px; height: 22px; background: var(--primary); color: #fff;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; margin-right: 12px; transition: transform 0.1s;
}
.plus-btn-wrap svg { width: 18px; height: 18px; fill: #fff; }

.dropdown { position: relative; display: inline-block; }
.tool-btn {
    height: 34px; min-width: 34px; padding: 0 8px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #5f6368; border-radius: 4px; transition: 0.2s; font-size: 13px;
}
.tool-btn:hover { background: rgba(0,0,0,0.05); color: #000; }
.tool-btn svg { width: 20px; height: 20px; fill: currentColor; }

.dropdown-content {
    position: absolute; top: 100%; left: 0; background: #fff; border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); padding: 8px; width: 180px;
    display: none; z-index: 2000; border: 1px solid #eee; margin-top: 4px;
}
.dropdown:hover .dropdown-content { display: block; }
.dropdown-item { padding: 8px 12px; display: flex; align-items: center; gap: 10px; cursor: pointer; border-radius: 4px; font-size: 13px; color: #444; }
.dropdown-item:hover { background: #f5f5f5; color: #000; }
.v-line { width: 1px; height: 16px; background: rgba(0,0,0,0.1); margin: 0 8px; }

/* 调色板 */
.color-pop { width: 250px; padding: 16px; }
.c-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 12px; }
.c-cell { width: 22px; height: 22px; border-radius: 4px; cursor: pointer; border: 1px solid rgba(0,0,0,0.1); }

/* --- 编辑区布局 --- */
.workspace { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; position: relative; }

.editor-main-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    /* 这里的 160px 是对的，它是为了防止内容被底部的发布栏遮挡 */
    padding: 30px 20px 160px 20px;
    width: 100%;
    max-width: 1400px;
    /* 确保即使内容少，点击布局区域也能触发编辑器聚焦 */
    cursor: text;
}
.codex-editor__redactor {
    padding-bottom: 0px;
}
.editor-paper {
    width: var(--paper-w);
    background: #fff;
    /* 修改这里：不要用 1000px */
    min-height: 50px;
    padding: 60px 0;
    border-radius: 2px;
    flex-shrink: 0;
    position: relative;
    /* 建议添加：确保阴影或边界清晰 */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.outline-side {
    width: 240px; /* 略微调宽大纲 */
    position: sticky;
    top: 30px;
    color: #999;
    font-size: 13px;
    flex-shrink: 0;
}
.outline-side b { color: #333; display: block; margin-bottom: 12px; font-size: 14px; }
#toc div { padding: 5px 0; cursor: pointer; transition: 0.2s; }
#toc div:hover { color: var(--primary); }

.title-area { display: flex; justify-content: center; margin-bottom: 30px; }
.title-input { width: var(--content-w); font-size: 26px; font-weight: bold; border: none; padding: 0; color: #0f1b37; background: transparent; }

/* --- 修复点：底部保存栏对齐 --- */
.footer-fixed {
    position: fixed;
    bottom: 0px;
    /* 关键算法：左偏移量 = 侧边栏宽 + (主舞台宽 - 纸张宽 - 大纲宽 - 间距) / 2 */
    /* 简化方案：使用 left: 50% 配合 margin-left 修正，或者更稳健的 calc */
    left: calc(var(--sb-w) + (100vw - var(--sb-w) - 1080px) / 2); /* 1080 = paper-w(800) + gap(40) + outline(240) */
    width: var(--paper-w);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 24px;
    border-radius: 12px;
    /*box-shadow: 0 8px 32px rgba(0,0,0,0.1);*/
    z-index: 1000;
    border-top: 1px solid whitesmoke;
}

/* 兼容小屏幕时让 footer 始终居中 */
@media (max-width: 1400px) {
    .footer-fixed {
        left: 50%;
        transform: translateX(calc(-50% - 120px)); /* 向左微调 120px 是因为大纲在右侧占位 */
    }
}

.btn { padding: 9px 22px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; border: 1px solid #dcdfe6; background: #fff; }
.btn-green { background: var(--primary); color: #fff; border: none; margin-right: 0; } /* 居右 */

.ce-block__content, .ce-toolbar__content { max-width: var(--content-w); }
.image-tool--caption {padding-bottom: 0px}
.image-tool__caption {
    display: none;
}
.link-tool__content--rendered {
    box-shadow: none;
}
.exps {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 90%;
}
.exp-item {
    display: flex;
    align-items: center;
    padding: 8px;
    height: 30px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* 悬停效果：灰色背景 */
.exp-item:hover {
    cursor: pointer;
    background-color: #e2e2e3;
}

/* 当前选中状态（对应截图中的淡灰色高亮） */
.exp-item.active {
    background-color: #ebebeb;
    font-weight: 500;
}

/* 状态标识：草稿样式微调 */
.status-tag {
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 8px;
    background: #fdf6ec;
    color: #e6a23c;
    flex-shrink: 0;
}
.sidebar-header-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 0px 5px 0px;
}

/* 搜索框容器 */
.search-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    background: #f4f4f4;
    border-radius: 4px;
    padding: 6px 10px;
    border: 1px solid #c8c8c8;
    transition: all 0.2s;
}

.search-wrapper:focus-within {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

#articleSearchInput {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    width: 100%;
    color: #333;
}

.search-shortcut {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    margin-left: 5px;
}

/* 新建文章按钮 */
.btn-add-article {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #07c160;
    background: #07c160;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-add-article:hover {
    background: #f9f9f9;
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}
#content .cdx-simple-image__picture img,
#content .image-tool__image-picture img {
    cursor: zoom-in;
}
/* 确保父容器是定位参考 */
.dropdown {
    position: relative;
    display: inline-block;
}

/* 颜色面板基础样式 */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%; /* 紧贴父级底部 */
    left: 0;
    padding: 15px;
    background: #fff;
    box-shadow: 0 5px 25px rgba(0,0,0,0.1);
    z-index: 100;
}

/* 💡 核心：这座“桥”负责连接按钮和面板 */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -15px; /* 向上延伸 15px，覆盖按钮和面板之间的空隙 */
    left: 0;
    width: 100%;
    height: 15px; /* 高度必须等于或大于那个空隙 */
    background: transparent; /* 透明，用户看不见但鼠标能感知 */
}

/* 只有鼠标在 .dropdown 内部（包含那个伪元素）时才显示 */
.dropdown:hover .dropdown-content {
    display: block;
}
.create-btn {
    display: flex;          /* 开启弹性布局 */
    align-items: center;    /* 垂直居中 */
    gap: 0px;               /* 图标和文字之间的间距 */
    padding: 6px;      /* 内边距控制按钮大小 */
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;      /* 防止文字被意外选中 */

    /* 文字样式 */
    font-size: 14px;
    color: #333;
}

.create-btn:hover {
    background-color: #f0f2f5; /* 悬停时的浅灰色背景 */
}

.plus-btn-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 确保图标颜色跟随文字 */
.plus-btn-wrap svg {
    display: block;
    stroke: currentColor;
}
/* 引入深色主题 */
@import url('https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css');

.better-code-card {
    border: 1px solid #2d2d2d;
    border-radius: 8px;
    background: #1d1f21 !important;
    margin: 20px 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 顶部工具栏：强制恢复正常文字排版，防止受 pre 继承影响 */
.better-code-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #282a2e;
    border-bottom: 1px solid #373b41;
    white-space: normal !important;
    flex-shrink: 0;
}

.better-code-title {
    font-size: 12px;
    color: #969896;
    font-family: sans-serif;
}

.lang-tag {
    font-size: 11px;
    color: #b294bb;
    font-weight: bold;
    text-transform: uppercase;
    background: rgba(178, 148, 187, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.2;
}

.copy-btn {
    font-size: 12px;
    color: #969896;
    cursor: pointer;
    font-family: sans-serif;
    user-select: none;
}

/* 代码主体容器：只在这里开启横向滚动 */
.better-code-main {
    position: relative;
    background: #1d1f21;
    overflow-x: auto !important;
    overflow-y: hidden;
    width: 100%;
}

/* 输入层/内容层 */
.better-code-editor {
    position: relative;
    z-index: 2;
    min-width: 100%;
    min-height: 120px;
    border: none;
    outline: none;
    padding: 16px !important;
    font-family: "Fira Code", "Consolas", monospace !important;
    font-size: 13px !important;
    line-height: 1.6 !important;
    background: transparent !important;
    color: transparent !important;
    caret-color: #fff;
    resize: none;
    white-space: pre !important;
    word-wrap: normal !important;
}

/* 只读模式微调 */
.ce-editor--read-only .better-code-editor {
    caret-color: transparent !important;
    cursor: text;
}

/* 高亮层 */
.better-code-highlight {
    position: absolute !important;
    top: 0;
    left: 0;
    min-width: 100%;
    height: 100%;
    margin: 0 !important;
    padding: 16px !important;
    z-index: 1;
    pointer-events: none;
    font-size: 13px !important;
    line-height: 1.6 !important;
    background: transparent !important;
    border: none !important;
    white-space: pre !important;
}

/* 彻底隐藏 Prism 默认行号 */
.line-numbers .line-numbers-rows,
.line-numbers-rows {
    display: none !important;
}

/* 美化滚动条 */
.better-code-main::-webkit-scrollbar {
    height: 8px;
}
.better-code-main::-webkit-scrollbar-thumb {
    background: #373b41;
    border-radius: 4px;
}
.better-code-main::-webkit-scrollbar-track {
    background: #1d1f21;
}