/* ==========================================================================
   写作区专用样式（全量主题变量化）
   ========================================================================== */

/* ================= 默认主题：暗夜灰白 (Gray) ================= */
:root {
    --writer-bg: #1c1c1e;          /* 正文背景 */
    --writer-panel-bg: #161618;    /* 侧边栏背景 */
    --writer-text: #d1d1d6;        /* 正文文字 */
    --writer-text-secondary: #a1a1aa; /* 次要文字 */
    --writer-text-muted: #71717a;  /* 弱化文字 */
    --writer-border: #2c2c2e;      /* 边框线 */
    --writer-hover: #2a2a2c;       /* 悬停背景 */
    --writer-active: #6366f1;      /* 高亮色 */
    --writer-active-bg: rgba(99, 102, 241, 0.15);
    --writer-input-bg: rgba(0, 0, 0, 0.2); /* 输入框背景 */
}
/* 明亮白主题 */
body[data-w-theme="light"] {
    --writer-bg: #f9f9fb;
    --writer-panel-bg: #f2f2f7;
    --writer-text: #2c2c2e;
    --writer-text-secondary: #636366;
    --writer-text-muted: #8e8e93;
    --writer-border: #e5e5ea;
    --writer-hover: #e5e5ea;
    --writer-active: #4f46e5;
    --writer-active-bg: rgba(79, 70, 229, 0.1);
    --writer-input-bg: rgba(0, 0, 0, 0.04);
}
/* 羊皮纸主题 */
body[data-w-theme="parchment"] {
    --writer-bg: #f4ecd8;
    --writer-panel-bg: #ebdabf;
    --writer-text: #433422;
    --writer-text-secondary: #7a6550;
    --writer-text-muted: #a08b73;
    --writer-border: #dac6a8;
    --writer-hover: #e0cba8;
    --writer-active: #d97706;
    --writer-active-bg: rgba(217, 119, 6, 0.15);
    --writer-input-bg: rgba(0, 0, 0, 0.06);
}
/* 护眼绿主题 */
body[data-w-theme="green"] {
    --writer-bg: #c8e6c9;
    --writer-panel-bg: #b5d6b6;
    --writer-text: #1b3a2a;
    --writer-text-secondary: #3a5f48;
    --writer-text-muted: #5a8268;
    --writer-border: #9cc29d;
    --writer-hover: #aed4af;
    --writer-active: #059669;
    --writer-active-bg: rgba(5, 150, 105, 0.15);
    --writer-input-bg: rgba(0, 0, 0, 0.06);
}
/* 深海蓝主题 */
body[data-w-theme="blue"] {
    --writer-bg: #212b38;
    --writer-panel-bg: #1c2430;
    --writer-text: #a3b8cc;
    --writer-text-secondary: #7a93ab;
    --writer-text-muted: #526a82;
    --writer-border: #2d3b4e;
    --writer-hover: #2d3b4e;
    --writer-active: #3b82f6;
    --writer-active-bg: rgba(59, 130, 246, 0.15);
    --writer-input-bg: rgba(0, 0, 0, 0.25);
}

/* 统一定义选中文本的高亮颜色 */
.writer-editor-content ::selection { background: var(--writer-active-bg); color: var(--writer-active); }

/* ============ 作品列表 ============ */
.writer-list-wrap { padding: 24px 32px 60px; max-width: 1400px; margin: 0 auto; }
.writer-list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.writer-list-title { font-size: 18px; font-weight: 600; color: #e4e4e7; }
.writer-list-actions { display: flex; align-items: center; gap: 8px; }
.writer-search-box { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; background: #161616; border: 1px solid #232329; border-radius: 8px; min-width: 220px; }
.writer-search-box i { color: #71717a; font-size: 12px; }
.writer-search-box input { flex: 1; background: transparent; border: none; outline: none; color: #e4e4e7; font-size: 12.5px; font-family: inherit; }
.writer-btn-primary { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; background: linear-gradient(135deg, #6366f1, #4f46e5); border: none; border-radius: 8px; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.writer-btn-primary:hover { filter: brightness(1.1); }
.writer-books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; align-content: flex-start; min-height: 200px; }
.writer-book-card { position: relative; display: flex; flex-direction: column; background: #161616; border: 1px solid #232329; border-radius: 12px; overflow: hidden; cursor: pointer; transition: all 0.2s; padding: 16px; min-height: 160px; }
.writer-book-card:hover { border-color: #3a3a44; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.writer-book-title { font-size: 15px; font-weight: 600; color: #e4e4e7; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.writer-book-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11.5px; color: #71717a; margin-top: auto; }
.writer-book-meta span { display: inline-flex; align-items: center; gap: 4px; }
.writer-book-desc { font-size: 12px; color: #a1a1aa; line-height: 1.5; display: -webkit-box;  -webkit-box-orient: vertical; margin-bottom: 8px; overflow: hidden; }
.writer-book-actions { position: absolute; top: 8px; right: 8px; display: none; gap: 4px; }
.writer-book-card:hover .writer-book-actions { display: flex; }
.writer-book-action-btn { width: 26px; height: 26px; border: none; border-radius: 6px; background: rgba(0,0,0,0.5); color: #a1a1aa; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.writer-book-action-btn:hover { background: #6366f1; color: #fff; }
.writer-book-action-btn.danger:hover { background: #ef4444; }
.writer-empty { grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: #52525b; font-size: 13px; }
.writer-empty i { font-size: 40px; display: block; margin-bottom: 14px; opacity: 0.4; }

/* ============ 写作台覆盖层 ============ */
.writer-workbench { position: fixed; inset: 0; z-index: 500000; background: var(--writer-bg); display: none; flex-direction: column; color: var(--writer-text); transition: background 0.3s, color 0.3s; }
.writer-workbench.show { display: flex; }
.writer-wb-header { height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 12px; background: var(--writer-panel-bg); border-bottom: 1px solid var(--writer-border); flex-shrink: 0; transition: background 0.3s, border-color 0.3s; }
.writer-wb-header .header-left, .writer-wb-header .header-right { display: flex; align-items: center; gap: 8px; }
.writer-wb-back { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; background: transparent; border: 1px solid var(--writer-border); border-radius: 6px; color: var(--writer-text-secondary); font-size: 12.5px; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.writer-wb-back:hover { background: var(--writer-hover); color: var(--writer-text); }
.writer-icon-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: none; border-radius: 6px; color: var(--writer-text-secondary); cursor: pointer; transition: all 0.15s; }
.writer-icon-btn:hover { background: var(--writer-hover); color: var(--writer-text); }
.writer-icon-btn.active { background: var(--writer-active-bg); color: var(--writer-active); }
.writer-wb-breadcrumb { flex: 1; text-align: center; font-size: 13px; color: var(--writer-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.writer-wb-breadcrumb strong { color: var(--writer-text); font-weight: 500; }
.writer-wb-save-status { font-size: 12px; color: var(--writer-text-muted); display: inline-flex; align-items: center; gap: 4px; }
.writer-wb-save-status.saved { color: #10b981; }

/* 主题选择菜单 */
.writer-theme-menu {
    position: absolute;
    top: calc(100% + 6px); /* 紧贴在按钮下方 */
    right: 0;              /* 右对齐，不会漂移 */
    min-width: 160px;      /* 保证有足够的宽度 */
    background: var(--writer-panel-bg);
    border: 1px solid var(--writer-border);
    border-radius: 8px;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 1000;
    white-space: nowrap;   /* ★ 核心修复：强制文字水平排列，禁止换行 */
}
.writer-theme-menu.show { display: flex; }

.writer-theme-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    color: var(--writer-text);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.writer-theme-item:hover { background: var(--writer-hover); }
.writer-theme-item.active { background: var(--writer-active-bg); color: var(--writer-active); font-weight: 600; }
.writer-theme-item .color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(128, 128, 128, 0.3);
    flex-shrink: 0;
}

/* ============ 主体三栏 ============ */
.writer-wb-body { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.writer-wb-tree { width: 260px; flex-shrink: 0; background: var(--writer-panel-bg); border-right: 1px solid var(--writer-border); display: flex; flex-direction: column; overflow: hidden; transition: width 0.25s ease, opacity 0.25s, background 0.3s, border-color 0.3s; }
.writer-wb-tree.collapsed { width: 0; opacity: 0; border-right: none; }
.writer-wb-tree-head { height: 40px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--writer-border); font-size: 12.5px; color: var(--writer-text-secondary); flex-shrink: 0; }
.writer-tree-add-btn { width: 24px; height: 24px; border: none; background: transparent; color: var(--writer-text-muted); border-radius: 5px; cursor: pointer; transition: all 0.15s; }
.writer-tree-add-btn:hover { background: var(--writer-hover); color: var(--writer-text); }
.writer-tree-progress { padding: 8px 12px; border-bottom: 1px solid var(--writer-border); font-size: 11.5px; color: var(--writer-text-muted); flex-shrink: 0; display: flex; justify-content: space-between; }
.writer-tree-progress strong { color: var(--writer-active); font-weight: 600; }
.writer-tree-list { flex: 1; overflow-y: auto; padding: 8px 6px; }
.writer-tree-list::-webkit-scrollbar { width: 6px; }
.writer-tree-list::-webkit-scrollbar-thumb { background: var(--writer-border); border-radius: 3px; }

.writer-volume-item { display: flex; align-items: center; height: 30px; padding: 0 8px; border-radius: 6px; color: var(--writer-text-secondary); font-size: 12.5px; font-weight: 500; cursor: pointer; transition: background 0.1s; position: relative; }
.writer-volume-item:hover { background: var(--writer-hover); }
.writer-volume-arrow { width: 16px; font-size: 9px; color: var(--writer-text-muted); transition: transform 0.15s; }
.writer-volume-item.expanded .writer-volume-arrow { transform: rotate(90deg); }
.writer-volume-name { flex: 1; margin-left: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.writer-volume-count { font-size: 10px; color: var(--writer-text-muted); }
.writer-volume-actions { display: none; gap: 2px; margin-left: 4px; }
.writer-volume-item:hover .writer-volume-actions { display: flex; }
.writer-volume-actions button { width: 20px; height: 20px; border: none; background: transparent; color: var(--writer-text-muted); cursor: pointer; border-radius: 4px; font-size: 10px; }
.writer-volume-actions button:hover { background: rgba(128,128,128,0.2); color: var(--writer-text); }

.writer-chapter-item.drag-over { border-top: 2px solid var(--writer-active); margin-top: -2px; }
.writer-chapter-item { display: flex; align-items: center; height: 28px; padding: 0 8px 0 28px; border-radius: 6px; color: var(--writer-text-secondary); font-size: 12px; cursor: pointer; transition: background 0.1s; position: relative; }
.writer-chapter-item:hover { background: var(--writer-hover); color: var(--writer-text); }
.writer-chapter-item.active { background: var(--writer-active-bg); color: var(--writer-active); font-weight: 500; }
.writer-chapter-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.writer-chapter-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--writer-text-muted); margin-right: 6px; flex-shrink: 0; }
.writer-chapter-status-dot.done { background: #10b981; }
.writer-chapter-status-dot.draft { background: #fbbf24; }
.writer-chapter-actions { display: none; gap: 2px; }
.writer-chapter-item:hover .writer-chapter-actions { display: flex; }
.writer-chapter-actions button { width: 18px; height: 18px; border: none; background: transparent; color: var(--writer-text-muted); cursor: pointer; border-radius: 3px; font-size: 9px; }
.writer-chapter-actions button:hover { background: rgba(128,128,128,0.2); color: var(--writer-text); }
.writer-tree-empty { text-align: center; padding: 24px 12px; color: var(--writer-text-muted); font-size: 11.5px; }

/* 中栏：正文 */
.writer-wb-editor { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--writer-bg); overflow: hidden; position: relative; transition: background 0.3s; }
.writer-wb-editor-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--writer-text-muted); font-size: 13px; gap: 12px; }
.writer-wb-editor-empty i { font-size: 44px; opacity: 0.4; }

/* 悬浮工具栏 */
.writer-float-toolbar { position: fixed; z-index: 1000; display: none; align-items: center; gap: 4px; background: var(--writer-panel-bg); border: 1px solid var(--writer-border); border-radius: 8px; padding: 4px 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); transform: translate(-50%, -100%); }
.writer-float-toolbar.show { display: flex; }
.writer-float-toolbar button { height: 28px; padding: 0 8px; border: none; background: transparent; color: var(--writer-text); border-radius: 4px; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; white-space: nowrap; }
.writer-float-toolbar button:hover { background: var(--writer-hover); }
.writer-float-toolbar .divider { width: 1px; height: 16px; background: var(--writer-border); margin: 0 4px; }

.writer-chapter-title-input { height: 64px; padding: 0 40px; border: none; background: transparent; color: var(--writer-text); font-size: 22px; font-weight: 600; outline: none; font-family: inherit; flex-shrink: 0; width: 100%; box-sizing: border-box; }
.writer-chapter-title-input::placeholder { color: var(--writer-text-muted); }
.writer-editor-scroll { flex: 1; overflow-y: auto; padding: 10px 0 100px; }
.writer-editor-scroll::-webkit-scrollbar { width: 8px; }
.writer-editor-scroll::-webkit-scrollbar-thumb { background: var(--writer-border); border-radius: 4px; }
.writer-editor-content { max-width: 820px; margin: 0 auto; padding: 0 40px; font-size: 16px; line-height: 1.9; color: var(--writer-text); outline: none; min-height: 400px; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; transition: color 0.3s; }
.writer-editor-content:empty::before { content: attr(data-placeholder); color: var(--writer-text-muted); pointer-events: none; }
.writer-editor-content p { margin: 0 0 1em 0; text-indent: 2em; }
.writer-editor-content h1, .writer-editor-content h2, .writer-editor-content h3 { text-indent: 0; color: var(--writer-text); margin: 1.5em 0 0.8em; }
.writer-editor-content blockquote { text-indent: 0; border-left: 3px solid var(--writer-active); padding-left: 12px; color: var(--writer-text-secondary); margin: 1em 0; font-style: italic; }

.writer-wb-editor-bottom { height: 44px; padding: 0 20px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--writer-border); background: var(--writer-panel-bg); flex-shrink: 0; transition: background 0.3s, border-color 0.3s; }
.writer-chapter-nav-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; background: transparent; border: 1px solid var(--writer-border); border-radius: 6px; color: var(--writer-text-secondary); font-size: 12px; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.writer-chapter-nav-btn:hover:not(:disabled) { background: var(--writer-hover); color: var(--writer-text); }
.writer-chapter-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.writer-wb-editor-bottom .spacer { flex: 1; }
.writer-wb-word-count { font-size: 12px; color: var(--writer-text-muted); font-family: 'SF Mono', Monaco, monospace; }

/* 右栏：细纲 */
.writer-wb-outline { width: 300px; flex-shrink: 0; background: var(--writer-panel-bg); border-left: 1px solid var(--writer-border); display: flex; flex-direction: column; overflow: hidden; transition: width 0.25s ease, opacity 0.25s, background 0.3s, border-color 0.3s; }
.writer-wb-outline.collapsed { width: 0; opacity: 0; border-left: none; }
.writer-wb-outline-head { height: 40px; padding: 0 12px; display: flex; align-items: center; border-bottom: 1px solid var(--writer-border); font-size: 12.5px; color: var(--writer-text-secondary); font-weight: 500; flex-shrink: 0; }
.writer-outline-scroll { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.writer-outline-scroll::-webkit-scrollbar { width: 6px; }
.writer-outline-scroll::-webkit-scrollbar-thumb { background: var(--writer-border); border-radius: 3px; }
.writer-outline-section-label { font-size: 11.5px; color: var(--writer-text-muted); font-weight: 500; margin-bottom: 6px; display: flex; justify-content: space-between; }
.writer-outline-textarea { width: 100%; min-height: 120px; background: var(--writer-input-bg); border: 1px solid var(--writer-border); border-radius: 6px; padding: 10px 12px; color: var(--writer-text); font-size: 12.5px; line-height: 1.7; outline: none; resize: vertical; font-family: inherit; box-sizing: border-box; transition: background 0.3s, border-color 0.3s; }
.writer-outline-textarea:focus { border-color: var(--writer-active); }
.writer-outline-preview { background: var(--writer-input-bg); border: 1px solid var(--writer-border); border-radius: 6px; padding: 10px 12px; color: var(--writer-text-muted); font-size: 12px; line-height: 1.7; max-height: 160px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; transition: background 0.3s, border-color 0.3s; }
.writer-outline-preview.empty { font-style: italic; }

/* 专注模式 */
body.writer-focus-mode .writer-wb-tree,
body.writer-focus-mode .writer-wb-outline { display: none !important; }
body.writer-focus-mode .writer-wb-editor { max-width: 900px; margin: 0 auto; border-left: 1px solid var(--writer-border); border-right: 1px solid var(--writer-border); }

/* AI 打字机效果闪烁光标 */
@keyframes writer-cursor-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.writer-ai-cursor { display: inline-block; width: 2px; height: 18px; background: var(--writer-active); vertical-align: middle; animation: writer-cursor-blink 1s step-end infinite; margin-left: 2px; }


/* ================= 左侧 Tab 切换 ================= */
.writer-tree-tabs {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid var(--writer-border);
    background: var(--writer-panel-bg);
    flex-shrink: 0;
}

.w-tab {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    font-size: 12.5px;
    color: var(--writer-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    user-select: none;
}

.w-tab:hover {
    color: var(--writer-text);
}

.w-tab.active {
    color: var(--writer-active);
    font-weight: 600;
    border-bottom-color: var(--writer-active);
}


/* ================= 统一写作台滚动条样式 ================= */
/* 覆盖所有滚动区域：正文、左侧树、右侧细纲/预览 */
.writer-workbench ::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}

.writer-workbench ::-webkit-scrollbar-track {
    background: transparent !important;
}

.writer-workbench ::-webkit-scrollbar-thumb {
    /* 使用半透明灰色，在深色/浅色主题下都自然 */
    background: rgba(128, 128, 128, 0.3) !important;
    border-radius: 3px !important;
    transition: background 0.2s !important;
}

.writer-workbench ::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.6) !important;
}


/* ================= 强制允许写作台内文字选中复制 ================= */

/* 覆盖原稿预览区、正文编辑区、细纲预览区的选择限制 */
.writer-workbench .writer-preview-text,
.writer-workbench .writer-outline-preview,
.writer-workbench .writer-editor-content,
.writer-workbench #canvasPreviewContent {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    cursor: text;
}

/* 允许选中的文字显示系统高亮色 */
.writer-workbench ::selection {
    background: var(--writer-active-bg) !important;
    color: var(--writer-active) !important;
}


/* ================= 自动续写弹窗 ================= */
.writer-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    z-index: 10000; display: none; align-items: center; justify-content: center;
}
.writer-modal-overlay.show { display: flex; }
.writer-modal-dialog {
    background: var(--writer-panel-bg); border: 1px solid var(--writer-border);
    border-radius: 12px; width: 700px; max-width: 90vw; height: 80vh; max-height: 800px;
    display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    color: var(--writer-text); animation: wModalFadeIn 0.2s ease;
}
@keyframes wModalFadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.writer-modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--writer-border);
    display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 600;
}
.writer-modal-body {
    flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 12px; overflow: hidden;
}
.writer-modal-body label { font-size: 13px; font-weight: 500; color: var(--writer-text-secondary); flex-shrink: 0; }
.writer-modal-body textarea {
    flex: 1; min-height: 80px; background: var(--writer-input-bg); border: 1px solid var(--writer-border);
    border-radius: 6px; padding: 12px; color: var(--writer-text); font-family: inherit;
    font-size: 13px; line-height: 1.6; outline: none; resize: none;
}
.writer-modal-body textarea:focus { border-color: var(--writer-active); }
.writer-modal-footer {
    padding: 16px 20px; border-top: 1px solid var(--writer-border);
    display: flex; justify-content: flex-end; gap: 12px;
}
.writer-modal-btn {
    height: 34px; padding: 0 18px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: none;
}
.writer-modal-btn.cancel { background: var(--writer-border); color: var(--writer-text); }
.writer-modal-btn.primary { background: var(--writer-active); color: #fff; }



/* ================= 统一悬浮积分样式 ================= */
.writer-cost-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.writer-cost-wrap:hover {
    background: var(--writer-hover);
}
.writer-cost-wrap .cost-val {
    color: #fbbf24;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
.writer-cost-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--writer-panel-bg);
    border: 1px solid var(--writer-border);
    border-radius: 10px;
    padding: 12px;
    width: 240px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    z-index: 9999;
    font-size: 12px;
    color: var(--writer-text-secondary);
    text-align: left;
}
.writer-cost-wrap:hover .writer-cost-popup {
    display: block;
}
.writer-cost-popup .cp-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.writer-cost-popup .cp-row:last-child {
    margin-bottom: 0;
}
.writer-cost-popup .cp-divider {
    height: 1px;
    background: var(--writer-border);
    margin: 8px 0;
}
.writer-cost-popup .cp-total {
    font-weight: 600;
    color: var(--writer-text);
    font-size: 13px;
}



/* ==========================================================================
   双线缝合工作区 (Writer Merge) - 完整样式
   ========================================================================== */

/* 1. 整体布局 */
.writer-merge-workbench {
    position: fixed; inset: 0; z-index: 600000;
    background: var(--writer-bg); color: var(--writer-text);
    display: none; flex-direction: column;
    animation: wmSlideUp 0.3s ease;
}
.writer-merge-workbench.show { display: flex; }
@keyframes wmSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.wm-header {
    height: 56px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between;
    background: var(--writer-panel-bg); border-bottom: 1px solid var(--writer-border); flex-shrink: 0;
}
.wm-header-left { display: flex; align-items: center; gap: 16px; }
.wm-btn-close {
    background: transparent; border: 1px solid var(--writer-border); color: var(--writer-text);
    height: 32px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all 0.2s;
}
.wm-btn-close:hover { background: var(--writer-hover); }
.wm-title { font-size: 15px; font-weight: 600; color: var(--writer-active); }
.wm-subtitle { font-size: 12.5px; color: var(--writer-text-muted); border-left: 1px solid var(--writer-border); padding-left: 16px; }

.wm-body { flex: 1; display: flex; min-height: 0; }

/* 统一暗黑滚动条 */
.writer-merge-workbench ::-webkit-scrollbar { width: 6px !important; height: 6px !important; }
.writer-merge-workbench ::-webkit-scrollbar-track { background: transparent !important; }
.writer-merge-workbench ::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, 0.3) !important; border-radius: 3px !important; }
.writer-merge-workbench ::-webkit-scrollbar-thumb:hover { background: rgba(128, 128, 128, 0.6) !important; }

/* 2. 左侧面板 */
.wm-left-panel {
    width: 35%; max-width: 480px; padding: 24px; border-right: 1px solid var(--writer-border);
    display: flex; flex-direction: column; gap: 20px; overflow-y: auto;
}
.wm-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--writer-text-secondary); }
.wm-field textarea {
    width: 100%; background: var(--writer-input-bg); border: 1px solid var(--writer-border);
    border-radius: 8px; padding: 12px; color: var(--writer-text); font-family: inherit;
    font-size: 13px; outline: none; transition: border 0.2s; min-height: 100px; resize: vertical; line-height: 1.6;
}
.wm-field textarea:focus { border-color: var(--writer-active); }

.wm-source-card {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--writer-input-bg); border: 1px dashed var(--writer-border);
    padding: 10px 14px; border-radius: 8px; font-size: 12.5px; margin-bottom: 8px;
}
.wm-preview-btn {
    background: transparent; border: 1px solid var(--writer-border); color: var(--writer-text-secondary);
    border-radius: 4px; padding: 2px 8px; font-size: 11.5px; cursor: pointer; transition: all 0.2s;
}
.wm-preview-btn:hover { background: var(--writer-hover); color: var(--writer-text); border-color: var(--writer-active); }

/* AI 控制台 */
.wm-ctrl-row { display: flex; gap: 8px; align-items: center; width: 100%; margin-bottom: 8px; }
.wm-select {
    flex: 1; min-width: 0; height: 32px;
    background-color: var(--writer-input-bg) !important; border: 1px solid var(--writer-border) !important;
    border-radius: 6px; color: var(--writer-text) !important; font-size: 12.5px; line-height: 30px;
    outline: none; cursor: pointer; appearance: none; -webkit-appearance: none;
    padding: 0 24px 0 10px !important; box-sizing: border-box;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a1a1aa%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat; background-position: right 8px center; background-size: 10px; transition: border-color 0.2s;
}
.wm-select:focus { border-color: var(--writer-active) !important; }
.wm-select option { background-color: var(--writer-panel-bg) !important; color: var(--writer-text) !important; }

.wm-ctrl-btn {
    display: flex; align-items: center; justify-content: center; gap: 4px; height: 32px; padding: 0 12px;
    background: var(--writer-input-bg); border: 1px solid var(--writer-border); border-radius: 6px;
    color: var(--writer-text-secondary); font-size: 12.5px; cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.wm-ctrl-btn:hover { background: var(--writer-hover); color: var(--writer-text); }

.wm-footer-left { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--writer-border); z-index: 10; }
.wm-btn-primary {
    width: 100%; height: 40px; background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: filter 0.2s;
}
.wm-btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.wm-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.wm-btn-secondary {
    height: 40px; padding: 0 20px; background: var(--writer-border); color: var(--writer-text);
    border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* 3. 右侧面板 */
.wm-right-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--writer-bg); }
.wm-tabs { display: flex; border-bottom: 1px solid var(--writer-border); background: var(--writer-panel-bg); }
.wm-tab {
    padding: 14px 24px; font-size: 14px; font-weight: 500; color: var(--writer-text-secondary);
    cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s;
}
.wm-tab.active { color: var(--writer-active); border-bottom-color: var(--writer-active); font-weight: 600; }
.wm-tab:hover:not(.active) { color: var(--writer-text); }
.wm-tab-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* 全屏方案编辑区 */
.wm-plan-full-editor {
    flex: 1; overflow-y: auto; padding: 24px 40px;
    font-size: 14px; line-height: 1.8; color: var(--writer-text-secondary);
    outline: none; word-wrap: break-word;
}
.wm-plan-full-editor:focus { color: var(--writer-text); }
.wm-plan-full-editor:empty::before { content: attr(data-placeholder); color: #71717a; pointer-events: none; }

/* Markdown 样式 */
.wm-plan-full-editor h1, .wm-plan-full-editor h2, .wm-plan-full-editor h3 { color: #a5b4fc; margin-top: 1.5em; margin-bottom: 0.8em; font-weight: 600; }
.wm-plan-full-editor h2 { font-size: 18px; border-bottom: 1px solid var(--writer-border); padding-bottom: 8px; }
.wm-plan-full-editor h3 { font-size: 15px; }
.wm-plan-full-editor p { margin-bottom: 1em; }
.wm-plan-full-editor table { width: 100%; border-collapse: collapse; margin-bottom: 1.5em; font-size: 13px; }
.wm-plan-full-editor th, .wm-plan-full-editor td { border: 1px solid var(--writer-border); padding: 10px 14px; text-align: left; }
.wm-plan-full-editor th { background: rgba(255, 255, 255, 0.03); color: var(--writer-text); font-weight: 600; }
.wm-plan-full-editor tr:nth-child(even) { background: rgba(255, 255, 255, 0.01); }
.wm-plan-full-editor strong { color: #fbbf24; }

/* 生成结果区 */
.wm-result-body {
    flex: 1; min-height: 0; overflow-y: auto; padding: 30px 40px;
    font-size: 16px; line-height: 1.9; color: var(--writer-text);
    word-wrap: break-word; white-space: pre-wrap;
}

.wm-footer-right {
    padding: 16px 24px; border-top: 1px solid var(--writer-border);
    background: var(--writer-panel-bg); display: flex; justify-content: flex-end; gap: 12px;
}
.wm-footer-right .wm-btn-primary { width: auto; padding: 0 24px; }

/* 4. 自定义下拉面板（历史记录） */
.wm-custom-select { width: 100%; position: relative; user-select: none; z-index: 50; }
.wm-custom-select-trigger {
    display: flex; justify-content: space-between; align-items: center; height: 32px;
    background: var(--writer-input-bg) !important; border: 1px solid var(--writer-border) !important;
    border-radius: 6px; padding: 0 10px; color: var(--writer-text-secondary) !important;
    font-size: 12.5px; cursor: pointer; transition: border-color 0.2s;
}
.wm-custom-select-trigger:hover { border-color: var(--writer-active) !important; }
.wm-custom-select.show .wm-custom-select-trigger {
    border-color: var(--writer-active) !important; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.wm-custom-select-trigger i { font-size: 10px; transition: transform 0.2s; }
.wm-custom-select.show .wm-custom-select-trigger i { transform: rotate(180deg); }

.wm-custom-select-options {
    display: none; position: absolute; top: 100%; left: 0; width: 100%;
    background: var(--writer-panel-bg); border: 1px solid var(--writer-active); border-top: none;
    border-bottom-left-radius: 6px; border-bottom-right-radius: 6px;
    max-height: 250px; overflow-y: auto; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
.wm-custom-select.show .wm-custom-select-options { display: block; }

.wm-custom-option {
    display: flex; justify-content: space-between; align-items: center; padding: 6px 10px;
    font-size: 12.5px; color: var(--writer-text-secondary); border-bottom: 1px solid var(--writer-border);
    transition: background 0.2s; cursor: default;
}
.wm-custom-option:last-child { border-bottom: none; }
.wm-custom-option:hover { background: var(--writer-hover); color: var(--writer-text); }
.wm-option-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; padding: 4px 0; }
.wm-option-text:hover { color: var(--writer-active); }

.wm-option-actions { display: flex; gap: 6px; margin-left: 10px; }
.wm-opt-btn {
    width: 24px; height: 24px; border: none; border-radius: 4px; background: transparent;
    color: var(--writer-text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 11px; transition: all 0.15s;
}
.wm-opt-load:hover { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
.wm-opt-del:hover { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

/* 5. 预览弹窗 */
.wm-preview-modal {
    position: fixed; inset: 0; z-index: 999999;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
}
.wm-preview-modal.show { display: flex; }
.wm-preview-dialog {
    width: 800px; max-width: 90vw; height: 80vh; max-height: 800px;
    background: var(--writer-panel-bg); border: 1px solid var(--writer-border);
    border-radius: 12px; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: wmSlideUp 0.2s ease;
}
.wm-preview-header {
    padding: 16px 20px; border-bottom: 1px solid var(--writer-border);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 15px; font-weight: 600; color: var(--writer-text);
}
.wm-preview-close { background: transparent; border: none; color: var(--writer-text-muted); cursor: pointer; font-size: 16px; transition: color 0.2s; }
.wm-preview-close:hover { color: var(--writer-text); }
.wm-preview-body {
    flex: 1; overflow-y: auto; padding: 24px; font-size: 14px; line-height: 1.9;
    color: var(--writer-text-secondary); user-select: text;
}
.wm-preview-footer {
    padding: 12px 20px; border-top: 1px solid var(--writer-border);
    display: flex; justify-content: space-between; align-items: center; background: var(--writer-bg);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .wm-body { flex-direction: column; }
    .wm-left-panel { width: 100%; max-width: 100%; border-right: none; border-bottom: 1px solid var(--writer-border); padding: 16px; }
    .wm-right-panel { min-height: 400px; }
    .wm-plan-full-editor { padding: 16px; }
    .wm-result-body { padding: 16px; }
    .wm-subtitle { display: none; }
}

/* ==================== 右侧历史记录抽屉 ==================== */
.wm-header-right {
    display: flex;
    align-items: center;
}
.wm-btn-history {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--writer-input-bg); border: 1px solid var(--writer-border);
    color: var(--writer-text-secondary); height: 32px; padding: 0 14px;
    border-radius: 6px; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.wm-btn-history:hover {
    background: var(--writer-hover); color: var(--writer-text); border-color: var(--writer-active);
}

.wm-history-sidebar {
    position: absolute;
    top: 56px; /* 头部高度 */
    right: -400px; /* 默认隐藏在屏幕外 */
    bottom: 0;
    width: 380px; /* 侧边栏宽度 */
    background: var(--writer-panel-bg);
    border-left: 1px solid var(--writer-border);
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1000;
    box-shadow: -10px 0 30px rgba(0,0,0,0.4);
}
.wm-history-sidebar.show {
    right: 0;
}
.wm-history-header {
    padding: 16px; border-bottom: 1px solid var(--writer-border);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 14px; font-weight: 600; color: var(--writer-text);
}
.wm-history-close {
    background: transparent; border: none; color: var(--writer-text-muted);
    cursor: pointer; font-size: 16px; transition: color 0.2s;
}
.wm-history-close:hover { color: #ef4444; }

.wm-history-list {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.wm-history-list::-webkit-scrollbar { width: 6px; }
.wm-history-list::-webkit-scrollbar-thumb { background: var(--writer-border); border-radius: 3px; }

.wm-history-item {
    background: var(--writer-bg); border: 1px solid var(--writer-border);
    border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 10px;
    transition: border-color 0.2s;
}
.wm-history-item:hover {
    border-color: var(--writer-active);
}
.wm-hi-top {
    font-size: 12px; color: var(--writer-text-muted);
    display: flex; justify-content: space-between;
}
.wm-hi-title {
    font-size: 13.5px; font-weight: 600; color: var(--writer-text);
    line-height: 1.5; word-break: break-all;
}
.wm-hi-actions {
    display: flex; gap: 10px; margin-top: 4px;
}
.wm-hi-btn {
    flex: 1; height: 30px; border-radius: 6px; border: none;
    font-size: 12px; font-weight: 500; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    transition: all 0.2s;
}
.wm-hi-load {
    background: rgba(99, 102, 241, 0.15); color: #a5b4fc;
}
.wm-hi-load:hover { background: rgba(99, 102, 241, 0.3); color: #fff; }
.wm-hi-del {
    background: rgba(239, 68, 68, 0.1); color: #fca5a5;
}
.wm-hi-del:hover { background: rgba(239, 68, 68, 0.25); color: #fff; }