:root {
    /* Dark Theme (Default) */
    --bg-color: #121212;
    --surface-color: #1a1a2e;
    --surface-accent: #2a2a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --border-color: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(255, 255, 255, 0.05);

    --accent-primary: #4a6da7;
    --accent-hover: #3a5d97;

    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;

    --glass-bg: rgba(26, 26, 46, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --viewer-bg: #525659;
    --header-bg: var(--bg-color);
    /* Match background in dark mode */
    --text-drag-drop: rgba(255, 255, 255, 0.2);
    --title-color: var(--warning-color);
    /* Original orange for dark mode */
    --dragover-bg: var(--surface-accent);

    /* Process Overlay Dark Theme */
    --proc-overlay-bg: rgba(0, 0, 0, 0.85);
    --proc-text-main: #ffffff;
    --proc-text-sub: #b2bec3;
    --proc-log-bg: rgba(255, 255, 255, 0.05);
    --proc-log-border: rgba(255, 255, 255, 0.1);

    --accent-batch: #00b894;
    /* Mint leaf green for batch */
}

body.light-theme {
    --bg-color: #f5f7fa;
    /* Sidebar/Overall Background */
    --surface-color: #ffffff;
    /* Card/Panel Background */
    --surface-accent: #ffffff;
    /* Nested Panel - White in light mode for distinction */
    --text-primary: #121212;
    --text-secondary: #3d3d3d;
    --border-color: rgba(0, 0, 0, 0.12);
    --input-bg: #ffffff;

    --accent-primary: #3498db;
    --accent-hover: #2980b9;

    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;

    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.1);
    --viewer-bg: #e8ecef;
    --text-muted: #555555;
    --input-border: #ced4da;
    --header-bg: #edf1f7;
    /* Very light, elegant blue-gray */
    --text-drag-drop: #94a3b8;
    /* Slate gray for better contrast in light mode */
    --title-color: #d35400;
    /* Deep, rich orange for light mode brand */
    --dragover-bg: #e3f2fd;
    /* Very light blue for drop zone in light mode */

    /* Process Overlay Light Theme */
    --proc-overlay-bg: rgba(255, 255, 255, 0.95);
    --proc-text-main: #2d3436;
    --proc-text-sub: #636e72;
    --proc-log-bg: rgba(0, 0, 0, 0.04);
    --proc-log-border: rgba(0, 0, 0, 0.1);
}

/* Action Buttons Unification */
.btn-action-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--input-bg);
    color: var(--success-color);
    border: 1px dashed var(--success-color);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-action-add:hover {
    background: var(--success-color);
    color: white;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

.btn-action-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.btn-action-remove:hover {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

/* --- Layout --- */
.tools-container {
    display: flex;
    flex-direction: row;
    height: 100%;
    width: 100%;
}

.tools-sidebar {
    width: 38.2%;
    min-width: 550px;
    max-width: 80%;
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    box-sizing: border-box;
    z-index: 10;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.tools-main {
    flex: 1;
    min-width: 400px;
    /* Reduced from 550px to match pure frontend */
    height: 100%;
    position: relative;
    background-color: var(--viewer-bg);
    display: flex;
    flex-direction: column;
    container-type: inline-size;
    /* CRITICAL: Enables @container queries */
}

/* --- Control Rows --- */
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
    padding: 8px 16px;
    background: var(--surface-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
    /* Allow wrapping on small controls in sidebar */
}

.mini-label-bold {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* --- Resizer --- */
.resizer {
    width: 6px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background-color 0.2s;
    z-index: 100;
}

.resizer:hover,
.resizer.resizing {
    background-color: var(--accent-primary);
}

/* --- Typography & Base Components --- */
.tools-title {
    margin: 0;
    font-size: 1.25rem;
    color: var(--warning-color);
    font-weight: 800;
    /* Extra bold for authority */
    letter-spacing: -0.02em;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.section-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

/* --- Buttons & Inputs --- */


.btn-base {
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    height: 36px;
    /* Enforce fixed height */
    padding: 0 20px;
    /* Horizontal padding only */
    line-height: 36px;
    /* Center text vertically */
    box-sizing: border-box;
    /* Ensure padding doesn't affect height */
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

/* Action Buttons States */
.btn-base:disabled,
.btn-primary:disabled {
    background-color: #95a5a6;
    color: #f8f9fa;
    opacity: 0.6;
    cursor: not-allowed;
    border-color: transparent;
}


.full-width-btn {
    width: 100%;
    padding: 12px;
    font-weight: 600;
}

.range-input {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.85rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
    box-sizing: border-box;
    max-width: 100%;
    /* Safety for narrow screens */
}

.range-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

/* 修复下拉列表选项在某些浏览器下看不清的问题 */
.range-input option {
    background-color: var(--surface-color);
    /* Updated for light theme consistency */
    color: var(--text-primary);
    /* Updated for light theme consistency */
}

/* 列属性小选择框样式 */
.prop-select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.75rem;
    padding: 4px 8px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.prop-select:hover {
    background-color: var(--input-bg);
    border-color: var(--accent-primary);
}

.prop-select option {
    background-color: var(--surface-color);
    color: var(--text-primary);
}

.range-input::placeholder {
    color: #7f8c8d;
    opacity: 0.7;
}

.badge {
    background-color: var(--accent-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: bold;
}

/* --- Content Boxes (Shared Style for Consistency) --- */
.content-box {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.col-tag-wrap {
    margin-bottom: 12px;
    background: var(--surface-color);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.col-tag-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    min-height: 40px;
    background: transparent;
    transition: background 0.2s ease;
}

.remove-col {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 2px 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.remove-col:hover {
    color: var(--danger-color);
    background-color: rgba(231, 76, 60, 0.1);
    border-radius: 4px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 20px;
    font-size: 0.9rem;
}

/* --- Document Info Section --- */
.tabs-nav {
    display: flex;
    gap: 2px;
    margin-bottom: -1px;
    z-index: 2;
    position: relative;
}

.tab-btn {
    background-color: var(--surface-accent);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 8px 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: var(--surface-color);
}

.tab-btn.active {
    background-color: var(--surface-color);
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
    font-weight: 600;
}

.tab-content-container {
    border-top-left-radius: 0;
    min-height: 200px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    background: var(--surface-color);
}

/* Pure Text Display Div */
#infoDisplayArea {
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.6;
    flex: 1;
    font-family: inherit;
    padding: 0;
    background-color: var(--surface-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    overflow: auto;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* 强行平分/固定宽度 */
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.preview-table th {
    background: var(--surface-accent);
    color: var(--accent-primary);
    padding: 8px 4px;
    text-align: left;
    border: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.preview-table td {
    padding: 8px 4px;
    border: 1px solid var(--border-color);
    word-break: break-all;
    /* 核心：列内换行 */
    vertical-align: top;
    color: var(--text-primary);
}

.preview-table tr.row-filtered td {
    opacity: 0.4;
    text-decoration: line-through;
    color: var(--text-secondary);
}

.preview-table tr:hover td {
    background: rgba(74, 109, 167, 0.1);
    /* 使用 --accent-primary 的颜色值 */
}

/* --- Viewer Tools & Canvas --- */
.page-jump-input {
    width: 36px;
    /* Refined width */
    height: 26px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-primary);
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    outline: none;
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* --- Viewer Tools (Cloned from Pure Frontend Logic) --- */
.pdf-toolbar {
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    background-color: var(--header-bg);
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 15px;
    gap: 12px;
    flex-shrink: 0;
    z-index: 20;
    box-sizing: border-box;
    overflow: hidden;
    /* Safety */
    flex-wrap: nowrap !important;
    /* Force single line */
}

.toolbar-group,
.toolbar-zoom {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: nowrap !important;
}

.pagination-hub,
.toolbar-zoom {
    background-color: var(--surface-accent);
    padding: 0 8px;
    /* Compact padding */
    height: 32px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
    flex-wrap: nowrap !important;
}

.page-nav-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
}

/* --- Responsive Adjustments via Media & Container Queries --- */
@container (max-width: 650px) {
    .pdf-toolbar {
        justify-content: space-between;
        padding: 0 8px;
        gap: 4px;
        flex-wrap: nowrap !important;
    }

    .sidebar-header-upload {
        padding: 0 4px;
        gap: 0;
        border-width: 1px;
        flex-shrink: 0;
        border-color: transparent;
        /* Cleaner in very tight spaces */
        background: transparent;
    }

    /* Hide redundant elements when tight */
    .drop-invitation,
    .page-label,
    .total-pages,
    .title-ext,
    #zoomLevel {
        display: none !important;
    }

    .page-jump-input {
        width: 32px;
        margin: 0 2px;
        font-size: 0.8rem;
    }

    .tool-btn {
        min-width: 28px;
        padding: 4px;
        font-size: 0.9rem;
    }
}

@media screen and (max-width: 768px) {
    .pdf-toolbar {
        position: sticky;
        top: 48px;
        /* Below the header */
        z-index: 999;
        padding: 0 8px;
        background: var(--header-bg);
    }

    .toolbar-spacer {
        display: none;
    }
}



.page-jump-input::-webkit-inner-spin-button,
.page-jump-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-jump-input:focus {
    border-color: var(--accent-primary);
    background: var(--surface-color);
}

.toolbar-spacer {
    flex: 1;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background-color: var(--border-color);
}

.tool-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    padding: 6px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background-color: var(--surface-accent);
    color: var(--accent-primary);
}

.pdf-viewer-container {
    flex: 1;
    overflow: auto;
    padding: 10px;
    display: flex;
    /* justify-content: center; REMOVED to fix scroll clipping */
    /* align-items: center; REMOVED to fix scroll clipping */
    position: relative;
}

.drag-drop-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-drag-drop);
    font-size: 2.2rem;
    font-weight: 700;
    opacity: 0.8;
    pointer-events: none;
    z-index: 0;
    text-align: center;
    user-select: none;
}

.drag-drop-overlay label {
    pointer-events: auto;
}

#pdfCanvas {
    display: block;
    margin: auto;
    /* Auto margin centers content when smaller than container, handles overflow correctly when larger */
    background-color: white;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

/* --- Compact Header with Theme Toggle --- */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    flex-shrink: 0;
    position: sticky;
    top: -20px;
    /* Match sidebar padding-top to stick at absolute top */
    z-index: 5;
    background-color: var(--header-bg);
    padding: 0 15px;
    margin: -20px -20px 0 -20px;
    /* Offset sidebar padding */
    border-bottom: 2px solid var(--border-color);
    box-sizing: border-box;
}

.sidebar-header-upload {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 2px 4px;
    border: 1px dashed var(--text-secondary);
    border-radius: 6px;
    background: transparent;
    opacity: 0.8;
    width: fit-content;
    white-space: nowrap;
    transition: all 0.3s ease;
    height: 32px;
    /* Fixed height container */
    box-sizing: border-box;
    flex-shrink: 0;
}



.sidebar-header-upload.dragover {
    border-color: var(--accent-primary);
    background: var(--dragover-bg);
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.3);
    /* Subtle glow */
}

/* --- Process Overlay (Loading Mask) --- */
#process-overlay {
    display: none;
    /* Toggled by JS */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--proc-overlay-bg);
    z-index: 2000;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    color: var(--proc-text-main);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding-top: 40px;
}

.process-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.process-log-container {
    width: 85%;
    max-height: 50%;
    overflow-y: auto;
    background: var(--proc-log-bg);
    padding: 15px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--proc-text-sub);
    font-family: 'Consolas', monospace;
    text-align: left;
    line-height: 1.6;
    border: 1px solid var(--proc-log-border);
}

.process-status-container {
    margin-top: 20px;
    text-align: center;
}

.process-number {
    font-size: 2.5rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--proc-text-main);
}

.process-status-text {
    font-size: 0.9rem;
    color: var(--accent-primary);
    margin-top: 5px;
}

.process-ai-timer {
    display: none;
    font-size: 1.2rem;
    color: #a29bfe;
    /* Keep AI distinct mostly */
    font-weight: bold;
    margin-top: 10px;
    font-family: 'Consolas', monospace;
}

.process-bar-wrap {
    margin-top: 20px;
    width: 250px;
    height: 6px;
    background: var(--proc-log-border);
    border-radius: 3px;
    overflow: hidden;
}

#process-bar {
    width: 0%;
    height: 100%;
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

.drop-invitation {
    font-size: 0.75rem;
    color: var(--text-secondary);
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    order: 2;
    /* Removed overflow: hidden to ensure full text shows */
}

/* Upload Button Tweak in Toolbar Context */
.pdf-toolbar .sidebar-header-upload .btn-primary {
    height: 24px;
    line-height: 24px;
    padding: 0 10px;
    font-size: 0.7rem;
    flex-shrink: 0;
    order: 1;
    /* Button first */
    display: flex;
    align-items: center;
}


/* 全局拖拽遮罩 */
.pdf-viewer-container.dragover {
    background-color: var(--surface-accent) !important;
}

/* --- Animations & Scrollbars --- */
@keyframes pulse-grey {
    0% {
        box-shadow: 0 0 0 0 rgba(238, 238, 238, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(238, 238, 238, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(238, 238, 238, 0);
    }
}

#processPdfBtn.processing {
    background-color: #eeeeee;
    color: #ff3d00;
    cursor: wait;
    animation: pulse-grey 1.5s infinite;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

/* --- Responsive Layout (Mobile/Tablet Snap) - Matched to Pure Frontend Logic --- */
@media screen and (max-width: 1100px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
        display: block;
    }

    .tools-container {
        display: flex;
        flex-direction: column;
        height: auto !important;
        overflow: visible;
    }

    /* Secret Sauce: display: contents makes sidebar children direct flex items of tools-container */
    .tools-sidebar {
        display: contents !important;
    }

    /* 1. Sticky Header */
    .sidebar-header {
        order: 1 !important;
        position: sticky;
        top: 0;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 20px;
        justify-content: space-between;
        z-index: 1000;
        background: var(--header-bg);
        border-bottom: 2px solid var(--border-color);
        box-sizing: border-box;
        height: 48px;
        display: flex;
        align-items: center;
    }

    .sidebar-header .tools-title {
        font-size: 1rem;
        margin: 0;
    }

    /* 2. Privacy & Identify (Moved below header) */
    #introSection {
        order: 10 !important;
    }

    /* 3. Main Preview Area (Order 20) */
    .tools-main {
        order: 20 !important;
        width: 100% !important;
        min-width: unset !important;
        height: auto !important;
        background: var(--viewer-bg);
        display: flex;
        flex-direction: column;
    }

    .pdf-toolbar {
        position: sticky;
        top: 48px;
        /* Sticks below the header */
        z-index: 999;
        width: 100% !important;
        box-sizing: border-box;
        padding: 0 8px;
        background: var(--header-bg);
    }

    .toolbar-spacer {
        display: none;
        /* Compact on mobile */
    }

    .pdf-viewer-container {
        min-height: 400px;
        height: auto !important;
        padding: 10px;
    }

    /* 4. Settings & Lists (Order 30+) */
    .tools-container .tool-section {
        order: 30;
        width: 100%;
        background-color: var(--surface-color);
        padding: 15px;
        border-bottom: 1px solid var(--border-color);
        box-sizing: border-box;
    }

    #docInfoSection {
        order: 40;
    }

    .resizer,
    .title-ext {
        display: none;
    }
}


/* AI Mode Enhancements */
.ai-active-overlay {
    background: linear-gradient(135deg, rgba(46, 20, 113, 0.9) 0%, rgba(20, 30, 48, 0.95) 100%);
    border: 2px solid #a29bfe;
}

.ai-pulse-text {
    background: linear-gradient(90deg, #a29bfe, #6c5ce7, #a29bfe);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: ai-pulse 2s linear infinite;
}

@keyframes ai-pulse {
    to {
        background-position: 200% center;
    }
}

.ai-active-overlay #process-bar {
    background: linear-gradient(90deg, #6c5ce7, #a29bfe, #6c5ce7);
    background-size: 200% auto;
    animation: bar-shimmer 2s linear infinite;
}

@keyframes bar-shimmer {
    to {
        background-position: 200% center;
    }
}

.process-log-area {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) rgba(0, 0, 0, 0.1);
}

#process-log div {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Beautiful Close Button */
.close-process-btn {
    margin-top: 30px;
    background: var(--glass-bg);
    color: var(--text-primary);
    padding: 12px 36px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.close-process-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.close-process-btn:active {
    transform: translateY(1px);
    background: rgba(255, 255, 255, 0.05);
}

#ai-timer {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    color: #ffd700;
    font-size: 1.1rem;
    margin-top: 5px;
    font-weight: bold;
}

/* UI Compact Components */
.mini-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-color);
    padding: 3px 6px;
    font-size: 0.75rem;
    min-width: 0;
    outline: none;
}

.mini-input:focus {
    border-color: var(--button-primary);
}

.mini-input[type="number"] {
    width: 42px;
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

.mini-input[type="number"]::-webkit-inner-spin-button,
.mini-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mini-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.mini-btn-add {
    background: rgba(52, 152, 219, 0.2);
    border: 1px solid rgba(52, 152, 219, 0.3);
    color: #3498db;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.mini-btn-add:hover {
    background: rgba(52, 152, 219, 0.3);
}

.filter-row {
    display: flex;
    gap: 4px;
    align-items: center;
    background: var(--input-bg);
    padding: 6px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.filter-remove {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 4px;
}

.filter-remove:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 4px;
}

/* --- Text Search Styles --- */
#textSearchBar {
    display: flex;
}

.text-highlight {
    background-color: #ffd700;
    /* 黄色高亮 */
    color: #000;
    padding: 1px 2px;
    border-radius: 2px;
}

.text-highlight.current {
    background-color: #ff8c00;
    /* 橙色高亮当前选中 */
    color: #fff;
    font-weight: bold;
}

/* --- Template Recommendation Modal --- */
.template-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.template-modal {
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.template-modal-header {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    padding: 20px 24px;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.template-modal-header i {
    font-size: 1.5rem;
}

.template-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.template-card {
    padding: 24px;
}

.template-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.template-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.confidence-container {
    background: var(--input-bg);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.confidence-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.confidence-bar {
    width: 100%;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--accent-primary));
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

.confidence-value {
    text-align: right;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.match-reasons {
    margin-top: 20px;
}

.reasons-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.match-reasons ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.match-reasons li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.match-reasons li i {
    color: var(--success-color);
    font-size: 0.85rem;
}

.template-modal-actions {
    padding: 0 24px 24px 24px;
    display: flex;
    gap: 12px;
}

.template-modal-actions button {
    flex: 1;
    gap: 8px;
}

.footer-brand-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.footer-brand-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

body.light-theme .template-modal-overlay {
    background: rgba(0, 0, 0, 0.5);
}

/* ============================================================
   FileBridge 文件识别弹窗 (紧凑版)
   ============================================================ */
.fb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fb-modal-overlay.fb-modal-visible {
    opacity: 1;
}

.fb-modal-overlay.fb-modal-visible .fb-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.fb-modal {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    width: 320px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    transform: translateY(14px) scale(0.97);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
    overflow: hidden;
}

.fb-modal-header {
    display: flex;
    justify-content: flex-end;
    padding: 10px 10px 0;
}

.fb-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    line-height: 1;
}

.fb-modal-close:hover {
    background: var(--surface-accent);
    color: var(--text-primary);
}

.fb-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 20px 16px;
    text-align: center;
}

.fb-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.fb-modal-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.fb-modal-sublabel {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.fb-modal-fname {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin-top: 2px;
}

.fb-modal-footer {
    display: flex;
    gap: 8px;
    padding: 0 16px 16px;
}

.fb-modal-footer .btn-base {
    height: 36px;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.fb-btn-download {
    flex: 1;
    background: var(--accent-primary);
    border: none !important;
    color: white;
}

.fb-btn-download:hover {
    background: var(--accent-hover);
}

.fb-btn-skip {
    background: var(--input-bg);
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary);
    padding: 0 18px;
}

.fb-btn-skip:hover {
    border-color: var(--text-secondary) !important;
    color: var(--text-primary);
}

body.light-theme .fb-modal-overlay {
    background: rgba(0, 0, 0, 0.4);
}

body.light-theme .fb-modal {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

/* --- Auto Column Detector Button Styling --- */
.btn-auto-detect {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #ffffff;
    border: none;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 5px rgba(108, 92, 231, 0.25);
    transition: all 0.2s ease;
}

.btn-auto-detect:hover {
    background: linear-gradient(135deg, #5b4bc4, #8c7ae6);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(108, 92, 231, 0.35);
}

.btn-auto-detect:active {
    transform: translateY(0);
}

.btn-auto-detect:disabled {
    background: var(--input-bg) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

body.light-theme .btn-auto-detect {
    background: linear-gradient(135deg, #0984e3, #74b9ff);
    box-shadow: 0 2px 5px rgba(9, 132, 227, 0.2);
}

body.light-theme .btn-auto-detect:hover {
    background: linear-gradient(135deg, #0770c4, #0984e3);
}

/* --- Clear All Columns Button Styling --- */
.btn-clear-cols {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.35);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.btn-clear-cols:hover {
    background: #e74c3c;
    color: #ffffff;
    border-color: #e74c3c;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
}

.btn-clear-cols:active {
    transform: translateY(0);
}

.btn-clear-cols:disabled {
    background: var(--input-bg) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
    box-shadow: none !important;
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

body.light-theme .btn-clear-cols {
    background: rgba(231, 76, 60, 0.1);
    color: #d63031;
    border-color: rgba(231, 76, 60, 0.25);
}
