/* NOTE: 单文件约3100行，建议按功能模块拆分:
 *   variables.css (CSS变量) → layout.css (布局) → components.css (组件) → animations.css (动画)
 */
:root {
    --primary: #00a8a8;
    --primary-light: #14c9c9;
    --primary-hover: #008d8d;
    --primary-dark: #007777;
    --primary-bg: rgba(0, 168, 168, 0.08);
    --primary-bg-strong: rgba(0, 168, 168, 0.15);
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #34d399;
    --danger: #ef4444;
    --danger-light: #f87171;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.03);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.05);
    --shadow: 0 2px 6px -1px rgb(0 0 0 / 0.08), 0 1px 4px -2px rgb(0 0 0 / 0.06);
    --shadow-md: 0 4px 12px -2px rgb(0 0 0 / 0.1), 0 2px 8px -4px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 10px 25px -5px rgb(0 0 0 / 0.1), 0 4px 12px -6px rgb(0 0 0 / 0.08);
    --shadow-xl: 0 20px 50px -12px rgb(0 0 0 / 0.15);
    --shadow-primary: 0 4px 16px rgba(0, 168, 168, 0.25);
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 16px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 28px;
    --font-display: 'Outfit', 'Plus Jakarta Sans', sans-serif;
    /* D11.10.151-补 38: 字体链修复
       根因: 浏览器 sans-serif 兜底在 Windows 中文系统下可能解析为"宋体"(SimSun, 衬线字体)
             导致 body 内所有文字显示为衬线, 看起来"描边"感很重
       修复: 把 Microsoft YaHei (无衬线) 移到 fallback 第 2 位 (优先于 Noto Sans SC),
             并把最后的 sans-serif 兜底也加上 'PingFang SC' / 'Hiragino Sans GB' (macOS) / 'WenQuanYi Micro Hei' (Linux)
             避免任何场景 fallback 到 SimSun */
    --font-body: 'DM Sans', 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', 'HarmonyOS Sans SC', 'Noto Sans SC', Arial, sans-serif;
    /* D11.10.151-补 38: 等宽字体链修复
       根因: 浏览器 monospace 兜底在 Windows 下解析为 Courier New (衬线字体)
             导致解析弹窗内 0/204, 25/578 等数字看起来"有衬线"
       修复: 链尾去掉 monospace, 改用 'Microsoft YaHei' / 'Consolas' / 'Lucida Console' (都是无衬线等宽)
             强制无衬线 */
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Microsoft YaHei', Consolas, 'Lucida Console', 'Courier New', sans-serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --container-max-width: 1750px;
    --container-padding: 24px;
    --section-spacing: 16px;
    --component-spacing: 12px;
    --item-spacing: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

.section-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.section-tab { padding: 10px 20px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; transition: all .2s; }
.section-tab:hover { color: var(--text-primary); }
.section-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

input, textarea, select, button {
    font-family: inherit;
}

.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.header {
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
    overflow: visible;
    margin: 0;
    padding: 0;
}

.header-content {
    max-width: 1750px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: visible;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-img {
    height: 19px;
    width: auto;
}

.logo svg {
    width: 16px;
    height: 16px;
}

.logo-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: visible;
}

.main {
    flex: 1;
    max-width: 1750px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.main > [id$="Section"] {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.search-section {
    margin-bottom: 14px;
}

.search-container {
    display: flex;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.search-container:hover {
    border-color: var(--text-tertiary);
    box-shadow: var(--shadow);
}

.search-container:focus-within {
    box-shadow: 0 0 0 4px var(--primary-bg), var(--shadow);
    border-color: var(--primary);
}

.search-container svg {
    flex-shrink: 0;
    color: var(--text-tertiary);
}

#searchInput {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
}

#searchInput::placeholder {
    color: var(--text-tertiary);
}

.app-tabs {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: center;
    margin: 0 16px;
}

.app-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition-normal);
    white-space: nowrap;
    position: relative;
}

.app-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.app-tab.active {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-primary);
}

/* 2026-10-03: 未授权功能标签置灰不可用(替代隐藏, 保持导航结构稳定) */
.app-tab.app-tab-disabled,
.app-tab.app-tab-disabled:hover,
.app-tab.app-tab-disabled.active {
    background: transparent;
    color: var(--text-secondary);
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@keyframes sectionFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-section,
.quote-section,
.proposal-section,
.design-section,
.files-section,
.plc-section,
.monitor-section {
    animation: sectionFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-section {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.files-section {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg);
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.content-section {
    width: 100%;
    max-width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}

.tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-normal);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
    font-weight: 600;
}

.file-list-header {
    display: flex;
    align-items: center;
    padding: 8px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* 卡片模式文件列表 */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* 树形文件列表样式 */
.file-grid {
    display: block;
    padding: 8px 0;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.file-grid::-webkit-scrollbar {
    width: 6px;
}

.file-grid::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.file-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
    transition: background 0.2s;
}

.file-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.dark-theme .file-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

.dark-theme .file-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.file-tree-folder,
.file-tree-file {
    padding: 4px 0;
}

.file-tree-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.file-tree-item:hover {
    background: var(--bg-tertiary);
}

.file-tree-arrow {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.file-tree-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.file-tree-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--text-primary);
}

.file-tree-size {
    font-size: 13px;
    color: var(--text-tertiary);
    white-space: nowrap;
    min-width: 50px;
    text-align: right;
}

.file-tree-count {
    font-size: 13px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.file-tree-action {
    opacity: 0;
    transition: opacity 0.15s;
}

.file-tree-item:hover .file-tree-action {
    opacity: 1;
}

.file-tree-file.selected {
    background: rgba(0, 168, 168, 0.1);
}

.file-tree-folder.selected {
    background: rgba(0, 168, 168, 0.08);
    border-left: 3px solid var(--primary);
}

.file-card.selected {
    border-color: var(--primary);
    background: rgba(0, 168, 168, 0.05);
}

.file-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.file-card:hover {
    border-color: var(--text-tertiary);
    box-shadow: var(--shadow-md);
}

.file-thumbnail {
    height: 60px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.file-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.file-info {
    padding: 8px 10px;
    flex: 1;
}

.file-name {
    font-size: 13px;
    line-height: 1.3;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.file-type-badge {
    font-size: 13px;
    padding: 2px 4px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    color: var(--text-secondary);
}

.file-remark {
    flex: 1;
    color: var(--warning, #f59e0b);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-highlight {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-actions {
    padding: 4px 8px 8px;
    display: flex;
    gap: 4px;
}

/* 大图预览 */
.preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.75);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-primary);
}

.preview-content img {
    max-width: 100%;
    max-height: 80vh;
    display: block;
}

.preview-close {
    position: fixed;
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 10001;
}

.chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.chat-send-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.chat-send-btn:hover {
    background: var(--primary-hover);
}

.proposal-form {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.proposal-result {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.search-box:focus-within {
    border-color: var(--primary);
}

.optimization-hint {
    background: rgba(0, 168, 168, 0.08);
    border: 1px solid rgba(0, 168, 168, 0.2);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}

.sheet-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.result-content {
    line-height: 1.6;
    font-size: 14px;
}

.result-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
}

.result-content th,
.result-content td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
}

.result-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.files-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.filter-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.filter-select:focus {
    border-color: var(--primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
    min-height: 400px;
}

.chat-message {
    display: flex;
    max-width: 90%;
}

.chat-message.assistant {
    align-self: flex-start;
    max-width: calc(100% - 50px);
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 100%;
}

.chat-message .message-content {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    line-height: 1.55;
    font-size: 14px;
    max-width: 75%;
    width: fit-content;
    position: relative;
    word-break: normal;
    overflow-wrap: break-word;
    white-space: normal;
    overflow-x: hidden;
    min-width: 0;
}

.chat-message.assistant .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: var(--radius-xs);
    border-left: 3px solid var(--primary);
    padding-right: 56px;
    position: relative;
    /* D11.10.151-补 152 fix31: assistant 消息撑满父级, 避免长文本被 max-width:75% 截断
       根因: 父级 .chat-message.assistant 是 max-width:100% (覆盖 90%), 但 .message-content 是 max-width:75% + fit-content,
             当内容超 75% 父级时, fit-content 让容器变宽到内容宽, 但 max-width 又卡住,
             配合 overflow-x:hidden → 文字被裁切, 用户看到"超出边界被截断"
       修法: assistant 的 message-content 改 max-width:100% (撑满父级), 由父级 90% 限制最大宽度
             配合 .chat-md-host 的 overflow-wrap:break-word / word-break:break-word, 长内容自然换行
       风险: 改 100% 后 assistant 消息可占满 90% 父级 — 这是预期效果 (原本就该这样, 不应被 75% 卡住)
       业务验证: 用户截图见 第五部分 总结 文字超出 .message-content 灰色背景被切到下一行 */
    max-width: 100%;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #ffffff;
    border-bottom-right-radius: var(--radius-xs);
    box-shadow: var(--shadow-primary);
    padding: 6px 12px;
    line-height: 1.35;
    max-width: none;
}

.chat-message .message-content ul,
.chat-message .message-content ol {
    padding-left: 22px;
    margin: 0;
    list-style-position: outside;
}

.chat-message .message-content li {
    margin: 0;
    line-height: 1.55;
}

.chat-message.assistant .message-content ul,
.chat-message.assistant .message-content ol {
    color: var(--text-primary);
}

.chat-message.user .message-content ul,
.chat-message.user .message-content ol {
    color: #ffffff;
}

.chat-message.user .message-content li::marker {
    color: rgba(255, 255, 255, 0.7);
}

.chat-bubble {
    padding: 14px 18px;
    border-radius: 14px;
    line-height: 1.7;
    font-size: 14px;
    max-width: 100%;
    word-break: break-word;
}

.chat-message.assistant .chat-bubble {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: var(--radius-xs);
    width: 100%;
}

.chat-message.user .chat-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: var(--radius-xs);
}

.chat-md-host {
    line-height: 1.7;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

/* 补 265: 强制所有子元素允许自动换行 — 防止 pre/code/table 等覆盖继承
   根因: pre 默认 white-space: pre, code/table/th/td 可能继承 nowrap, 长 URL/长英文不换行
   修法: 用 :where() 低选择器重设所有可能阻止换行的属性 */
.chat-md-host :where(pre, code, kbd, samp, table, th, td, thead, tbody, tr) {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
/* 但 pre 里我们自己设了 pre-wrap, 恢复一下 */
.chat-md-host pre {
    white-space: pre-wrap;
}

/* 补 248: 智能问答 SVG 流程图自适应宽度 — 只防溢出，不强制撑大 */
.chat-md-host svg {
    max-width: 100%;
    height: auto;
}

/* 2026-10-01: SVG 文字若**未显式写 fill**，默认按"形状外标注"渲染为褐色，避免继承正文色导致颜色不可预期；
   形状内的文字由作者显式写 fill="#000000"（内联属性优先级高于本规则），即"控件内黑字、控件外褐字"。 */
.chat-md-host svg text:not([fill]),
.chat-md-host svg tspan:not([fill]) {
    fill: #8B5A2B;
}

.chat-md-host p,
.chat-md-host li,
.chat-md-host ul,
.chat-md-host ol {
    margin: 0;
    line-height: 1.7;
}

.chat-md-host p + p {
    margin-top: 0.8em;
}

.chat-md-host br:first-child,
.chat-md-host br:last-child {
    display: none;
}

.chat-md-host h1,
.chat-md-host h2,
.chat-md-host h3,
.chat-md-host h4 {
    margin: 1em 0 0.4em;
    font-weight: 600;
    line-height: 1.4;
}

.chat-md-host h1 { font-size: 17px; }
.chat-md-host h2 { font-size: 16px; }
.chat-md-host h3 { font-size: 15px; }
.chat-md-host h4 { font-size: 14px; }

.chat-md-host pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin: 10px 0;
    /* 补 265: pre 默认 white-space: pre (不换行) — 改成 pre-wrap 让长代码自动换行
       根因: LLM 输出的长代码行/长 URL 在 <pre> 里被横向滚动 (overflow-x:auto), 用户看不到完整内容
       修法: white-space: pre-wrap 保留缩进但允许自然换行, 配合 word-break: break-word 处理长单词/URL */
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.chat-md-host pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

.chat-md-host code {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 13px;
}

.chat-md-host blockquote {
    border-left: 4px solid var(--primary);
    margin: 10px 0;
    padding: 6px 14px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.6;
}

.chat-md-host ul,
.chat-md-host ol {
    padding-left: 24px;
    margin: 8px 0;
}

.chat-md-host li {
    margin: 6px 0;
}

/* 块级元素统一间距（对齐/分层一致）: 相邻块之间至少 0.6em */
.chat-md-host > * + * {
    margin-top: 0.6em;
}

/* 提示框（:::tip / :::info / :::warning）: 左色条 + 浅底色 = 重点内容强调
   （此前 .callout 无任何样式，提示框渲染为纯文本，无强调效果） */
.chat-md-host .callout {
    margin: 12px 0;
    padding: 10px 14px;
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--bg-secondary);
    line-height: 1.7;
}
.chat-md-host .callout-title {
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text-primary);
}
.chat-md-host .callout > :first-child { margin-top: 0; }
.chat-md-host .callout > :last-child { margin-bottom: 0; }
.chat-md-host .callout p { margin: 6px 0; }
.chat-md-host .callout ul,
.chat-md-host .callout ol { margin: 6px 0; }
.chat-md-host .callout-tip { border-left-color: #10b981; background: rgba(16, 185, 129, 0.10); }
/* tip（如"核心结论"）: 保留冷色底，标题改暖色 → 冷底暖字对比清晰（原先冷底冷字看不清） */
.chat-md-host .callout-tip .callout-title { color: #c2410c; }
.chat-md-host .callout-info { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.10); }
.chat-md-host .callout-info .callout-title { color: #2563eb; }
.chat-md-host .callout-warning { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.chat-md-host .callout-warning .callout-title { color: #b45309; }
.dark-theme .chat-md-host .callout-tip .callout-title { color: #fdba74; }
.dark-theme .chat-md-host .callout-info .callout-title { color: #60a5fa; }
.dark-theme .chat-md-host .callout-warning .callout-title { color: #fbbf24; }

.chat-md-host table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 13px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.chat-md-host th,
.chat-md-host td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    line-height: 1.5;
}

.chat-md-host th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.chat-md-host hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

.chat-md-host a {
    color: var(--primary);
    text-decoration: none;
}

.chat-md-host a:hover {
    text-decoration: underline;
}

/* D11.10.151-补 105 fix24: LaTeX 公式块状显示 — 块级公式居中换行，行内公式不换行 */
.chat-md-host .math-display {
    display: block;
    text-align: center;
    margin: 0.8em 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
}

.chat-md-host .math-inline {
    display: inline-block;
    vertical-align: middle;
}

/* D11.10.151-补 152 + 补 159 + 补 160: KaTeX 公式字号微调
   补 152 设 1.25em (比正文略大, 公式符号清晰) — 用户反馈"有点大"
   补 159 试 1.15em — 用户反馈"再大一点"
   补 160 定 1.2em — 正文 120%, 比正文略大且紧凑, 视觉权重平衡 */
.chat-md-host .katex {
    font-size: 1.2em !important;
    line-height: 1.2;
}

.chat-md-host .katex-display {
    margin: 0.5em 0;
    font-size: 1.2em !important;
}

/* 公式字号兜底: 不被父级 p 字号影响 */
.chat-md-host p .katex,
.chat-md-host li .katex {
    font-size: 1.2em !important;
}

/* D11.10.151-补 105 fix28: 图号徽章 — 智能问答回答中的 "图5-26" 等图号引用
   点击徽章滚动到本消息内的图片卡片区域 */
.chat-md-host .img-ref-badge {
    display: inline-block;
    padding: 0 4px;
    margin: 0 1px;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--primary, #00a8a8);
    background: var(--primary-bg, rgba(0, 168, 168, 0.08));
    border: 1px solid var(--primary-bg-strong, rgba(0, 168, 168, 0.15));
    border-radius: var(--radius-xs, 4px);
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s ease);
    vertical-align: baseline;
    user-select: none;
}
.chat-md-host .img-ref-badge:hover {
    background: var(--primary, #00a8a8);
    color: #fff;
    border-color: var(--primary, #00a8a8);
}
.chat-md-host .img-ref-badge:active {
    transform: scale(0.96);
}

.chat-sources {
    margin: 8px -56px -10px -14px;
    padding: 6px 14px 10px 14px;
    border-top: 1px solid var(--border);
}

.chat-sources-thumbs {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.chat-source-thumb {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.15s;
}

.chat-source-thumb:hover {
    background: var(--bg-tertiary);
}

.chat-thumb-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
    opacity: 0.7;
}

.chat-thumb-icon svg {
    width: 100%;
    height: 100%;
}

.chat-thumb-name {
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.chat-sources-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.chat-sources-toggle:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    opacity: 1;
}

.chat-sources-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

.chat-sources-toggle.expanded svg {
    transform: rotate(90deg);
}

.chat-sources-items {
    margin-top: 4px;
}

.chat-source-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-xs);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.chat-source-item:hover {
    background: var(--bg-tertiary);
}

.chat-source-item:last-child {
    border-bottom: none;
}

.chat-source-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.chat-source-size {
    color: var(--text-tertiary);
    font-size: 13px;
    flex-shrink: 0;
}

.chat-source-chunks-badge {
    display: inline-block;
    padding: 1px 6px;
    margin-left: 4px;
    background: var(--primary-light, #e8f0fe);
    color: var(--primary, #1a73e8);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
}

/* =====================================================================
   D11.10.78: 标题栏左侧"参考文件"卡片 (方案生成/设计辅助/自控编程)
   复用 chat-sources 视觉, 但作为 inline 卡片插入到 header 内
   - .plc-sources-header-card: 卡片容器 (relative 定位, 容纳 absolute 子菜单)
   - .plc-sources-header-toggle: 紧凑型 toggle 按钮 (header 内显示, 不撑高)
   - .plc-sources-header-items: absolute 浮层 (默认 hidden, 点击展开)
   - .plc-sources-header-item: 单个文件行
   ===================================================================== */
.plc-sources-header-card {
    position: relative;
    flex: 0 0 auto;
    /* 覆盖 .chat-sources 继承的 border-top/margin/padding (chat-sources 是全宽卡片样式, 不适合 header 内联) */
    border-top: none !important;
    margin: 0 !important;
    padding: 0 !important;
}
.plc-sources-header-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    background: var(--bg-elevated, #fff);
    color: var(--text-secondary);
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.plc-sources-header-toggle:hover {
    background: var(--primary-light, #e8f0fe);
    color: var(--primary, #1a73e8);
    border-color: var(--primary, #1a73e8);
}
.plc-sources-header-toggle.expanded {
    background: var(--primary-light, #e8f0fe);
    color: var(--primary, #1a73e8);
    border-color: var(--primary, #1a73e8);
}
.plc-sources-header-toggle svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}
.plc-sources-header-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.plc-sources-header-items {
    margin-top: 4px;
}
.plc-sources-header-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}
.plc-sources-header-item:hover {
    background: var(--bg-hover, #f5f5f5);
}
.plc-sources-header-item:last-child {
    border-bottom: none;
}

/* =====================================================================
   E2.5 阶段5: 内联图片卡片(相关图片) + 全屏预览模态框
   渲染入口: app-shared.js renderImages / openImagePreview
   ===================================================================== */
.chat-images-inline {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 12px 0 6px 0;
    padding: 4px 0;
}

.chat-image-card-inline {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.chat-image-card-inline:hover {
    border-color: var(--primary, #1a73e8);
    box-shadow: 0 4px 16px rgba(26, 115, 232, 0.12);
}

.chat-image-thumb-inline {
    position: relative;
    width: 100%;
    background: var(--bg-tertiary, #f3f4f6);
    overflow: visible;
    cursor: zoom-in;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 0;
}

.chat-image-thumb-inline img {
    max-width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.chat-image-card-inline:hover .chat-image-thumb-inline img {
    transform: scale(1.02);
}

.chat-image-page-inline {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    border-radius: 10px;
    font-weight: 500;
    line-height: 1.5;
    backdrop-filter: blur(4px);
}

.chat-image-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0);
    opacity: 0;
    transition: all 0.2s ease;
}

.chat-image-card-inline:hover .chat-image-overlay {
    background: rgba(0, 0, 0, 0.35);
    opacity: 1;
}

.chat-image-btn-preview,
.chat-image-btn-dl {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
}

.chat-image-btn-preview:hover,
.chat-image-btn-dl:hover {
    background: #fff;
    color: var(--primary, #1a73e8);
    transform: scale(1.08);
}

.chat-image-meta-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 7px 8px;
    border-top: 1px solid var(--border, #f0f0f0);
}

.chat-image-type-badge {
    flex-shrink: 0;
    padding: 1px 6px;
    font-size: 11px;
    background: var(--bg-tertiary, #f3f4f6);
    color: var(--text-secondary, #6b7280);
    border-radius: 4px;
    font-weight: 500;
}

.chat-image-caption-inline {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary, #4b5563);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- 全屏预览模态框 ---- */
.image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: image-modal-fade-in 0.18s ease-out;
    overflow: hidden;
}

@keyframes image-modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.image-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    box-sizing: border-box;
}

.image-modal-topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    flex-shrink: 0;
}

.image-modal-nav-placeholder {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.image-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
    flex-shrink: 0;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.image-modal-nav {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
    z-index: 2;
    flex-shrink: 0;
}

.image-modal-nav:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.6);
}

.image-modal-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.image-modal-stage {
    flex: 1;
    width: 100%;
    max-width: 96vw;
    max-height: calc(92vh - 140px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-sm, 6px);
    background: transparent;
    user-select: none;
}

.image-modal-stage.panning {
    cursor: grabbing;
}

.image-modal-stage:not(.panning):not(.zoomed) {
    cursor: zoom-in;
}

.image-modal-stage.zoomed {
    cursor: grab;
}

.image-modal-img {
    max-width: 96vw;
    max-height: calc(92vh - 140px);
    object-fit: contain;
    display: block;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-sm, 6px);
    transform-origin: center center;
    transition: transform 0.15s ease-out;
    will-change: transform;
}

.image-modal-img.dragging {
    transition: none;
}

.image-modal-zoom-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    z-index: 5;
}

.image-modal-zoom-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
}

.image-modal-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.image-modal-zoom-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.image-modal-zoom-level {
    min-width: 48px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-family: Consolas, Monaco, monospace;
    padding: 0 4px;
}

.image-modal-toolbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 4px 0 4px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    flex-shrink: 0;
}

.image-modal-caption {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.image-modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.image-modal-counter {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.image-modal-download {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}

.image-modal-download:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
}

.image-modal-download svg {
    width: 14px;
    height: 14px;
}

/* 响应式: 窄屏调整 */
@media (max-width: 640px) {
    .image-modal-topbar { gap: 12px; }
    .chat-image-card { flex-basis: 110px; width: 110px; }
    .chat-image-thumb-wrap { height: 74px; }
    .image-modal-zoom-controls { bottom: 8px; right: 8px; }
}

.chat-source-chunks {
    /* D11.10.151-补 105 fix28: 在 flex 父容器内强制换行, 让片段列表落到文件名下方 */
    width: 100%;
    flex-basis: 100%;
    margin: 4px 0 8px 12px;
    padding: 6px 8px;
    background: var(--bg-tertiary, #f6f8fa);
    border-left: 2px solid var(--primary, #1a73e8);
    border-radius: 0 var(--radius-xs, 4px) var(--radius-xs, 4px) 0;
}

.chat-source-chunk {
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px dashed var(--border-color, #e0e0e0);
}

.chat-source-chunk:last-child {
    border-bottom: none;
}

.chat-source-chunk-meta {
    color: var(--text-tertiary, #666);
    font-size: 11px;
    margin-bottom: 3px;
    font-weight: 500;
}

.chat-source-chunk-snippet {
    color: var(--text-secondary, #444);
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-copy-btn {
    position: absolute;
    top: 6px;
    right: 10px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-message.assistant:hover .chat-copy-btn {
    opacity: 0.95;
}

.chat-copy-btn:hover {
    background: var(--bg-primary);
    color: var(--primary);
    opacity: 1 !important;
}

.chat-copy-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

.chat-sources-list {
    margin-top: 4px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
}

.dark-theme .chat-sources-list {
    background: #252639;
}

.welcome-message {
    padding: 6px 14px;
    text-align: left;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.dark-theme .welcome-message {
    color: var(--text-secondary);
}

.chat-loading-text {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 14px;
    color: var(--text-secondary);
}

.loading-label {
    display: inline-block;
    font-weight: 500;
}

.loading-label.label-think {
    color: var(--primary);
}

.loading-label.label-search {
    color: var(--warning);
}

.loading-dots {
    display: inline-flex;
    align-items: center;
}

.loading-dots span {
    animation: dot-pulse 1.4s ease-in-out infinite;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: inherit;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

.page-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0 var(--container-padding);
    background: var(--bg-secondary);
    box-sizing: border-box;
    max-width: var(--container-max-width);
    margin: 0 auto;
    width: 100%;
}

.page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

.content-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.content-card-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.content-card-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}

.content-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--item-spacing);
    flex-shrink: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--component-spacing);
    width: 100%;
}

.form-group-full {
    grid-column: 1 / -1;
}

.button-group {
    display: flex;
    align-items: center;
    gap: var(--item-spacing);
    flex-wrap: wrap;
}

.button-group-right {
    justify-content: flex-end;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--item-spacing);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: var(--item-spacing);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 var(--item-spacing);
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--component-spacing);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.action-bar {
    display: flex;
    align-items: center;
    gap: var(--item-spacing);
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.info-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 80px;
    font-weight: 500;
}

.info-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--component-spacing);
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

/* ===== 暗色主题组件级覆盖（CSS变量已在 dark-theme.css 中统一覆盖）===== */

.dark-theme .file-tree-file.selected {
    background: var(--primary-bg-strong);
}

.dark-theme .file-card.selected {
    background: var(--primary-bg);
}

.dark-theme .app-tab.active {
    background: var(--primary);
    color: var(--bg-primary);
}

.dark-theme .app-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dark-theme .form-input:focus,
.dark-theme .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg-strong);
}

.dark-theme #chatInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg-strong);
}

.dark-theme .spinner {
    border-color: var(--border);
    border-top-color: var(--primary);
}

.dark-theme .optimization-hint {
    background: var(--primary-bg);
}

.dark-theme .sheet-tab.active {
    background: var(--bg-primary);
    color: var(--primary);
    border-bottom-color: var(--bg-primary);
}

/* ===== 硬编码颜色暗色模式覆盖 ===== */

.dark-theme .chat-message.assistant .message-content {
    background: #252639;
    color: var(--text-primary);
    border-left: 3px solid var(--primary-hover);
}

.dark-theme .chat-message.user .message-content {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-dark));
    color: #e0f7f7;
}

.dark-theme .chat-message.assistant .chat-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dark-theme .chat-message.user .chat-bubble {
    background: var(--primary-dark);
    color: #e0f7f7;
}

.dark-theme .parse-pending {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border);
}

.dark-theme .parse-pending:hover {
    background: #3b3f57;
}

.dark-theme .parse-parsing {
    background: #1e3a5f;
    color: #89b4fa;
    border-color: var(--border);
}

.dark-theme .parse-parsing:hover {
    background: #2a4a70;
}

.dark-theme .parse-done {
    background: #1a3a2a;
    color: #a6e3a1;
    border-color: var(--border);
}

.dark-theme .parse-done:hover {
    background: #234a34;
}

.dark-theme .meta-row .ps-badge.parse-pending {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border);
}

.dark-theme .meta-row .ps-badge.parse-done {
    background: #1a3a2a;
    color: #a6e3a1;
    border-color: var(--border);
}

.dark-theme .meta-row .ps-badge.parse-parsing {
    background: #1e3a5f;
    color: #89b4fa;
    border-color: var(--border);
}

.dark-theme .design-card-icon {
    color: var(--text-primary);
}

.dark-theme .toggle-checkmark::after {
    background: var(--text-primary);
}

.dark-theme .preview-overlay {
    background: rgba(0, 0, 0, 0.85);
}

.dark-theme .preview-close {
    background: rgba(60, 60, 80, 0.8);
    color: var(--text-primary);
}

.dark-theme .user-menu-trigger:hover {
    box-shadow: var(--shadow-sm);
}

.dark-theme .dropdown-item:hover,
.dark-theme .context-menu-item:hover {
    background: var(--bg-tertiary) !important;
}

.dark-theme .chat-copy-btn.copied {
    color: #a6e3a1;
    border-color: #a6e3a1;
}

.dark-theme .loading-label.label-search {
    color: #f9e07a;
}

.dark-theme .chat-sources-list {
    background: #252639;
    box-shadow: var(--shadow-md);
}

.dark-theme .chat-sources-toggle {
    border-color: var(--border);
}

.dark-theme .chat-copy-btn:hover {
    background: var(--bg-tertiary);
}

.dark-theme .chat-sources-toggle:hover {
    background: var(--bg-tertiary);
}

.dark-theme .chat-source-chunks {
    background: rgba(255, 255, 255, 0.04);
}

.dark-theme .chat-source-chunks-badge {
    background: rgba(26, 115, 232, 0.18);
    color: #7cb1ff;
}

.dark-theme .chat-source-chunk {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.dark-theme .chat-source-chunk-snippet {
    color: var(--text-secondary, #b0b0b0);
}

.dark-theme .btn-danger:hover {
    background: var(--danger);
}

.dark-theme .btn-warning {
    background: var(--warning);
}

.dark-theme .btn-warning:hover {
    background: var(--warning);
}

.dark-theme .btn-success:hover {
    background: var(--success);
}

.dark-theme .chat-input-container {
    background: var(--bg-secondary);
    border-top-color: var(--border);
}

.dark-theme .proposal-section {
    background: transparent;
}

.dark-theme .design-section {
    background: transparent;
}

.dark-theme .chat-section {
    background: transparent;
}

.dark-theme .files-section {
    background: transparent;
}

.dark-theme .plc-section {
    background: transparent;
}

.dark-theme .monitor-section {
    background: transparent;
}

.dark-theme .quote-section {
    background: transparent;
}

.dark-theme .office-section {
    background: transparent;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-normal);
    background: transparent;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.theme-toggle .sun-icon {
    display: none;
}

.theme-toggle .moon-icon {
    display: block;
}

.dark-theme .theme-toggle .sun-icon {
    display: block;
}

.dark-theme .theme-toggle .moon-icon {
    display: none;
}

.user-dropdown {
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.user-dropdown[style*="display: block"],
.user-dropdown[style*="display:block"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dropdown-item:hover, .context-menu-item:hover {
    background: var(--bg-tertiary) !important;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-state svg {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0 0 10px;
    font-weight: 600;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
}

.btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    padding: 9px 18px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 9px 18px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-tertiary);
}

.btn-active {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
    box-shadow: var(--shadow-sm);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.25);
}

.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.btn-warning:hover {
    background: var(--warning);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.25);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: var(--success);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}

.parse-pending {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
    font-size: 13px;
    padding: 2px 8px;
    border-radius: var(--radius);
    cursor: pointer;
}
.parse-pending:hover {
    background: #e2e8f0;
}
.parse-parsing {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    font-size: 13px;
    padding: 2px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    animation: pulse-border 1.5s ease-in-out infinite;
}
.parse-parsing:hover {
    background: #bfdbfe;
}
.parse-done {
    background: #dcfce7;
    color: var(--success);
    border: 1px solid #86efac;
    font-size: 13px;
    padding: 2px 8px;
    border-radius: var(--radius);
    cursor: pointer;
}
.parse-done:hover {
    background: #bbf7d0;
}

/* 元信息行解析状态标签 */
.meta-row .ps-badge {
    display: inline-block;
    font-size: 13px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    line-height: 1.4;
    cursor: default;
}
.meta-row .ps-badge.parse-pending {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
}
.meta-row .ps-badge.parse-done {
    background: #dcfce7;
    color: var(--success);
    border: 1px solid #86efac;
}
.meta-row .ps-badge.parse-parsing {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}
/* 2026-06-08 E2.0 解析字符数注解（已解析文件显示总字符数） */
.meta-row .chars-badge {
    display: inline-block;
    font-size: 13px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}
.dark-theme .meta-row .chars-badge {
    background: rgba(125, 211, 252, 0.12);
    color: #7dd3fc;
    border-color: rgba(125, 211, 252, 0.35);
}

/* 2026-06-08 E2.0 文件归类 chip：放在 meta-row 最前面
   用紫色系与 chars-badge（蓝）区分，颜色与 vision-badge 一脉相承 */
.meta-row .cat-badge {
    display: inline-block;
    font-size: 13px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #c4b5fd;
}
.dark-theme .meta-row .cat-badge {
    background: rgba(196, 181, 253, 0.14);
    color: #c4b5fd;
    border-color: rgba(196, 181, 253, 0.38);
}
@keyframes pulse-border {
    0%, 100% { border-color: #93c5fd; }
    50% { border-color: #3b82f6; }
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: #059669;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 200px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

#chatInput {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 15px;
    padding: 12px 16px;
    font-family: var(--font-body);
    resize: none;
    max-height: 150px;
    outline: none;
    transition: all var(--transition-normal);
    box-sizing: border-box;
    line-height: 1.6;
}

#chatInput:hover {
    border-color: var(--text-tertiary);
}

#chatInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg);
}

#chatInput::placeholder {
    color: var(--text-muted);
}

.proposal-section {
    width: 100%;
    max-width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.proposal-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: 1750px;
    width: 100%;
    margin: 0 auto;
}

.proposal-tabs {
    padding: 12px 16px 0;
    border-bottom: 2px solid var(--border);
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.design-section {
    width: 100%;
    max-width: 100%;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.design-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: 1750px;
    width: 100%;
    margin: 0 auto;
}

.design-tabs {
    padding: 12px 16px 0;
    border-bottom: 2px solid var(--border);
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.design-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.design-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.design-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.design-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 8px 14px 0;
}

.design-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
}

.design-card-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.design-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.design-card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 1px 0 0;
}

.design-card-tags {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    flex: 1;
    justify-content: center;
}

.design-card-tags span {
    display: inline-block;
    padding: 1px 6px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.design-card-link {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
    flex-shrink: 0;
    transition: all 0.15s;
}

.design-card-link:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.design-card-desc {
    padding: 0 14px 10px;
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.design-code-area {
    padding: 8px 14px;
}

.design-code-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.design-code-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin: 4px 0;
}

.design-code-output {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    min-height: 60px;
    max-height: 200px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.quote-section {
    width: 100%;
    max-width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
    min-height: 0;
}

.quote-section .quote-tabs {
    display: flex;
    gap: 0;
    padding: 2px 16px 0;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
    background: transparent;
}

.quote-section .quote-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.quote-section .quote-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.quote-section .quote-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.quote-section .quote-panel {
    display: none;
    width: 100%;
    height: 100%;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.quote-section .quote-panel.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition-normal);
    box-sizing: border-box;
}

.form-input:hover,
.form-textarea:hover {
    border-color: var(--text-tertiary);
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.plc-section {
    width: 100%;
    max-width: 100%;
    background: transparent;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.plc-intro {
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.plc-tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
    margin-bottom: 6px;
    background: transparent;
}

.plc-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.plc-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.plc-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
    font-weight: 600;
}

.plc-code-input:focus {
    border-color: var(--primary);
}

.plc-code-toggle-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: all 0.15s;
    user-select: none;
    white-space: nowrap;
    min-height: 28px;
}

.clean-comment-btn {
    padding: 8px 16px !important;
    font-weight: 500;
}

.plc-code-toggle-switch:hover {
    border-color: var(--text-tertiary);
    color: var(--text-primary);
}

.plc-code-toggle-switch .toggle-checkmark {
    display: none;
}

.plc-code-toggle-switch .toggle-label {
    font-size: 13px;
    color: inherit;
    line-height: 1.3;
}

.plc-code-toggle-switch:has(input:checked) {
    background: #00888A;
    border-color: #00888A;
    color: #fff;
}

.dark-theme .plc-code-toggle-switch:has(input:checked) {
    background: #00888A;
    border-color: #00888A;
    color: #fff;
}

.plc-code-toggle-switch input[type="checkbox"] {
    display: none;
}

.plc-code-output {
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    white-space: pre-wrap;
    overflow-y: auto;
    box-sizing: border-box;
    margin: 0;
}

.plc-code-content {
    font-family: var(--font-mono) !important;
    margin: 0;
    padding: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* D11.10.151-补 115: plc 右侧"代码说明"输出区
   父容器 .plc-code-output-body 用了等宽字体 + pre-wrap + break-all (适合代码显示),
   但右侧是 markdown 渲染的文档, 需要正常字体 + 自动换行, 与 chat-md-host 兼容。
   覆盖规则仅作用于加 .plc-doc-output class 的元素 (即 plc 右侧 4 个). */
.plc-doc-output {
    font-family: inherit;
    font-size: 14px;
    line-height: 1.7;
    white-space: normal;
    word-break: normal;
}
.plc-doc-output .plc-code-content {
    /* 代码块仍保留等宽字体 + pre-wrap, 跟左侧代码块视觉一致 */
    font-family: var(--font-mono) !important;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin: 10px 0;
}

.plc-code-output .plc-code-placeholder {
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.plc-code-output-body {
    flex: 1;
    min-height: 0;
    padding: 14px 16px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
    box-sizing: border-box;
}

.plc-code-output-body .plc-code-placeholder {
    color: var(--text-tertiary);
    font-family: var(--font-body, inherit);
    font-style: italic;
}

.design-doc-content {
    font-family: var(--font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    font-size: 14px;
    line-height: 1.75;
    color: var(--text-primary);
    padding: 0;
}

.design-doc-content h2 {
    font-size: 15px;
    font-weight: 700;
    margin: 14px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.design-doc-content h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0 4px;
    color: var(--text-primary);
}

.design-doc-content h4 {
    font-size: 13px;
    font-weight: 600;
    margin: 8px 0 3px;
    color: var(--text-secondary);
}

.design-doc-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.design-doc-content ul {
    margin: 3px 0;
    padding-left: 20px;
}

.design-doc-content li {
    margin: 1px 0;
    line-height: 1.55;
}

.design-doc-content pre.plc-code-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin: 10px 0;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.design-doc-content br {
    display: block;
    content: '';
    margin-top: 2px;
}

.design-doc-content table.design-doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
}

.design-doc-content table.design-doc-table th,
.design-doc-content table.design-doc-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
    white-space: nowrap;
}

.design-doc-content table.design-doc-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.design-doc-content table.design-doc-table td {
    background: var(--bg-primary);
}

.design-doc-content code {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.design-doc-content ol {
    margin: 3px 0;
    padding-left: 20px;
}

.design-doc-content hr.design-doc-hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

.plc-code-btn,
.plc-code-copy-btn {
    font-family: inherit;
}

.monitor-section {
    width: 100%;
    max-width: 100%;
    background: transparent;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.monitor-tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
    margin-bottom: 6px;
    background: transparent;
}

.monitor-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.monitor-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.monitor-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
    font-weight: 600;
}

.monitor-mode-toggle {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    flex-shrink: 0;
}

.monitor-mode-toggle .mode-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.monitor-mode-toggle .mode-btn:hover {
    background: var(--bg-tertiary);
}

.monitor-mode-toggle .mode-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    font-weight: 600;
}

.monitor-iframe-error .error-action {
    font-family: inherit;
}

@media (max-width: 768px) {
    .header-content {
        padding: 8px 12px;
    }
    .logo-text {
        display: none;
    }
    .app-tabs {
        flex-direction: column;
    }
    .main {
        padding: 16px;
    }
    .search-container {
        padding: 8px 10px;
    }
    .file-grid {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .chat-section {
        height: calc(100vh - 250px);
    }
    .plc-section { min-height: calc(100vh - 180px); }
    .design-section { min-height: calc(100vh - 180px); }
    .plc-tabs { gap: 2px; }
    .monitor-card-grid { grid-template-columns: 1fr; }
    .monitor-mode-toggle { flex-wrap: wrap; gap: 8px; }
}

.highlight {
    background: #fef3c7;
    padding: 2px 4px;
    border-radius: var(--radius-xs);
}

/* PLC / Design 卡片面板 */
.plc-panel {
    display: none;
}

.plc-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.plc-card-grid {
    padding: 8px 16px 4px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    flex-shrink: 0;
}

.plc-platform-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
}

.card-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.card-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.card-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    margin: 1px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.card-features {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.feature-tag {
    display: inline-block;
    padding: 1px 6px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.card-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.card-btn:hover {
    background: var(--bg-tertiary);
}

.card-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.card-btn.primary:hover {
    background: var(--primary-hover);
}

.card-desc {
    padding: 0 14px 10px;
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.card-desc-inline {
    font-size: 12px;
    color: var(--text-secondary);
    width: 100%;
    margin-top: -4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
}
.plc-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 代码生成区域 */
.plc-code-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 16px;
    min-height: 0;
    position: relative; /* 补 220.58i: 为历史下拉框悬浮 absolute 定位提供锚点 */
}

.plc-code-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.plc-code-input {
    width: 100%;
    min-height: 48px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    resize: vertical;
    box-sizing: border-box;
    line-height: 1.4;
}

.plc-code-input-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

/* 补 220.58c: 设计辅助面板历史 toggle 按钮 pill 样式
   补 220.58n: 去掉 height:fit-content, 让 align-items:stretch 生效, toggle 高度跟随 textarea */
.plc-code-input-row .codegen-chat-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    height: auto;
}
.plc-code-input-row .codegen-chat-toggle:hover {
    border-color: var(--accent);
}
.plc-code-input-row .codegen-chat-toggle .arrow {
    font-size: 10px;
    transition: transform 0.15s;
}
.plc-code-input-row .codegen-chat-toggle.expanded .arrow {
    transform: rotate(90deg);
}
.plc-code-input-row .codegen-chat-toggle .codegen-chat-count {
    font-size: 11px;
    opacity: 0.7;
}
/* design-lang-select 基础样式 (与 select 同视觉) */
.plc-code-input-row .design-lang-select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
}

/* 补 220.58l+58n+58o: 非 textimage 面板语言选择+历史垂直组
   关键: langGroup 作为 flex column 子项, align-items:stretch 让它拉到 row 高度;
   select/toggle 用 height:100% 各占一半 */
.plc-code-input-row .design-lang-group {
    display: flex;
    flex-direction: column;
    gap: 0px;
    flex-shrink: 0;
    align-items: stretch;
    min-width: 72px;
    height: 100%;
}
.plc-code-input-row .design-lang-group .design-lang-select {
    flex: 1;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
    min-height: 0;
    height: 100%;
}
.plc-code-input-row .design-lang-group .codegen-chat-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0px 6px;
    font-size: 10px;
    cursor: pointer;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    height: 100%;
}
.design-lang-group .codegen-chat-toggle:hover {
    border-color: var(--accent);
}
.design-lang-group .codegen-chat-toggle .arrow {
    font-size: 9px;
    transition: transform 0.15s;
}
.design-lang-group .codegen-chat-toggle.expanded .arrow {
    transform: rotate(90deg);
}
.design-lang-group .codegen-chat-toggle .codegen-chat-count {
    font-size: 10px;
    opacity: 0.7;
}

/* 补 220.58i: 历史下拉框展开时悬浮叠加, 不挤压下方输出区 */
.codegen-chat-list-wrap.chat-overlay {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 100;
    margin-top: 0;
    border-radius: 0 0 var(--radius-sm, 6px) var(--radius-sm, 6px);
    max-height: 240px;
}

.plc-code-input-row .plc-code-input {
    flex: 1;
    min-height: 48px;
}

.plc-code-input-row .plc-code-actions {
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    margin: 0;
    position: relative;
}

.plc-code-input-row .plc-code-actions .plc-code-btn {
    flex: 1;
}

.plc-code-input-row .plc-code-actions .plc-code-toggle-switch {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
}

.plc-code-actions {
    display: flex;
    gap: 8px;
    margin: 4px 0;
}

.plc-code-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.plc-code-btn:hover {
    background: var(--bg-tertiary);
}

.plc-code-btn.primary {
    background: var(--primary);
    color: white;
    border: none;
}

.plc-code-btn.primary:hover {
    background: var(--primary-hover);
}

.plc-code-btn.primary:active {
    opacity: .9;
}

/* 补 190: 导入打开 按钮 (次要操作) */
.plc-code-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.plc-code-btn.secondary:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
/* 补 191: 启动中 spinner 旋转 */
svg.spin {
    animation: spin 0.6s linear infinite;
}

/* ============================================================
   补 191: 导入打开 错误引导 modal
   ============================================================ */
.launch-modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: launchModalFadeIn 0.2s ease-out;
}
@keyframes launchModalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.launch-modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: min(560px, 92vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: launchModalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes launchModalPop {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.launch-modal-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}
.launch-modal-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
}
.launch-modal-error .launch-modal-icon   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.launch-modal-warn  .launch-modal-icon   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.launch-modal-info  .launch-modal-icon   { background: linear-gradient(135deg, #10b981, #059669); }
.launch-modal-title { flex: 1; min-width: 0; }
.launch-modal-tool  { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.launch-modal-tool .launch-modal-code {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 1px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    margin-left: 6px;
}
.launch-modal-msg   { font-size: 15px; font-weight: 600; color: var(--text-primary); line-height: 1.5; word-break: break-word; }
.launch-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.launch-modal-close:hover { color: var(--text-primary); }
.launch-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.launch-modal-runmsg {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--primary);
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 12px;
}
.launch-modal-section { margin-top: 8px; }
.launch-modal-section-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}
.launch-modal-steps {
    margin: 0;
    padding-left: 22px;
    color: var(--text-primary);
    font-size: 13.5px;
    line-height: 1.75;
}
.launch-modal-steps li {
    margin-bottom: 4px;
    word-break: break-word;
}
.launch-modal-detail {
    margin-top: 12px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 12px;
}
.launch-modal-detail summary {
    cursor: pointer;
    color: var(--text-secondary);
    user-select: none;
}
.launch-modal-detail pre {
    margin: 8px 0 0;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11.5px;
    max-height: 200px;
    overflow-y: auto;
}
.launch-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg-primary);
}
.launch-modal-copy-btn,
.launch-modal-ok-btn {
    padding: 7px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}
.launch-modal-copy-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.launch-modal-ok-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.launch-modal-ok-btn.primary:hover {
    opacity: 0.9;
}

.plc-code-lang-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.plc-code-lang-tabs .plc-code-toggle-switch {
    margin-left: auto;
}

.plc-lang-tab {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}

.plc-lang-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.plc-lang-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.plc-code-output-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.plc-code-dual-output {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    min-height: 200px; margin-top: 4px;
    padding: 0 16px;
    flex: 1;
    min-height: 0;
}

.plc-code-dual-output > .plc-code-output-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 200px;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.plc-code-output-timer {
    font-size: 13px;
    color: var(--text-tertiary);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}


.plc-code-output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    position: relative;
}

.plc-code-output-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* D11.10.53 textimage 渲染结果阶段的提示词 (渲染结果 label 右侧) */
.plc-code-output-status {
    font-size: 12px;
    color: var(--text-tertiary);
    transition: color 0.3s;
    flex-shrink: 0;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plc-code-copy-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.ladder-mode-select {
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    outline: none;
    margin-left: auto;
    margin-right: 2px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.ladder-mode-select:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.ladder-svg-container {
    padding: 8px 14px;
    overflow: auto;
    min-height: 60px;
}

.ladder-svg-container svg {
    display: block;
}

.plc-code-copy-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.plc-code-copy-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

/* 补 220.22: textimage 编辑器右键 context menu */
.timg-context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 140px;
    background: var(--bg-elevated, #fff);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs, 4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
}
.timg-context-menu-item {
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
}
.timg-context-menu-item:hover {
    background: var(--bg-tertiary, #f1f5f9);
    color: var(--primary, #2563eb);
}
.timg-context-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
/* 补 220.22: textimage 编辑模式 — 让 SVG 子元素响应点击 */
.plc-svg-viewer-content.timg-edit-mode {
    cursor: default;
}
.plc-svg-viewer-content.timg-edit-mode svg line,
.plc-svg-viewer-content.timg-edit-mode svg polyline,
.plc-svg-viewer-content.timg-edit-mode svg path,
.plc-svg-viewer-content.timg-edit-mode svg text {
    cursor: pointer;
}
.plc-svg-viewer-content.timg-edit-mode svg .timg-edit-handle {
    cursor: pointer !important;
}

/* D11.10.49 textimage 渲染结果保存按钮的格式下拉菜单 */
.save-format-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 100;
    min-width: 88px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.save-format-menu button {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.12s;
}

.save-format-menu button:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

/* D11.10.51 textimage 渲染结果交互式查看 (滚轮缩放/左键拖/右键旋转)
   D11.10.54 让 SVG 撑满 viewer 宽度 (max-width: 100% 改为 width: 100%)
   D11.10.57 结果框扩展到页面底部 (去掉固定 max-height, viewer 填满 body)
   D11.10.61 viewer 背景透明
   D11.10.62 SVG 充满 viewer 整页: viewer-content 改 flex 占满, svg 元素
     width:100% height:100% 强制撑满; 内部 viewBox 按默认
     preserveAspectRatio="xMidYMid meet" 保持比例, viewer 透明背景让
     比例不一致时的空隙与页面背景一致, 视觉上既不留空也不溢出
   D11.10.65 强制全链透明: viewer/viewer-content/svg 三层都 !important 透明,
     兜底 AI 在 svg 根 inline style 写 background:#xxx 也覆盖不到的情况 */
.plc-svg-viewer {
    display: flex; align-items: center; justify-content: center;
    height: 100%; min-height: 400px;
    /* D11.10.61 viewer 背景改为透明: 让 SVG/页面自身背景透出,
       适应 light/dark theme, 不强制灰底. 之前 #fafafa 灰底在小屏/白底 SVG
       下会显得突兀, 现在 SVG 内容为空时直接显示页面背景, 一眼能区分"viewer 没东西".
       D11.10.65 !important 强制覆盖任何 inline style 兜底. */
    background: transparent !important;
    border-radius: 6px;
    overflow: hidden; position: relative;
    user-select: none; -webkit-user-select: none;
}

.plc-svg-viewer-content {
    /* D11.10.62 改为 flex 占满: 之前是 inline-block + max-width/max-height,
       SVG 元素只占 viewBox 比例大小, viewer 内会有大块空白. 现在
       width:100% + height:100% + flex 居中, SVG 元素强制撑满 viewer.
       D11.10.65 强制透明背景
       【Mermaid 放大模糊 fix】transform 已移到 <svg> 元素上,
       content 层只做 flex 居中容器, 不做任何 transform.
       去掉 will-change: transform 和 overflow: hidden, 避免栅格化. */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: transparent !important;
    cursor: grab;
}

.plc-svg-viewer-content:active {
    cursor: grabbing;
}

.plc-svg-viewer-content > svg {
    /* D11.10.62 SVG 充满整页: width:100% + height:100% 强制 SVG 元素占满
       viewer 区域; max-width/max-height 兜底避免溢出. SVG 内部 viewBox
       按默认 preserveAspectRatio="xMidYMid meet" 保持比例 + 居中,
       viewer 透明背景让比例不一致时的空隙与页面一致, 不留空.
       D11.10.65 !important 强制 svg 自身透明, 覆盖 AI 写在 svg 根上
       的 inline style="background:#fff/#eef..."
       【Mermaid 放大模糊 fix】transform-origin: center center ——
       transform 从父 div 移到 svg 自身, 需要 transform-origin 来让
       缩放和拖动以 SVG 中心为锚点 */
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
    background: transparent !important;
    pointer-events: auto;
    text-rendering: geometricPrecision;
    shape-rendering: geometricPrecision;
    transform-origin: center center;
}

/* Mermaid: 固定尺寸, 不随容器宽度拉伸 (useMaxWidth=false 后 viewBox 决定自然宽高) */
.plc-svg-viewer-content > svg.mermaid-svg {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
}

/* D11.10.65 父容器 (plc-code-output-body) 在 textimage 区域也强制透明,
   避免 plc-code-output 的 white (--bg-primary) 透出. 限定 #output-textimage-left
   是避免影响 AutoCAD/SolidWorks 等代码输出框的等宽字体白底. */
#output-textimage-left.plc-code-output-body,
#output-textimage-left.plc-code-output-body .plc-svg-viewer {
    background: transparent !important;
}

/* 行号代码展示 */
.code-line {
    display: flex;
    line-height: 1.6;
    font-size: 13px;
}

.code-line-number {
    display: inline-block;
    width: 40px;
    text-align: right;
    padding-right: 12px;
    color: var(--text-tertiary);
    user-select: none;
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.code-line-content {
    flex: 1;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: var(--font-mono);
}

/* 历史记录 */
.plc-history-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.plc-history-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    width: 100%;
    margin-bottom: 2px;
}

.plc-history-item {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.plc-history-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.plc-history-num {
    font-weight: 600;
    margin-right: 4px;
}

/* 打字动画 */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px !important;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingDot 1.2s ease-in-out infinite;
}

.chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* 暗色主题适配 */
.dark-theme .plc-platform-card {
    background: var(--bg-primary);
    border-color: var(--border);
}

.dark-theme .card-desc {
    color: var(--text-secondary);
}

.dark-theme .plc-code-output-header {
    background: var(--bg-tertiary);
}

/* D11.10.122: 左侧代码输出框去掉灰色背景, 与页面底色一致 */
.dark-theme .plc-code-output,
.dark-theme .plc-code-output-body {
    background: transparent;
}
.dark-theme .plc-code-output-header {
    background: transparent;
}

.dark-theme .plc-history-item {
    background: var(--bg-secondary);
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex: 1;
}

.chat-input-wrapper #chatInput {
    flex: 1;
}

.chat-input-wrapper #sendBtn {
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 0;
    flex-wrap: wrap;
}

.chat-actions #clearChatBtn {
    margin-left: auto;
}

.chat-websearch-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

.chat-websearch-toggle input[type="checkbox"] {
    display: none;
}

.toggle-checkmark {
    width: 36px;
    height: 20px;
    background: var(--border);
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-checkmark::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.chat-websearch-toggle input:checked + .toggle-checkmark {
    background: var(--primary);
}

.chat-websearch-toggle input:checked + .toggle-checkmark::after {
    transform: translateX(16px);
}

.plc-code-toggle-switch input:checked + .toggle-checkmark,
.plc-code-toggle-switch input:checked + .toggle-checkmark::after,
.dark-theme .plc-code-toggle-switch input:checked + .toggle-checkmark {
    display: none;
}

.toggle-label {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.3;
}

/* 询单报价容器 */
.quote-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 方案生成面板 */
.proposal-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.proposal-panel.active {
    display: flex;
}

.proposal-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.proposal-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.proposal-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* 监控面板 */
.monitor-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.monitor-panel.active {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex: 1;
    min-height: 0;
}

/* 文件夹选择�?*/
.folder-tree-item {
    transition: all 0.15s;
}

.folder-tree-item:hover {
    background: var(--bg-tertiary);
}

.folder-tree-item.selected {
    background: rgba(0, 168, 168, 0.08);
    color: var(--primary);
}

/* Websearch toggle */
#webSearchToggle .toggle-label,
#independentSearchToggleLabel .toggle-label {
    display: inline;
}

/* 来源详情 */
.source-item-detailed {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.source-item-detailed:hover {
    background: var(--bg-tertiary);
}

.source-icon {
    flex-shrink: 0;
    font-size: 20px;
}

.source-info {
    flex: 1;
    min-width: 0;
}

.source-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-meta {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.source-folder {
    font-size: 13px;
}

.chat-time {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 6px;
    text-align: right;
    opacity: 0.7;
}

/* 监控卡片网格 */
.monitor-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 16px;
}

/* 监控 iframe 错误 */
.monitor-iframe-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

/* PLC 暗色主题 */
.dark-theme .chat-typing span {
    background: var(--text-tertiary);
}

/* ===== 剩余缺失样式 ===== */

/* 用户菜单 */
.user-menu-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    background: transparent;
}

.user-menu-trigger:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.dark-theme .user-menu-trigger:hover {
    box-shadow: var(--shadow-sm);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

/* 下拉菜单 */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    padding: 4px;
    margin-top: 4px;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.dropdown-menu[style*="display: block"],
.dropdown-menu[style*="display:block"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s ease;
}

.dropdown-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

/* 管理员专�?*/
.admin-only {
    display: none;
}

/* ===== 文件管理标签页 ===== */
.files-tabs-bar {
    display: flex;
    gap: 0;
    padding: 6px 16px 0;
    border-bottom: 1px solid var(--border);
}

.files-tab-btn {
    padding: 8px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s ease;
}

.files-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.files-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.dark-theme .files-tab-btn.active {
    color: var(--primary-hover);
    border-bottom-color: var(--primary-hover);
}

/* 报价内容�?*/
.quote-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.quote-reload-btn {
    padding: 4px 10px;
    font-size: 13px;
    margin-left: auto;
}

/* 方案生成按钮 */
.generate-proposal-btn,
.clear-proposal-btn {
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.clear-proposal-btn {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.generate-proposal-btn:hover {
    background: var(--primary-hover);
}

.clear-proposal-btn:hover {
    background: var(--bg-tertiary);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* 方案表单 */
.proposal-project-name,
.proposal-requirements,
.proposal-technical-params,
.proposal-budget,
.proposal-timeline,
.proposal-status {
    width: 100%;
}

.propose-select-folder-btn {
    padding: 6px 12px;
    font-size: 13px;
}

.propose-selected-folders {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

/* 结果头部 */
.result-header {
    font-size: 14px;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

/* ONLYOFFICE */
.onlyoffice-editor-container {
    flex: 1;
    min-height: 0;
}

/* 监控面板卡片 */
.monitor-card-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.monitor-platform-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.monitor-iframe-container {
    flex: 1;
    position: relative;
    min-height: 400px;
}

.monitor-iframe-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 1;
}

.monitor-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* PLC/监控平台图标和标�?*/
.platform-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.mode-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* 状态指�?*/
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 面包屑路�?*/
.app-path {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 检测中 */
.checking {
    opacity: 0.5;
}

/* 监控平台图标颜色 */

/* 来源列表 */
.sources-list {
    margin-top: 8px;
}

.sources-list-detailed {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.sources-toggle-icon {
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chat-md-host strong {
    font-weight: 600;
}

.chat-md-host em {
    font-style: italic;
}

/* D11.10.151-补 161: 方案生成内容区加载占位 — 借鉴 chat 的三跳点 loading
   之前进度条只在顶部动, 内容区一直空白, 用户以为"卡住"
   现在内容区显示居中 loading, 跟 chat 体验一致
   复用 chat-loading-text + loading-dots (这两个类已有完整样式, 这里只做外层居中) */
.prop-stream-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 20px;
}
.prop-stream-loading .chat-loading-text {
    font-size: 14px;
}







/* ========== UI动画 (v2.0) ========== */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* 收藏按钮高亮 */
#showFavoritesBtn:hover {
    background: rgba(245, 158, 11, 0.1) !important;
    transform: scale(1.05);
}

/* 文件卡片收藏状态 */
.file-card.favorited {
    border-left: 3px solid var(--warning);
}

.file-card .favorite-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
}

.file-card .favorite-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

.file-card .favorited .favorite-icon {
    color: var(--warning);
    opacity: 1;
}

@keyframes upload-progress-shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

#uploadProgressBarInner,
#projectUploadProgressBarInner {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 20px 20px;
    animation: upload-progress-shimmer 1s linear infinite;
}

/* ========== 重新解析进度对话框 ========== */
.reparse-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.reparse-dialog {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 520px;
    padding: 24px;
    animation: reparseFadeIn 0.2s ease;
}

@keyframes reparseFadeIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.reparse-dialog h3 {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.reparse-status {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reparse-message {
    font-size: 14px;
    color: var(--text-primary);
    text-align: center;
    min-height: 20px;
    font-weight: 500;
}

.reparse-progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.reparse-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    border-radius: var(--radius-xs);
    transition: width 0.3s ease;
}

.reparse-stats {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.reparse-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.reparse-details span {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
}

.reparse-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.reparse-close-btn {
    padding: 8px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.reparse-close-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

/* Upload progress overlay (复用reparse模式) */
.upload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.upload-dialog {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    padding: 24px;
    animation: reparseFadeIn 0.2s ease;
}

.upload-dialog h3 {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.upload-file-name {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 12px;
    word-break: break-all;
    max-height: 36px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-status-text {
    font-size: 13px;
    color: var(--primary);
    text-align: center;
    margin-bottom: 10px;
    font-weight: 500;
}

.upload-progress-bar {
    height: 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-xs);
    overflow: hidden;
    margin-bottom: 8px;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #00d4d4);
    border-radius: 0;
    transition: width 0.3s ease;
}

.upload-stats {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-tertiary);
}

.upload-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

.upload-close-btn {
    padding: 8px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.upload-close-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
    color: var(--primary);
}

/* ========== 增强版上传弹窗 ========== */
.upload-dialog-enhanced {
    /* D11.10.151-补 24: 加大到 720px, 容纳 6 格 system-status-grid (双卡 GPU 0/1 拆 SM+显存) */
    max-width: 720px;
    padding: 28px;
}

/* 文件列表区域 */
.pd-files-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pd-file-item {
    transition: background 0.15s;
}
.pd-file-item:hover {
    background: var(--bg-tertiary) !important;
}

/* 阶段指示器 */
.upload-stages {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    gap: 4px;
}

.upload-stage-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    min-width: 60px;
}

.upload-stage-item.active {
    background: var(--primary);
    color: #fff;
}

.upload-stage-item.completed {
    opacity: 0.6;
}

.upload-stage-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.upload-stage-label {
    font-size: 12px;
    font-weight: 500;
}

.upload-stage-arrow {
    color: var(--text-tertiary);
    font-size: 14px;
    margin: 0 2px;
}

/* GPU 提示 */
.upload-gpu-hint {
    margin: 12px 0;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.1), rgba(0, 212, 170, 0.1));
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: var(--radius);
    font-size: 13px;
    color: #00ff88;
    text-align: center;
}

/* 解析工具网格 */
.upload-tool-info {
    margin: 16px 0;
}

.upload-tool-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.upload-tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.upload-tool-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    font-size: 12px;
}

.upload-tool-item .tool-icon {
    margin-right: 8px;
    font-size: 14px;
}

.upload-tool-item .tool-name {
    color: var(--text-secondary);
    flex: 1;
}

.upload-tool-item .tool-status {
    color: var(--success);
    font-weight: 500;
}

/* 当前工具提示 */
.upload-current-tool {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    text-align: center;
}

.tool-gpu-note {
    color: #00ff88;
    font-size: 12px;
}

/* 耗时统计 */
.upload-time-elapsed {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* 详细状态区域 */
.upload-detail-section {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.upload-detail-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-detail-content {
    font-size: 12px;
    color: var(--text-secondary);
}

.detail-item {
    display: flex;
    align-items: center;
    padding: 4px 0;
    gap: 8px;
}

.detail-icon {
    font-size: 14px;
}

/* 系统资源状态显示 */
.upload-system-status {
    margin: 16px 0;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.system-status-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.system-status-grid {
    display: grid;
    /* D11.10.151-补 24: 6 格统一风格 (CPU / 内存 / GPU0 SM / GPU0 显存 / GPU1 SM / GPU1 显存) */
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.system-resource-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    min-width: 0;
}

.system-resource-item .resource-icon {
    font-size: 18px;
    margin-bottom: 4px;
}

.system-resource-item .resource-name {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.system-resource-item .resource-value {
    font-size: 13px;
    font-weight: 600;
}

.upload-cancel-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: #ef4444;
    cursor: pointer;
    font-size: 14px;
}

.upload-cancel-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

.upload-cancel-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 统一解析弹窗 - 当前工具高亮 */
.upload-tool-item.pd-tool-active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(0, 212, 212, 0.1));
    border: 1px solid var(--primary);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}

.upload-tool-item.pd-tool-active .tool-name {
    color: var(--primary);
    font-weight: 600;
}

/* ===== 温度滑动条美化 ===== */
.temp-slider-row {
    transition: background 0.2s ease;
}

.temp-slider-row:hover {
    background: var(--surface-elevated, rgba(255, 255, 255, 0.08));
}

.temp-slider {
    -webkit-appearance: none !important;
    appearance: none !important;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 50%, var(--primary-dark) 100%) !important;
    border-radius: 3px !important;
    height: 6px !important;
    cursor: pointer;
    transition: opacity 0.2s;
}

.temp-slider:hover {
    opacity: 0.85;
}

.temp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.temp-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.temp-slider::-webkit-slider-thumb:active {
    transform: scale(1.1);
}

.temp-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.temp-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   ✨ 全局组件美化增强
   ============================================================ */

/* ========== 1. 按钮增强 ========== */
.btn {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-secondary) 100%);
    transition: all var(--transition-normal);
}

.btn:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--primary-bg) 100%);
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(0, 168, 168, 0.08);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-xs);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(0, 168, 168, 0.15);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
    pointer-events: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-dark) 100%);
    box-shadow: var(--shadow), 0 4px 16px rgba(0, 168, 168, 0.25);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(0, 168, 168, 0.15);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.btn-secondary:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--primary-bg) 100%);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    border: none;
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(239, 68, 68, 0.15);
}

.btn-danger:hover {
    box-shadow: var(--shadow), 0 4px 16px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    border: none;
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(245, 158, 11, 0.15);
}

.btn-warning:hover {
    box-shadow: var(--shadow), 0 4px 16px rgba(245, 158, 11, 0.3);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border: none;
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(16, 185, 129, 0.15);
}

.btn-success:hover {
    box-shadow: var(--shadow), 0 4px 16px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

/* ========== 2. 输入框增强 ========== */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea,
select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: var(--text-sm);
    transition: all var(--transition-normal);
    outline: none;
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="email"]:hover,
input[type="number"]:hover,
input[type="search"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
textarea:hover,
select:hover {
    border-color: var(--text-tertiary);
    box-shadow: var(--shadow-xs);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg), var(--shadow-sm);
    background: var(--bg-elevated);
}

/* ========== 3. 卡片增强 ========== */
.card,
.file-card,
.upload-item,
.result-card,
.info-card,
.history-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-secondary) 100%);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-normal);
}

.card:hover,
.file-card:hover,
.upload-item:hover,
.result-card:hover,
.info-card:hover,
.history-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(0, 168, 168, 0.05);
    transform: translateY(-2px);
}

/* ========== 4. 标签页/Tab 增强 ========== */
.section-tabs {
    border-bottom: 2px solid var(--border-light);
    position: relative;
}

.section-tab {
    position: relative;
    padding: 10px 20px;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-normal);
    margin-bottom: -2px;
}

.section-tab:hover {
    color: var(--primary);
    background: var(--primary-bg);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}

.section-tab.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom-color: var(--primary);
    background: transparent;
}

/* ========== 5. 复选框/单选框美化 ========== */
input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
    border-radius: 3px;
    transition: all var(--transition-fast);
    vertical-align: middle;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
    accent-color: var(--primary-hover);
    transform: scale(1.1);
}

/* ========== 6. 徽章/Tag 增强 ========== */
.badge,
.tag,
.status-badge,
.file-type-tag {
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    letter-spacing: 0.3px;
    transition: all var(--transition-fast);
}

/* ========== 7. 加载动画增强 ========== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-shimmer {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes gentle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.loading-pulse {
    animation: gentle-pulse 2s ease-in-out infinite;
}

/* ========== 8. 分割线美化 ========== */
hr,
.divider {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 16px 0;
}

/* ========== 9. 滚动条美化 ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ========== 10. 选择文本增强 ========== */
::selection {
    background: var(--primary);
    color: white;
}

/* ========== 11. 工具提示增强 ========== */
[title] {
    position: relative;
}

/* ========== 12. 链接增强 ========== */
a {
    color: var(--primary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ========== 13. 空状态增强 ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    opacity: 0.4;
    margin-bottom: 12px;
}

/* ========== 14. 进度条增强 ========== */
progress {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border: none;
    border-radius: 3px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

progress::-webkit-progress-bar {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 3px;
    transition: width var(--transition-normal);
}

/* ========== 15. 下拉菜单增强 ========== */
.dropdown-menu,
.context-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-lg);
    padding: 4px;
}

.dropdown-menu li,
.context-menu li {
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.dropdown-menu li:hover,
.context-menu li:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

/* ========== 暗色主题适配 ========== */
.dark-theme .btn {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(255,255,255,0.02) 100%);
}

.dark-theme .card,
.dark-theme .file-card,
.dark-theme .upload-item,
.dark-theme .result-card,
.dark-theme .info-card,
.dark-theme .history-item {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(255,255,255,0.02) 100%);
}

.dark-theme .btn-primary:hover {
    box-shadow: var(--shadow), 0 4px 20px rgba(0, 168, 168, 0.3);
}

/* ============================================================
   D11.10.110: 站内即时通讯 (IM)
   ============================================================ */
.im-toggle {
    position: relative;
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-normal);
    background: transparent;
}

.im-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.im-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--bg-primary);
}

.im-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.im-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.im-modal-content {
    position: relative;
    width: 1500px;
    max-width: calc(100vw - 40px);
    height: 880px;
    max-height: calc(100vh - 60px);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.im-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.im-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.im-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.im-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.im-modal-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.im-sidebar {
    width: 300px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.im-sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.im-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.im-conversation {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease;
    margin-bottom: 4px;
}

.im-conversation:hover,
.im-conversation.active {
    background: var(--primary-bg);
}

.im-conversation.active {
    box-shadow: inset 2px 0 0 var(--primary);
}

.im-conv-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

/* D11.10.113: IM 联系人在线/离线状态指示器 */
.im-conv-status {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
    box-sizing: content-box;
}
.im-conv-status.online { background: #22c55e; }
.im-conv-status.offline { background: #9ca3af; }

.im-conv-info {
    flex: 1;
    min-width: 0;
}

.im-conv-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.im-conv-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.im-conv-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.im-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
}

.im-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    flex-shrink: 0;
}

.im-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.im-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 14px;
}

.im-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 80%;
}

.im-message.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.im-message-content {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    box-shadow: var(--shadow-xs);
}

.im-message.mine .im-message-content {
    background: var(--primary-bg-strong);
    border-bottom-right-radius: 4px;
}

.im-message:not(.mine) .im-message-content {
    border-bottom-left-radius: 4px;
}

.im-message-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.im-message-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    object-fit: cover;
}

.im-message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    justify-content: flex-end;
}

.im-message-status {
    color: var(--primary);
}

.im-message-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.im-message:hover .im-message-actions {
    opacity: 1;
}

.im-action {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: var(--radius-xs);
}

.im-action:hover {
    color: var(--primary);
    background: var(--bg-tertiary);
}

.im-input-area {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.im-input-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.im-tool-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.im-tool-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.im-input-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.im-input {
    resize: none;
    min-height: 60px;
    max-height: 120px;
}

.im-send-btn {
    align-self: flex-end;
    padding: 8px 20px;
}

.im-picker-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.im-picker-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}

.im-picker-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 20px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.im-picker-content h4 {
    margin: 0;
    font-size: 15px;
}

.im-picker-select {
    width: 100%;
}

.im-picker-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 8px;
    font-size: 13px;
}

.btn-text:hover {
    color: var(--danger);
    background: var(--bg-tertiary);
}

@media (max-width: 768px) {
    .im-modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .im-sidebar {
        width: 200px;
    }
}

/* ============================================================
   Agent 工具调用轨迹面板 — 主题自适应
   ============================================================ */
.agent-tool-trace .agent-trace-details {
    margin: 8px 0;
    padding: 10px 12px;
    background: var(--bg-tertiary, #f8fafc);
    border-radius: 6px;
    border: 1px solid var(--border-color, #e2e8f0);
}

.agent-tool-trace .agent-trace-summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary, #64748b);
    font-weight: 500;
    user-select: none;
}

.agent-tool-trace .agent-trace-summary:hover {
    color: var(--primary, #00a8a8);
}

.agent-tool-trace .agent-trace-hidden {
    color: var(--text-muted, #94a3b8);
    font-weight: normal;
}

.agent-tool-trace .agent-trace-body {
    margin-top: 6px;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
}

.agent-tool-trace .tool-call-item {
    padding: 3px 0;
    font-size: 13px;
    color: var(--text-primary, #334155);
    line-height: 1.5;
}

.agent-tool-trace .tool-call-item .tool-name {
    background: var(--primary-bg, rgba(0,168,168,0.08));
    color: var(--primary, #00a8a8);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.agent-tool-trace .tool-call-item .tool-count-tag {
    background: var(--border-color, #e2e8f0);
    color: var(--text-secondary, #64748b);
    border-radius: 8px;
    padding: 0 6px;
    font-size: 11px;
    margin-left: 4px;
}

.agent-tool-trace .tool-call-item .tool-summary {
    color: var(--text-secondary, #64748b);
    margin-left: 6px;
}

.agent-tool-trace .tool-call-item .tool-duration {
    color: var(--text-muted, #94a3b8);
    margin-left: 8px;
    font-size: 11px;
}

.agent-tool-trace .tool-imp-high {
    color: var(--primary, #00a8a8);
    font-size: 11px;
}

.agent-tool-trace .tool-hidden-hint {
    padding: 4px 0;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    font-style: italic;
}

/* ———————————————————————————————————————————————
 * Phase 2: 推荐追问 chip
 * 显示在 AI 回答底部，3 个可点击 chip，点击填入输入框并发送
 * ——————————————————————————————————————————————— */
.suggested-questions {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-tertiary, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
}
.suggested-q-label {
    font-size: 12px;
    color: var(--text-muted, #64748b);
    margin-bottom: 8px;
    font-weight: 500;
    letter-spacing: 0.3px;
}
.suggested-q-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.suggested-q-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-primary, #334155);
    background: var(--bg-secondary, #ffffff);
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.18s ease;
    text-align: left;
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
}
.suggested-q-chip:hover {
    background: var(--primary-color, #3b82f6);
    color: #ffffff;
    border-color: var(--primary-color, #3b82f6);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}
.suggested-q-chip:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ========== CGTN Radio 悬浮挂件 ==========
   定位策略: toggle 是固定锚点, panel 从它左下方弹出
   widget 容器尺寸 = toggle 尺寸 (48x48), panel 用 absolute 溢出
*/
.radio-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    transition: none;
    user-select: none;
}
/* toggle 始终在 widget 右上角 (锚点, 永远不动) */
.radio-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary, #00a8a8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 168, 168, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    z-index: 5;
}
.radio-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 168, 168, 0.45);
}
/* LIVE 小红点 */
.radio-live-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4d4f;
    box-shadow: 0 0 6px rgba(255, 77, 79, 0.7);
    animation: pulse-dot 1.5s ease-in-out infinite;
}
.radio-widget:not(.expanded) .radio-toggle .radio-live-dot { display: inline-block; }
.radio-title .radio-live-dot { position: static; width: 8px; height: 8px; display: inline-block; }
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(0.85); }
}
/* panel 始终 absolute, 从 toggle 下方弹出 (右对齐 → 向左延伸) */
/* ---- 向上展开模式: 下方空间不够时 ---- */
.radio-panel.radio-panel-flip-up {
    top: auto !important;
    bottom: 56px !important;
    transform-origin: bottom right;
}

.radio-panel {
    position: absolute;
    top: 56px;       /* toggle 底部 + 8px 间距 */
    right: 0;        /* 与 toggle 右对齐 */
    width: 540px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 12px;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top right;   /* 从 toggle 位置向外展开 */
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: none;
    z-index: 4;
}
.radio-widget.expanded .radio-panel {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.radio-widget:not(.expanded) .radio-panel { display: none; }
/* 展开时 toggle 不再单独显示 LIVE 小红点 */
.radio-widget.expanded .radio-toggle .radio-live-dot { display: none !important; }
/* TV section head 右侧操作按钮 (画中画 + 全屏) */
.radio-section-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.radio-section-action {
    width: 26px; height: 26px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}
.radio-section-action:hover {
    background: var(--border, #e5e7eb);
    color: var(--text-primary, #1f2937);
}
/* 频道切换 */
.radio-channels {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}
.radio-channel-btn {
    min-height: 48px;
    min-width: 0;
    flex: 1 1 0%;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: all 0.15s;
}

/* ===== CCTV 央视折叠面板 ===== */
/* ====== 合并折叠按钮 (▲央视 / ▼卫视) ====== */
.radio-more-wrap {
    position: relative;
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    align-items: stretch;
    box-sizing: border-box;
}
.radio-more-btn {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 6px 6px 6px 8px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 6px;
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    min-height: 48px;
    overflow: hidden;
}
.radio-more-btn:hover {
    border-color: var(--primary, #00a8a8);
    color: var(--primary, #00a8a8);
    background: rgba(0, 168, 168, 0.06);
}
.radio-more-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    opacity: 0.75;
    padding: 0 4px;
    margin: 0;
    line-height: 1;
    flex: 1 1 0;
    min-height: 0;
    cursor: pointer;
    user-select: none;
    border-radius: 3px;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.radio-more-arrow:hover {
    opacity: 1;
    background: rgba(0,0,0,0.06);
}
.dark-theme .radio-more-arrow:hover {
    background: rgba(255,255,255,0.12);
}
.radio-more-up {
    color: #e11d48;
}
.radio-more-up:hover { background: rgba(225, 29, 72, 0.15); }
.radio-more-down {
    color: #059669;
}
.radio-more-down:hover { background: rgba(5, 150, 105, 0.15); }
.radio-more-arrow:hover {
    opacity: 1;
    background: rgba(255,255,255,0.15);
}
.radio-more-up { color: #e11d48; }
.radio-more-up:hover { background: rgba(225, 29, 72, 0.15); }
.radio-more-down { color: #059669; }
.radio-more-down:hover { background: rgba(5, 150, 105, 0.15); }

/* 激活态 */
.radio-more-btn.open-up .radio-more-up {
    opacity: 1; color: #e11d48;
    background: rgba(225, 29, 72, 0.15);
    transform: translateY(-1px);
}
.radio-more-btn.open-down .radio-more-down {
    opacity: 1; color: #059669;
    background: rgba(5, 150, 105, 0.15);
    transform: translateY(1px);
}
.radio-more-label {
    flex: 1 1 auto;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: color 0.15s;
    white-space: nowrap;
    gap: 1px;
}
.radio-more-label-top {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.radio-more-label-bot {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    opacity: 0.75;
}
/* 右侧双箭头容器 */
.radio-more-arrows {
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    align-items: stretch;
    flex: 0 0 auto;
    min-width: 22px;
    max-width: 28px;
    height: 100%;
    gap: 0;
    border-left: 1px solid var(--border, #d1d5db);
    margin-left: 2px;
    padding-left: 2px;
}

.radio-more-btn.open-up .radio-more-label { color: #e11d48; }
.radio-more-btn.open-down .radio-more-label { color: #059669; }

/* 面板基础 */
/* 以下 pop 面板默认 hidden, 由 JS 动态 clone 到 body 下用 position: fixed */
.radio-cctv-panel,
.radio-weishi-panel {
    display: none;
    position: fixed;
    z-index: 10000;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* 向上弹出 (央视) */
.radio-pop-above {
    /* position: fixed, 由 JS 设置 top/left */
}
.radio-pop-above.open {
    display: flex;
    animation: popUp 0.22s cubic-bezier(.4,0,.2,1);
}
@keyframes popUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 向下弹出 (卫视) */
.radio-pop-below {
    /* position: fixed, 由 JS 设置 top/left */
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
    max-height: 520px;
    overflow-y: auto;
}
.radio-pop-below.open {
    display: flex;
    animation: popDown 0.22s cubic-bezier(.4,0,.2,1);
}
@keyframes popDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 央视面板: 红色系 */
.radio-cctv-panel {
    background: rgba(225, 29, 72, 0.08);
    border: 1px solid rgba(225, 29, 72, 0.20);
}
.radio-cctv-panel .radio-channel-btn {
    background: rgba(225, 29, 72, 0.08);
    border-color: rgba(225, 29, 72, 0.25);
    color: #be123c;
}
.radio-cctv-panel .radio-channel-btn:hover {
    background: rgba(225, 29, 72, 0.18);
    border-color: #e11d48;
    color: #e11d48;
}

/* 卫视面板分组 */
.radio-ws-group { display: flex; flex-direction: column; gap: 6px; }
.radio-ws-group + .radio-ws-group {
    margin-top: 4px;
    padding-top: 6px;
}
.radio-ws-group-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b7280;
    padding: 0 2px;
}
.radio-ws-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* 卫视面板 */
.radio-weishi-panel {
    background: linear-gradient(135deg, rgba(37,99,235,0.06) 0%, rgba(5,150,105,0.06) 100%);
    border: 1px solid rgba(37, 99, 235, 0.20);
}
.radio-ws-group:first-child .radio-channel-btn {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.25);
    color: #1d4ed8;
}
.radio-ws-group:first-child .radio-channel-btn:hover {
    background: rgba(37, 99, 235, 0.18);
    border-color: #2563eb;
    color: #2563eb;
}
.radio-ws-group:last-child .radio-channel-btn {
    background: rgba(5, 150, 105, 0.08);
    border-color: rgba(5, 150, 105, 0.25);
    color: #047857;
}
.radio-ws-group:last-child .radio-channel-btn:hover {
    background: rgba(5, 150, 105, 0.18);
    border-color: #059669;
    color: #059669;
}

/* ====== 暗色主题 ====== */

.dark-theme .radio-more-up { color: #fda4af; }
.dark-theme .radio-more-down { color: #6ee7b7; }
.dark-theme .radio-more-btn.open-up .radio-more-up {
    color: #f87171;
    background: rgba(239, 68, 68, 0.20);
}
.dark-theme .radio-more-btn.open-down .radio-more-down {
    color: #34d399;
    background: rgba(52, 211, 153, 0.20);
}
.dark-theme .radio-more-btn.open-up .radio-more-label { color: #f87171; }
.dark-theme .radio-more-btn.open-down .radio-more-label { color: #34d399; }

.dark-theme .radio-cctv-panel {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.22);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.dark-theme .radio-cctv-panel .radio-channel-btn {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.30);
    color: #fda4af;
}
.dark-theme .radio-cctv-panel .radio-channel-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #f87171;
    color: #fecaca;
}

.dark-theme .radio-weishi-panel {
    background: linear-gradient(135deg, rgba(59,130,246,0.10) 0%, rgba(16,185,129,0.10) 100%);
    border-color: rgba(59, 130, 246, 0.25);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.dark-theme .radio-ws-group:first-child .radio-channel-btn {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.30);
    color: #93c5fd;
}
.dark-theme .radio-ws-group:first-child .radio-channel-btn:hover {
    background: rgba(59, 130, 246, 0.26);
    border-color: #60a5fa;
    color: #bfdbfe;
}
.dark-theme .radio-ws-group:last-child .radio-channel-btn {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.30);
    color: #6ee7b7;
}
.dark-theme .radio-ws-group:last-child .radio-channel-btn:hover {
    background: rgba(16, 185, 129, 0.26);
    border-color: #34d399;
    color: #a7f3d0;
}
.dark-theme .radio-ws-group + .radio-ws-group { border-top-color: rgba(255,255,255,0.10); }
.dark-theme .radio-ws-group-title { color: #6b7280; }

.radio-close-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(120, 120, 120, 0.10);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s cubic-bezier(.4,0,.2,1);
    flex-shrink: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
.radio-close-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    transform: scale(1.10);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.40), inset 0 0 0 1px rgba(239, 68, 68, 0.30);
}
.radio-close-btn:hover svg { transform: scale(1.12); }
.radio-close-btn svg { transition: transform 0.25s cubic-bezier(.4,0,.2,1); }
.radio-close-btn:active { transform: scale(0.93); }
.dark-theme .radio-close-btn {
    background: rgba(255,255,255,0.08);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.dark-theme .radio-close-btn:hover {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.45), inset 0 0 0 1px rgba(239, 68, 68, 0.35);
}
.radio-close-btn.active {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.30), inset 0 0 0 1px rgba(239, 68, 68, 0.25);
}
.dark-theme .radio-close-btn.active {
    color: #f87171;
    background: rgba(239, 68, 68, 0.18);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.35), inset 0 0 0 1px rgba(239, 68, 68, 0.30);
}
.radio-volume {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    color: var(--text-secondary, #6b7280);
}
.radio-volume-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}
.radio-volume-icon:hover {
    color: var(--text-primary, #111827);
    background: rgba(0,0,0,0.04);
}
.radio-volume-icon.muted {
    color: #ef4444;
}
.radio-volume-icon.muted:hover {
    background: rgba(239, 68, 68, 0.08);
}
.radio-volume-icon svg {
    flex-shrink: 0;
}
.radio-volume input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--border, #e5e7eb);
    outline: none;
}
.radio-volume input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--primary, #00a8a8);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.radio-volume input[type="range"]::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--primary, #00a8a8);
    cursor: pointer;
    border: 2px solid #fff;
}
/* 字幕按钮 (▶️🔊 📝 三控件) */
.radio-subtitle-btn {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.radio-subtitle-btn:hover { border-color: var(--primary, #00a8a8); color: var(--primary, #00a8a8); }
.radio-subtitle-btn.active {
    border-color: var(--primary, #00a8a8);
    color: var(--primary, #00a8a8);
    background: rgba(0, 168, 168, 0.1);
}
/* 字幕区: 默认隐藏, .expanded 时滑下 */
.radio-subtitle-area {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid var(--border, #e5e7eb);
    margin-top: 4px;
}
.radio-subtitle-area.expanded {
    max-height: 240px;
}
.radio-subtitle-list {
    padding: 8px 4px 4px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary, #6b7280);
    max-height: 220px;
}
.radio-subtitle-list::-webkit-scrollbar { width: 4px; }
.radio-subtitle-list::-webkit-scrollbar-thumb { background: var(--border, #e5e7eb); border-radius: 2px; }
.radio-subtitle-seg {
    padding: 2px 4px;
    border-radius: 4px;
    word-break: break-word;
}
.radio-subtitle-seg.current {
    color: var(--text-primary, #1f2937);
    background: var(--bg-secondary, #f3f4f6);
    font-weight: 500;
}
.radio-subtitle-loading {
    padding: 10px 8px;
    font-size: 11px;
    text-align: center;
    color: var(--text-tertiary, #9ca3af);
}
.radio-subtitle-area:not(.expanded) + .radio-subtitle-loading { display: none; }

/* 状态 */
.radio-status {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary, #9ca3af);
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-secondary, #f3f4f6);
    line-height: 1.4;
}
/* LIVE 状态用主色 */
.radio-status[data-playing="true"] {
    color: var(--primary, #00a8a8);
    background: rgba(0, 168, 168, 0.12);
}
/* 旋转动画 */
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 视频预览区 (全宽) --- */
.radio-video-full {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}
.radio-video-full video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    display: none;
}
.radio-video-full video.active { display: block; }
/* 纯音频频道封面 (Radio 无画面 → 缩略图填满) */
.radio-video-cover {
    position: absolute;
    inset: 0;
    display: none;
    background: #05060b;
}
.radio-video-cover.show { display: block; }
.radio-video-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 视频占位符 */
.radio-video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    color: #6b7280;
    font-size: 13px;
    text-align: center;
    line-height: 1.5;
}
.radio-video-placeholder.hidden { display: none; }
.radio-video-empty-icon { font-size: 36px; opacity: 0.4; }
.radio-video-empty-text { white-space: nowrap; padding: 4px 0; }
/* 视频状态栏 (左上角浮层) */
.radio-video-status {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 6px;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font-size: 11px;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
.radio-video-status .radio-live-dot { width: 7px; height: 7px; }
.radio-mute-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border, #e5e7eb);
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.radio-mute-btn:hover {
    border-color: var(--primary, #00a8a8);
    color: var(--primary, #00a8a8);
    transform: scale(1.06);
}
.radio-mute-btn:active { transform: scale(0.94); }
.radio-mute-btn.muted {
    color: #ef4444;
    border-color: #ef4444;
}
.dark-theme .radio-mute-btn:hover {
    border-color: var(--primary, #00c4c4);
    color: var(--primary, #00c4c4);
}

/* --- section 纵向独立区域 --- */
.radio-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.radio-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.radio-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #888);
    text-transform: none;
    letter-spacing: 0;
    padding: 0;
    user-select: none;
}
.radio-channel-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 6px;
    align-items: stretch;
}
.radio-channel-row .radio-channel-btn { flex: 1; }

/* 电视区分割线 (视觉区分) */
.radio-tv-section {
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border, #e5e7eb);
}
.radio-tv-section .radio-section-head .radio-channel-btn.active {
    /* 电视激活态在按钮上, head 里只有 label + collapse */
}

/* 视频频道按钮激活态 (红/橙渐变, 区别于音频的青) */
.radio-tv-section .radio-channel-btn.active {
    background: linear-gradient(135deg, #dc2626 0%, #ea580c 100%);
    border-color: #dc2626;
    color: #fff;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
    text-shadow: none;
}
.dark-theme .radio-tv-section .radio-channel-btn.active {
    background: linear-gradient(135deg, #b91c1c 0%, #c2410c 100%);
    border-color: #dc2626;
    color: #fff;
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.40);
}

/* Radio 激活态: 水青色 */
.radio-audio-section .radio-channel-btn.active {
    background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    border-color: #0891b2;
    color: #fff;
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.35);
    text-shadow: none;
}
.dark-theme .radio-audio-section .radio-channel-btn.active {
    background: linear-gradient(135deg, #0e7490 0%, #0891b2 100%);
    border-color: #0891b2;
    color: #fff;
    box-shadow: 0 2px 8px rgba(14, 116, 144, 0.40);
}


/* --- 暗色主题适配 --- */
.dark-theme .radio-panel {
    background: var(--bg-primary, #1f2937);
    border-color: var(--border, #374151);
}
.dark-theme .radio-channel-btn {
    background: var(--bg-secondary, #374151);
    border-color: var(--border, #4b5563);
    color: var(--text-secondary, #9ca3af);
}
.dark-theme .radio-volume input[type="range"] { background: var(--border, #4b5563); }
.dark-theme .radio-section-action { color: var(--text-secondary, #9ca3af); }
.dark-theme .radio-section-action:hover { background: var(--border, #4b5563); color: var(--text-primary, #f9fafb); }
.dark-theme .radio-status { background: var(--bg-secondary, #374151); color: var(--text-secondary, #9ca3af); }
.dark-theme .radio-status[data-playing="true"] { color: #00d4d4; background: rgba(0, 196, 196, 0.18); }
.dark-theme .radio-subtitle-btn { background: var(--bg-secondary, #374151); border-color: var(--border, #4b5563); color: var(--text-secondary, #9ca3af); }
.dark-theme .radio-subtitle-btn.active { border-color: var(--primary, #00c4c4); color: var(--primary, #00c4c4); background: rgba(0, 196, 196, 0.15); }
.dark-theme .radio-subtitle-area { border-top-color: var(--border, #374151); }
.dark-theme .radio-subtitle-list { color: var(--text-secondary, #9ca3af); }
.dark-theme .radio-tv-section { border-bottom-color: var(--border, #374151); }
/* ====== 面板基础 ====== */
.radio-cctv-panel,
.radio-weishi-panel {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 20;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* === 4 列 grid (JS 已展平 DOM, 这里只管布局) === */
.radio-pop-open .radio-weishi-panel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    align-items: stretch;
}
.radio-pop-open .radio-weishi-panel .radio-ws-group-title {
    grid-column: 1 / -1;
    text-align: left;
    padding: 8px 4px 4px;
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary, #64748b);
    letter-spacing: 2px;
}
.radio-pop-open .radio-weishi-panel .radio-channel-btn {
    min-height: 36px;
    width: auto;
}

/* ===== 2026-10-17: 「更多电视频道」改为缩略图瓦片 =====
   原来是纯文字按钮, 与 tv.html 的频道抽屉/精选墙不一致;
   改为 16:9 缩略图 + 暗色 scrim + 左侧分类色条 + 左下台名, 视觉与 ViewCast 统一。
   底图来自 /static/thumbs/<id>.jpg (与 tv-page.js 同一份, 版本号 THUMB_V 需两边同步)。
   注意: 弹出面板的 .radio-pop-open 与 .radio-weishi-panel 在同一个元素上, 不能写成祖孙选择器。 */
.radio-pop-open .radio-channel-btn.rvc-tile {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: block;
    width: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
    padding: 0;
    text-align: left;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background-color: rgba(15, 23, 42, 0.05);
    background-image: linear-gradient(180deg, rgba(5, 9, 16, 0.18) 0%, rgba(5, 9, 16, 0.08) 36%,
                      rgba(5, 9, 16, 0.72) 76%, rgba(5, 9, 16, 0.94) 100%),
                      var(--thumb, linear-gradient(158deg, #334155, #0f172a));
    background-size: 100% 100%, cover;
    background-position: center, center;
    background-repeat: no-repeat;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.radio-pop-open .radio-channel-btn.rvc-tile::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--tile-c, #00e5ff);
    opacity: 0.9;
    z-index: 1;
}
.radio-pop-open .radio-channel-btn.rvc-tile:hover {
    transform: translateY(-3px);
    border-color: rgba(0, 229, 255, 0.45);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.radio-pop-open .radio-channel-btn.rvc-tile.active {
    border-color: var(--tile-c, #00e5ff);
    box-shadow: inset 0 0 0 2px var(--tile-c, #00e5ff);
}
.radio-pop-open .rvc-name {
    position: absolute;
    left: 9px;
    right: 8px;
    bottom: 7px;
    z-index: 1;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.radio-pop-open .radio-channel-btn {
    width: 100%;
    min-height: 36px;
    padding: 8px 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.4;
    text-align: center;
    box-sizing: border-box;
}

/* 向上弹出 (央视) */
.radio-pop-above {
    bottom: calc(100% + 8px);
    flex-direction: row;
}
.radio-pop-above.open {
    display: flex;
    animation: popUp 0.22s cubic-bezier(.4,0,.2,1);
}
@keyframes popUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 向下弹出 (卫视) */
.radio-pop-below {
    top: calc(100% + 8px);
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
    max-height: 520px;
    overflow-y: auto;
}
.radio-pop-below.open {
    display: flex;
    animation: popDown 0.22s cubic-bezier(.4,0,.2,1);
}
@keyframes popDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 央视面板: 红色系 */
.radio-cctv-panel {
    background: rgba(225, 29, 72, 0.08);
    border: 1px solid rgba(225, 29, 72, 0.20);
}
.radio-cctv-panel .radio-channel-btn {
    background: rgba(225, 29, 72, 0.08);
    border-color: rgba(225, 29, 72, 0.25);
    color: #be123c;
}
.radio-cctv-panel .radio-channel-btn:hover {
    background: rgba(225, 29, 72, 0.18);
    border-color: #e11d48;
    color: #e11d48;
}

/* 卫视面板分组 */
.radio-ws-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.radio-ws-group + .radio-ws-group {
    margin-top: 4px;
    padding-top: 6px;
}
.radio-ws-group-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b7280;
    padding: 0 2px;
}
.radio-ws-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* 卫视面板: 蓝绿渐变 */
.radio-weishi-panel {
    background: linear-gradient(135deg, rgba(37,99,235,0.06) 0%, rgba(5,150,105,0.06) 100%);
    border: 1px solid rgba(37, 99, 235, 0.20);
}
.radio-ws-group:first-child .radio-channel-btn {
    /* 浙江本地台: 蓝 */
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.25);
    color: #1d4ed8;
}
.radio-ws-group:first-child .radio-channel-btn:hover {
    background: rgba(37, 99, 235, 0.18);
    border-color: #2563eb;
    color: #2563eb;
}
.radio-ws-group:last-child .radio-channel-btn {
    /* 全国卫视: 绿 */
    background: rgba(5, 150, 105, 0.08);
    border-color: rgba(5, 150, 105, 0.25);
    color: #047857;
}
.radio-ws-group:last-child .radio-channel-btn:hover {
    background: rgba(5, 150, 105, 0.18);
    border-color: #059669;
    color: #059669;
}

/* ====== 暗色主题 ====== */


.dark-theme .radio-more-up { color: #fda4af; }
.dark-theme .radio-more-down { color: #6ee7b7; }
.dark-theme .radio-more-btn.open-up .radio-more-up {
    color: #f87171;
    background: rgba(239, 68, 68, 0.20);
}
.dark-theme .radio-more-btn.open-down .radio-more-down {
    color: #34d399;
    background: rgba(52, 211, 153, 0.20);
}
.dark-theme .radio-more-btn.open-up .radio-more-label { color: #f87171; }
.dark-theme .radio-more-btn.open-down .radio-more-label { color: #34d399; }

/* 暗色: 央视面板 */
.dark-theme .radio-cctv-panel {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.22);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.dark-theme .radio-cctv-panel .radio-channel-btn {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.30);
    color: #fda4af;
}
.dark-theme .radio-cctv-panel .radio-channel-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #f87171;
    color: #fecaca;
}

/* 暗色: 卫视面板 */
.dark-theme .radio-weishi-panel {
    background: linear-gradient(135deg, rgba(59,130,246,0.10) 0%, rgba(16,185,129,0.10) 100%);
    border-color: rgba(59, 130, 246, 0.25);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.dark-theme .radio-ws-group:first-child .radio-channel-btn {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.30);
    color: #93c5fd;
}
.dark-theme .radio-ws-group:first-child .radio-channel-btn:hover {
    background: rgba(59, 130, 246, 0.26);
    border-color: #60a5fa;
    color: #bfdbfe;
}
.dark-theme .radio-ws-group:last-child .radio-channel-btn {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.30);
    color: #6ee7b7;
}
.dark-theme .radio-ws-group:last-child .radio-channel-btn:hover {
    background: rgba(16, 185, 129, 0.26);
    border-color: #34d399;
    color: #a7f3d0;
}
.dark-theme .radio-ws-group + .radio-ws-group {
    border-top-color: rgba(255,255,255,0.10);
}
.dark-theme .radio-ws-group-title {
    color: #6b7280;
}



/* ---- 控制区单行 ---- */
.radio-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 6px;
}

/* pop 面板展开动画 (display 由 inline style 控制, 不加 !important) */
.radio-pop-open {
    animation: popPanelIn 0.18s cubic-bezier(.4,0,.2,1);
}
@keyframes popPanelIn {
    from { opacity: 0; transform: scale(0.96) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
/* 原始位置的 pop 面板永远 hidden */
.radio-more-wrap .radio-cctv-panel,
.radio-more-wrap .radio-weishi-panel {
    display: none !important;
}

.dark-theme .radio-channel-btn.active {
    box-shadow: 0 2px 8px rgba(0, 196, 196, 0.40);
}

/* Panel 向左翻转: widget 在屏幕左侧时, panel 右对齐改为左对齐 */
.radio-panel.radio-panel-flip-left {
    left: 0;
    right: auto;
    transform-origin: top left;
}
.radio-panel.radio-panel-flip-left.radio-panel-flip-up {
    transform-origin: bottom left;
}

/* ===== 频道流畅度 dots (与 TV 页同款视觉, 独立类名避免冲突) ===== */
.radio-channel-btn[data-video], .radio-channel-btn[data-channel] {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.radio-smoothness-dots {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-top: 1px;
    line-height: 1;
}
.radio-smoothness-dots .radio-sd {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid #555;
    background: transparent;
    transition: all .2s;
    /* 防御: 空心态类名就叫 empty, 若页面另有通用 .empty{padding} 规则 (如 gk.css),
       padding 无人竞争会生效, 把 5px 圆点撑成 50x114 的大椭圆 —— 这里显式清零 */
    padding: 0;
}
.radio-smoothness-dots .radio-sd.filled {
    background: #00E6FF;
    border-color: #00E6FF;
    box-shadow: 0 0 3px rgba(0,230,255,.5);
}
/* 半实心: 左实右空 (10 分一档)
   描边必须透明、且不发光: 若沿用青色描边/发光, 右半"空"的部分会被 1px 青边和光晕
   补出青色轮廓, 5px 尺寸下整颗看起来就是实心圆 (2026-09-25 16 倍放大实测确认)。 */
.radio-smoothness-dots .radio-sd.half {
    background: linear-gradient(90deg, #00E6FF 0 50%, transparent 50% 100%);
    border-color: transparent;
    box-shadow: none;
}
.radio-smoothness-dots .radio-sd.untested {
    border-color: #333;
    opacity: .4;
}

/* ===== APK 下载 QR 码 (充满 video placeholder) ===== */
.radio-apk-qr-row {
    display: flex;
    gap: clamp(16px, 4%, 40px);
    flex: 1;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.radio-apk-qr-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.radio-apk-qr-img {
    width: clamp(140px, 32%, 260px);
    height: clamp(140px, 32%, 260px);
    border-radius: 6px;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.radio-apk-qr-img img,
.radio-apk-qr-img canvas {
    width: 100% !important;
    height: 100% !important;
    image-rendering: crisp-edges;       /* 缩小缩放时保持硬边缘, 二维码黑白块不糊 */
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
}
.radio-apk-qr-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
}
.radio-apk-name {
    font-size: clamp(12px, 1.4vw, 16px);
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
}
.radio-apk-desc {
    font-size: clamp(10px, 1.1vw, 13px);
    color: #94a3b8;
    white-space: nowrap;
}
/* 沉到底部一行 */
.radio-video-empty-text {
    font-size: 12px;
    color: #64748b;
    margin-top: auto;
    white-space: nowrap;
}

/* ============================================================
   2026-10-17: 悬浮球「在线电视」合并「实时电台」后的新布局
   ① 两个固定频道卡片 → 收藏卡片墙 (与 tv.html 收藏墙同源: vc_tv_favs)
   ② 下一行 = 频道列表按钮
   ③ 音量 / 开关 / 静音 / 字幕 合并为一组
   ============================================================ */
.radio-fav-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0 2px;
    /* 收藏多了也不把面板撑出屏幕: 最多两行, 超出滚动 */
    max-height: 296px;
    overflow-y: auto;
    padding-right: 2px;
}
.radio-fav-empty {
    grid-column: 1 / -1;
    padding: 14px 10px;
    border: 1px dashed var(--border, #e5e7eb);
    border-radius: 8px;
    font-size: 11.5px;
    line-height: 1.5;
    text-align: center;
    color: var(--text-tertiary, #94a3b8);
}
.radio-fav-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: block;
    aspect-ratio: 16 / 9;
    padding: 0;
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background-color: rgba(15, 23, 42, 0.05);
    background-image: linear-gradient(180deg, rgba(5, 9, 16, 0.18) 0%, rgba(5, 9, 16, 0.08) 36%,
                      rgba(5, 9, 16, 0.72) 76%, rgba(5, 9, 16, 0.94) 100%),
                      var(--thumb, linear-gradient(158deg, #334155, #0f172a));
    background-size: 100% 100%, cover;
    background-position: center, center;
    background-repeat: no-repeat;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.radio-fav-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--tile-c, #00e5ff);
    opacity: 0.9;
    z-index: 1;
}
.radio-fav-card:hover {
    transform: translateY(-3px);
    border-color: rgba(0, 229, 255, 0.45);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.radio-fav-card .rvc-name {
    position: absolute;
    left: 9px;
    right: 32px;
    bottom: 7px;
    z-index: 1;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.rfc-star,
.rvc-fav {
    position: absolute;
    right: 6px;
    bottom: 6px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    color: #93a4b8;
    background: rgba(2, 6, 15, 0.62);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    transition: transform 0.2s ease, background 0.2s ease;
}
.rfc-star,
.rvc-fav.on {
    color: #FFC53D;
    border-color: rgba(255, 197, 61, 0.45);
}
.rfc-star:hover,
.rvc-fav:hover {
    transform: scale(1.1);
    background: rgba(2, 6, 15, 0.85);
}

/* 频道列表按钮: 整行 */
.radio-channel-row.radio-list-row {
    margin-top: 8px;
}
.radio-list-wrap {
    flex: 1 1 auto;
}
.radio-list-wrap .radio-list-btn {
    width: 100%;
    min-height: 38px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 12px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid rgba(0, 229, 255, 0.35);
    background: rgba(0, 229, 255, 0.10);
    color: #00b8d4;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.radio-list-wrap .radio-list-btn:hover {
    background: rgba(0, 229, 255, 0.18);
    border-color: rgba(0, 229, 255, 0.6);
}
.dark-theme .radio-list-wrap .radio-list-btn {
    color: #00e5ff;
}

/* 合并控制组: 电源 + 音量/静音 + 字幕 */
.radio-controls.radio-controls-merged {
    gap: 10px;
    margin-top: 8px;
}
