/**
 * v4_portal_layout.css
 * YOESIS 4.0 门户布局增量：沿用 v3 顶栏/侧栏色系，中间为 AI 对话，右侧为任务步骤与输出。
 */

.v4-portal-layout {
    /* 三栏：左顾问侧栏 + 中对话 + 右任务 */
    /* 竖式 navbar 整体宽度相对 v3 基准增加 0.3 倍（×1.3） */
    --v3-sidebar-width: calc(238px * 1.3);
    --v3-sidebar-width-compact: calc(67px * 1.3);
    --v3-sidebar-width-mobile: calc(288px * 1.3);
    --v3-sidebar-width-mobile-compact: calc(77px * 1.3);
}

/* 对话工作台占满主栏剩余高度 */
.v4-portal-layout .v3-portal-main-col > .v4-chat-workbench {
    flex: 1;
    min-height: 0;
}

/* 对话清单项用 button 时对齐 v3 任务链接 */
.v4-portal-layout button.v4-chat-list-link {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

/* 右侧任务栏：步骤 + 输出，占满主栏高度 */
.v4-portal-task-panel {
    flex-shrink: 0;
    width: min(360px, 32vw);
    min-width: 280px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-left: 1px solid var(--v3-sidebar-border);
    color: #344767;
}

/* 拖拽条贴在「当前项目」左缘（主栏最右侧） */
.v4-task-resizer {
    flex-shrink: 0;
    width: 6px;
    align-self: stretch;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 2;
}

.v4-task-resizer::before {
    content: "";
    position: absolute;
    top: 20%;
    bottom: 20%;
    left: 2px;
    right: 2px;
    border-radius: 999px;
    background: #dde1e7;
    transition: background-color 0.15s ease;
}

.v4-task-resizer:hover::before,
.v4-task-resizer.is-dragging::before {
    background: #4a6fa5;
}

.v4-portal-layout.ai-collapsed .v4-task-resizer,
.v4-portal-layout-aux-only .v4-task-resizer {
    display: none;
}

/* 辅助页：隐藏右侧任务栏，中间铺满 */
.v4-portal-layout-aux-only .v4-portal-task-panel {
    display: none;
}

.v4-portal-task-panel-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--v3-sidebar-border);
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e3d59;
}

.v4-portal-task-panel-head .v2-ai-title {
    min-width: 0;
}

/* 宽屏也显示收起按钮，便于把当前项目收起 */
.v4-portal-layout .v2-ai-close-btn {
    display: inline-flex;
}

/* 收起后隐藏右侧任务栏 */
.v4-portal-layout.ai-collapsed .v4-portal-task-panel {
    display: none;
}

/* 辅助页不展示当前项目浮动按钮 */
.v3-portal-page:has(.v4-portal-layout-aux-only) .v4-task-floating-toggle {
    display: none;
}

.v4-portal-task-panel-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.v4-portal-task-section {
    padding: 0.75rem 0.9rem 0.85rem;
}

.v4-portal-task-section + .v4-portal-task-section {
    border-top: 1px solid var(--v3-sidebar-border);
}

.v4-portal-task-section-title {
    margin: 0 0 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #94a3b8;
    text-transform: none;
}

/* 任务步骤列表 */
.v4-portal-step-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.v4-portal-step-item {
    display: flex;
    gap: 0.55rem;
    padding: 0.4rem 0;
    font-size: 0.8rem;
    line-height: 1.4;
}

.v4-portal-step-num {
    flex-shrink: 0;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    background: #e8eef6;
    color: #4a6fa5;
}

.v4-portal-step-item.is-done .v4-portal-step-num {
    background: #d1fae5;
    color: #047857;
}

.v4-portal-step-item.is-current .v4-portal-step-num {
    background: #dbeafe;
    color: #1d4ed8;
}

.v4-portal-step-text {
    min-width: 0;
    flex: 1;
}

.v4-portal-step-name {
    display: block;
    font-weight: 600;
    color: #1e3d59;
}

.v4-portal-step-meta {
    display: block;
    font-size: 0.72rem;
    color: #94a3b8;
}

.v4-risk-running-card {
    margin-bottom: 0.75rem;
}

.v4-risk-running-title {
    margin: 0 0 0.25rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #1e3d59;
}

.v4-risk-done-item {
    align-items: center;
}

/* 定容 / 财务已完成：可收起参数 + 图标下载（同风险调研） */
.v4-risk-done-item--analysis {
    align-items: flex-start;
}

.v4-risk-done-item--analysis .v4-portal-step-text {
    flex: 1;
    min-width: 0;
}

.v4-analysis-details {
    margin-top: 0.3rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.35rem;
    background: #fff;
}

.v4-analysis-details + .v4-analysis-details {
    margin-top: 0.25rem;
}

.v4-analysis-details > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    font-size: 0.68rem;
    font-weight: 600;
    color: #475569;
    padding: 0.28rem 0.45rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.v4-analysis-details > summary::-webkit-details-marker {
    display: none;
}

.v4-analysis-details > summary::before {
    content: "▸";
    display: inline-block;
    font-size: 0.62rem;
    color: #94a3b8;
    transition: transform 0.12s ease;
}

.v4-analysis-details[open] > summary::before {
    transform: rotate(90deg);
}

.v4-analysis-details-body {
    padding: 0 0.45rem 0.35rem;
    border-top: 1px solid #f1f5f9;
}

.v4-analysis-kv {
    list-style: none;
    margin: 0;
    padding: 0;
}

.v4-analysis-kv li {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.68rem;
    line-height: 1.35;
    padding: 0.12rem 0;
    border-bottom: 1px dashed #e2e8f0;
}

.v4-analysis-kv li:last-child {
    border-bottom: none;
}

.v4-analysis-k {
    color: #64748b;
    flex-shrink: 0;
}

.v4-analysis-v {
    color: #1e293b;
    text-align: right;
    word-break: break-all;
}

.v4-risk-task-card .v4-analysis-details > summary {
    font-size: 0.72rem;
}

.v4-risk-task-card .v4-analysis-kv li {
    font-size: 0.72rem;
}

.v4-risk-task-card .v4-reader-file-actions {
    margin: 0.25rem 0 0.15rem;
}

.v4-risk-report-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.2rem;
    font-size: 0.72rem;
}

.v4-risk-report-links a {
    color: #1d4ed8;
}

.v4-risk-task-card {
    margin-top: 0.65rem;
    padding: 0.65rem 0.7rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.45rem;
    border-left: 3px solid var(--v2-accent, #4a6fa5);
}

.v4-risk-task-card iframe {
    width: 100%;
    min-height: 280px;
    margin-top: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.35rem;
    background: #fff;
}

/* 对话：加载更早 */
.v4-chat-load-earlier-wrap {
    display: flex;
    justify-content: center;
    padding: 0.35rem 0 0.6rem;
}

.v4-chat-load-earlier-btn {
    font-size: 0.78rem;
    color: #475569;
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 999px;
    padding: 0.2rem 0.85rem;
}

.v4-chat-load-earlier-btn:hover {
    background: #f8fafc;
    color: #1e293b;
}

.v4-task-detail-slot {
    display: block;
    margin-top: 0.4rem;
}

.v4-task-detail-slot[hidden] {
    display: none !important;
}

.v4-risk-expand-report-btn,
.v4-risk-expand-detail-btn {
    font-size: 0.75rem;
    margin-top: 0.35rem;
}

.v4-risk-task-card .v4-portal-step-list {
    margin-top: 0.35rem;
}

/* 任务输出卡片 */
.v4-portal-task-output {
    padding: 0.7rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.45rem;
    border-left: 3px solid var(--v2-accent, #4a6fa5);
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.5;
}

.v4-portal-task-output h4 {
    margin: 0 0 0.35rem;
    font-size: 0.84rem;
    font-weight: 700;
    color: #1e3d59;
}

/* 左栏：智能顾问下拉（浅色侧栏） */
.v4-advisor {
    position: relative;
    flex: 1;
    min-width: 0;
}

.v4-advisor-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.2rem 0.45rem;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: left;
    cursor: pointer;
}

.v4-advisor-trigger:hover,
.v4-advisor.is-open .v4-advisor-trigger {
    color: #4a6fa5;
}

.v4-advisor-caret {
    display: inline-flex;
    width: 10px;
    height: 6px;
    margin-left: 0.25rem;
    color: inherit;
}

.v4-advisor-caret svg {
    width: 10px;
    height: 6px;
}

.v4-advisor.is-open .v4-advisor-caret {
    transform: rotate(180deg);
}

.v4-advisor-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: #ffffff;
    border: 1px solid var(--v3-sidebar-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.v4-advisor-menu[hidden] {
    display: none;
}

.v4-advisor-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #334155;
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
}

.v4-advisor-option:hover,
.v4-advisor-option:focus-visible {
    background: #f1f5f9;
}

.v4-advisor-option.is-active {
    background: #e8eef6;
    color: #1e3d59;
    font-weight: 600;
}

.v4-advisor-option:disabled,
.v4-advisor-option--disabled {
    color: #94a3b8;
    cursor: not-allowed;
    background: transparent;
}

.v4-advisor-option:disabled:hover,
.v4-advisor-option--disabled:hover {
    background: transparent;
}

.v4-advisor-dev-badge {
    margin-left: 0.35rem;
    font-size: 0.62rem;
    font-weight: 600;
    color: #94a3b8;
}

/* 对话清单 */
.v4-chat-list-title {
    display: block;
    padding: 0.65rem 0.9rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #94a3b8;
}

.v4-chat-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0 0.5rem;
}

.v4-chat-list-item {
    margin: 0;
}

.v4-chat-list-link {
    display: block;
    width: 100%;
    padding: 0.5rem 0.9rem;
    border: 0;
    background: transparent;
    color: #334155;
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
    border-radius: 0;
}

.v4-chat-list-link:hover {
    background: #f1f5f9;
}

.v4-chat-list-link.is-active {
    background: #e8eef6;
    color: #1e3d59;
    font-weight: 600;
}

.v4-chat-list-meta {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.7rem;
    font-weight: 400;
    color: #94a3b8;
}

/* 中间 AI 对话工作台 */
.v4-chat-workbench {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.v4-chat-workbench-inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0.75rem 0 1rem;
    font-size: 0.80rem;
    line-height: 1.35;
}

.v4-chat-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    width: 100%;
    max-width: 920px;
    margin: 0 auto 0.35rem;
    padding: 0 1rem;
}

.v4-chat-cumulative {
    color: #4b5563;
    font-size: 0.8rem;
}

.v4-chat-clear-btn {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    color: #4b5563 !important;
}

.v4-chat-clear-btn:hover {
    background: #f9fafb !important;
    border-color: #d1d5db !important;
    color: #111827 !important;
}

.v4-chat-clear-btn i {
    color: #4a6fa5;
}

.v4-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    padding: 0;
}

.v4-chat-messages-inner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    padding: 0.5rem 1rem 0.75rem;
    min-height: min-content;
}

.v4-chat-bubble {
    max-width: 78%;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    font-size: 0.80rem;
    line-height: 1.35;
    color: #1e293b;
}

.v4-chat-bubble.is-assistant {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.v4-chat-bubble.is-user {
    align-self: flex-end;
    background: #1e3d59;
    color: #f8fafc;
}

.v4-chat-bubble-role {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    opacity: 0.7;
}

.v4-chat-composer-wrap {
    position: relative;
    flex-shrink: 0;
    width: calc(100% - 2rem);
    max-width: 920px;
    margin: 0 auto;
}

.v4-chat-tool-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.3rem;
    margin: 0 0 0.35rem;
    min-height: 30px;
}

.v4-chat-tool-badges {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}

.v4-tool-toggle,
.v4-tool-badge,
.v4-tool-upload,
.v4-tool-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    height: 30px;
    padding: 0 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    line-height: 1;
    user-select: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* 图标模式：方形圆形按钮，只显示图标 */
.v4-tool-badge.is-icon,
.v4-tool-upload.is-icon,
.v4-tool-info-btn.is-icon {
    width: 30px;
    min-width: 30px;
    padding: 0;
}

.v4-tool-toggle,
.v4-tool-upload,
.v4-tool-badge.is-icon,
.v4-tool-info-btn {
    cursor: pointer;
}

.v4-tool-badge:not(.is-icon) {
    cursor: default;
}

.v4-tool-toggle.is-on,
.v4-tool-badge.is-on,
.v4-tool-upload.is-on,
.v4-tool-badge.is-icon.is-active,
.v4-tool-info-btn.is-active {
    background: #e8eef7;
    border-color: #4a6fa5;
    color: #2f4d73;
}

.v4-tool-badge.is-muted {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #94a3b8;
}

.v4-tool-upload input {
    display: none;
}

.v4-chat-tool-tip {
    margin: 0 0 0.4rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.45rem;
    background: #f8fafc;
    color: #334155;
    font-size: 0.75rem;
    line-height: 1.45;
}

.v4-chat-tool-tip[hidden] {
    display: none !important;
}

.v4-chat-tool-tip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.15rem;
}

.v4-chat-tool-tip-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #1e3d59;
}

.v4-chat-tool-tip-close {
    flex-shrink: 0;
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #94a3b8;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.v4-chat-tool-tip-close:hover {
    color: #475569;
    background: #e2e8f0;
}

.v4-chat-tool-tip-body {
    margin: 0;
    color: #64748b;
}

.v4-sizing-load-charts {
    margin-top: 0.5rem;
}

.v4-sizing-load-chart-card {
    border: 1px solid var(--v2-border, #dee2e6);
    border-radius: 0.35rem;
    padding: 0.4rem 0.5rem 0.55rem;
    background: var(--v2-card-bg, #fff);
}

.v4-sizing-load-chart-wrap {
    position: relative;
    width: 100%;
    height: 180px;
}

.v4-portal-step-item.is-failed > .v4-portal-step-num {
    background: #dc3545;
    color: #fff;
}

.v4-upload-purpose-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin: 0.35rem 0 0.25rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--v2-border, #dee2e6);
    border-radius: 0.4rem;
    background: var(--v2-card-bg, #fff);
}

.v4-upload-purpose-panel[hidden] {
    display: none !important;
}

.v4-upload-purpose-label {
    font-size: 0.8125rem;
    color: var(--v2-muted, #6c757d);
    font-weight: 600;
}

.v4-upload-purpose-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.85rem;
}

.v4-upload-purpose-option {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8125rem;
    margin: 0;
    cursor: pointer;
}

.v4-upload-purpose-option input {
    margin: 0;
}

.v4-tool-upload-hint {
    min-height: 0;
    margin: 0 0 0.35rem;
    font-size: 0.75rem;
    color: #64748b;
}

/* 文件说明正文隐藏，仅作 tip 数据源 */
.v4-chat-tool-limits {
    display: none !important;
}

.v4-pending-file-list {
    list-style: none;
    margin: 0 0 0.4rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.v4-pending-file-list li {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    padding: 0.15rem 0.45rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    font-size: 0.72rem;
    color: #334155;
}

.v4-pending-file-list button {
    border: 0;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.v4-chat-status {
    color: #64748b;
    font-size: 0.82rem;
}

.v4-chat-composer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
    width: 100%;
    padding: 0.65rem 0.7rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.v4-task-composer-toggle {
    display: none;
}

.v4-chat-composer textarea {
    flex: 1 1 12rem;
    min-height: 44px;
    max-height: 140px;
    resize: none;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 0.80rem !important;
    color: #1e293b;
}

.v4-chat-composer textarea:disabled {
    color: #94a3b8;
}

.v4-chat-composer-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    flex-shrink: 0;
}

.v4-chat-composer-send {
    flex-shrink: 0;
    background: #4a6fa5 !important;
    border: 1px solid #4a6fa5 !important;
    color: #ffffff !important;
    height: 38px;
    min-height: 38px;
    min-width: 72px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.80rem;
}

.v4-chat-voice-btn,
.v4-chat-stop-btn {
    height: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    white-space: nowrap;
    font-size: 0.80rem;
}

.v4-chat-stop-btn {
    display: none;
}

.v4-chat-stop-btn.is-visible {
    display: inline-flex;
}

.v4-chat-voice-btn.is-listening {
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
    background: #fef2f2 !important;
}

.v4-asr-hint {
    flex: 1 0 100%;
    font-size: 0.72rem;
    line-height: 1.3;
    color: #6b7280;
}

/* 主栏底部备案脚注（v4_base 全站） */
.v4-page-icp {
    flex-shrink: 0;
    margin: 0;
    padding: 0.35rem 0.75rem 0.5rem;
    text-align: center;
    font-size: 0.68rem;
    line-height: 1.35;
    color: #94a3b8;
}

.v4-page-icp a {
    color: inherit;
    text-decoration: none;
}

.v4-page-icp a:hover,
.v4-page-icp a:focus {
    text-decoration: underline;
}

.v4-chat-user-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.v4-chat-workbench .assistant-markdown {
    font-size: 0.80rem;
}

.v4-chat-workbench .assistant-markdown h1 { font-size: 1.1em; font-weight: 600; margin: 0.5em 0 0.3em; }
.v4-chat-workbench .assistant-markdown h2 { font-size: 1.05em; font-weight: 600; margin: 0.5em 0 0.3em; }
.v4-chat-workbench .assistant-markdown h3,
.v4-chat-workbench .assistant-markdown h4,
.v4-chat-workbench .assistant-markdown h5,
.v4-chat-workbench .assistant-markdown h6 { font-size: 1em; font-weight: 600; margin: 0.4em 0 0.25em; }
.v4-chat-workbench .assistant-markdown p { margin-bottom: 0.5em; }
.v4-chat-workbench .assistant-markdown p:last-child { margin-bottom: 0; }
.v4-chat-workbench .assistant-markdown ul,
.v4-chat-workbench .assistant-markdown ol { margin: 0.3em 0; padding-left: 1.5em; }
.v4-chat-workbench .assistant-markdown code { background: #f0f0f0; padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.9em; }
.v4-chat-workbench .assistant-markdown pre { background: #f5f5f5; padding: 0.6em; border-radius: 4px; overflow-x: auto; margin: 0.5em 0; }
.v4-chat-workbench .assistant-markdown pre code { background: none; padding: 0; }
.v4-chat-workbench .assistant-markdown blockquote { border-left: 3px solid #ccc; margin: 0.5em 0; padding-left: 1em; color: #555; }
.v4-chat-workbench .assistant-markdown table { border-collapse: collapse; margin: 0.5em 0; }
.v4-chat-workbench .assistant-markdown th,
.v4-chat-workbench .assistant-markdown td { border: 1px solid #ddd; padding: 0.3em 0.6em; }
.v4-chat-workbench .assistant-markdown th { background: #f0f0f0; }
.v4-chat-workbench .assistant-markdown a { color: #1e3d59; }

.v4-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.35rem 0.4rem 0.5rem;
}

.v4-sidebar-action-btn {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
}

.v4-sidebar-project-head {
    align-items: center;
    min-width: 0;
}

.v4-sidebar-project-toggle {
    flex: 1 1 auto;
    min-width: 0;
    gap: 0.35rem;
    padding-left: 0.45rem;
}

.v4-sidebar-project-toggle .v3-nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 去掉项目/对话清单左侧竖线，避免项目被夹在框线里 */
.v4-portal-layout .v3-portal-service-sidebar .v2-nav-sub {
    border-left: none;
    margin-left: 0;
}

.v4-portal-layout .v3-portal-service-sidebar button.v2-nav-link {
    border: 0;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
}

.v4-portal-layout .v3-portal-service-sidebar button.v2-nav-link:focus {
    outline: none;
    box-shadow: none;
}

.v4-portal-layout .v3-portal-service-sidebar button.v2-nav-link:focus-visible {
    background: var(--v2-accent-soft, #e5edf7);
}

/* 项目行操作：宽栏始终可见加对话、图钉 */
.v4-portal-layout .v4-sidebar-project-row > .v4-sidebar-project-head > .v3-portal-sidebar-task-actions {
    opacity: 1;
}

/* 竖栏收起后隐藏加对话、置顶（以及对话删除），避免挤在图标上 */
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v3-portal-sidebar-task-actions {
    display: none !important;
}

.v4-sidebar-icon-form {
    display: inline-flex;
    margin: 0;
}

/* 窄栏时仍显示项目列表（v3 会隐藏任务清单整段） */
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v3-portal-sidebar-task-section {
    display: block;
}

.v4-sidebar-chat-list {
    margin-left: 0.35rem;
    /* 对话记录：竖排一行一条，避免并排挤在一起 */
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.v4-portal-layout .v4-sidebar-chat-list > .v2-nav-item {
    width: 100%;
    min-width: 0;
}

.v4-portal-layout .v4-sidebar-chat-list .v3-portal-sidebar-task-row-inner {
    width: 100%;
    min-width: 0;
}

/* 覆盖通用 .v4-chat-list-link { display:block }，侧栏对话保持 flex 单行 */
.v4-portal-layout .v4-sidebar-chat-list .v4-chat-list-link {
    display: flex;
    align-items: center;
    width: auto;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
}

/* 标题放不下则单行省略号；完整标题仍可用 a[title] */
.v4-portal-layout .v4-sidebar-chat-list .v4-chat-list-link .v3-nav-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v4-portal-layout .v4-sidebar-chat-list .v4-chat-list-link > i {
    flex-shrink: 0;
}

/* 收起后：所有图标同一尺寸、同一列对齐，去掉子项描边框 */
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v4-sidebar-actions {
    padding-left: 0;
    padding-right: 0;
    align-items: center;
}

.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v4-sidebar-action-btn {
    width: auto;
    justify-content: center;
}

.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-list,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-sub,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v4-sidebar-chat-list {
    padding-left: 0;
    margin-left: 0;
    border-left: none;
}

.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-link,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-parent-toggle,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v4-sidebar-project-toggle {
    justify-content: center;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
}

.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-link i,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-parent-toggle i:first-child,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-sub .v2-nav-link i {
    margin: 0 auto;
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border: none;
    border-radius: 8px;
    background: #eef2f7;
    color: #334155;
    box-shadow: none;
}

.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-link.active i,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-parent-toggle.active i:first-child,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-parent-toggle[aria-expanded="true"] i:first-child,
.v4-portal-layout .v3-portal-service-sidebar.sidebar-compact .v2-nav-sub .v2-nav-link.active i {
    border: none;
    background: var(--v2-accent-soft, #e5edf7);
    color: var(--v2-accent, #4a6fa5);
}

.v4-chat-empty {
    margin: 1.25rem auto;
    max-width: 28rem;
    text-align: center;
    color: #64748b;
    font-size: 0.88rem;
}

.v4-chat-md p {
    margin-bottom: 0.4em;
}

.v4-chat-md p:last-child {
    margin-bottom: 0;
}

.v4-project-meta {
    margin: 0;
    font-size: 0.82rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem 0.75rem;
}

.v4-project-meta-item {
    min-width: 0;
}

.v4-project-meta-item.is-full {
    grid-column: 1 / -1;
}

.v4-project-meta-label {
    display: block;
    color: #64748b;
    font-weight: 600;
    margin: 0;
}

.v4-project-meta-value {
    display: block;
    margin: 0.15rem 0 0;
    color: #1e293b;
    word-break: break-word;
}

@media (max-width: 576px) {
    .v4-project-meta {
        grid-template-columns: 1fr;
    }
}

.v4-task-file-list {
    margin: 0.35rem 0 0;
    padding-left: 0;
    list-style: none;
    font-size: 0.82rem;
    color: #334155;
}

.v4-task-file-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.28rem 0;
    border-bottom: 1px solid #eef2f7;
}

.v4-reader-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v4-reader-file-actions {
    display: inline-flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.v4-reader-file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #4a6fa5;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    font-size: 0.82rem;
}

.v4-reader-file-icon:hover {
    background: #e8eef7;
    color: #2f4d73;
}

.v4-reader-file-icon.is-danger {
    color: #b45353;
}

.v4-reader-file-icon.is-danger:hover {
    background: #fdecec;
    color: #9b3a3a;
}

.v4-reader-file-empty {
    color: #94a3b8;
    border-bottom: 0 !important;
}

.v4-reader-file-text {
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.9rem 1rem;
    font-size: 0.85rem;
}

/* 侧栏 z-index 高于 Bootstrap 默认 modal，需抬高登录/项目弹层 */
.v4-portal-body .modal {
    z-index: 1400;
}

.v4-portal-body .modal-backdrop {
    z-index: 1350;
}

/* 窄屏：主栏铺满对话；左栏抽屉；当前项目覆盖层，不挤掉对话区 */
@media (max-width: 768px) {
    .v4-portal-layout:not(.v4-portal-layout-aux-only) {
        flex-wrap: nowrap;
    }

    .v4-portal-layout .v3-portal-main-col {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
        min-height: 0;
        height: 100%;
    }

    .v4-portal-layout .v3-portal-main-col > .v4-chat-workbench {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
    }

    .v4-task-resizer {
        display: none !important;
    }

    .v4-portal-task-panel {
        position: fixed;
        top: var(--v3-topbar-height);
        right: 0;
        bottom: 0;
        left: auto;
        width: min(100vw, 360px);
        max-width: 100vw;
        min-width: 0;
        min-height: 0;
        max-height: none;
        z-index: 1300;
        border-left: 1px solid var(--v3-sidebar-border);
        border-top: 0;
        box-shadow: -4px 0 24px rgba(15, 23, 42, 0.12);
        transform: translateX(100%);
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
        transition: visibility 0.2s ease, opacity 0.2s ease, transform 0.25s ease;
    }

    .v4-portal-layout.ai-collapsed .v4-portal-task-panel {
        display: flex !important;
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
        transform: translateX(100%);
    }

    .v4-portal-layout:not(.ai-collapsed) .v4-portal-task-panel {
        display: flex !important;
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transform: translateX(0);
    }

    /* 底栏大胶囊隐藏；图标钉在输入框右上角 */
    .v4-portal-body .v4-task-floating-toggle {
        display: none !important;
    }

    .v4-chat-composer-wrap {
        width: calc(100% - 1.25rem);
        margin: 0 auto;
        padding-top: 2.15rem;
    }

    .v4-task-composer-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 0;
        right: 0;
        z-index: 6;
        width: 2rem;
        height: 2rem;
        padding: 0;
        border: 1px solid #e5e7eb;
        border-radius: 999px;
        background: #ffffff;
        color: #4a6fa5;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    }

    .v4-task-composer-toggle i {
        font-size: 0.85rem;
        color: #4a6fa5;
    }

    .v4-chat-bubble {
        max-width: 92%;
    }
}

/* 知识库助理右栏：知识明细卡片 */
.v4-kb-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 280px;
    overflow: auto;
}

.v4-kb-item-card {
    border: 1px solid var(--v3-sidebar-border, #e2e8f0);
    border-radius: 8px;
    padding: 0.5rem 0.65rem;
    background: #f8fafc;
}

.v4-kb-items-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.v4-kb-graph-details > summary {
    cursor: pointer;
    list-style: none;
}

.v4-kb-graph-details > summary::-webkit-details-marker {
    display: none;
}

/* 侧栏窄：图画布与节点详情上下排列，不要并排 */
.v4-kb-graph-layout.v3-ekb-graph-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: 0;
}

.v4-kb-graph-layout .v3-ekb-graph-canvas-wrap {
    min-height: 220px;
}

.v4-kb-graph-side {
    max-height: 180px;
    overflow: auto;
}

/* 对话内知识库引用（对齐 v3 .ekb-cite） */
.v4-chat-bubble .ekb-chat-cites {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #cbd5e1;
}

.v4-chat-bubble .ekb-cite {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}
