/**
 * LEUCS 响应式兼容层 — 最小字体保障 + 非聊天组件专项修复
 * ================================================================
 * 此文件靠后加载, 只能做兼容兜底, 不能作为组件排版事实源:
 *   1. 全局最小字体保障
 *   2. 非聊天功能区域专项字体规范
 *   3. 拉伸栏 / resize handle 样式统一
 *
 * 聊天容器/对话历史归 _12_workflow_tchat.css 管;
 * 最终答案/Markdown/思考块归 _42_leucs_typography.css 管。
 * 不要在这里用后加载规则覆盖它们。
 */

/* ══════════════════════════════════════════════════════════════
   第一区: 全局最小字体保障
   防止任何继承或内联样式导致字体过小
   ══════════════════════════════════════════════════════════════ */

/* LEUCS 主应用根节点 — 统一基准字体 + 宽屏居中 */
#leucs-app {
    font-size: var(--font-md);
    line-height: 1.5;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* 所有消息对话框 */
#leucs-messages,
#leucs-messages .leucs-message,
#leucs-messages > * {
    font-size: var(--font-sm);
}

/* ══════════════════════════════════════════════════════════════
   第二区: 欢迎页/示例卡片
   ══════════════════════════════════════════════════════════════ */

/* 欢迎页标题 */
.wf-welcome-title {
    font-size: var(--font-xl) !important;
}

/* 欢迎页副标题 */
.wf-welcome-subtitle {
    font-size: var(--font-md) !important;
}

/* 示例卡片文字 */
.wf-welcome-card,
.wf-welcome-card * {
    font-size: var(--font-sm) !important;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════
   第四区: Sandwich 提示词预览面板
   用户说 "System Prompt 面板字体太小"
   ══════════════════════════════════════════════════════════════ */

/* Sandwich 标题 */
.wf-sandwich-split-panel .wf-sw-title,
#leucs-sandwich-panel .wf-sw-title {
    font-size: var(--font-md) !important;
}

/* Sandwich Tab 按钮 */
.wf-sandwich-tabs .wf-sw-tab,
#leucs-sandwich-panel .wf-sw-tab {
    font-size: var(--font-sm) !important;
}

/* Sandwich 内容 pre/code */
.wf-sandwich-body,
.wf-sandwich-body pre,
.wf-sandwich-body code,
#leucs-sandwich-panel pre,
#leucs-sandwich-panel code {
    font-size: var(--font-canvas-sm) !important;
    line-height: 1.65;
}

/* Sandwich 字段标签 */
.wf-sandwich-field-label {
    font-size: var(--font-canvas-xs) !important;
}

/* ══════════════════════════════════════════════════════════════
   第五区: Agent 参数配置面板
   用户说 "config 里的参数字体太小"
   ══════════════════════════════════════════════════════════════ */

#leucs-agent-params {
    font-size: var(--font-canvas-sm) !important;
}

#leucs-agent-params label,
#leucs-agent-params span,
#leucs-agent-params .leucs-param-key {
    font-size: var(--font-canvas-xs) !important;
}

#leucs-agent-params input,
#leucs-agent-params select {
    font-size: var(--font-canvas-sm) !important;
}

/* ══════════════════════════════════════════════════════════════
   第六区: 代码查看器 (pre/code 块)
   ══════════════════════════════════════════════════════════════ */

#leucs-code-block,
#leucs-code-block pre,
#leucs-code-viewer-pre {
    font-size: var(--font-canvas-sm) !important;
    line-height: 1.6;
    tab-size: 4;
}

/* 代码行号 */
#leucs-code-lines {
    font-size: var(--font-canvas-xxs) !important;
    opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════
   第七区: 拓扑树 / 依赖图
   ══════════════════════════════════════════════════════════════ */

#topo-tree-content,
#topo-tree-content * {
    font-size: var(--font-canvas-xs) !important;
    line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════════
   第九区: 顶部 Tab / 导航栏
   ══════════════════════════════════════════════════════════════ */

.leucs-topbar .leucs-tab {
    font-size: var(--font-canvas-md);
}

/* ══════════════════════════════════════════════════════════════
   第十区: 按钮全局规范 (继承 font-size, 不硬编码)
   ══════════════════════════════════════════════════════════════ */

button, .leucs-btn {
    font-size: inherit;
    min-font-size: var(--font-canvas-xs); /* 非标准, 有浏览器支持 */
}

/* 小型操作按钮 */
.leucs-btn-sm,
.leucs-icon-btn {
    font-size: var(--font-canvas-xxs);
}

/* ══════════════════════════════════════════════════════════════
   第十一区: 拉伸分隔条 (复刻 LEUV01 wf-sidebar-resize-handle)
   ══════════════════════════════════════════════════════════════ */

/* 侧边栏拖拽手柄 — 同 LEUV01 wf-sidebar-resize-handle */
.leucs-resize-handle,
.leucs-sidebar-resize {
    position: absolute;
    top: 0;
    right: 0;
    width: 0.3125rem;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 20;
    transition: background 0.15s;
    flex-shrink: 0;
}

.leucs-resize-handle:hover,
.leucs-resize-handle.dragging,
.leucs-sidebar-resize:hover {
    background: var(--accent-authority, var(--c-1e7fd4));
    box-shadow: 0 0 6px rgba(30, 127, 212, 0.4);
}

/* ══════════════════════════════════════════════════════════════
   第十三区: 监视器 / 状态面板
   ══════════════════════════════════════════════════════════════ */

#leucs-agent-monitor,
.leucs-monitor-row {
    font-size: var(--font-canvas-xs);
}

/* ══════════════════════════════════════════════════════════════
   第十四区: 全局输入框 / 发送栏
   ══════════════════════════════════════════════════════════════ */

#leucs-input {
    font-size: var(--font-sm) !important;
    line-height: 1.5;
}

/* S12b 正本清源: 本区旧"输入框禁横向拉伸"按 id 专项 (#leucs-input) 已物理
   删除 —— 一类组件约束必须落通用选择器, 全站 textarea 包裹钳制唯一规则
   归 _17b_tno_layout.css 基座层 (登录墙 #lb-w-reason 越父事故=按 id 打
   地鼠漏网实锤). 死选择器 .leucs-sendbar (全仓零引用) 一并清除. */

/* ══════════════════════════════════════════════════════════════
   第十五区: 系统探索 / 拓扑节点
   ══════════════════════════════════════════════════════════════ */

.leucs-pkg-name {
    font-size: var(--font-canvas-sm) !important;
}

.leucs-pkg-version,
.leucs-pkg-deps {
    font-size: var(--font-canvas-xxs) !important;
}

/* ══════════════════════════════════════════════════════════════
   第十六区: 移动端断点 (<768px) — N2-T3 双端自适应
   权威 seam = _03b_wf_block_layout_engine.js 的 matchMedia 单列决策;
   本区是无 JS / 竞态下的兼容兜底 + 触摸目标规范 (≤768px 才生效,
   桌面多列布局零影响). 只用 media query 与经典属性, 兼容安卓 Chrome /
   iOS Safari (含旧版, 无 :has() 等新特性).
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

    /* ── Block 主布局单列兜底 (JS seam 为权威; !important 仅在本断点内) ── */
    .wf-block-container {
        grid-template-columns: minmax(0, 1fr) !important;
        grid-template-rows: none !important;
        grid-auto-rows: auto;
        gap: 0.375rem;
        overflow-y: auto;
        height: auto;
        min-height: 100%;
    }

    /* 块在单列下随内容伸展, 不再被均分视口高度裁切 */
    .wf-block-container > .wf-block {
        min-height: 40vh;
    }

    /* 单列下分隔条无意义 (JS seam 不创建; 兜底的也藏掉) */
    .wf-block-container > .wf-block-divider {
        display: none !important;
    }

    /* ── 触摸目标 ≥44px (WCAG 2.1 最小推荐) ── */
    button,
    [role="button"],
    .leucs-tab,
    .leucs-btn,
    .leucs-hdr-btn,
    .leucs-icon-btn,
    .wf-rtab,
    .wf-block-title,
    select {
        min-height: 2.75rem;
    }

    /* 纯图标小按钮: 宽高双 44px */
    .leucs-icon-btn,
    .leucs-hdr-btn,
    .wf-block-replace-btn,
    .wf-block-expand-btn,
    .wf-block-toggle {
        min-width: 2.75rem;
        min-height: 2.75rem;
    }

    /* 消除 300ms 双击缩放延迟, 不拦截缩放本身 */
    button,
    [role="button"],
    .leucs-tab,
    select,
    input[type="checkbox"],
    input[type="radio"] {
        touch-action: manipulation;
    }

    /* ── S11-T1: chat 双栏抽屉化 — 窄屏默认收起对话历史侧栏,
       打开时全宽顶条弹出 (复用 wf-sidebar-open + wf-wrap-column 既有机制,
       与 wf-r-compact 范式同一套规则, 禁新发明) ── */
    .wf-tchat-sidebar {
        display: none;
    }
    .wf-tchat-sidebar.wf-sidebar-open {
        display: flex;
        width: 100%;
        min-width: unset;
        max-width: none;
        max-height: 40vh;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-primary, var(--bg-raised-navy));
        flex-shrink: 0;
    }
    .wf-tchat-wrap.wf-wrap-column {
        flex-direction: column !important;
    }
    /* 全页面禁横向滚动条 (clip 不产生新滚动容器, 不扰动滚动链律⑬) */
    html, body {
        overflow-x: clip;
    }

    /* ── S11-T2: tab 行固定高度 — 块内 wf-rtab 行锁高居中,
       不再随块标题栏 44px 触达按钮起伏; 主 tab 栏固定高度+横滑 ── */
    .wf-responsive-tab-bar {
        height: 2.5rem;
        align-items: center;
        padding-top: 0;
        max-width: 100%;
    }
    .wf-rtab {
        min-height: 0;
        height: 1.75rem;
        margin-bottom: 0;
    }
    #leucs-main-tab-bar {
        height: 2.75rem;
        overflow-x: auto;
    }
    #leucs-main-tab-bar .leucs-tab {
        min-height: 0;
    }
    /* S11-T2 补: 聊天区 mini-tab 行 (💬对话|📋Memory|⚙API) —
       tab 按钮豁免 44px 下限 (行本身锁定 2.75rem 横滑, 触达面积由行保证),
       旋转/跨断点行高恒定, 根治"tabs 高度不固定" */
    .leucs-mini-tabs-bar {
        min-height: 2.75rem;
        align-items: center;
    }
    .leucs-mini-tab {
        min-height: 0;
    }

    /* ── S11-T3: 窄屏禁用拉伸改自动高度 — 律⑳ 移动端 block 由 loop 引擎
       流式排版、无 block 尺寸概念, 拉伸句柄触屏既拖不动也无网格边界可对;
       PC 拖拽路径零改动。句柄与分隔条窄屏全隐。 ── */
    .leucs-resize-handle,
    .wf-sidebar-resize-handle,
    .wf-block-divider {
        display: none !important;
    }

    /* ── S11-T4: 悬浮层秩序 — tooltip 窄屏放宽不裁剪 (定位已随视口钳制);
       全屏运行角标落籍规则见文件尾 (原 JS cssText 私造外观已物理删除, 律㉓③) ── */
    #leucs-ctx-hint {
        max-width: 85vw;
        min-width: unset;
    }
}

/* ── S11-T4 落籍: 全屏运行角标 (仅 pointer:coarse 挂载, 见 _leu_bit_session.js) ──
   z-index 99800 < hint tooltip 999999: 瞬时提示永远 paints 在常驻角标之上,
   二者不再互遮; 外观 token 化, 禁回内联 cssText。 */
#lb-fs-btn {
    position: fixed;
    right: 0.75rem;
    bottom: 4.5rem;
    z-index: 99800;
    background: var(--bg-panel, var(--c-1e1e1e));
    color: var(--text-highlight, var(--c-daa520));
    border: 1px solid var(--border-primary);
    border-left: 3px solid var(--text-highlight, var(--c-daa520));
    font-family: var(--tno-font-mono, monospace);
    font-size: 0.8rem;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
}
