/**
 * LEUCS 排版体系 — 铁律: 只有两种字体 (标题 vs 正文)
 * ======================================================
 * 设计原则 (2026-06-14 用户裁定):
 *   1. 所有文本仅两种表现: 标题(粗+无衬线) / 正文(等宽)
 *   2. 强调 = 加粗 + 高亮色, 不得用超大字号
 *   3. h1-h6 在对话内容中必须与正文清晰区分
 *   4. 所有 markdown 渲染内容(Sandwich 面板 + 最终答案 + 欢迎页)
 *      必须统一走此排版系统
 *
 * Phase 420-TYPO-V2: 正文尺寸与标题尺寸必须有≥4px的清晰差距
 *   根因: vw+clamp 在高分辨率下让各档位收敛 → 必须用独立变量拉开
 *
 * 加载位置: _02_main_template.py _CSS_LIST 末尾 (最高优先级)
 * ====================================================== */

/* ═══════════════════════════════════════════════════════════════
   第一区: 全局标题 vs 正文 两字体系
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* 标题字体 — 粗体无衬线, 与正文明显区分 */
    --leucs-font-title: var(--tno-font-title, 'Arial Black', 'Impact', sans-serif);
    /* 正文字体 — 等宽, 保持 TNO 设计语言 */
    --leucs-font-body: var(--tno-font-body, 'Courier Prime', 'Courier New', monospace);

    /* ★ 防止 Unicode 三角/箭头被渲染为 emoji (蓝色背景)
       浏览器默认将 ▸(U+25B8) ◂(U+25C2) ↗(U+2197) 等渲染为 emoji
       font-variant-emoji: text 强制文本呈现, 保持 TNO 严肃工程风格 */
    font-variant-emoji: text;

    /* ★ Phase 619 FIX: 纯 rem 字体 — 浏览器缩放友好, 不再用 VW
       旧 clamp() 的 VW 随缩放反向变化, 放大时字体反而变小 */
    --leucs-content-body:  0.875rem;      /* 14px — 正文 */
    --leucs-content-h4:    0.9375rem;     /* 15px — 标题4 */
    --leucs-content-h3:    1.0625rem;     /* 17px — 标题3 */
    --leucs-content-h2:    1.25rem;       /* 20px — 标题2 */
    --leucs-content-h1:    1.5rem;        /* 24px — 标题1 */

    /* 标题高亮色 */
    --leucs-title-color: var(--text-highlight, var(--c-daa520));
    --leucs-title-border: var(--accent-authority, var(--navy-mid));
}

/* ── 手动工具类 ── */
.leucs-title {
    font-family: var(--leucs-font-title) !important;
    font-weight: 900 !important;
    text-transform: none !important;
    letter-spacing: 0.03em !important;
    color: var(--leucs-title-color);
}
.leucs-body {
    font-family: var(--leucs-font-body) !important;
    font-weight: 550 !important;
    text-transform: none !important;
}
/* 强调: 用加粗+高亮色, 不用大字 */
.leucs-em {
    font-weight: 700 !important;
    color: var(--leucs-title-color) !important;
    font-style: normal !important;
}

/* ═══════════════════════════════════════════════════════════════
   第〇区: 全局字号工具类 — 替代所有 inline font-size 硬编码
   铁律: JS 代码中禁止出现 "font-size:" 字符串
   ═══════════════════════════════════════════════════════════════ */
/* Phase 619 FIX: 纯 rem, 不再用 clamp() VW */
.leucs-sz-badge  { font-size: var(--font-badge, 0.5625rem) !important; }
.leucs-sz-xxs   { font-size: var(--font-canvas-xxs, 0.6875rem) !important; }
.leucs-sz-xs    { font-size: var(--font-canvas-xs, 0.75rem) !important; }
.leucs-sz-body  { font-size: var(--leucs-content-body) !important; }
.leucs-sz-title { font-size: var(--leucs-content-h2) !important; }
.leucs-ff-mono  { font-family: var(--tno-font-mono, 'Consolas', 'Monaco', monospace) !important; }

/* ═══════════════════════════════════════════════════════════════
   第二区: Markdown 渲染内容 — 最终答案 / 历史消息
   LLM 回复中的 h1-h6 必须与正文明显区分
   ═══════════════════════════════════════════════════════════════ */

/* ★ V2: .wf-final-answer 父容器由JS inline style设了font-size, 这里强制重置为正文尺寸 */
.wf-final-answer {
    font-size: var(--leucs-content-body) !important;
}

/* 最终答案内容容器 — 统一基准 (正文尺寸) */
.wf-final-answer-content {
    font-family: var(--leucs-font-body);
    font-size: var(--leucs-content-body);
    line-height: 1.7;
    color: var(--text-primary);
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ★ 所有元素默认继承正文样式 — 只有显式标题才用标题字体 */
.wf-final-answer-content * {
    font-family: inherit;
    font-size: inherit;
}

/* 所有 markdown 渲染的标题 — 强制标题字体 + 独立尺寸变量 */
.wf-final-answer-content h1,
.wf-final-answer-content h2,
.wf-final-answer-content h3,
.wf-final-answer-content h4,
.wf-final-answer-content h5,
.wf-final-answer-content h6 {
    font-family: var(--leucs-font-title) !important;
    font-weight: 900 !important;
    text-transform: none !important;
    letter-spacing: 0.02em;
    color: var(--leucs-title-color);
    margin: 0.6em 0 0.3em 0;
    padding: 0;
    line-height: 1.3;
    border: none;
}
.wf-final-answer-content h1 {
    font-size: var(--leucs-content-h1);
    border-bottom: 1px solid var(--leucs-title-border);
    padding-bottom: 0.25em;
    margin-top: 1em;
}
.wf-final-answer-content h2 {
    font-size: var(--leucs-content-h2);
}
.wf-final-answer-content h3 {
    font-size: var(--leucs-content-h3);
}
.wf-final-answer-content h4,
.wf-final-answer-content h5,
.wf-final-answer-content h6 {
    font-size: var(--leucs-content-h4);
    font-weight: 700 !important;
}

/* 正文段落 — 显式使用正文尺寸 */
.wf-final-answer-content p {
    font-family: var(--leucs-font-body);
    font-size: var(--leucs-content-body);
    margin: 0.4em 0;
    line-height: 1.7;
}

/* 代码块 — 与正文同尺寸, 等宽字体 */
.wf-final-answer-content pre {
    font-family: var(--tno-font-mono, monospace);
    font-size: var(--leucs-content-body);
    line-height: 1.5;
    padding: 0.5rem;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}
.wf-final-answer-content code {
    font-family: var(--tno-font-mono, monospace);
    font-size: var(--leucs-content-body);
}

/* 内联代码 */
.wf-final-answer-content p code,
.wf-final-answer-content li code {
    background: rgba(255,255,255,0.06);
    padding: 0.1em 0.3em;
    border-radius: var(--radius-sm);
}

/* 列表 — 原点确保不被左侧时间线遮挡 */
.wf-final-answer-content ul,
.wf-final-answer-content ol,
.wf-final-answer ul,
.wf-final-answer ol {
    font-family: var(--leucs-font-body);
    margin: 0.3em 0;
    padding-inline-start: 2rem;
    list-style-position: outside;
    overflow: visible;
}
.wf-final-answer-content li,
.wf-final-answer ul > li,
.wf-final-answer ol > li {
    margin: 0.15em 0;
    line-height: 1.6;
    padding-inline-start: 0.3rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 强调 — 用加粗+高亮色替代大字号 */
.wf-final-answer-content strong,
.wf-final-answer-content b {
    font-weight: 700;
    color: var(--leucs-title-color);
}
.wf-final-answer-content em,
.wf-final-answer-content i {
    font-style: italic;
    color: var(--text-secondary);
}

/* 引用块 */
.wf-final-answer-content blockquote {
    border-left: 3px solid var(--leucs-title-border);
    margin: 0.5em 0;
    padding: 0.3em 0.8em;
    background: rgba(255,255,255,0.03);
    font-style: italic;
    color: var(--text-secondary);
}

/* 分割线 */
.wf-final-answer-content hr {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 0.8em 0;
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════════════════
   表格 —— 覆盖所有 markdown 渲染容器 (唯一排版出处, SHARED-SKIN).
   实拍发现表格落在 .leucs-table-block / .markdown-body / .leucs-api-body-sec-content
   等容器中, 旧规则无一命中 → 表格裸奔无边框无斑马纹.
   Word 化排版 (2026-08-10): width:100% 占满版心 + table-layout:auto
   按内容分配列宽; 首列(键列)收窄; 值列左对齐; 超宽表自身横向滚动.
   _12a_tchat_font_reset.css 不再另设表格规则, 全部以此为准.
   ═══════════════════════════════════════════════════════════════ */

.wf-final-answer-content table,
.wf-final-answer table,
.wf-msg-collapsed-preview table,
.wf-sandwich-md-content table,
.leucs-api-body table,
.leucs-api-body-sec-content table,
.leucs-table-block table,
.markdown-body table,
.wf-steps-container table,
.wf-collapsed-answer table {
    font-size: var(--leucs-content-body);
    border-collapse: collapse;
    margin: 0.5em 0;
    width: 100%;
    max-width: 100%;
    table-layout: auto;
    display: block;
    overflow-x: auto;
}
.wf-final-answer-content th,
.wf-final-answer-content td,
.wf-final-answer th,
.wf-final-answer td,
.wf-msg-collapsed-preview th,
.wf-msg-collapsed-preview td,
.wf-sandwich-md-content th,
.wf-sandwich-md-content td,
.leucs-api-body th,
.leucs-api-body td,
.leucs-api-body-sec-content th,
.leucs-api-body-sec-content td,
.leucs-table-block th,
.leucs-table-block td,
.markdown-body th,
.markdown-body td,
.wf-steps-container th,
.wf-steps-container td,
.wf-collapsed-answer th,
.wf-collapsed-answer td {
    border: 1px solid var(--border-primary);
    padding: 0.22em 0.6em;
    text-align: left;
    vertical-align: top;
    line-height: 1.5;
}
/* 首列(键列)自适应收窄贴合内容, 把宽度让给值列 */
.wf-final-answer-content th:first-child,
.wf-final-answer-content td:first-child,
.wf-final-answer th:first-child,
.wf-final-answer td:first-child,
.wf-msg-collapsed-preview th:first-child,
.wf-msg-collapsed-preview td:first-child,
.wf-sandwich-md-content th:first-child,
.wf-sandwich-md-content td:first-child,
.leucs-api-body th:first-child,
.leucs-api-body td:first-child,
.leucs-api-body-sec-content th:first-child,
.leucs-api-body-sec-content td:first-child,
.leucs-table-block th:first-child,
.leucs-table-block td:first-child,
.markdown-body th:first-child,
.markdown-body td:first-child,
.wf-steps-container th:first-child,
.wf-steps-container td:first-child,
.wf-collapsed-answer th:first-child,
.wf-collapsed-answer td:first-child {
    width: 1%;
    white-space: nowrap;
}
.wf-final-answer-content th,
.wf-final-answer th,
.wf-msg-collapsed-preview th,
.wf-sandwich-md-content th,
.leucs-api-body th,
.leucs-api-body-sec-content th,
.leucs-table-block th,
.markdown-body th,
.wf-steps-container th,
.wf-collapsed-answer th {
    font-family: var(--leucs-font-title);
    font-weight: 700;
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    white-space: nowrap;
}
.wf-final-answer-content tbody tr:nth-child(even) td,
.wf-final-answer tbody tr:nth-child(even) td,
.wf-msg-collapsed-preview tbody tr:nth-child(even) td,
.wf-sandwich-md-content tbody tr:nth-child(even) td,
.leucs-api-body tbody tr:nth-child(even) td,
.leucs-api-body-sec-content tbody tr:nth-child(even) td,
.leucs-table-block tbody tr:nth-child(even) td,
.markdown-body tbody tr:nth-child(even) td,
.wf-steps-container tbody tr:nth-child(even) td,
.wf-collapsed-answer tbody tr:nth-child(even) td {
    background: rgba(255,255,255,0.025);
}
.wf-final-answer-content td:last-child,
.wf-final-answer td:last-child,
.wf-msg-collapsed-preview td:last-child,
.wf-sandwich-md-content td:last-child,
.leucs-api-body td:last-child,
.leucs-api-body-sec-content td:last-child,
.leucs-table-block td:last-child,
.markdown-body td:last-child,
.wf-steps-container td:last-child,
.wf-collapsed-answer td:last-child {
    /* 长内容(如路径)允许换行但不做 break-all 滥断 */
    overflow-wrap: break-word;
    word-break: normal;
}

/* 链接 */
.wf-final-answer-content a {
    color: var(--accent-authority);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.wf-final-answer-content a:hover {
    color: var(--text-highlight);
}

/* FA 表格单元格一律左对齐 — Word 式排版, 值列不再居中浪费空间 (2026-08-10 移除旧的居中覆盖) */

/* ═══════════════════════════════════════════════════════════════
   第三区: Sandwich 面板排版
   ═══════════════════════════════════════════════════════════════ */

/* Sandwich 标题栏 */
.wf-sandwich-split-panel .wf-sw-title,
#leucs-sandwich-panel .wf-sw-title {
    font-family: var(--leucs-font-title) !important;
    font-weight: 900 !important;
    text-transform: none !important;
    letter-spacing: 0.03em;
    color: var(--leucs-title-color);
    font-size: var(--font-md);
}

/* Sandwich Tab 按钮 */
.wf-sandwich-tabs .wf-sw-tab,
#leucs-sandwich-panel .wf-sw-tab {
    font-family: var(--leucs-font-body);
    font-size: var(--font-sm);
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    padding: 0.25rem 0.625rem;
}

/* Sandwich 内容 — 正文 */
.wf-sandwich-body,
.wf-sandwich-body pre,
.wf-sandwich-body code,
#leucs-sandwich-panel pre,
#leucs-sandwich-panel code {
    font-family: var(--leucs-font-body);
    font-size: var(--font-canvas-sm);
    line-height: 1.65;
}

/* Sandwich body 中的标题 */
.wf-sandwich-body h1,
.wf-sandwich-body h2,
.wf-sandwich-body h3,
.wf-sandwich-body h4 {
    font-family: var(--leucs-font-title) !important;
    font-weight: 900 !important;
    text-transform: none !important;
    color: var(--leucs-title-color);
}
.wf-sandwich-body h1 {
    font-size: var(--font-lg);
    border-bottom: 1px solid var(--leucs-title-border);
}
.wf-sandwich-body h2 { font-size: var(--font-md); }
.wf-sandwich-body h3 { font-size: var(--font-sm); font-weight: 700; }

/* Sandwich field label */
.wf-sandwich-field-label {
    font-family: var(--leucs-font-title);
    font-size: var(--font-canvas-xs) !important;
    font-weight: 700 !important;
    text-transform: none !important;
    letter-spacing: 0.02em;
    color: var(--leucs-title-color);
}

/* ═══════════════════════════════════════════════════════════════
   第四区: 欢迎页排版
   ═══════════════════════════════════════════════════════════════ */

.wf-welcome-title {
    font-family: var(--leucs-font-title) !important;
    font-weight: 900 !important;
    font-size: var(--font-xl) !important;
    text-transform: none !important;
    letter-spacing: 0.03em;
    color: var(--leucs-title-color);
}
.wf-welcome-subtitle {
    font-family: var(--leucs-font-body);
    font-size: var(--font-md) !important;
    color: var(--text-secondary);
}
.wf-welcome-card,
.wf-welcome-card * {
    font-family: var(--leucs-font-body);
    font-size: var(--font-sm) !important;
}

/* ═══════════════════════════════════════════════════════════════
   第五区: UI 组件标题 — 模块名 / 面板标题 / Block 标题
   用 --leucs-font-title 替代 text-transform:uppercase 实现语义区分
   ═══════════════════════════════════════════════════════════════ */

/* 大模块 header 名称 */
.leucs-module-name {
    font-family: var(--leucs-font-title);
    font-weight: 900;
    text-transform: none !important;
    letter-spacing: 0.04em;
    font-size: var(--font-canvas-sm);
    color: var(--text-primary);
}

/* Block 小模块标题 */
.wf-block-title .wf-block-label {
    font-family: var(--leucs-font-title);
    font-weight: 700;
    text-transform: none !important;
    letter-spacing: 0.02em;
    font-size: var(--font-xs);
}

/* 对话历史列表标题 */
.wf-tchat-conv-title {
    font-family: var(--leucs-font-title);
    font-weight: 600;
    text-transform: none !important;
    letter-spacing: 0.01em;
}

/* 侧边栏标题 */
.wf-tchat-sidebar-title {
    font-family: var(--leucs-font-title);
    font-weight: 700;
    text-transform: none !important;
    letter-spacing: 0.03em;
    font-size: var(--font-canvas-xxs);
    color: var(--text-secondary);
}

/* 区域 header */
.wf-tchat-zone-header {
    font-family: var(--leucs-font-title);
    font-weight: 700;
    text-transform: none !important;
    letter-spacing: 0.03em;
    font-size: var(--font-canvas-xxs);
}

/* API 标签 */
.wf-tchat-api-label {
    font-family: var(--leucs-font-title);
    font-weight: 700;
    text-transform: none !important;
    letter-spacing: 0.03em;
    font-size: var(--font-canvas-xxs) !important;
}

/* 段落分割标头 */
.wf-segment-label {
    font-family: var(--leucs-font-title);
    font-weight: 700;
    text-transform: none !important;
    letter-spacing: 0.02em;
}

/* 折叠事件标签 */
.wf-cev-label {
    font-family: var(--leucs-font-title);
    font-weight: 600;
    text-transform: none !important;
    letter-spacing: 0.02em;
}

/* 工具栏按钮 */
.wf-tchat-send-btn,
.wf-tchat-interrupt-btn,
.wf-tchat-sandwich-btn,
.wf-tchat-new-btn {
    font-family: var(--leucs-font-body);
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* ═══════════════════════════════════════════════════════════════
   第六区: 流式实时渲染内容 (thinking 块等)
   ═══════════════════════════════════════════════════════════════ */

.wf-thinking-content,
.wf-think-body {
    font-family: var(--leucs-font-body);
    font-size: var(--font-canvas-sm);
    line-height: 1.7;
}

/* Thinking 块中的标题 */
.wf-thinking-content h1,
.wf-thinking-content h2,
.wf-thinking-content h3 {
    font-family: var(--leucs-font-title) !important;
    font-weight: 900 !important;
    text-transform: none !important;
    color: var(--leucs-title-color);
}

/* ═══════════════════════════════════════════════════════════════
   第七区: 聊天消息中的 SSE 事件卡片排版
   ═══════════════════════════════════════════════════════════════ */

.wf-collapsible-event {
    font-family: var(--leucs-font-body);
    font-size: var(--font-canvas-sm);
}

.wf-chat-segment {
    font-family: var(--leucs-font-body);
    font-size: var(--font-canvas-sm);
}

.wf-segment-header {
    font-family: var(--leucs-font-title);
    font-weight: 700;
    text-transform: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   第八区: 消息内容中的代码语法着色
   ═══════════════════════════════════════════════════════════════ */

.wf-syntax-json {
    font-family: var(--tno-font-mono, monospace);
    font-size: var(--font-canvas-sm);
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════
   第九区: 万能表格覆盖 — 任何 markdown 容器内表格必须有边框
   策略: 用属性选择器 [class*="markdown"] 做宽泛命中兜底,
   确保即使新容器增加了也不会裸奔.
   ═══════════════════════════════════════════════════════════════ */

/* 宽泛兜底: 所有含 "markdown" 的 class 容器内表格 (取值与第二区主块保持一致) */
[class*="markdown"] table,
.leucs-know-md table,
.leucs-mermaid-body table {
    font-size: var(--leucs-content-body);
    border-collapse: collapse;
    margin: 0.5em 0;
    width: 100%;
    max-width: 100%;
    table-layout: auto;
    display: block;
    overflow-x: auto;
}
[class*="markdown"] th,
[class*="markdown"] td,
.leucs-know-md th,
.leucs-know-md td {
    border: 1px solid var(--border-primary);
    padding: 0.22em 0.6em;
    text-align: left;
    vertical-align: top;
    line-height: 1.5;
}
[class*="markdown"] th:first-child,
[class*="markdown"] td:first-child,
.leucs-know-md th:first-child,
.leucs-know-md td:first-child {
    width: 1%;
    white-space: nowrap;
}
[class*="markdown"] th,
.leucs-know-md th {
    font-family: var(--leucs-font-title);
    font-weight: 700;
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    white-space: nowrap;
}
[class*="markdown"] tbody tr:nth-child(even) td,
.leucs-know-md tbody tr:nth-child(even) td {
    background: rgba(255,255,255,0.025);
}
[class*="markdown"] td:last-child,
.leucs-know-md td:last-child {
    overflow-wrap: break-word;
    word-break: normal;
}

/* ═══════════════════════════════════════════════════════════════
   第十区: Mermaid 图表 / 目录树 / 通用图表块
   ═══════════════════════════════════════════════════════════════ */

/* Mermaid 图表 */
.leucs-mermaid-block {
    font-family: var(--leucs-font-body);
}
.leucs-mermaid-body svg {
    max-width: 100%;
    height: auto;
}
.leucs-mermaid-body pre {
    font-family: var(--tno-font-mono, monospace);
    font-size: var(--font-xs, 0.6875rem);
    line-height: 1.5;
    margin: 0;
    padding: 0;
    background: transparent;
}

/* 目录树 */
.leucs-tree-block {
    font-family: var(--leucs-font-body);
}
.leucs-tree-body {
    line-height: 1.8;
    white-space: pre;
    overflow-x: auto;
}

/* 通用代码块内嵌套表格 */
.leucs-code-block table {
    font-size: var(--leucs-content-body);
    border-collapse: collapse;
}
.leucs-code-block th,
.leucs-code-block td {
    border: 1px solid var(--border-primary);
    padding: 0.35em 0.55em;
}

/* ASCII 表格机械生成的表格 — 居中覆盖 */
.leucs-tree-block table th,
.leucs-tree-block table td {
    text-align: center;
}
