.hidden { display: none !important; }
/* CSS Variables - High-Contrast Professional Vintage / Old Beige Theme */
:root {
    /* Rich Warm Parchment Background */
    --bg-primary: #EDE5D8;
    --bg-gradient: linear-gradient(135deg, #F5EFE6 0%, #E6DCCD 100%);
    --card-bg: #FFFFFF;
    
    /* Text - High Contrast Razor-Sharp Carbon Typewriter Ink */
    --text-primary: #120F0D;
    --text-secondary: #2C231C;
    --text-muted: #57483B;
    
    /* Warm Vintage Accents */
    --accent: #8A5A2B;
    --accent-hover: #70461E;
    
    --success: #1B6636;
    --success-light: #EAF4EE;
    --error: #B52B1E;
    --error-light: #FCECEB;
    --warning: #B37D14;
    --warning-light: #FDF6E7;
    
    /* Crisp High-Contrast Structural Borders */
    --border: #BAA68B;
    --border-light: #DFD2C0;
    --border-dark: #786044;
    
    /* Typography */
    --font-heading: 'IBM Plex Mono', monospace;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Professional Elevation Shadows */
    --shadow-sm: 0 1px 3px rgba(35, 25, 15, 0.08), 0 1px 2px rgba(35, 25, 15, 0.05);
    --shadow-md: 0 4px 12px rgba(35, 25, 15, 0.09), 0 2px 4px rgba(35, 25, 15, 0.05);
    --shadow-lg: 0 12px 28px rgba(35, 25, 15, 0.12), 0 4px 8px rgba(35, 25, 15, 0.06);
    
    /* Radii */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-gradient);
    min-height: 100vh;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* CSS-only Noise Texture */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.text-muted {
    color: var(--text-muted);
}
.text-center {
    text-align: center;
}

/* Layout */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.top-section {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    gap: 24px;
}

.middle-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.settings-card,
.api-card {
    height: 100%;
    padding: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.api-key-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 16px;
}

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

.setting-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

.app-container {
    max-width: 1800px;
    width: 96%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 160px);
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .top-section {
        grid-template-columns: 1fr 1fr;
    }
    .settings-col {
        grid-column: span 2;
    }
    .settings-grid {
        display: flex;
        gap: 16px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .top-section {
        grid-template-columns: 1fr;
    }
    .settings-col {
        grid-column: span 1;
    }
    .settings-grid {
        flex-direction: column;
    }
    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .btn {
        width: 100%;
        justify-content: center;
    }
    .api-key-form .input-group {
        flex-direction: column !important;
    }
    .api-key-form select, .api-key-form input {
        width: 100% !important;
    }
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-dark);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.title {
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    position: relative;
    padding-left: 16px;
    border-left: 2px solid var(--border);
}

.subtitle {
    font-size: 0.65em;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 8px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mode-buttons {
    display: flex;
    background: var(--border-light);
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.mode-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Toggle Switch */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 500;
}

.mode-label.turbo {
    color: var(--warning);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-dark);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    box-shadow: var(--shadow-sm);
}

input:checked + .slider {
    background-color: var(--warning);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}
.slider.round:before {
    border-radius: 50%;
}

/* Cards & Panels */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-top: 4px solid var(--text-primary);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.collapsible {
    overflow: hidden;
    transition: max-height var(--transition-normal), padding var(--transition-normal), opacity var(--transition-normal);
}

.collapsible.hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    border: none;
    margin: 0;
}

.file-thumb-small {
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #f0f0f0;
}

.results-table th:first-child,
.results-table td:first-child {
    text-align: center;
    vertical-align: middle;
}

/* API Key Panel */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.rotation-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--border-dark);
}
.rotation-status.active .status-dot {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.api-key-form {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* Forms & Inputs */
.text-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    background: #fafafa;
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.btn:active {
    transform: translateY(1px);
}

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

.btn.primary {
    background-color: var(--text-primary);
    color: white;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.1);
}
.btn.primary:hover:not(:disabled) {
    background-color: #000;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.2);
    transform: translate(2px, 2px);
}

.btn.secondary {
    background-color: white;
    color: var(--text-primary);
    border-color: var(--text-primary);
}
.btn.secondary:hover {
    background-color: #f0f0f0;
}

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

.btn.success:hover:not(:disabled) {
    background: #257540;
}

.btn.danger {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.btn.danger:hover:not(:disabled) {
    background: #A93226;
}

.btn.large {
    padding: 14px 24px;
    font-size: 1rem;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.icon-btn:hover {
    background-color: var(--border-light);
    color: var(--text-primary);
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: underline;
}
.text-btn:hover {
    color: var(--error);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-dark);
    border-radius: var(--radius-md);
    background-color: rgba(255,255,255,0.5);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    margin-bottom: 24px;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--text-primary);
    background-color: var(--card-bg);
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
}

.drop-icon {
    color: var(--accent);
    margin-bottom: 12px;
}

.drop-zone h3 {
    margin-bottom: 8px;
}
.drop-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.accepted-formats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-heading);
    background-color: var(--border-light);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge.image { background-color: #E3F2FD; color: #1565C0; border-color: #90CAF9;}
.badge.vector { background-color: #FFF3E0; color: #E65100; border-color: #FFCC80;}
.badge.video { background-color: #F3E5F5; color: #6A1B9A; border-color: #CE93D8;}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
}
.status-badge.ready { color: var(--text-secondary); }
.status-badge.processing { color: var(--warning); font-weight: 600; animation: pulse 2s infinite; }
.status-badge.done { color: var(--success); font-weight: 600; }
.status-badge.error { color: var(--error); font-weight: 600; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* File Queue */
.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.file-queue {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 380px);
    overflow-y: auto;
    padding-right: 4px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    animation: slideUp 0.3s ease;
}

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

.file-thumb {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    background-color: var(--border-light);
    border: 1px solid var(--border);
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.progress-container.hidden {
    display: none;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-family: var(--font-heading);
}

.progress-track {
    height: 8px;
    background-color: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background-color: var(--text-primary);
    width: 0%;
    transition: width 0.3s ease;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255,255,255,0.1) 10px,
        rgba(255,255,255,0.1) 20px
    );
    background-size: 28px 28px;
    animation: moveStripes 1s linear infinite;
}

@keyframes moveStripes {
    0% { background-position: 0 0; }
    100% { background-position: 28px 0; }
}

.files-done {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

/* Results Table */
.results-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.table-wrapper {
    overflow: auto;
    border: none;
    border-right: 1px solid var(--border);
    border-bottom: 2px solid var(--border-dark);
}

/* ─── Editable CSV Header ─── */
.editable-csv-header {
    margin-bottom: 12px;
}

.editable-csv-header h4 {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    padding-bottom: 4px;
    border-bottom: 3px solid var(--error); /* Red underline */
}

/* ─── Find and Replace Bar ─── */
.find-replace-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.find-replace-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.find-replace-inputs select.select-column {
    flex: 0 0 150px;
    max-width: 160px;
    background: #ffffff;
    cursor: pointer;
    font-weight: 500;
}

.find-replace-inputs input {
    flex: 1;
}

.match-count-display {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 80px;
    text-align: right;
}

.results-table {
    width: 100%;
    border-collapse: separate;
    font-size: 0.85rem;
    min-width: 800px;
}

.results-table th, .results-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.results-table th {
    background-color: #E8DDCF;
    font-family: var(--font-heading);
    font-weight: 700;
    color: #120F0D;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2.5px solid #786044;
}

.results-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
    position: relative; /* For word count positioning */
}

.results-table tbody tr.selected {
    background: rgba(66, 133, 244, 0.05); /* Light blue for selected rows */
}

.results-table tbody tr:hover {
    background: var(--bg-primary);
}

.cell-editable {
    outline: none;
    cursor: text;
    transition: background var(--transition-fast);
    padding-bottom: 24px; /* Space for word count */
}

.cell-editable:hover {
    background: rgba(255, 255, 255, 0.5);
}

.cell-editable:focus {
    background: #fff;
    box-shadow: inset 0 0 0 2px var(--border);
    border-radius: 4px;
}

.word-count {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 0.65rem;
    color: #4285F4; /* Small blue text */
    font-weight: 600;
    user-select: none;
    pointer-events: none;
}

.highlight {
    background-color: rgba(255, 235, 59, 0.6);
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

.results-table th:nth-child(1), .results-table td:nth-child(1) { width: 40px; min-width: 40px; text-align: center; }
.results-table th:nth-child(2), .results-table td:nth-child(2) { width: 120px; min-width: 120px; text-align: center; }
.results-table th:nth-child(3), .results-table td:nth-child(3) { width: 20%; min-width: 180px; }
.results-table th:nth-child(4), .results-table td:nth-child(4) { width: 20%; min-width: 180px; }
.results-table th:nth-child(5), .results-table td:nth-child(5) { width: 10%; min-width: 100px; }
.results-table th:nth-child(6), .results-table td:nth-child(6) { width: 40%; min-width: 300px; }
.results-table th:nth-child(7), .results-table td:nth-child(7) { width: 40px; min-width: 40px; text-align: center; }

.auto-corrected {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--warning);
    font-style: italic;
}

/* Turbo Panel */
.turbo-panel {
    border-top: 4px solid var(--warning);
    margin-bottom: 24px;
}
.turbo-panel.hidden {
    display: none;
}

.batch-progress {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--warning);
}

.grid-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 16px;
    background: #f0f0f0;
    padding: 12px;
    border-radius: var(--radius-sm);
    min-height: 100px;
    border: 1px inset var(--border);
}

.video-queue-section {
    margin-top: 20px;
    border-top: 1px dashed var(--border);
    padding-top: 16px;
}

/* Modals & Overlays */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity var(--transition-normal);
}

.modal-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 90%;
    max-width: 450px;
    border-top: 6px solid var(--text-primary);
    transform: translateY(0);
    transition: transform var(--transition-normal);
}

.modal-backdrop.hidden .modal {
    transform: translateY(-20px);
}

.modal h2 {
    margin-bottom: 12px;
}
.modal p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.brand-footer {
    font-family: var(--font-heading);
    font-weight: 600;
}

.brand-footer a {
    transition: color var(--transition-fast);
}

.brand-footer a:hover {
    color: var(--accent) !important;
    text-decoration: underline !important;
}

.version-info {
    letter-spacing: 1px;
}

.processing-text {
    color: white;
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 1px;
}

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

/* Footer */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-dark);
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-left: 1px solid var(--border-light);
}
::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ─── Toast Notifications ─── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    max-width: 380px;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: var(--success-light);
    color: var(--success);
    border-left: 4px solid var(--success);
}

.toast-error {
    background: var(--error-light);
    color: var(--error);
    border-left: 4px solid var(--error);
}

.toast-warning {
    background: var(--warning-light);
    color: var(--warning);
    border-left: 4px solid var(--warning);
}

/* ─── Dynamic File Queue Items ─── */
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    transition: all var(--transition-fast);
}

.file-item:hover {
    border-left-color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.file-thumb-wrap {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-thumb.placeholder {
    font-size: 1.5rem;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.type-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
}

.status-icon {
    font-size: 0.85rem;
}

.warning-text {
    font-size: 0.75rem;
    cursor: help;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-remove:hover {
    background: var(--error-light);
    color: var(--error);
}

/* ─── Results Table Dynamic ─── */
.cell-editable {
    cursor: text;
    transition: background var(--transition-fast);
}

.cell-editable:focus {
    background: #FFFDE7;
    outline: 2px solid var(--warning);
    outline-offset: -2px;
}

.cell-keywords {
    font-size: 0.78rem;
    word-break: break-word;
}

.cell-filename {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

.corrected-badge {
    cursor: help;
    font-size: 0.9rem;
}

.result-row:hover {
    background: #F5F5F0;
}

/* ─── API Key Items ─── */
.api-key-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    font-family: var(--font-heading);
    font-size: 0.82rem;
}

.key-value.active {
    color: var(--success);
    font-weight: 600;
}

.btn-delete-key {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-delete-key:hover {
    background: var(--error-light);
    color: var(--error);
}

/* Video format badges - hidden in turbo mode */
.turbo-active .video-format {
    display: none;
}

/* Get API Key button */
.get-key-btn {
    text-decoration: none;
    font-size: 0.8rem;
    padding: 8px 14px;
    margin-bottom: 10px;
    display: inline-flex;
    gap: 4px;
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}

.get-key-btn:hover {
    background: rgba(107, 123, 141, 0.08);
}

/* Info Link Button */
.info-link-btn {
    background: none;
    border: none;
    color: var(--accent);
    text-decoration: underline;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 4px;
    font-family: var(--font-body);
}
.info-link-btn:hover {
    color: var(--text-primary);
}

/* Auth Loading Overlay */
.auth-loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-primary);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

/* Login Modal (Full Screen) */
.login-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-gradient);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border-light);
}

.login-card .logo {
    color: var(--text-primary);
    margin-bottom: 20px;
}

.login-card h2 {
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.google-btn {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    background: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    font-family: 'Google Sans', var(--font-body);
    font-weight: 500;
    box-shadow: none;
}

.google-btn:hover {
    background: #f8f9fa;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

/* Announcements Banner */
.announcement-banner {
    background: var(--text-primary);
    color: white;
    padding: 8px 20px;
    font-size: 0.85rem;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-sm);
    margin: 20px auto 0 auto;
    max-width: 1360px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.scrolling-text {
    white-space: nowrap;
    animation: scrollText 20s linear infinite;
    font-weight: 500;
    letter-spacing: 0.5px;
}

@keyframes scrollText {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* User Profile Widget */
.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--card-bg);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-light);
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1;
}

.quota-bar-container {
    width: 100%;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
    min-width: 120px;
}

.quota-bar {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.quota-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-heading);
    line-height: 1;
}

.user-actions {
    display: flex;
    gap: 8px;
    border-left: 1px solid var(--border-light);
    padding-left: 16px;
}

/* Drag and drop */
.api-key-item.drag-over { border: 2px dashed var(--primary); background: var(--bg-hover); opacity: 0.8; }

/* ─── AI CSV Co-Pilot Side Drawer ─── */
.btn-ai-chat {
    background: linear-gradient(135deg, #1A1A1A 0%, #3B4B5A 100%) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-ai-chat:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.22);
}

.ai-sparkle-icon {
    display: inline-block;
    animation: sparkle-pulse 2s infinite ease-in-out;
}

@keyframes sparkle-pulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.25); filter: brightness(1.3); }
}

.ai-chat-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    background: #ffffff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-drawer.hidden {
    display: flex !important;
    transform: translateX(100%);
    pointer-events: none;
}

.ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #fafafa;
    border-bottom: 1px solid var(--border-light);
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-avatar {
    font-size: 1.5rem;
    line-height: 1;
}

.ai-chat-title {
    margin: 0;
    font-size: 0.95rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
}

.ai-chat-badge {
    font-size: 0.7rem;
    color: var(--accent);
    font-family: var(--font-heading);
    font-weight: 500;
}

.ai-chat-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ai-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.ai-icon-btn:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

/* Quick Action Chips */
.ai-quick-chips {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
}

.ai-quick-chips::-webkit-scrollbar {
    height: 3px;
}

.ai-quick-chips::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.ai-chip {
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-family: var(--font-heading);
    padding: 5px 10px;
    background: #f7f7f7;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.ai-chip:hover {
    background: #1A1A1A;
    color: #ffffff;
    border-color: #1A1A1A;
}

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fcfcfc;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}

.chat-msg.user {
    align-self: flex-end;
}

.chat-msg.user .chat-msg-content {
    background: var(--text-primary);
    color: #ffffff;
    border-radius: 12px 12px 2px 12px;
    padding: 9px 13px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg.bot {
    align-self: flex-start;
}

.chat-msg.bot .chat-msg-content {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: 12px 12px 12px 2px;
    padding: 10px 14px;
    font-size: 0.84rem;
    line-height: 1.45;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    word-break: break-word;
}

.chat-msg-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 3px;
    padding: 0 4px;
}

.chat-msg.user .chat-msg-time {
    text-align: right;
}

/* Chat Action Card (inside bot reply) */
.chat-action-card {
    margin-top: 8px;
    padding: 8px 10px;
    background: #f0f7f2;
    border: 1px solid #c3e6cb;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: #155724;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-action-card.warning {
    background: #fff8e6;
    border-color: #ffe699;
    color: #856404;
}

.chat-undo-link {
    background: none;
    border: none;
    color: #0c5460;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0;
}

.chat-undo-link:hover {
    color: #002752;
}

/* Target & Status Bar */
.ai-chat-target-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    background: #fafafa;
    border-top: 1px solid var(--border-light);
}

.ai-chat-undo {
    background: none;
    border: none;
    color: #4285F4;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background var(--transition-fast);
}

.ai-chat-undo:hover {
    background: #e8f0fe;
    text-decoration: underline;
}

/* Form */
.ai-chat-form {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid var(--border-light);
}

.ai-chat-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    background: #fafafa;
    color: var(--text-primary);
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--text-primary);
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(26,26,26,0.1);
}

.ai-chat-send-btn {
    width: 36px;
    height: 36px;
    background: var(--text-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.ai-chat-send-btn:hover {
    background: #333333;
    transform: scale(1.05);
}

.ai-chat-send-btn:disabled {
    background: #a0a0a0;
    cursor: not-allowed;
    transform: none;
}

/* Table Row Highlight flash */
@keyframes row-flash {
    0% { background-color: rgba(66, 133, 244, 0.25); }
    100% { background-color: transparent; }
}

.row-mutated {
    animation: row-flash 2s ease-out;
}




/* Download Dropdown & Multi-Platform Stock CSV Buttons */
.download-dropdown-container {
    position: relative;
    display: inline-block;
}

.download-main-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.dropdown-chevron {
    transition: transform var(--transition-fast);
}

.download-dropdown-container.open .dropdown-chevron {
    transform: rotate(180deg);
}

.download-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 330px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    padding: 8px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: menu-slide-down 0.18s ease-out;
}

@keyframes menu-slide-down {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.download-menu-header {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 6px 10px 4px 10px;
    font-family: var(--font-heading);
}

.download-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
}

.download-menu-item:hover {
    background: #f4f6f8;
    border-color: var(--border-light);
    transform: translateX(2px);
}

.download-menu-item .menu-item-content {
    display: flex;
    flex-direction: column;
}

.download-menu-item .menu-item-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.download-menu-item .menu-item-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.download-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

.download-both-item {
    background: #f9fbf9;
}

.download-both-item:hover {
    background: #edf7f0;
}

/* Microstock Platform Badges */
.stock-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-heading);
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.stock-badge-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-heading);
    margin-right: 2px;
}

.adobe-badge {
    background: #ffebe8;
    color: #e02424;
    border: 1px solid rgba(224, 36, 36, 0.25);
}

.shutter-badge {
    background: #fef0e6;
    color: #d9480f;
    border: 1px solid rgba(217, 72, 15, 0.25);
}

.pond-badge {
    background: #e8f4fc;
    color: #0284c7;
    border: 1px solid rgba(2, 132, 199, 0.25);
}

.both-badge {
    background: #eaf7ee;
    color: #15803d;
    border: 1px solid rgba(21, 128, 61, 0.25);
}

/* Quick Stock Download Buttons in Editable CSV Header */
.btn-stock-quick {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    padding: 6px 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-stock-quick:hover:not(:disabled) {
    background: #f7f7f7;
    border-color: var(--border-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-stock-quick:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f0f0f0;
    border-color: var(--border-light);
}

/* Mapped Adobe Category Tag inside Unified Table */
.adobe-cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    padding: 2px 6px;
    background: #fafafa;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.2;
    cursor: default;
    user-select: none;
}

.adobe-pill-tag {
    font-family: var(--font-heading);
    font-weight: 700;
    color: #d00000;
    background: rgba(208, 0, 0, 0.08);
    padding: 1px 4px;
    border-radius: 3px;
}


/* ─── Floating AI CSV Co-Pilot (Fixed Bottom Right - High Contrast Vintage) ─── */
.floating-copilot-container {
    position: fixed;
    bottom: 26px;
    right: 26px;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.floating-copilot-container.drawer-open {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
    pointer-events: none;
}

.floating-copilot-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    border-radius: 50px;
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    cursor: pointer;
    outline: none;
    background: linear-gradient(135deg, #16120F 0%, #2C221A 100%);
    color: #FFF8F0;
    border: 1.5px solid #8C7558;
    box-shadow: 0 8px 24px rgba(22, 18, 15, 0.35), 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.floating-copilot-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 30px rgba(22, 18, 15, 0.45), 0 0 16px rgba(138, 90, 43, 0.4);
    color: #FFFFFF;
}

.floating-copilot-btn .ai-sparkle-icon {
    display: inline-block;
    animation: sparkle-pulse 1.8s infinite ease-in-out;
}

@media (max-width: 768px) {
    .floating-copilot-container {
        bottom: 16px;
        right: 16px;
    }
    .floating-copilot-btn {
        padding: 9px 16px;
        font-size: 0.8rem;
    }
}

/* ─── High Contrast Professional Vintage Overhauls ─── */
.card {
    background-color: #FFFFFF !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-md) !important;
}

.app-header {
    border-bottom: 2px solid var(--border-dark) !important;
}

.brand .title {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
    border-left: 3px solid var(--accent) !important;
}

.user-profile-widget {
    background: #FAF6EE !important;
    border: 1px solid var(--border) !important;
}

.user-name {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
}

.quota-text {
    color: var(--text-muted) !important;
    font-weight: 600 !important;
}

.mode-buttons {
    background: #E2D6C5 !important;
    border: 1px solid var(--border) !important;
}

.mode-btn {
    color: #382D22 !important;
    font-weight: 600 !important;
}

.mode-btn.active {
    background: #FFFFFF !important;
    color: var(--text-primary) !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 5px rgba(35, 25, 15, 0.12) !important;
}

.btn.primary {
    background: linear-gradient(135deg, #181411 0%, #2E251E 100%) !important;
    color: #FFFFFF !important;
    border: 1px solid #000000 !important;
    font-weight: 700 !important;
    box-shadow: 0 3px 8px rgba(18, 15, 13, 0.25) !important;
}

.btn.primary:hover {
    background: linear-gradient(135deg, #2A211B 0%, #42352B 100%) !important;
    transform: translateY(-1px);
}

.btn.secondary {
    background: #FAF6EE !important;
    border: 1.5px solid var(--border) !important;
    color: var(--text-primary) !important;
    font-weight: 600 !important;
}

.btn.secondary:hover {
    background: #EFE7DA !important;
    border-color: var(--accent) !important;
    transform: translateY(-1px);
}

.text-input,
.api-input,
select {
    background: #FFFFFF !important;
    border: 1.5px solid var(--border) !important;
    color: var(--text-primary) !important;
    font-weight: 500 !important;
}

.text-input:focus,
.api-input:focus,
select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(138, 90, 43, 0.18) !important;
    outline: none !important;
}

.drop-zone {
    background: #FAF5EB !important;
    border: 2px dashed var(--border-dark) !important;
}

.drop-zone:hover,
.drop-zone.dragover {
    background: #F2E8D8 !important;
    border-color: var(--accent) !important;
}

.drop-content h3 {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
}

.drop-icon {
    stroke: var(--accent) !important;
}

.badge {
    background: #FFFFFF !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    font-weight: 600 !important;
}

.results-table {
    border: 1px solid var(--border) !important;
    background: #FFFFFF !important;
}

.results-table td {
    border-bottom: 1px solid var(--border-light) !important;
    color: var(--text-primary) !important;
}

.results-table tbody tr:hover {
    background: #F5EFE3 !important;
}

.results-table tbody tr.selected {
    background: rgba(138, 90, 43, 0.13) !important;
}

.cell-editable:focus {
    background: #FFFFFF !important;
    box-shadow: inset 0 0 0 2px var(--accent) !important;
}

.word-count {
    color: var(--accent) !important;
    font-weight: 700 !important;
}

.find-replace-bar {
    background: #FAF6EE !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
}

.ai-chat-drawer {
    background: #FAF6EF !important;
    border-left: 2px solid var(--border-dark) !important;
    box-shadow: -6px 0 28px rgba(25, 18, 12, 0.22) !important;
}

.ai-chat-header {
    background: #E8DDCF !important;
    border-bottom: 1.5px solid var(--border) !important;
}

.ai-chat-title {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
}

.ai-quick-chips {
    background: #FAF6EF !important;
    border-bottom: 1.5px solid var(--border-light) !important;
}

.ai-chip {
    background: #FFFFFF !important;
    border: 1.5px solid var(--border) !important;
    color: var(--text-primary) !important;
    font-weight: 600 !important;
}

.ai-chip:hover {
    background: #EFE6D6 !important;
    border-color: var(--accent) !important;
    transform: translateY(-1px);
}

.ai-chat-messages {
    background: #F1E8DC !important;
}

.chat-msg.bot .chat-msg-content {
    background: #FFFFFF !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 1px 4px rgba(35, 25, 15, 0.06) !important;
}

.chat-msg.user .chat-msg-content {
    background: #231C16 !important;
    color: #FFF8F0 !important;
}

.ai-chat-target-bar {
    background: #E8DDCF !important;
    border-top: 1.5px solid var(--border-light) !important;
}

.ai-chat-form {
    background: #E8DDCF !important;
    border-top: 1.5px solid var(--border) !important;
}

.ai-chat-input {
    background: #FFFFFF !important;
    border: 1.5px solid var(--border) !important;
    color: var(--text-primary) !important;
}

.download-menu {
    background: #FFFFFF !important;
    border: 1.5px solid var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
}

.download-menu-item:hover {
    background: #FAF6EE !important;
}

/* ─── API Mode Selector & Key Management Enhanced ─── */
.api-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.mode-pills {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-pill {
    padding: 4px 10px;
    font-size: 0.78rem;
    font-family: var(--font-heading);
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-pill:hover {
    background: #E6DCCD;
    color: var(--text-primary);
}

.mode-pill.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.test-conn-btn {
    padding: 4px 10px !important;
    font-size: 0.78rem !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    cursor: pointer;
}

.rotation-status.manual .status-dot {
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.api-key-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-family: var(--font-heading);
    font-size: 0.82rem;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    cursor: pointer;
}

.api-key-item:hover {
    border-color: var(--border-dark);
}

.api-key-item.selected {
    border-color: var(--accent);
    background: #FFF9F2;
    box-shadow: 0 0 0 1px var(--accent);
}

.api-key-item.active-rotation {
    border-color: #2D68C4;
}

.key-left-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.key-right-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.key-radio {
    cursor: pointer;
    accent-color: var(--accent);
    margin: 0;
}

.key-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.key-badge.badge-selected {
    background: var(--accent);
    color: #ffffff;
}

.key-badge.badge-auto {
    background: #2D68C4;
    color: #ffffff;
}

.key-conn-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.key-conn-badge.success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(27, 102, 54, 0.2);
}

.key-conn-badge.error {
    background: var(--error-light);
    color: var(--error);
    border: 1px solid rgba(181, 43, 30, 0.2);
}

.key-conn-badge.testing {
    background: var(--warning-light);
    color: var(--warning);
}

.btn-test-key {
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--accent);
    cursor: pointer;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.btn-test-key:hover {
    background: #E6DCCD;
    color: var(--accent-hover);
    border-color: var(--accent);
}



/* ─── Card Tabs & Clean Layout ─── */
.card-tabs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.card-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-primary);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.card-tab {
    border: none;
    background: transparent;
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.card-tab:hover {
    color: var(--text-primary);
    background: rgba(0,0,0,0.04);
}

.card-tab.active {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tab-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 10px;
    background: var(--border-light);
    color: var(--text-secondary);
    font-weight: 700;
}

.card-tab.active .tab-badge {
    background: var(--accent);
    color: #ffffff;
}

.tab-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.tab-content.hidden {
    display: none !important;
}

.api-key-list, .model-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
    margin: 0;
    list-style: none;
}

.api-key-list::-webkit-scrollbar,
.model-list::-webkit-scrollbar {
    width: 5px;
}
.api-key-list::-webkit-scrollbar-thumb,
.model-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* ─── Gemini Model List Items ─── */
.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 5px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.model-item:hover {
    border-color: var(--border-dark);
}

.model-item.selected {
    border-color: var(--accent);
    background: #FFF9F2;
    box-shadow: 0 0 0 1px var(--accent);
}

.model-item.disabled-model {
    opacity: 0.5;
    background: #E8E0D5;
}

.model-checkbox, .model-radio {
    cursor: pointer;
    accent-color: var(--accent);
    margin: 0 4px;
}

.model-rank-badge {
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--font-heading);
    color: var(--text-secondary);
}

.model-item.selected .model-rank-badge {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.btn-move-model:hover {
    color: var(--accent) !important;
}

.btn-move-model:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.btn-test-model {
    white-space: nowrap;
}


/* ─── More API Settings Link & Modal ─── */
.more-api-settings-footer {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.more-settings-link {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--accent);
    font-family: var(--font-heading);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    transition: color var(--transition-fast);
}

.more-settings-link:hover {
    color: var(--accent-hover);
}

.model-status-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-heading);
}

.more-settings-modal-card {
    max-width: 650px !important;
    width: 92% !important;
    max-height: 88vh;
    overflow-y: auto;
    padding: 24px !important;
    box-sizing: border-box;
}

.modal-header-custom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1.5px solid var(--border-light);
    padding-bottom: 12px;
}

.btn-modal-close {
    border: none;
    background: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-modal-close:hover {
    color: var(--error);
    background: var(--error-light);
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.mode-desc-text {
    font-size: 0.78rem;
    font-family: var(--font-heading);
    color: var(--text-muted);
}

.modal-footer-custom {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1.5px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
}
