/* 参谋部 - PM 智能副驾 - 样式表 */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}

/* ========== Header ========== */
.header {
    background: var(--card-bg); border-bottom: 1px solid var(--border);
    padding: 0 24px; height: 60px; display: flex; align-items: center;
    justify-content: space-between; box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
    width: 36px; height: 36px; background: linear-gradient(135deg, #2563eb, #7c3aed);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.logo-icon svg { width: 30px; height: 30px; }
.logo-text { display: flex; flex-direction: column; }
.logo-title { font-weight: 700; font-size: 16px; }
.logo-sub { font-size: 11px; color: var(--text-light); }
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
    padding: 8px 20px; border: none; background: transparent;
    color: var(--text-light); font-size: 14px; cursor: pointer;
    border-radius: 6px; transition: all 0.2s;
}
.nav-tab:hover { background: var(--bg); color: var(--text); }
.nav-tab.active { background: var(--primary); color: white; }
.header-right { display: flex; align-items: center; gap: 12px; }
.badge { padding: 4px 12px; background: var(--warning-light); color: var(--warning); border-radius: 16px; font-size: 12px; font-weight: 500; }

/* ========== Buttons ========== */
.btn {
    padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer;
    font-size: 13px; font-weight: 500; transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 4px;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-default { background: var(--border); color: var(--text); }

/* ========== Main ========== */
.main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== Toolbar ========== */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toolbar-left { display: flex; align-items: center; gap: 12px; }
.toolbar-left h2 { font-size: 20px; font-weight: 700; }
.toolbar-right { display: flex; gap: 8px; }
.count-badge { padding: 3px 10px; background: var(--primary-light); color: var(--primary); border-radius: 16px; font-size: 12px; font-weight: 500; }

/* ========== Stats Bar ========== */
.req-stats-bar {
    background: var(--card-bg); border-radius: var(--radius); padding: 10px 16px;
    box-shadow: var(--shadow); margin-bottom: 16px; font-size: 13px;
    color: var(--text); font-weight: 500;
}

/* ========== Filter Bar ========== */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-bar select {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
    background: white; font-size: 13px; cursor: pointer; outline: none;
}
.filter-bar select:focus { border-color: var(--primary); }

/* ========== Requirement Table ========== */
.req-table-wrapper { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.req-table { width: 100%; border-collapse: collapse; }
.req-table th { background: var(--bg); padding: 10px 12px; text-align: left; font-weight: 600; font-size: 12px; color: var(--text-light); border-bottom: 1px solid var(--border); white-space: nowrap; }
.req-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.req-table tbody tr:hover { background: #f8fafc; }
.req-table tbody tr:last-child td { border-bottom: none; }
.empty-state { text-align: center; color: var(--text-light); padding: 48px 0 !important; }

/* Priority Tags */
.tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.tag-p0 { background: var(--danger-light); color: var(--danger); }
.tag-p1 { background: var(--warning-light); color: var(--warning); }
.tag-p2 { background: #e0e7ff; color: #4338ca; }
.tag-p3 { background: var(--bg); color: var(--text-light); }
.tag-suggested { background: #f1f5f9; color: #64748b; }

/* Source Tags */
.source-tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.source-ticket { background: #fee2e2; color: #991b1b; }
.source-customer_service { background: #fef3c7; color: #92400e; }
.source-business { background: #dbeafe; color: #1e40af; }
.source-operations { background: #d1fae5; color: #065f46; }

/* Status Tags */
.status-tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.status-pending_review { background: #e0e7ff; color: #3730a3; }
.status-queued { background: #dbeafe; color: #1e40af; }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-accepting { background: #d1fae5; color: #065f46; }
.status-completed { background: #dcfce7; color: #16a34a; }
.status-suspended { background: #f1f5f9; color: #94a3b8; }
.status-rejected { background: #fee2e2; color: #dc2626; }

/* ========== Stat Cards ========== */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
    border-left: 3px solid var(--primary);
}
.stat-card.stat-p0 { border-left-color: var(--danger); }
.stat-card.stat-p1 { border-left-color: var(--warning); }
.stat-label { font-size: 13px; color: var(--text-light); }
.stat-value { font-size: 28px; font-weight: 700; }

/* ========== Charts ========== */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.chart-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.chart-card.chart-wide { grid-column: span 2; }
.chart { width: 100%; height: 300px; }

/* ========== Smart Q&A ========== */
.ask-container { max-width: 800px; margin: 0 auto; }
.ask-suggestions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.suggestion-label { font-size: 13px; color: var(--text-light); }
.suggestion-btn {
    padding: 6px 14px; background: var(--primary-light); color: var(--primary);
    border: 1px solid var(--primary); border-radius: 16px; cursor: pointer; font-size: 12px; transition: all 0.2s;
}
.suggestion-btn:hover { background: var(--primary); color: white; }
.ask-chat {
    background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px; min-height: 400px; max-height: 500px; overflow-y: auto; margin-bottom: 16px;
}
.chat-empty { text-align: center; color: var(--text-light); padding: 100px 0; font-size: 14px; }
.chat-msg { margin-bottom: 16px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg-user { text-align: right; }
.chat-msg-user .msg-bubble { background: var(--primary); color: white; display: inline-block; padding: 10px 16px; border-radius: 16px 16px 4px 16px; max-width: 80%; text-align: left; }
.chat-msg-ai {
    position: relative;
}
.chat-msg-ai .msg-bubble { background: var(--bg); color: var(--text); display: inline-block; padding: 10px 16px; border-radius: 4px 16px 16px 16px; width: 90%; max-width: 90%; }
.chat-msg-ai .msg-bubble strong { color: var(--primary); }
.ask-input-bar { display: flex; gap: 8px; }
.ask-input-bar input { flex: 1; padding: 10px 16px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; }
.ask-input-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
    border-radius: 6px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 80%;
    word-break: break-word;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.success,
.toast.error,
.toast.warning {
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
}

/* ========== Loading ========== */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8); display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 2000;
}
.loading-spinner {
    width: 40px; height: 40px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: 16px; color: var(--text-light); font-size: 14px; }

/* ========== Modal ========== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); display: flex; align-items: center;
    justify-content: center; z-index: 1500;
}
.modal {
    background: var(--card-bg); border-radius: 12px; width: 640px;
    max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-lg { width: 800px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-light); cursor: pointer; line-height: 1; padding: 0; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ========== Detail Modal ========== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-item label { font-size: 11px; color: var(--text-light); text-transform: uppercase; }
.detail-item select {
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; outline: none; cursor: pointer;
}
.detail-item select:focus { border-color: var(--primary); }
.detail-value-mono { font-family: "SF Mono", Monaco, monospace; font-size: 12px; color: #94a3b8; }
.detail-section { margin-bottom: 20px; }
.detail-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.detail-section p { font-size: 13px; color: var(--text); line-height: 1.8; }

.merged-item {
    padding: 10px 12px; background: var(--bg); border-radius: 6px;
    margin-bottom: 8px; border-left: 3px solid var(--primary);
    font-size: 13px; line-height: 1.6;
}

.follow-record {
    padding: 10px 12px; border-left: 3px solid var(--success);
    background: var(--success-light, #dcfce7); border-radius: 6px;
    margin-bottom: 8px;
}
.follow-time { font-size: 11px; color: var(--text-light); margin-bottom: 4px; }
.follow-content { font-size: 13px; color: var(--text); }

.follow-input-bar { display: flex; gap: 8px; flex: 1; }
.follow-input-bar input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; }
.follow-input-bar input:focus { border-color: var(--primary); }

.text-muted { color: var(--text-light); font-size: 13px; }

/* ========== Strategy Modal ========== */
.rules-hint {
    font-size: 13px; color: var(--text-light); margin-bottom: 16px;
    padding: 8px 12px; background: var(--primary-light); border-radius: 6px;
}
.rules-textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; outline: none; resize: vertical; font-family: inherit; line-height: 1.6;
}
.rules-textarea:focus { border-color: var(--primary); }

/* ========== RAG ========== */
.kb-info-bar {
    display: flex; gap: 24px; padding: 12px 16px; background: var(--card-bg);
    border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; flex-wrap: wrap;
}
.kb-info-item { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.kb-info-label { color: var(--text-light); }
.kb-info-value { color: var(--text); }
.kb-tag-success { background: var(--success-light); color: var(--success); padding: 2px 8px; border-radius: 4px; font-weight: 600; font-size: 12px; }
.kb-search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.kb-search-bar input { flex: 1; padding: 10px 16px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; }
.kb-search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.kb-search-results { margin-bottom: 16px; }
.kb-search-result-item { background: var(--card-bg); border-radius: 6px; padding: 12px 16px; margin-bottom: 8px; box-shadow: var(--shadow); border-left: 3px solid var(--primary); }
.kb-result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.kb-result-title { font-weight: 600; font-size: 13px; }
.kb-result-relevance { font-size: 12px; color: var(--text-light); background: var(--bg); padding: 2px 8px; border-radius: 4px; }
.kb-result-content { font-size: 12px; color: var(--text-light); line-height: 1.5; }
.kb-add-form { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.kb-add-form h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.kb-form-row { margin-bottom: 12px; }
.kb-form-row label { display: block; font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.kb-form-row input, .kb-form-row select, .kb-form-row textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 13px; outline: none; font-family: inherit;
}
.kb-form-row input:focus, .kb-form-row select:focus, .kb-form-row textarea:focus { border-color: var(--primary); }
.kb-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.kb-list { display: flex; flex-direction: column; gap: 8px; }
.kb-card { background: var(--card-bg); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; gap: 12px; }
.kb-card-category { width: 110px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.kb-cat-tag { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.kb-source-tag { display: inline-block; padding: 2px 6px; background: var(--bg); color: var(--text-light); border-radius: 4px; font-size: 10px; }
.kb-cat-product_roadmap { background: #dbeafe; color: #1e40af; }
.kb-cat-historical_decision { background: #fef3c7; color: #92400e; }
.kb-cat-business_constraint { background: #fee2e2; color: #991b1b; }
.kb-cat-competitor { background: #e0e7ff; color: #3730a3; }
.kb-cat-customer_segment { background: #d1fae5; color: #065f46; }
.kb-cat-tech_constraint { background: #f3e8ff; color: #6b21a8; }
.kb-card-body { flex: 1; }
.kb-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.kb-card-content { font-size: 13px; color: var(--text-light); line-height: 1.5; margin-bottom: 4px; }
.kb-card-tags { font-size: 11px; color: var(--text-light); }
.kb-card-actions { display: flex; align-items: flex-start; }
.kb-delete-btn { background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 16px; padding: 4px; border-radius: 4px; }
.kb-delete-btn:hover { background: var(--danger-light); color: var(--danger); }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .chart-grid { grid-template-columns: 1fr; }
    .chart-card.chart-wide { grid-column: span 1; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
}

/* ========== 智能问答思考过程 ========== */
.msg-thinking {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 12px;
    background: transparent;
    width: 90%;
    max-width: 90%;
    display: inline-block;
}

.thinking-title {
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    font-size: 12px;
}

.thinking-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 280px;
    overflow-y: auto;
}

.thinking-step {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px 0;
    font-size: 11px;
    line-height: 1.5;
    background: transparent;
    border: none;
}

.thinking-step-result {
    background: transparent;
    border-color: transparent;
}

.step-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
}

.step-label {
    color: #475569;
    font-size: 11px;
    flex-shrink: 0;
}

.step-row code {
    background: transparent;
    color: #334155;
    padding: 0;
    border-radius: 0;
    font-size: 11px;
    font-family: 'SF Mono', Consolas, monospace;
}

.step-args {
    color: #64748b;
    font-size: 10px;
    font-family: 'SF Mono', Consolas, monospace;
    word-break: break-word;
    white-space: pre-wrap;
}

.step-result {
    color: #334155;
    font-size: 10px;
    font-family: 'SF Mono', Consolas, monospace;
    word-break: break-word;
    white-space: pre-wrap;
    max-height: none;
    overflow: visible;
    text-overflow: clip;
    margin-top: 2px;
}

/* ========== 流式输出光标 ========== */
.streaming-cursor {
    display: inline-block;
    animation: cursor-blink 1s step-end infinite;
    color: #2563eb;
    font-weight: bold;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ========== 澄清问题框 ========== */
.clarify-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 12px;
    margin-top: 4px;
}

.clarify-question {
    font-weight: 500;
    color: #92400e;
    margin-bottom: 8px;
}

.clarify-opt {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 10px;
    margin-bottom: 4px;
    background: #fff;
    border: 1px solid #fde68a;
    border-radius: 4px;
    color: #92400e;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}

.clarify-opt:hover {
    background: #fef3c7;
}

.clarify-input-bar {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.clarify-input-bar input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #fde68a;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
}

.clarify-input-bar button {
    padding: 6px 14px;
    background: #f59e0b;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}


/* ========== Markdown 渲染样式（智能问答回答区） ========== */
.msg-bubble > h1,
.msg-bubble > h2,
.msg-bubble > h3,
.msg-bubble > h4 {
    margin: 12px 0 6px 0;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
}
.msg-bubble > h1 { font-size: 18px; }
.msg-bubble > h2 { font-size: 16px; }
.msg-bubble > h3 { font-size: 15px; }
.msg-bubble > h4 { font-size: 14px; }

.msg-bubble > p {
    margin: 6px 0;
    line-height: 1.7;
    color: #334155;
}

.msg-bubble > strong {
    color: #1e40af;
    font-weight: 600;
}

.msg-bubble > ul,
.msg-bubble > ol {
    margin: 6px 0;
    padding-left: 22px;
    line-height: 1.7;
}
.msg-bubble > li {
    margin: 3px 0;
    color: #334155;
}
.msg-bubble > ul li { list-style: disc; }
.msg-bubble > ol li { list-style: decimal; }

/* 表格：核心需求，必须好看 */
.msg-bubble > table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 13px;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.msg-bubble > table th,
.msg-bubble > table td {
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    text-align: left;
    color: #334155;
}
.msg-bubble > table thead tr {
    background: #f1f5f9;
}
.msg-bubble > table th {
    font-weight: 600;
    color: #1e293b;
    font-size: 12px;
}
.msg-bubble > table tbody tr:nth-child(even) {
    background: #f8fafc;
}
.msg-bubble > table tbody tr:hover {
    background: #eff6ff;
}

/* 行内代码 + 代码块 */
.msg-bubble > code {
    background: #f1f5f9;
    color: #be185d;
    padding: 1px 6px;
    border-radius: 3px;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 12.5px;
}
.msg-bubble > pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px 14px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12.5px;
    line-height: 1.6;
}
.msg-bubble > pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

/* 引用 */
.msg-bubble > blockquote {
    border-left: 3px solid #3b82f6;
    padding: 4px 12px;
    margin: 8px 0;
    background: #f8fafc;
    color: #475569;
    font-style: italic;
    border-radius: 0 4px 4px 0;
}

/* 分隔线 */
.msg-bubble > hr {
    border: 0;
    border-top: 1px dashed #cbd5e1;
    margin: 12px 0;
}

/* 链接 */
.msg-bubble > a {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px solid #93c5fd;
}
.msg-bubble > a:hover {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}


/* ========== 打字动画（流式阶段显示，避免 markdown 字符闪烁） ========== */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
    vertical-align: middle;
}
.typing-dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ========== 批注功能 ========== */
.annotation-highlight {
    background: #e2e8f0 !important;
    border-radius: 2px;
    padding: 1px 0;
    cursor: pointer;
    position: relative;
    color: #1e293b !important;
}

/* 侧边批注面板 - 相对于 .chat-msg-ai 定位，嵌在对话框内部 */
.annotation-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    min-height: 200px;
    background: #fff;
    box-shadow: -4px 0 16px rgba(0,0,0,0.10);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    border-radius: 0 8px 8px 0;
}
.annotation-panel.open {
    transform: translateX(0);
}

.annotation-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.annotation-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}
.annotation-panel-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.annotation-panel-close:hover { color: #475569; }

.annotation-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 面板内的引用文字 */
.ann-quote-card {
    padding: 10px 14px;
    background: #f8fafc;
    border-left: 3px solid #cbd5e1;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #475569;
    line-height: 1.6;
    font-style: italic;
    max-height: 120px;
    overflow-y: auto;
}

/* 面板内的 textarea */
.annotation-panel textarea {
    width: 100%;
    min-height: 100px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    line-height: 1.6;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.annotation-panel textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

/* 面板底部操作栏 */
.annotation-panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.ann-btn-cancel {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}
.ann-btn-cancel:hover { background: #f1f5f9; color: #334155; }

.ann-btn-save {
    background: #2563eb;
    border: none;
    color: #fff;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}
.ann-btn-save:hover { background: #1d4ed8; }
.ann-btn-save:disabled { background: #93c5fd; cursor: not-allowed; }

/* 面板内已保存批注列表 */
.saved-ann-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.saved-ann-item {
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 13px;
}
.saved-ann-item .saved-ann-quote {
    color: #64748b;
    font-size: 12px;
    font-style: italic;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #bbf7d0;
}
.saved-ann-item .saved-ann-text {
    color: #166534;
    line-height: 1.5;
}

/* 添加批注浮动按钮 */
.add-annotation-btn {
    position: fixed;
    z-index: 99999;
    background: #1e293b;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    white-space: nowrap;
}
.add-annotation-btn:hover {
    background: #334155;
}

/* 结合批注重答 按钮 */
.reanswer-bar {
    display: none;
    padding: 8px 14px;
    margin-top: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    align-items: center;
    gap: 10px;
}
.reanswer-bar.show {
    display: flex;
}
.reanswer-bar .reanswer-info {
    font-size: 13px;
    color: #166534;
}
.reanswer-bar .reanswer-btn {
    margin-left: auto;
    background: #16a34a;
    border: none;
    color: #fff;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}
.reanswer-bar .reanswer-btn:hover { background: #15803d; }
.reanswer-bar .reanswer-btn:disabled { background: #86efac; cursor: not-allowed; }

/* 批注面板背景层（对话框内部的半透明遮罩） */
.annotation-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.04);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    border-radius: 8px;
    transition: opacity 0.25s ease;
}
.annotation-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
