:root {
    --primary-color: #3b82f6;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* --- Compatibility mappings for HTML class names used in index.html --- */
.input-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}
.section-title {
    font-size: 1.1em;
    color: var(--gray-900);
    font-weight: 700;
    margin-bottom: 15px;
}
.text-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.input-group {
    display: flex;
    flex-direction: column;
}
.input-group label {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95em;
}
.input-group textarea {
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95em;
    resize: vertical;
    min-height: 200px;
    transition: all 0.3s ease;
}
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.char-counter, .char-count {
    font-size: 0.85em;
    color: var(--gray-600);
    margin-top: 5px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}
.stat-label {
    font-size: 0.95em;
    color: rgba(255,255,255,0.85);
}
.stat-value {
    font-size: 1.4em;
    font-weight: 700;
    color: #fff;
}
/* --- End compatibility mappings --- */


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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Microsoft YaHei', sans-serif;
    color: var(--gray-800);
    background-color: #fafbfc;
    scroll-behavior: smooth;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
}

.logo h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.95;
    font-weight: 300;
}

.main-content {
    padding: 0 20px 40px 20px;
}

section {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.section-header {
    margin-bottom: 25px;
    border-bottom: 2px solid var(--gray-100);
    padding-bottom: 15px;
}

.section-header h2 {
    font-size: 1.5em;
    color: var(--gray-900);
}

.input-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.text-input-group {
    display: flex;
    flex-direction: column;
}

.text-input-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-800);
    font-size: 0.95em;
}

.text-input {
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95em;
    resize: vertical;
    min-height: 200px;
    transition: all 0.3s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.char-count {
    font-size: 0.85em;
    color: var(--gray-600);
    margin-top: 5px;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--gray-200);
    color: var(--gray-800);
}

.btn-secondary:hover {
    background-color: var(--gray-300);
}

.btn-accent {
    background-color: #10b981;
    color: #fff;
}

.btn-accent:hover {
    background-color: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.options-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-group label {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.95em;
}

.option-group input[type='text'],
.option-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.95em;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.option-group textarea {
    min-height: 72px;
    resize: vertical;
    line-height: 1.5;
}

.option-group input[type='text']:focus,
.option-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.option-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.95em;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.option-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.option-group select:disabled {
    background-color: var(--gray-100);
    color: var(--gray-600);
    cursor: not-allowed;
    opacity: 0.8;
}


.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--gray-200);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.input-small {
    width: 100px;
    padding: 6px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.9em;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.tabs-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    background-color: var(--gray-100);
    border-bottom: 1px solid var(--gray-300);
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    min-width: 150px;
    padding: 15px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--gray-600);
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    font-size: 0.95em;
}

.tab-btn:hover {
    background-color: rgba(59, 130, 246, 0.05);
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    background-color: white;
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.content-inner {
    padding: 30px;
}

.chart-container {
    margin-bottom: 30px;
}

.chart-container h3 {
    margin-bottom: 15px;
    font-size: 1.2em;
    color: var(--gray-900);
}

.chart-container canvas {
    max-height: 400px;
}

.table-container {
    margin-top: 30px;
}

.table-container h3 {
    margin-bottom: 15px;
    font-size: 1.2em;
    color: var(--gray-900);
}

.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.9em;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.data-table thead {
    background-color: var(--gray-100);
    border-top: 1px solid var(--gray-300);
    border-bottom: 2px solid var(--gray-300);
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-800);
    white-space: normal;
    vertical-align: top;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-200);
}

.data-table tbody tr:hover {
    background-color: var(--gray-100);
}

.comparison-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.stat-card h4 {
    margin-bottom: 15px;
    font-size: 1.1em;
}

.stat-card p {
    margin-bottom: 8px;
    font-size: 0.95em;
}

.stat-card span {
    font-weight: 700;
    font-size: 1.1em;
}

.word-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 15px;
    background-color: var(--gray-100);
    border-radius: var(--border-radius);
    min-height: 100px;
}

.word-tag {
    display: inline-block;
    padding: 6px 12px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.9em;
    transition: all 0.3s ease;
    cursor: default;
}

.word-tag:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.word-tag.unique1 {
    background-color: #ef4444;
}

.word-tag.unique2 {
    background-color: #3b82f6;
}

.word-tag.common {
    background-color: #10b981;
}

.comparison-lists {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.list-group {
    background-color: var(--gray-100);
    padding: 20px;
    border-radius: var(--border-radius);
}

.list-group h4 {
    margin-bottom: 15px;
    font-size: 1em;
    color: var(--gray-900);
}

.topics-container {
    margin: 30px 0;
}

.topic-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.topic-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.topic-card h5 {
    margin-bottom: 10px;
    font-size: 1.1em;
}

.topic-card .count {
    font-size: 0.9em;
    opacity: 0.95;
}

.topic-card .percentage {
    font-weight: 700;
    font-size: 1.2em;
    margin-top: 5px;
}

.report-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--gray-200);
}

.report-meta {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    font-size: 0.95em;
    color: var(--gray-600);
}

.report-content {
    line-height: 1.8;
    color: var(--gray-600);
}

.report-content h3 {
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.3em;
    color: var(--primary-color);
}

.report-content h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: var(--gray-800);
}

.report-content p {
    margin-bottom: 10px;
}

.report-content ul, .report-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.report-content li {
    margin-bottom: 8px;
}

.report-actions {
    margin-top: 30px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.placeholder {
    text-align: center;
    color: var(--gray-500);
    font-style: italic;
    padding: 40px;
}

.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    z-index: 1000;
}

.loading-indicator.is-hidden {
    display: none !important;
}

.hidden {
    display: none;
}

.spinner {
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.notification.hidden {
    display: none;
}

.notification.success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.notification.error {
    background-color: #fee2e2;
    color: #7f1d1d;
    border-left: 4px solid #ef4444;
}

.notification.info {
    background-color: #dbeafe;
    color: #0c2d6b;
    border-left: 4px solid #3b82f6;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .logo h1 {
        font-size: 1.8em;
    }

    .input-container {
        grid-template-columns: 1fr;
    }

    .comparison-stats {
        grid-template-columns: 1fr;
    }

    .comparison-lists {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        min-width: auto;
    }

    .options-container {
        grid-template-columns: 1fr;
    }

    .topic-cards {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .data-table {
        font-size: 0.8em;
    }

    .data-table th, .data-table td {
        padding: 8px;
    }

    section {
        padding: 20px;
    }

    .content-inner {
        padding: 20px;
    }

    .main-content {
        padding: 0 10px 20px 10px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.4em;
    }

    .subtitle {
        font-size: 0.95em;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .chart-container canvas {
        max-height: 300px;
    }

    .stat-card {
        padding: 15px;
    }

    .controls {
        flex-direction: column;
    }

    .search-box {
        min-width: auto;
    }

    .report-meta {
        flex-direction: column;
        gap: 10px;
    }
}


/* --- Fix: 限制文档对比（comparison）区域的 chart 大小 --- */
#comparisonChart, .tab-content#comparison canvas {
    max-width: 100%;
    width: 100% !important;
    max-height: 360px;
    height: 360px !important;
    display: block;
    object-fit: contain;
}
@media (max-width: 768px) {
    #comparisonChart, .tab-content#comparison canvas {
        max-height: 300px;
        height: 300px !important;
    }
}
/* --- End comparison chart size fix --- */

/* 文件上传按钮美化 - 优雅配色 */
.file-upload-wrapper {
    margin-top: 10px;
    position: relative;
    border: 2px dashed var(--gray-200);
    border-radius: var(--border-radius);
    padding: 24px 20px 60px;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.file-upload-wrapper.dragover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: var(--shadow-lg);
}

.file-upload-wrapper .helper-text {
    margin-top: 18px;
}

.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.25);
    border: none;
    user-select: none;
}

.file-upload-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.35);
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
}

.file-upload-label:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(79, 172, 254, 0.25);
}

.file-upload-label::before {
    content: '📎';
    font-size: 18px;
    animation: paperclip 2s ease-in-out infinite;
}

@keyframes paperclip {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.file-upload {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* 文件上传成功提示 - 绿色渐变 */
.file-upload-wrapper.uploaded .file-upload-label {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.3);
}

.file-upload-wrapper.uploaded .file-upload-label::before {
    content: '✓';
    animation: checkmark 0.5s ease-out;
}

@keyframes checkmark {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* 暗色主题适配（可选） */
@media (prefers-color-scheme: dark) {
    .file-upload-label {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }
    
    .file-upload-label:hover {
        background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    }
}

/* 相似词容器动画 */
#similarWordsContainer {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 相似词卡片悬停效果 */
#similarWordsContainer > div > div {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 进度条动画 */
@keyframes progressBar {
    from {
        width: 0%;
    }
}

#similarWordsContainer [style*="width"] {
    animation: progressBar 0.8s ease-out;
}

/* LDA 主题关键词容器 */
#ldaTopicWords {
    scroll-behavior: smooth;
}

/* 自定义滚动条（仅 Webkit 浏览器） */
#ldaTopicWords::-webkit-scrollbar {
    width: 8px;
}

#ldaTopicWords::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 10px;
}

#ldaTopicWords::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

#ldaTopicWords::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* 主题卡片入场动画 */
#ldaTopicWords > div > div {
    animation: slideIn 0.5s ease-out backwards;
}

#ldaTopicWords > div > div:nth-child(1) { animation-delay: 0.1s; }
#ldaTopicWords > div > div:nth-child(2) { animation-delay: 0.2s; }
#ldaTopicWords > div > div:nth-child(3) { animation-delay: 0.3s; }
#ldaTopicWords > div > div:nth-child(4) { animation-delay: 0.4s; }
#ldaTopicWords > div > div:nth-child(5) { animation-delay: 0.5s; }

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.highlight {
  background-color: yellow;
  font-weight: bold;
}


/* Parallel text comparison layout */
.text-compare-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.text-compare-column {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 260px;
}

.text-compare-title {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.text-compare-content {
    flex: 1;
    background: var(--gray-100);
    border-radius: 6px;
    padding: 12px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

@media (max-width: 1024px) {
    .text-compare-layout {
        grid-template-columns: 1fr;
    }
}
.highlight-shared {
    background-color: #bfdbfe;
    color: #1e3a8a;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* 多文本统计页面 */
.multi-upload-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: stretch;
}

.multi-upload-panel .file-upload-wrapper {
    flex: 1 1 320px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.multi-options-grid {
    flex: 1 1 260px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.multi-section {
    margin-top: 30px;
    padding: 24px;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.helper-text {
    margin-top: 12px;
    color: var(--gray-500);
    font-size: 0.9em;
}

.doc-list-empty {
    border: 2px dashed var(--gray-200);
    border-radius: var(--border-radius);
    padding: 32px;
    text-align: center;
    color: var(--gray-500);
}

.multi-doc-table table {
    width: 100%;
    border-collapse: collapse;
}

.multi-doc-table th,
.multi-doc-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.multi-doc-table th {
    color: var(--gray-500);
    font-weight: 600;
}

.multi-chart-grid {
    display: grid;
    grid-template-columns: minmax(280px, 480px);
}

@media (min-width: 900px) {
    .multi-chart-grid {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

.chart-wrapper {
    background: #fff;
    padding: 16px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}


.tfidf-results {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tfidf-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 16px;
    background: #fff;
    box-shadow: var(--shadow);
}

.tfidf-card-header {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.tfidf-doc-name {
    font-weight: 600;
    color: var(--gray-900);
}

.tfidf-doc-meta {
    color: var(--gray-500);
    font-size: 0.9em;
}

.tfidf-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.tfidf-card th,
.tfidf-card td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--gray-100);
    text-align: left;
}

.tfidf-card th {
    background: var(--gray-100);
    color: var(--gray-600);
    font-weight: 600;
}

@media (max-width: 768px) {
    .tfidf-card table {
        font-size: 0.8em;
    }
}

.overlap-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.overlap-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    background: #fff;
    padding: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.overlap-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.overlap-card summary {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
}

.overlap-card summary::-webkit-details-marker {
    display: none;
}

.overlap-card-title {
    font-weight: 600;
    color: var(--gray-900);
}

.overlap-card-meta {
    color: var(--gray-500);
    font-size: 0.85em;
}

.overlap-word-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.overlap-word-chip {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--gray-100);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
}

.overlap-chip-count {
    font-weight: 600;
    color: var(--gray-600);
}

.overlap-chip-pill {
    display: inline-flex;
    margin-top: 12px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary-color);
    font-size: 0.85em;
    font-weight: 600;
}

.shared-card .overlap-card-title {
    font-size: 1.05em;
}

.unique-card {
    padding: 0;
    overflow: hidden;
}

.unique-card summary {
    padding: 16px;
}

.unique-card .overlap-word-chip-list {
    border-top: 1px solid var(--gray-200);
    padding: 16px;
}

@media (max-width: 600px) {
    .overlap-card-grid {
        grid-template-columns: 1fr;
    }
}



.cosine-matrix-wrapper {
    margin-top: 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    overflow-x: auto;
    box-shadow: var(--shadow);
    background: #fff;
}

.cosine-matrix-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-size: 0.92em;
}

.cosine-matrix-table th,
.cosine-matrix-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    border-right: 1px solid var(--gray-100);
}

.cosine-matrix-table th {
    background: var(--gray-100);
    color: var(--gray-600);
    font-weight: 600;
    text-align: center;
}

.cosine-matrix-table th:first-child {
    text-align: left;
    width: 180px;
}

.cosine-cell {
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--gray-800);
}

.cosine-cell.is-diagonal {
    background: rgba(16, 185, 129, 0.16);
    color: var(--secondary-color);
    font-weight: 600;
}

.cosine-cell.is-high-similarity {
    background: rgba(237, 244, 224, 0.5);
    color: var(--primary-color);
    font-weight: 600;
}

.cosine-matrix-table tr:last-child td {
    border-bottom: none;
}

.cosine-matrix-table tr td:last-child,
.cosine-matrix-table tr th:last-child {
    border-right: none;
}


/* PMC 页面样式 */
.pmc-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.pmc-config-grid .full-width {
    grid-column: 1 / -1;
}

.pmc-textarea-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 16px;
}

.pmc-textarea-group textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
}

.pmc-textarea-group .helper-text {
    margin-top: 6px;
    margin-bottom: 6px;
    font-size: 0.85em;
}

.pmc-textarea-group.full-width {
    grid-column: 1 / -1;
}

.pmc-matrix-wrapper,
.pmc-stats-wrapper {
    width: 100%;
}

.pmc-policy-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 16px;
}

.pmc-policy-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    background: #fff;
    color: var(--text-color);
    font-size: 0.9rem;
    line-height: 1.2;
    transition: all 0.2s ease;
}

.pmc-policy-tab .code {
    font-weight: 600;
    color: var(--primary-color);
}

.pmc-policy-tab .name {
    font-weight: 500;
    white-space: nowrap;
}

.pmc-policy-tab:hover {
    border-color: var(--primary-color);
}

.pmc-policy-tab.active {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.25);
}

.pmc-policy-tab:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.pmc-indicator-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 0 6px;
    margin-right: 6px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 600;
    font-size: 0.85rem;
}

.pmc-column-entry {
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
    white-space: normal;
}

.pmc-column-entry + .pmc-column-entry {
    margin-top: 4px;
}

.pmc-empty-placeholder {
    padding: 24px;
    text-align: center;
    border: 1px dashed rgba(15, 23, 42, 0.2);
    border-radius: var(--border-radius);
    color: var(--text-muted, #6b7280);
    background: #f9fafb;
}

.pmc-cell-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: #f3f4f6;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pmc-cell-btn.active {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}

.pmc-cell-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}

.pmc-matrix-cell {
    text-align: center;
}

.pmc-cell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.pmc-cell-label {
    font-size: 0.78rem;
    color: #6b7280;
    line-height: 1.2;
    text-align: center;
    min-height: 1.2em;
    word-break: break-word;
}

.pmc-cell-label.is-empty {
    color: #94a3b8;
}

.pmc-cell-placeholder {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius);
    border: 1px dashed rgba(148, 163, 184, 0.8);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #94a3b8;
}

.pmc-cell-disabled {
    opacity: 0.85;
}


.pmc-summary-table {
    margin-bottom: 16px;
}

.pmc-summary-table .table-title {
    font-weight: 600;
    margin-bottom: 8px;
}
.pmc-summary-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 8px;
}

.pmc-summary-actions .btn {
    min-width: 140px;
}


@media (max-width: 640px) {
    .pmc-cell-btn,
    .pmc-cell-placeholder {
        width: 36px;
        height: 36px;
    }
}

.pmc-charts-wrapper {
    margin-top: 16px;
}

.pmc-charts-controls {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin: 12px 0 8px;
}

.pmc-charts-controls .btn {
    min-width: 150px;
}

#pmcRenderChartsBtn {
    background-color: #f97316;
    border-color: #ea580c;
    color: #ffffff;
}

#pmcRenderChartsBtn:hover:not(:disabled) {
    background-color: #ea580c;
    border-color: #c2410c;
}

#pmcRenderChartsBtn:disabled {
    background-color: #fed7aa;
    border-color: #fdba74;
    color: #7c2d12;
}


.pmc-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.pmc-chart-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    min-height: 320px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pmc-chart-section {
    margin-bottom: 28px;
}

.pmc-chart-section-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 12px;
}

.pmc-surface-section {
    border-top: 1px solid #e5e7eb;
    padding-top: 20px;
}

.pmc-surface-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.pmc-surface-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pmc-surface-title {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--gray-900);
}

.pmc-surface-chart {
    height: 260px;
}

.pmc-surface-chart.pmc-surface-chart--empty {
    border: 1px dashed #cbd5f5;
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
}

.pmc-surface-chart--static {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pmc-surface-chart--static img,
.pmc-surface-chart-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

.pmc-surface-matrix {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.pmc-surface-cell {
    border-radius: 6px;
    padding: 10px 4px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
    transition: transform 0.2s ease;
}

.pmc-surface-cell:hover {
    transform: translateY(-1px);
}

.pmc-chart-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1f2937;
}

.pmc-chart-card canvas {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
}

/* PMC chart theme toggle */
.pmc-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background-color: #ffffff;
    font-size: 14px;
    line-height: 1;
}

.pmc-theme-toggle.is-active {
    border-color: #94a3b8;
    background-color: #f8fafc;
}

.pmc-toggle-text {
    font-weight: 500;
    color: #0f172a;
}

.pmc-toggle-state {
    min-width: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: #475569;
}

.pmc-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 44px;
    height: 24px;
}

.pmc-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.pmc-switch-slider {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    background-color: #cbd5f5;
    border-radius: 999px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.pmc-switch-slider::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.2);
    transition: transform 0.2s ease;
}

.pmc-switch input:checked + .pmc-switch-slider {
    background-color: #0f172a;
}

.pmc-switch input:checked + .pmc-switch-slider::after {
    transform: translateX(16px);
}

.pmc-switch input:focus-visible + .pmc-switch-slider::after {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

/* PMC 黑白模式（黑白打印/预览增强） */
body.pmc-theme-mono {
    --primary-color: #0f172a;
    --secondary-color: #1f2937;
    --danger-color: #0f172a;
    --warning-color: #4b5563;
    --gray-100: #f5f5f5;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #475569;
    --gray-800: #1f2937;
    --gray-900: #0b1120;
    background-color: #ffffff;
    color: #0f172a;
}

body.pmc-theme-mono .header {
    background: linear-gradient(135deg, #0f172a 0%, #1f2937 100%);
}

body.pmc-theme-mono section,
body.pmc-theme-mono .input-section,
body.pmc-theme-mono .multi-section {
    background: #ffffff;
}

body.pmc-theme-mono .pmc-policy-tab {
    border-color: #d1d5db;
    color: #0f172a;
}

body.pmc-theme-mono .pmc-policy-tab.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
    box-shadow: none;
}

body.pmc-theme-mono .pmc-cell-btn {
    background: #f8fafc;
    border-color: #cbd5f5;
    color: #0f172a;
}

body.pmc-theme-mono .pmc-cell-btn.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
}

body.pmc-theme-mono .pmc-cell-placeholder {
    background: #f1f5f9;
    border-color: #cbd5f5;
    color: #94a3b8;
}

body.pmc-theme-mono .pmc-chart-card,
body.pmc-theme-mono .pmc-surface-card {
    border-color: #e2e8f0;
    box-shadow: none;
    background: #ffffff;
}

body.pmc-theme-mono .pmc-chart-section-title,
body.pmc-theme-mono .pmc-surface-title,
body.pmc-theme-mono .pmc-chart-title {
    color: #0f172a;
}

body.pmc-theme-mono .pmc-theme-toggle {
    background-color: #f8fafc;
    border-color: #d1d5db;
}

body.pmc-theme-mono .pmc-theme-toggle.is-active {
    background-color: #0f172a;
    border-color: #0f172a;
}

body.pmc-theme-mono .pmc-theme-toggle.is-active .pmc-toggle-text,
body.pmc-theme-mono .pmc-theme-toggle.is-active .pmc-toggle-state {
    color: #ffffff;
}

body.pmc-theme-mono .pmc-switch input:checked + .pmc-switch-slider {
    background-color: #ffffff;
    border: 1px solid #0f172a;
}

body.pmc-theme-mono .pmc-switch-slider::after {
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.3);
}

body.pmc-theme-mono .pmc-surface-chart.pmc-surface-chart--empty {
    background: #f8fafc;
    border-color: #d7dcef;
    color: #1f2937;
}

.pmc-code-sub {
    font-size: 0.72em;
    line-height: 1;
    vertical-align: baseline;
    position: relative;
    top: 0.2em;
    display: inline-block;
}

.pmc-indicator-code .pmc-code-sub {
    color: inherit;
}

.surface-tabs{display:flex;gap:8px;margin-bottom:8px;flex-wrap:wrap}
.surface-tab{padding:4px 10px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;cursor:pointer;font-size:14px}
.surface-tab.active{border-color:#2563eb;background:#2563eb;color:#fff}