/* ========================================
   Neumorphic Design System
   Light Mode - Inspired by reference design
   ======================================== */

:root {
    /* Light mode colors from reference */
    --primary-light: #3676d8;
    --background-light: #f0f2f5;
    --background-outer: #ffffff;
    --text-dark: #1f2a3a;
    --text-muted-light: #6b7a90;
    --border-light: #e0e4e9;
    --success-light: #28a745;
    --success-light-bg: #e6faed;
    --info-light: #0d6efd;
    --info-light-bg: #e0edff;
    /* Danger palette — shared by .btn-danger, the Fallbacks card alert
       state, and the inline recommendation panel so all "stop / attention"
       surfaces stay visually consistent. */
    --danger-light: #ef4444;
    --danger-light-hover: #dc2626;
    --danger-light-border: #dc2626;

    /* Neumorphic shadows */
    --shadow-dark: #d8dbdf;
    --shadow-light: #ffffff;

    /* Translation preview height (based on MAX_TOKENS_PER_CHUNK) */
    /* Default: 300px for 450 tokens. Formula: (tokens / 450) * 300 */
    /* Min: 120px, Max: 400px */
    --preview-height: 300px;
}

/* ========================================
   Dark Mode Theme
   ======================================== */

html.dark {
    /* Dark mode colors - neutral grays */
    --primary-light: #5a8ee8;
    --background-light: #2a2a2a;
    --background-outer: #121212;
    --text-dark: #e8e8e8;
    --text-muted-light: #999999;
    --border-light: #444444;
    --success-light: #34d399;
    --success-light-bg: #1a2a1a;
    --info-light: #60a5fa;
    --info-light-bg: #1a1a2a;
    /* Slightly darker red in dark mode so the saturated solid fill does not
       glare against a dim background. */
    --danger-light: #dc2626;
    --danger-light-hover: #b91c1c;
    --danger-light-border: #b91c1c;

    /* Neumorphic shadows for dark mode */
    --shadow-dark: #1a1a1a;
    --shadow-light: #3a3a3a;
}

html.dark .neu-inset-light {
    background: #222222;
    border: 2px solid rgba(136, 136, 136, 0.15);
}

html.dark .neu-inset-light:hover {
    border-color: rgba(136, 136, 136, 0.35);
}

html.dark .neu-inset-light:focus-within {
    border-color: var(--primary-light);
}

html.dark .form-control {
    background: #222222;
    color: #e8e8e8;
}

html.dark .neu-inset-light .form-control {
    background: #222222;
}

html.dark .form-control:focus {
    background: #222222;
}

html.dark .form-control::placeholder {
    color: #777777;
}

html.dark .header {
    background: rgba(42, 42, 42, 0.9);
}

html.dark .file-upload {
    background: var(--background-light);
}

html.dark .file-table thead tr {
    background: rgba(136, 136, 136, 0.1);
}

html.dark .file-table tbody tr:hover {
    background: rgba(136, 136, 136, 0.05);
}

html.dark .message.error {
    background: #2d1f1f;
    border-color: #7f1d1d;
    color: #fca5a5;
}

html.dark .message.success {
    background: #1a3a2e;
    border-color: #166534;
    color: #86efac;
}

html.dark .message.info {
    background: #1e3a5f;
    border-color: #1e40af;
    color: #93c5fd;
}

html.dark #ttsOptions {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.15) 0%, rgba(52, 211, 153, 0.08) 100%);
    border-color: rgba(52, 211, 153, 0.4);
}

html.dark .log-entry.log-summary-detailed {
    background: #222222;
    border-color: rgba(136, 136, 136, 0.3);
    border-left-color: var(--primary-light);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--background-outer);
    color: var(--text-dark);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================
   Neumorphic Card Styles
   ======================================== */

.neu-card-light {
    background: var(--background-light);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 2rem;
}

.neu-inset-light {
    background: #ffffff;
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    border: 2px solid rgba(54, 118, 216, 0.15);
    border-radius: 1rem;
    transition: all 0.3s ease;
}

.neu-inset-light:hover {
    border-color: rgba(54, 118, 216, 0.35);
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.neu-inset-light:focus-within {
    border-color: var(--primary-light);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light), 0 0 0 3px rgba(54, 118, 216, 0.1);
}

/* ========================================
   Layout
   ======================================== */

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* ========================================
   Header
   ======================================== */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 3rem;
    margin-bottom: 3rem;
    background: rgba(240, 242, 245, 0.9);
    backdrop-filter: blur(30px);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border-light);
    border-radius: 2rem;
}

.header #themeToggleBtn {
    min-width: 2.25rem;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.header #themeToggleBtn:hover {
    transform: scale(1.08) rotate(15deg);
}

.header #themeToggleBtn .material-symbols-outlined {
    font-size: 1.125rem;
    transition: transform 0.3s ease;
}

.header .logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header .logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.header .logo-icon .material-symbols-outlined {
    color: var(--primary-light);
    font-size: 2rem;
}

.header img {
    max-width: 200px;
    height: auto;
}

.header .logo-text h2 {
    color: var(--text-dark);
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.025em;
    line-height: 1;
}

.header .logo-text p {
    color: var(--text-muted-light);
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.25rem;
}

.header .logo-text .app-version {
    color: var(--text-muted-light);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.header .status-section {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.header .status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    height: 2.25rem;
    background: var(--background-light);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 9999px;
}

.header .header-lang-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.55rem 0 0.7rem;
    height: 2.25rem;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 9999px;
    color: var(--text-muted-light);
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    cursor: pointer;
}

.header .header-lang-wrapper:hover,
.header .header-lang-wrapper:focus-within {
    color: var(--text-dark);
    border-color: var(--primary-light);
    background: rgba(54, 118, 216, 0.04);
}

.header .header-lang-icon {
    font-size: 0.95rem;
    line-height: 1;
    pointer-events: none;
}

.header .header-lang-display {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1;
    pointer-events: none;
    min-width: 1.1rem;
    text-align: center;
}

.header .header-lang-caret {
    font-size: 0.95rem;
    line-height: 1;
    pointer-events: none;
    opacity: 0.7;
}

.header .header-lang-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: transparent;
    border: 0;
    outline: 0;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-size: 0.72rem;
    color: transparent;
    cursor: pointer;
    opacity: 0;
}

.header .header-lang-select:focus-visible + * ,
.header .header-lang-wrapper:focus-within {
    outline: none;
}

.header .header-lang-select option {
    color: var(--text-dark);
    background: var(--background-light);
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
}

.header .status-indicator .status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 9999px;
    background-color: #6b7280;
    transition: background-color 0.3s ease;
}

/* Status dot states */
.header .status-indicator .status-dot.checking {
    background-color: #6b7280;
    animation: pulse-gray 2s infinite;
}

.header .status-indicator .status-dot.connected {
    background-color: #22c55e;
    animation: pulse-green 2s infinite;
}

.header .status-indicator .status-dot.disconnected {
    background-color: #dc2626;
    animation: pulse-red 2s infinite;
}

.header .status-indicator .status-dot.error {
    background-color: #f59e0b;
    animation: pulse-orange 2s infinite;
}

.header .status-indicator .status-dot.waiting {
    background-color: #6b7280;
    animation: pulse-gray 2s infinite;
}

.header .status-indicator span {
    font-size: 0.75rem;
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    color: #16a34a;
    transition: color 0.3s ease;
    min-width: 0;
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   Main Card
   ======================================== */

.main-card {
    background: var(--background-light);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 2.5rem;
    overflow: hidden;
    margin-bottom: 2rem;
}

.card-header {
    background: var(--background-light);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.card-header .material-symbols-outlined {
    color: var(--primary-light);
    font-size: 1.5rem;
}

.card-header h2 {
    color: var(--text-dark);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.card-body {
    padding: 2rem;
    color: var(--text-dark);
}

/* ========================================
   Form Controls
   ======================================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    color: var(--text-muted-light);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding-left: 0.25rem;
}

/* Prompt-options checkbox rows: shared layout for all toggles
   (Polish, Bilingual, Plain Text Mode, Text Cleanup, Disable Auto-Pause). */
.option-item {
    margin-bottom: 15px;
}

.option-item:last-child {
    margin-bottom: 0;
}

.option-item__label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    /* Reset inherited form-group label styling so titles/descriptions stay
       in normal case at a readable, uniform size. */
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    text-transform: none;
    letter-spacing: normal;
    padding-left: 0;
}

.option-item__title {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-dark);
    text-transform: none;
    letter-spacing: normal;
}

.option-item__description {
    margin: 4px 0 0 0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-muted-light);
    text-transform: none;
    letter-spacing: normal;
}

.option-item__description code {
    font-size: inherit;
}

.form-control {
    width: 100%;
    box-sizing: border-box;
    display: block;
    height: 2.75rem;
    min-height: 2.75rem;
    max-height: 2.75rem;
    padding: 0 1.25rem;
    margin: 0;
    background: #ffffff;
    border: none;
    border-radius: 1rem;
    color: #1a1a1a;
    font-size: 1rem;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 2.75rem;
    transition: all 0.3s;
    font-weight: 600;
    vertical-align: middle;
}

/* Native form controls have UA-specific intrinsic sizing.
   Explicit rules force <input> and <select> to identical box geometry. */
input.form-control,
select.form-control {
    height: 2.75rem;
    min-height: 2.75rem;
    max-height: 2.75rem;
    line-height: 2.75rem;
    padding: 0 1.25rem;
}

.neu-inset-light .form-control {
    background: #ffffff;
    border-radius: 1rem;
}

.form-control:focus {
    outline: none;
    background: #ffffff;
}

.form-control::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

select.form-control {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7a90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
    padding-right: 3rem;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: 0.025em;
}

.btn-primary {
    background: var(--primary-light);
    color: white;
    box-shadow: 0 8px 20px rgba(54, 118, 216, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 12px 30px rgba(54, 118, 216, 0.35);
    transform: scale(1.02);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--background-light);
    color: var(--text-dark);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
}

.btn-danger {
    background: var(--danger-light);
    color: white;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    background: var(--danger-light-hover);
    box-shadow: 0 12px 30px rgba(239, 68, 68, 0.35);
}

/* ========================================
   File Upload Area
   ======================================== */

.file-upload {
    margin: 2rem 0;
    padding: 4rem;
    border: 2px dashed rgba(54, 118, 216, 0.3);
    border-radius: 3rem;
    background: var(--background-light);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.file-upload:hover {
    border-color: rgba(54, 118, 216, 0.6);
    transform: scale(1.01);
}

.file-upload.dragging {
    border-color: var(--primary-light);
    background: linear-gradient(135deg, rgba(54, 118, 216, 0.05), rgba(54, 118, 216, 0.1));
}

.file-upload .upload-icon {
    background: rgba(54, 118, 216, 0.1);
    width: 5rem;
    height: 5rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    transition: transform 0.3s;
}

.file-upload:hover .upload-icon {
    transform: scale(1.1);
}

.file-upload .material-symbols-outlined {
    font-size: 3rem;
    color: var(--primary-light);
}

.file-upload h3 {
    color: var(--text-dark);
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
}

.file-upload p {
    color: var(--text-muted-light);
    font-size: 1rem;
}

.file-upload .browse-btn {
    margin-top: 1rem;
    padding: 0.75rem 2rem;
    background: var(--primary-light);
    color: white;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.05em;
    display: inline-block;
}

/* Secondary (refinement) drop zone — same elevated rendering as the primary, just more compact */
.file-upload-secondary {
    margin: 0.75rem 0 1rem;
    padding: 2rem;
    border-radius: 2rem;
}

.file-upload-secondary .upload-icon {
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 auto 1rem;
}

.file-upload-secondary .upload-icon .material-symbols-outlined {
    font-size: 2rem;
}

.file-upload-secondary h4 {
    color: var(--text-dark);
    font-size: 1.125rem;
    font-weight: 900;
    margin-bottom: 0.25rem;
}

.file-upload-secondary p {
    color: var(--text-muted-light);
    font-size: 0.875rem;
}

.file-upload.zone-disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* Per-file controls (language dropdown, refine-after toggle) */
.file-item-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border-light);
}

.file-item-controls label {
    font-size: 0.8125rem;
    color: var(--text-muted-light);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}

.file-item-controls select {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background: var(--background-light);
    color: var(--text-dark);
}

.file-item-controls .file-op-badge {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 0.5rem;
}

.file-item-controls .file-op-badge.op-translate {
    background: rgba(54, 118, 216, 0.12);
    color: #2c5fb0;
}

.file-item-controls .file-op-badge.op-refine {
    background: rgba(168, 85, 247, 0.12);
    color: #7e22ce;
}

/* ========================================
   Progress Section
   ======================================== */

.progress-section {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--background-light);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 2rem;
}

.progress-section h3 {
    color: var(--text-dark);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-bar-container {
    height: 2.5rem;
    background: var(--background-light);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 1.25rem;
    overflow: hidden;
    margin: 1.5rem 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light), #5a8ee8);
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

/* ========================================
   Stats Grid
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.stat-card {
    padding: 0.5rem 0.25rem;
    background: var(--background-light);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    text-align: center;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stat-card:hover {
    transform: translateY(-1px);
}

.stat-card h3 {
    font-size: 1.25rem;
    color: var(--primary-light);
    font-weight: 900;
    margin-bottom: 0.15rem;
}

.stat-card p {
    color: var(--text-muted-light);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Alert state for a quality-signal counter (e.g. Fallbacks): solid blue fill
   + white text, pulling from --primary-light (the same blue as the primary
   action buttons). Red is reserved for actually destructive surfaces like
   .btn-danger (Interrupt / Stop). */
.stat-card-critical {
    background: var(--primary-light);
    border-color: var(--primary-light);
    color: white;
    cursor: pointer;
}
.stat-card-critical h3 { color: white; }
.stat-card-critical p  { color: rgba(255, 255, 255, 0.92); }
.stat-card-critical .stat-card-chevron { display: inline-block; color: white; }
.stat-card-critical[aria-expanded="true"] .stat-card-chevron {
    transform: rotate(180deg);
}

/* Chevron affordance on the Fallbacks card.
   Hidden by default; only revealed when the card carries the alert state
   (count > 0), at which point the card becomes clickable to expand the
   recommendation panel below. */
.stat-card-chevron {
    display: none;
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    font-size: 1rem;
    color: white;
    transition: transform 0.2s ease;
}
.stat-card { position: relative; }

/* Inline recommendation panel toggled by the Fallbacks card.
   Spans the full progress section width and pulls from --primary-light to
   stay visually paired with the .stat-card-critical above. Informational —
   keeps the destructive red palette free for actually destructive actions. */
.recommendation-panel {
    margin: 0.75rem 0 1rem;
    padding: 0.875rem 1rem;
    background: var(--primary-light);
    border: 1px solid var(--primary-light);
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
}
.recommendation-panel[hidden] { display: none; }
.recommendation-panel strong {
    display: block;
    margin-bottom: 0.5rem;
    color: white;
}
.recommendation-list {
    margin: 0;
    padding-left: 1.25rem;
}
.recommendation-list li + li {
    margin-top: 0.25rem;
}
.recommendation-link {
    color: white;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    cursor: pointer;
}
.recommendation-link:hover { color: rgba(255, 255, 255, 0.85); }

/* ========================================
   Log Container
   ======================================== */

.log-container {
    max-height: 250px;
    min-height: 200px;
    overflow-y: auto;
    background: var(--background-light);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 2rem;
    padding: 2rem;
    padding-right: 1.5rem; /* Réduit pour faire de la place à la scrollbar */
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 0.875rem;
    margin-top: 1rem;
}

/* Last Translation Preview - Dynamic height based on MAX_TOKENS_PER_CHUNK */
#lastTranslationPreview {
    height: var(--preview-height) !important;
    min-height: var(--preview-height) !important;
    max-height: var(--preview-height) !important;
}

/* Scrollbar visible uniquement pour log-container */
.log-container::-webkit-scrollbar {
    width: 8px;
}

.log-container::-webkit-scrollbar-track {
    background: transparent;
    margin: 1rem 0; /* Décale la scrollbar pour éviter les coins arrondis */
}

.log-container::-webkit-scrollbar-thumb {
    background: var(--shadow-dark);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.log-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted-light);
}

/* Scrollbar pour Firefox */
.log-container {
    scrollbar-width: thin;
    scrollbar-color: var(--shadow-dark) transparent;
}

.log-entry {
    margin-bottom: 0.75rem;
    display: flex;
    gap: 1rem;
}

.log-timestamp {
    color: var(--text-muted-light);
    font-weight: 700;
    flex-shrink: 0;
}

/* Progress log entry (updated in-place) */
.log-entry.log-progress {
    opacity: 0.8;
    font-style: italic;
}

/* Summary log entry (consolidated completion messages) */
.log-entry.log-summary {
    background: var(--success-light-bg);
    border-left: 3px solid var(--success-light);
    padding: 0.75rem;
    border-radius: 6px;
    display: block;
    margin: 1rem 0;
    line-height: 1.6;
}

/* Detailed summary with statistics and recommendations */
.log-entry.log-summary-detailed {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    padding: 1rem;
    border-radius: 6px;
    display: block;
    margin: 1rem 0;
    line-height: 1.8;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.log-content {
    color: var(--text-dark);
}

.log-content.success {
    color: var(--success-light);
    font-weight: 700;
}

.log-content.info {
    color: var(--primary-light);
    font-weight: 500;
}

.log-content.error {
    color: #ef4444;
    font-weight: 700;
}

/* ========================================
   Scrollbar Customization - Hidden
   ======================================== */

::-webkit-scrollbar {
    width: 0px;
    height: 0px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: transparent;
}

::-webkit-scrollbar-thumb:hover {
    background: transparent;
}

/* Hide scrollbars for Firefox */
* {
    scrollbar-width: none;
}

/* Hide scrollbars for IE and Edge Legacy */
* {
    -ms-overflow-style: none;
}

/* ========================================
   Toggle Sections
   ======================================== */

.prompt-options-toggle {
    cursor: pointer;
    padding: 1rem 1.5rem;
    background: var(--background-light);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-dark);
    transition: background 0.2s, border-radius 0.2s, margin 0.2s, box-shadow 0.2s;
}

.prompt-options-toggle:hover {
    box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
}

.prompt-options-toggle span {
    font-weight: 600;
}

#promptOptionsIcon,
#settingsOptionsIcon,
#activityLogIcon {
    transition: transform 0.2s;
    color: var(--primary-light);
}

/* When the section right after the toggle is expanded,
   fuse header + body into a single cartouche. */
.prompt-options-toggle:has(+ div:not(.hidden)) {
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: 1px solid var(--border-light);
    box-shadow: -5px -5px 10px var(--shadow-light), 5px 0 10px var(--shadow-dark);
}

.prompt-options-toggle:has(+ div:not(.hidden)):hover {
    box-shadow: -5px -5px 10px var(--shadow-light), 5px 0 10px var(--shadow-dark);
}

.prompt-options-toggle + div:not(.hidden) {
    padding: 1.5rem;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-top: none;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
    margin-bottom: 1rem;
    box-shadow: -5px 0 10px var(--shadow-light), 5px 5px 10px var(--shadow-dark);
}

/* ========================================
   Checkbox Styles
   ======================================== */

input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    min-height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary-light);
    flex-shrink: 0;
}

/* ========================================
   File Management
   ======================================== */

.file-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--background-light);
    border-radius: 1.5rem;
    overflow: hidden;
}

/* File table body with max height for 6 rows + scroll */
.file-table tbody {
    display: block;
    max-height: calc(6 * 3rem); /* 6 rows * ~3rem height per row (compact) */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--shadow-dark) transparent;
}

.file-table thead,
.file-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* Compact table header */
.file-table thead th {
    padding: 0.75rem 0.5rem;
}

.file-table tbody::-webkit-scrollbar {
    width: 6px;
}

.file-table tbody::-webkit-scrollbar-track {
    background: transparent;
}

.file-table tbody::-webkit-scrollbar-thumb {
    background: var(--shadow-dark);
    border-radius: 3px;
}

.file-table tbody::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted-light);
}

.file-table thead tr {
    background: rgba(54, 118, 216, 0.05);
}

.file-table th {
    padding: 1rem;
    text-align: left;
    color: var(--text-muted-light);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
}

.file-table tbody tr {
    border-top: 1px solid var(--border-light);
    transition: background 0.2s;
}

.file-table tbody tr:hover {
    background: rgba(54, 118, 216, 0.03);
}

.file-table td {
    padding: 0.5rem;
    color: var(--text-dark);
    font-size: 0.875rem;
    vertical-align: middle;
}

/* File icon in table cell */
.file-table .file-icon-cell {
    font-size: 1.125rem;
    vertical-align: middle;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

/* Filename text with ellipsis */
.file-table .filename-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.clickable-filename {
    cursor: pointer;
    color: var(--primary-light);
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    min-width: 0;
}

.clickable-filename:hover {
    text-decoration: underline;
}

/* Compact action buttons */
.file-action-btn {
    padding: 0;
    background: var(--background-light);
    box-shadow: 2px 2px 4px var(--shadow-dark), -2px -2px 4px var(--shadow-light);
    border: 1px solid var(--border-light);
    color: var(--text-dark);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    flex-shrink: 0;
}

.file-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

.file-action-btn.download {
    color: var(--primary-light);
}

.file-action-btn.delete {
    color: #ef4444;
}

.file-action-btn.audiobook {
    color: #8b5cf6;
}

.file-action-btn.reveal {
    color: #f59e0b;
}

.file-action-btn.open {
    color: var(--primary-light);
}

/* Action-button group containers (used by Files tab rows + completion card) */
.file-action-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.file-action-group--compact {
    gap: 0.125rem;
}

.file-action-group--labeled {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.file-row-actions {
    width: 160px;
    text-align: center;
    white-space: nowrap;
    padding: 0.5rem;
}

/* ========================================
   Messages
   ======================================== */

.message {
    position: relative;
    padding: 1rem 2.75rem 1rem 1.5rem;
    border-radius: 1rem;
    margin: 1rem 0;
    font-weight: 600;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

.message .message-dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
    font-weight: 700;
    opacity: 0.6;
}

.message .message-dismiss:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
}

.error {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.success {
    background: var(--success-light-bg);
    border: 1px solid #86efac;
    color: #166534;
}

.info {
    background: var(--info-light-bg);
    border: 1px solid #93c5fd;
    color: #1e3a8a;
}

/* ========================================
   Footer
   ======================================== */

.app-footer {
    padding: 1.5rem 2rem;
    margin-top: 3rem;
    border-top: 1px solid var(--border-light);
    border-radius: 2rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.footer-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted-light);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary-light);
}

.footer-links a .material-symbols-outlined {
    font-size: 1rem;
}

/* Ko-fi support link — uses the Ko-fi brand blue so it reads as a
   donation call-out without breaking the muted footer style. */
.footer-links a.footer-kofi {
    color: #72a4f2;
    font-weight: 600;
}

.footer-links a.footer-kofi:hover {
    color: #5a8de0;
}

/* ========================================
   TTS Section
   ======================================== */

#ttsOptions {
    margin-top: 1rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.05) 100%);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 1.5rem;
}

.gpu-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.gpu-status.gpu-available {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(22, 163, 74, 0.15) 100%);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #16a34a;
}

.gpu-status.gpu-unavailable {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(185, 28, 28, 0.15) 100%);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #dc2626;
}

.gpu-status.gpu-checking {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2) 0%, rgba(245, 158, 11, 0.15) 100%);
    border: 1px solid rgba(251, 191, 36, 0.4);
    color: #f59e0b;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.available {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    animation: pulse-green 2s infinite;
}

.status-dot.unavailable {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.status-dot.checking {
    background: #fbbf24;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
    animation: pulse-yellow 1s infinite;
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 15px rgba(34, 197, 94, 0.9);
        transform: scale(1.1);
    }
}

@keyframes pulse-yellow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 15px rgba(251, 191, 36, 0.9);
        transform: scale(1.1);
    }
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 0 8px rgba(220, 38, 38, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 15px rgba(220, 38, 38, 0.9);
        transform: scale(1.1);
    }
}

@keyframes pulse-orange {
    0%, 100% {
        box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 15px rgba(245, 158, 11, 0.9);
        transform: scale(1.1);
    }
}

@keyframes pulse-gray {
    0%, 100% {
        box-shadow: 0 0 8px rgba(107, 114, 128, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 15px rgba(107, 114, 128, 0.7);
        transform: scale(1.1);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.rotating {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* TTS Slider Styles */
.tts-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--background-light);
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    outline: none;
    cursor: pointer;
    margin-top: 0.5rem;
}

.tts-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-light);
    cursor: pointer;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    transition: all 0.2s;
}

.tts-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.tts-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-light);
    cursor: pointer;
    border: none;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    transition: all 0.2s;
}

.tts-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
}

/* ========================================
   API Key Status
   ======================================== */

.key-status {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    vertical-align: middle;
}

.key-status.configured {
    background: rgba(34, 197, 94, 0.2);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.key-status.not-configured {
    background: rgba(251, 191, 36, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(251, 191, 36, 0.4);
}

/* ========================================
   Modal Styles
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: 2rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    background: var(--background-light);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    color: var(--text-dark);
    font-weight: 700;
    margin: 0;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    background: var(--background-light);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text-dark);
}

/* ========================================
   Completion Card (shown after each finished translation)
   ======================================== */

.completion-card {
    margin-top: 1.25rem;
    margin-bottom: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--background-light);
    border: 1px solid var(--success-light);
    border-left: 4px solid var(--success-light);
    border-radius: 1rem;
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    overflow: hidden;
}

.completion-card__top {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    min-width: 0;
}

.completion-card__thumb {
    flex: 0 0 auto;
    width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    line-height: 1;
}

.completion-card__thumb img,
.completion-card__thumb svg {
    width: 48px;
    height: 72px;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: block;
}

.completion-card__main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.completion-card__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.completion-card__title {
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1rem;
    min-width: 0;
}

.completion-card__title .material-symbols-outlined {
    color: var(--success-light);
    font-size: 1.5rem;
    flex: 0 0 auto;
}

.completion-card__close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted-light);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex: 0 0 auto;
}

.completion-card__close:hover {
    background: var(--background-outer);
    color: var(--text-dark);
}

.completion-card__filename {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.85rem;
    color: var(--text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.completion-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.1rem;
}

.completion-card__actions .btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
}

.completion-card__actions .btn .material-symbols-outlined {
    font-size: 1.1rem;
}

.completion-card__stats {
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-muted-light);
    font-variant-numeric: tabular-nums;
}

.completion-card__stat--error {
    color: #dc2626;
}

.completion-card__stat--warn {
    color: #d97706;
}

/* Quality-warning block displayed inside the completion card when the run
   produced fallbacks, placeholder errors, or failed chunks. Uses the same
   blue informational palette as the live .recommendation-panel so the
   advice surfaces stay visually paired. */
.completion-card__warning {
    background: var(--primary-light);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 0.85rem;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.completion-card__warning-heading {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
}
.completion-card__warning-heading .material-symbols-outlined {
    font-size: 1.15rem;
}
.completion-card__warning-breakdown {
    font-variant-numeric: tabular-nums;
    opacity: 0.95;
}
.completion-card__warning-recommendations strong {
    display: block;
    margin-bottom: 0.4rem;
    color: white;
}
.completion-card__warning-recommendations .recommendation-list {
    margin: 0;
    padding-left: 1.25rem;
}
.completion-card__warning-recommendations .recommendation-list li + li {
    margin-top: 0.25rem;
}
.completion-card__warning-recommendations .recommendation-link {
    color: white;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    cursor: pointer;
}
.completion-card__warning-recommendations .recommendation-link:hover {
    color: rgba(255, 255, 255, 0.85);
}

/* ========================================
   Utility Classes
   ======================================== */

.hidden {
    display: none !important;
}

/* ========================================
   Range Input Styles
   ======================================== */

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--background-light);
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    outline: none;
    border-radius: 3px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-light);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-light);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

/* ========================================
   File List Container
   ======================================== */

/* Styles moved to EPUB Thumbnail Styles section below */

/* ========================================
   EPUB Thumbnail Styles
   ======================================== */

#fileListContainer {
    list-style: none;
    padding: 1rem;
    margin: 0;
    background: var(--background-light);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 1.5rem;
}

.file-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: 0.75rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.file-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-cost-badge {
    margin-top: 0;
    margin-left: 36px;
}

/* Clickable file items (Queued status) */
.file-item[style*="cursor: pointer"]:hover {
    box-shadow: 0 2px 8px rgba(54, 118, 216, 0.15);
    transform: translateY(-1px);
    border-color: var(--primary-light);
}

.file-item[style*="cursor: pointer"]:hover:not(.file-active) {
    background: rgba(54, 118, 216, 0.03);
}

/* Non-clickable file items (Processing/Completed) */
.file-item:not([style*="cursor: pointer"]):hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Active file - the last uploaded file that syncs with language selectors */
.file-item.file-active {
    border-color: var(--primary-light);
    border-width: 2px;
    background: linear-gradient(135deg, rgba(54, 118, 216, 0.05) 0%, rgba(54, 118, 216, 0.02) 100%);
}

.file-item.file-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-light);
    border-radius: 0.75rem 0 0 0.75rem;
}

.file-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-light);
    background: rgba(54, 118, 216, 0.1);
    border-radius: 4px;
    margin-left: 8px;
}

.file-icon {
    flex-shrink: 0;
    width: 48px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 4px;
    background: rgba(54, 118, 216, 0.05);
    font-size: 2rem;
}

.epub-thumbnail {
    width: 48px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.generic-epub-icon {
    width: 48px;
    height: 64px;
}

.file-info {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-dark);
}

.file-status {
    font-size: 0.875rem;
    color: var(--text-muted-light);
    font-style: italic;
}

.file-remove-btn {
    margin-left: auto;
    padding: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted-light);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.file-remove-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.file-remove-btn .material-symbols-outlined {
    font-size: 18px;
}

/* Dark mode support */
html.dark .file-item {
    background: rgba(26, 31, 46, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
}

html.dark .file-item.file-active {
    border-color: var(--primary-light);
    background: linear-gradient(135deg, rgba(90, 142, 232, 0.12) 0%, rgba(90, 142, 232, 0.05) 100%);
}

html.dark .file-active-badge {
    color: var(--primary-light);
    background: rgba(90, 142, 232, 0.2);
}

html.dark .file-icon {
    background: rgba(90, 142, 232, 0.1);
}



html.dark .file-info {
    color: var(--text-light);
}

/* ========================================
   Resumable Jobs Cards
   ======================================== */

.resumable-job-card {
    border: 1px solid var(--border-light) !important;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 1rem !important;
    background: var(--background-light) !important;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.resumable-job-card:hover {
    transform: translateY(-2px);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}

#resumableJobsList {
    padding: 1rem;
    background: var(--background-light);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    border: 1px solid var(--border-light);
    border-radius: 1.5rem;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .card-body {
        padding: 1.5rem;
    }

    .file-upload {
        padding: 2rem;
    }
}

/* ========================================
   Searchable Select Component
   ======================================== */

.searchable-select {
    position: relative;
    width: 100%;
}

/* Display area - shows selected value */
.searchable-select-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    min-height: 44px;
    transition: background 0.2s;
}

.searchable-select-display:hover {
    background: rgba(54, 118, 216, 0.05);
}

.searchable-select.open .searchable-select-display {
    background: rgba(54, 118, 216, 0.08);
}

.searchable-select-value {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-dark);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-select-value.placeholder {
    color: var(--text-muted-light);
}

.searchable-select-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    background: rgba(54, 118, 216, 0.12);
    color: var(--primary-light);
    border-radius: 9999px;
    white-space: nowrap;
}

.searchable-select-arrow {
    font-size: 1.25rem;
    color: var(--text-muted-light);
    transition: transform 0.2s, color 0.2s;
}

.searchable-select.open .searchable-select-arrow {
    color: var(--primary-light);
}

/* Dropdown */
.searchable-select-dropdown {
    /* Portalled to <body> and positioned via JS (see searchable-select.js).
       `fixed` + high z-index keep it above modals and immune to ancestor
       overflow clipping. top/left/width are set inline on open. */
    position: fixed;
    z-index: 12000;
    background: var(--background-light);
    border: 2px solid var(--primary-light);
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: max-height 0.25s ease, opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.searchable-select-dropdown.open {
    display: flex;
    flex-direction: column;
    max-height: var(--ss-max-h, 400px);
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Search header */
.searchable-select-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    background: rgba(54, 118, 216, 0.03);
    flex: 0 0 auto; /* never shrink when dropdown height is tight */
}

.searchable-select-search-icon {
    font-size: 1.25rem;
    color: var(--text-muted-light);
}

.searchable-select-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    color: var(--text-dark);
    outline: none;
    padding: 0.25rem 0;
}

.searchable-select-input::placeholder {
    color: var(--text-muted-light);
}

.searchable-select-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-muted-light);
    border-radius: 50%;
    transition: all 0.2s;
}

.searchable-select-clear:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.searchable-select-clear .material-symbols-outlined {
    font-size: 1rem;
}

/* Options list */
.searchable-select-options {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    /* Fill the remaining dropdown height (after the search header) and scroll.
       min-height:0 lets the flex item shrink below its content size. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.searchable-select-option {
    padding: 0.625rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s;
}

.searchable-select-option:hover,
.searchable-select-option.highlighted {
    background: rgba(54, 118, 216, 0.08);
}

.searchable-select-option.selected {
    background: rgba(54, 118, 216, 0.12);
}

.searchable-select-option .option-check {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 1rem;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.searchable-select-option .option-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.searchable-select-option .option-label {
    font-size: 0.875rem;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-select-option.selected .option-label {
    color: var(--primary-light);
    font-weight: 600;
}

.searchable-select-option .option-description {
    font-size: 0.75rem;
    color: var(--text-muted-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Group headers - sticky with opaque background */
.searchable-select-group {
    padding: 0.625rem 1rem 0.375rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-light);
    background: #f8f9fc;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 10;
}

.searchable-select-group:first-child {
    border-top: none;
}

/* No results */
.searchable-select-no-results {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted-light);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.searchable-select-no-results .material-symbols-outlined {
    font-size: 1.25rem;
}

.searchable-select-no-results .custom-value {
    font-weight: 600;
    color: var(--primary-light);
}

/* Scrollbar styling */
.searchable-select-options::-webkit-scrollbar {
    width: 8px;
}

.searchable-select-options::-webkit-scrollbar-track {
    background: transparent;
}

.searchable-select-options::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

.searchable-select-options::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted-light);
}

/* Dark mode adjustments */
html.dark .searchable-select-display:hover {
    background: rgba(90, 142, 232, 0.08);
}

html.dark .searchable-select.open .searchable-select-display {
    background: rgba(90, 142, 232, 0.12);
}

html.dark .searchable-select-badge {
    background: rgba(90, 142, 232, 0.2);
}

html.dark .searchable-select-dropdown {
    background: #2a2a2a;
    border-color: var(--primary-light);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

html.dark .searchable-select-search {
    background: rgba(90, 142, 232, 0.05);
    border-color: #444444;
}

html.dark .searchable-select-option:hover,
html.dark .searchable-select-option.highlighted {
    background: rgba(90, 142, 232, 0.12);
}

html.dark .searchable-select-option.selected {
    background: rgba(90, 142, 232, 0.18);
}

html.dark .searchable-select-group {
    background: #2a2a2a;
    border-color: #444444;
}

/* ========================================
   Provider Select with Logos
   ======================================== */

.provider-option {
    display: flex;
    align-items: center;
    gap: 10px;
}

.provider-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 4px;
    object-fit: contain;
}

.provider-name {
    flex: 1;
}

.provider-description {
    font-size: 0.75rem;
    color: var(--text-muted-light);
    margin-left: auto;
}

/* Provider logo in display area */
.searchable-select-display .provider-logo {
    width: 18px;
    height: 18px;
}

/* Larger logo in dropdown */
.searchable-select-option .provider-logo {
    width: 22px;
    height: 22px;
}

/* ========================================
   Toast notifications
   ======================================== */

.app-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.7rem 0.9rem 0.7rem 0.85rem;
    border-radius: 0.65rem;
    background: var(--background-outer);
    color: var(--text-dark);
    border: 1px solid var(--border-light);
    box-shadow: 0 8px 22px rgba(15, 25, 45, 0.18);
    font-size: 0.875rem;
    line-height: 1.35;
    min-width: 240px;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.18s ease, opacity 0.18s ease;
    border-left-width: 4px;
}
.app-toast.app-toast-show {
    transform: translateX(0);
    opacity: 1;
}
.app-toast.app-toast-leaving {
    transform: translateX(40%);
    opacity: 0;
}
.app-toast .app-toast-icon {
    font-size: 1.15rem;
    line-height: 1;
    margin-top: 1px;
}
.app-toast .app-toast-text {
    flex: 1;
    word-break: break-word;
    white-space: pre-line;
}
.app-toast .app-toast-close {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    margin-left: 0.25rem;
    color: var(--text-muted-light);
    display: flex;
    align-items: center;
    border-radius: 4px;
}
.app-toast .app-toast-close:hover {
    color: var(--text-dark);
    background: rgba(127, 127, 127, 0.12);
}
.app-toast .app-toast-close .material-symbols-outlined {
    font-size: 1.05rem;
}

.app-toast.app-toast-success {
    border-left-color: var(--success-light);
}
.app-toast.app-toast-success .app-toast-icon {
    color: var(--success-light);
}
.app-toast.app-toast-error {
    border-left-color: #ef4444;
}
.app-toast.app-toast-error .app-toast-icon {
    color: #ef4444;
}
.app-toast.app-toast-warn {
    border-left-color: #f59e0b;
}
.app-toast.app-toast-warn .app-toast-icon {
    color: #f59e0b;
}
.app-toast.app-toast-info {
    border-left-color: var(--info-light);
}
.app-toast.app-toast-info .app-toast-icon {
    color: var(--info-light);
}

/* ========================================
   Glossary editor — UX additions
   ======================================== */

/* Saved indicator next to meta fields (name/source/target/category) */
.glossary-saved-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    color: var(--success-light);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    user-select: none;
}
.glossary-saved-indicator.is-visible {
    opacity: 1;
}
.glossary-saved-indicator .material-symbols-outlined {
    font-size: 0.95rem;
}
.glossary-saved-indicator.is-saving {
    color: var(--text-muted-light);
}

/* Search bar above the terms table */
.glossary-search-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}
.glossary-search-row input {
    flex: 1;
    padding: 0.45rem 0.7rem;
    background: var(--background-outer);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    color: var(--text-dark);
    font-size: 0.875rem;
}
.glossary-search-row input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(54, 118, 216, 0.15);
}
.glossary-search-count {
    color: var(--text-muted-light);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Inflected-forms hint shown above the terms table */
.glossary-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.75rem 0 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    color: var(--text-dark);
    font-size: 0.82rem;
    line-height: 1.4;
}
.glossary-hint .material-symbols-outlined {
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--primary-light);
    flex-shrink: 0;
}
.glossary-hint code {
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.05);
    font-size: 0.85em;
}
html.dark .glossary-hint code {
    background: rgba(255, 255, 255, 0.08);
}

/* Sortable column headers */
#glossaryTermsTable th.sortable {
    cursor: pointer;
    user-select: none;
}
#glossaryTermsTable th.sortable:hover {
    color: var(--primary-light);
}
#glossaryTermsTable th.sortable .sort-indicator {
    display: inline-block;
    margin-left: 0.2rem;
    opacity: 0.4;
    font-size: 0.85rem;
}
#glossaryTermsTable th.sortable.sort-active .sort-indicator {
    opacity: 1;
    color: var(--primary-light);
}

/* Bulk actions bar */
.glossary-bulk-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.6rem;
    background: var(--info-light-bg);
    border: 1px solid var(--info-light);
    border-radius: 0.55rem;
    font-size: 0.85rem;
}
.glossary-bulk-bar .glossary-bulk-count {
    font-weight: 600;
    color: var(--text-dark);
}
.glossary-bulk-bar select {
    padding: 0.3rem 0.5rem;
    background: var(--background-outer);
    border: 1px solid var(--border-light);
    border-radius: 0.35rem;
    color: var(--text-dark);
    font-size: 0.85rem;
}
.glossary-bulk-bar .bulk-spacer {
    flex: 1;
}

/* Translate-tab glossary info card */
.glossary-info-card {
    margin-top: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: 0.55rem;
    font-size: 0.85rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.glossary-info-card .glossary-info-meta {
    color: var(--text-muted-light);
}
.glossary-info-card .glossary-info-link {
    margin-left: auto;
    color: var(--primary-light);
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}
.glossary-info-card .glossary-info-link:hover {
    text-decoration: underline;
}

#glossaryListTable tbody a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
}
#glossaryListTable tbody a:hover {
    text-decoration: underline;
}
.glossary-info-card.is-warning {
    border-left: 4px solid #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}
.glossary-info-card .glossary-info-warn {
    color: #b45309;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
html.dark .glossary-info-card.is-warning {
    background: rgba(245, 158, 11, 0.13);
}
html.dark .glossary-info-card .glossary-info-warn {
    color: #fbbf24;
}

/* Drag & drop overlay */
.glossary-drop-target {
    transition: outline 0.15s, background 0.15s;
}
.glossary-drop-target.is-drag-over {
    outline: 2px dashed var(--primary-light);
    outline-offset: -6px;
    background: rgba(54, 118, 216, 0.06);
}

/* NER status dots animation */
.glossary-ner-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.glossary-ner-loading .dot {
    width: 6px;
    height: 6px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: glossary-ner-bounce 1.2s infinite ease-in-out both;
}
.glossary-ner-loading .dot:nth-child(2) { animation-delay: 0.15s; }
.glossary-ner-loading .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes glossary-ner-bounce {
    0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* NER source-file dropzone */
.glossary-ner-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.4rem 1rem;
    background: var(--background-light);
    border: 1px dashed var(--border-light);
    border-radius: 0.6rem;
    color: var(--text-muted-light);
    transition: background 0.15s, border-color 0.15s;
    text-align: center;
}
.glossary-ner-dropzone.is-drag-over {
    border-color: var(--primary-light);
    background: rgba(54, 118, 216, 0.08);
}
.glossary-ner-dropzone .ner-dropzone-primary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.glossary-ner-dropzone .ner-dropzone-or {
    font-size: 0.85rem;
}
.glossary-ner-dropzone .ner-dropzone-hint {
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    opacity: 0.75;
}

/* NER candidate row dimmed when source == target — low value for strong models,
   but the user can still tick it to opt the pair into the glossary. */
.ner-row-identical {
    opacity: 0.5;
    transition: opacity 0.15s;
}
.ner-row-identical:hover {
    opacity: 0.85;
}
.ner-row-identical .ner-target-input,
.ner-row-identical .ner-category-select {
    background: transparent;
}

/* NER selected-file pill */
.glossary-ner-file-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.55rem;
    padding: 0.5rem 0.65rem;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    font-size: 0.85rem;
}
.glossary-ner-file-pill .ner-file-pill-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.glossary-ner-file-pill .ner-file-pill-size {
    color: var(--text-muted-light);
    font-variant-numeric: tabular-nums;
}
.glossary-ner-file-pill .ner-file-clear-btn {
    border: 0;
    background: transparent;
    color: var(--text-muted-light);
    cursor: pointer;
    padding: 0.15rem;
    border-radius: 0.3rem;
    line-height: 0;
}
.glossary-ner-file-pill .ner-file-clear-btn:hover {
    background: var(--background-outer);
    color: var(--text-dark);
}

/* Empty state with action buttons */
.glossary-empty-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    padding: 2.2rem 1rem;
}
.glossary-empty-cta p {
    color: var(--text-muted-light);
    margin: 0;
}
.glossary-empty-cta-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Preview-block modal pre */
#glossary-preview-modal .preview-block-output {
    white-space: pre-wrap;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 0.7rem 0.9rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-dark);
    max-height: 360px;
    overflow-y: auto;
}

/* ========================================
   NER Auto-extract candidates modal
   ======================================== */
.ner-modal-content {
    max-width: 720px;
}
.ner-modal-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    color: var(--text-dark);
    font-weight: 700;
}
.ner-modal-title .material-symbols-outlined {
    color: var(--primary-light);
    font-size: 1.4rem;
}
.ner-modal-intro {
    margin: 0 0 1.25rem 0;
    color: var(--text-muted-light);
    font-size: 0.9rem;
    line-height: 1.55;
}
.ner-modal-intro strong {
    color: var(--text-dark);
    font-weight: 600;
}

/* Settings row */
.ner-settings-row {
    display: flex;
    align-items: flex-end;
    gap: 1.25rem;
    margin-top: 1.1rem;
    flex-wrap: wrap;
}
.ner-settings-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.ner-settings-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.ner-settings-input {
    width: 110px;
    padding: 0.5rem 0.75rem;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    color: var(--text-dark);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.15s, box-shadow 0.15s;
    -moz-appearance: textfield;
    appearance: textfield;
}
.ner-settings-input::-webkit-outer-spin-button,
.ner-settings-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.ner-settings-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(54, 118, 216, 0.12);
}
.ner-status {
    margin-left: auto;
    align-self: center;
    font-size: 0.85rem;
    color: var(--text-muted-light);
    font-style: italic;
    min-height: 1.2em;
}
.ner-status:empty {
    display: none;
}

/* Results step */
.ner-warnings {
    margin-bottom: 1rem;
    padding: 0.7rem 1rem;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 0.55rem;
    color: var(--text-dark);
    font-size: 0.85rem;
    line-height: 1.4;
}
html.dark .ner-warnings {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.45);
    color: #fde68a;
}
.ner-warnings ul {
    margin: 0;
    padding-left: 1.2rem;
}
.ner-warnings li + li {
    margin-top: 0.25rem;
}
.ner-results-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}
.ner-results-count-label {
    font-size: 0.95rem;
    color: var(--text-dark);
}
.ner-results-count-label strong {
    color: var(--primary-light);
    font-size: 1.05rem;
    font-weight: 700;
    margin-right: 0.25rem;
}
.ner-results-new-count {
    color: var(--text-muted-light);
    font-weight: 400;
    margin-left: 0.35rem;
}
.ner-results-hint {
    font-size: 0.8rem;
    color: var(--text-muted-light);
    font-style: italic;
}
.ner-results-table-wrap {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 0.6rem;
    background: var(--background-light);
}
.ner-results-table-wrap #ner-candidates-table {
    margin: 0;
}

/* Footer button icons inside the NER modal */
#ner-modal .modal-footer .btn .material-symbols-outlined {
    font-size: 1rem;
    margin-right: 0.25rem;
    vertical-align: -2px;
}

/* ========================================
   Cost Estimate Badge (paid API estimation)
   ======================================== */
.cost-badge {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    padding: 0.45rem 0.75rem;
    border-radius: 0.6rem;
    background: var(--background-light);
    color: var(--text-dark);
    font-size: 0.85rem;
    line-height: 1.2;
    border: 1px solid var(--border-light);
    box-shadow: inset 2px 2px 4px var(--shadow-dark),
                inset -2px -2px 4px var(--shadow-light);
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.cost-badge .cost-badge-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.cost-badge .cost-badge-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cost-badge .cost-badge-edit {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--primary-light);
    padding: 0.15rem 0.55rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.cost-badge .cost-badge-edit:hover {
    background: var(--primary-light);
    color: #ffffff;
}
.cost-badge.cost-free {
    color: var(--success-light);
}
.cost-badge.cost-free .cost-badge-icon {
    color: var(--success-light);
}
.cost-badge.cost-estimated {
    color: var(--text-dark);
}
.cost-badge.cost-estimated .cost-badge-icon {
    color: var(--primary-light);
}
.cost-badge.cost-loading,
.cost-badge.cost-unknown {
    color: var(--text-muted-light);
}
.cost-badge.cost-error {
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.3);
}
html.dark .cost-badge.cost-error {
    color: #f87171;
}
.cost-badge .cost-spinning {
    animation: cost-spin 0.9s linear infinite;
}
@keyframes cost-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Edit pricing modal */
.cost-pricing-modal {
    max-width: 480px;
}
.cost-pricing-subtitle {
    margin: 0 0 0.5rem 0;
    color: var(--text-muted-light);
    font-size: 0.9rem;
}
.cost-pricing-subtitle strong {
    color: var(--text-dark);
    font-weight: 600;
}
.cost-pricing-help {
    margin: 0 0 1rem 0;
    color: var(--text-muted-light);
    font-size: 0.8125rem;
    line-height: 1.5;
}
.cost-pricing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.cost-pricing-note {
    margin: 1rem 0 0 0;
    padding: 0.5rem 0.75rem;
    background: var(--info-light-bg);
    color: var(--info-light);
    border-radius: 0.5rem;
    font-size: 0.8125rem;
}

/* ========================================
   Update Banner (auto-update notification)
   ======================================== */
.update-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--info-light-bg);
    border: 1px solid var(--info-light);
    border-radius: 0.75rem;
    color: var(--text-dark);
    font-size: 0.9rem;
    box-shadow: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
}
.update-banner.hidden { display: none; }
.update-banner__text { flex: 1 1 auto; }
.update-banner__text strong { color: var(--info-light); }
.update-banner__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}
.update-banner__actions .btn {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 0.5rem;
}
.update-banner__close {
    background: transparent;
    border: none;
    color: var(--text-muted-light);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.4rem;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.update-banner__close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dark);
}
html.dark .update-banner__close:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Modal-like overlay used while the update is running / restarting. */
.update-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 22, 35, 0.6);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.update-overlay.hidden { display: none; }
.update-overlay__panel {
    background: var(--background-outer);
    color: var(--text-dark);
    border-radius: 1rem;
    padding: 1.5rem 1.75rem;
    max-width: 640px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-light);
}
.update-overlay__title {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
    font-weight: 700;
}
.update-overlay__step {
    margin: 0 0 1rem 0;
    color: var(--text-muted-light);
    font-size: 0.9rem;
}
.update-overlay__log {
    max-height: 220px;
    overflow-y: auto;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-muted-light);
    white-space: pre-wrap;
    word-break: break-word;
}
.update-overlay__actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
.update-overlay__error {
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
    border-radius: 0.5rem;
    font-size: 0.85rem;
}
html.dark .update-overlay__error { color: #fca5a5; }

/* ========================================
   Sample & Compare tab
   ======================================== */

.sample-mode-btn {
    padding: 0.5rem 1rem;
}
.sample-mode-btn-active {
    background: var(--primary-light);
    color: #fff;
    border-color: var(--primary-light);
}

.sample-column-card {
    /* Use the recessed surface tone (not pure white) so the white input wells
       inside the card stand out. The neumorphic shadow keeps it raised. */
    background: var(--background-light);
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

/* While a Run is in flight, lock the column editor: editing a provider/model
   mid-run would race the arriving cell_done events. */
#sampleColumns.is-running {
    pointer-events: none;
    opacity: 0.6;
}
html.dark .sample-column-card {
    background: var(--background-light);
    border-color: var(--border-light) !important;
}

/* Give the provider/model searchable-selects and the endpoint input a clear
   input-well surface so they don't melt into the card background. */
.sample-column-card .searchable-select,
.sample-column-card .sample-endpoint-input,
.sample-column-card .sample-instructions-select,
.sample-column-card .sample-glossary-select {
    background: var(--background-outer);
    border: 1px solid var(--border-light);
    border-radius: 0.75rem;
}
.sample-column-card .sample-endpoint-input,
.sample-column-card .sample-instructions-select,
.sample-column-card .sample-glossary-select {
    box-sizing: border-box;
}
html.dark .sample-column-card .searchable-select,
html.dark .sample-column-card .sample-endpoint-input,
html.dark .sample-column-card .sample-instructions-select,
html.dark .sample-column-card .sample-glossary-select {
    background: #222222;
    border-color: #444444;
}

.sample-warning {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
    border-left: 3px solid #f59e0b;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}
html.dark .sample-warning {
    background: rgba(245, 158, 11, 0.16);
    color: #fbbf24;
}
.sample-warning-error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger-light);
    border-left-color: var(--danger-light);
}
html.dark .sample-warning-error {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
}
.sample-warning-success {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
    border-left-color: #22c55e;
}
html.dark .sample-warning-success {
    background: rgba(34, 197, 94, 0.18);
    color: #86efac;
}
.sample-warning-info {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
    border-left-color: #3b82f6;
}
html.dark .sample-warning-info {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

.sample-cards {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.sample-card {
    background: var(--background-outer);
    border-radius: 0.9rem;
    padding: 16px;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
}
html.dark .sample-card {
    background: var(--background-outer);
    border: 1px solid var(--border-light);
}

.sample-card-source {
    padding: 12px 14px;
    padding-right: 42px;
    border-radius: 0.6rem;
    background: var(--background-light);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    position: relative;
}
.sample-file-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    margin: 12px 0;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: 0.85rem;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    position: relative;
}
.sample-file-cover {
    width: 64px;
    height: 84px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--background-outer);
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    color: var(--primary-light);
    overflow: hidden;
}
.sample-file-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.sample-file-cover .material-symbols-outlined {
    font-size: 36px;
}
.sample-file-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sample-file-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted-light);
    font-weight: 600;
}
.sample-file-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sample-file-details {
    font-size: 0.8125rem;
    color: var(--text-muted-light);
}
.sample-file-remove {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}
.sample-file-remove:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}
.sample-file-remove .material-symbols-outlined {
    font-size: 20px;
}

.sample-card-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.sample-card-remove:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}
.sample-card-remove .material-symbols-outlined {
    font-size: 18px;
    line-height: 1;
}

.sample-add-row {
    display: flex;
    justify-content: center;
    margin-top: 18px;
}
.sample-empty {
    text-align: center;
    color: var(--text-muted-light);
    font-style: italic;
    padding: 18px;
}
.sample-card-source-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.sample-card-source-index {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--primary-light);
}
.sample-card-source-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted-light);
    font-weight: 600;
}
.sample-card-source-text {
    white-space: pre-wrap;
    line-height: 1.55;
    color: var(--text-dark);
    font-size: 0.9375rem;
}

.sample-card-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sample-llm-block {
    padding: 12px 14px;
    border-radius: 0.6rem;
    border: 1px solid var(--border-light);
    background: var(--background-outer);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sample-llm-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border-light);
}
.sample-llm-index {
    font-size: 0.6875rem;
    color: var(--text-muted-light);
    font-weight: 700;
}
.sample-llm-provider {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted-light);
    font-weight: 700;
}
.sample-llm-model {
    font-weight: 700;
    color: var(--text-dark);
}
.sample-llm-meta {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted-light);
}
.sample-llm-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sample-phase {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sample-phase-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted-light);
}
.sample-output {
    white-space: pre-wrap;
    line-height: 1.5;
}
/* Refined output: by default read as clean prose — the final text with the
   added words highlighted green and the removed words hidden. Hovering the
   block reveals the full word-level diff (struck-through removals in red). */
.sample-output-diff ins {
    background: rgba(34, 197, 94, 0.18);
    text-decoration: none;
    padding: 0 2px;
    border-radius: 2px;
}
.sample-output-diff del {
    display: none;
}
.sample-output-diff:hover del {
    display: inline;
    background: rgba(239, 68, 68, 0.18);
    text-decoration: line-through;
    padding: 0 2px;
    border-radius: 2px;
}
html.dark .sample-output-diff ins {
    background: rgba(34, 197, 94, 0.26);
}
html.dark .sample-output-diff:hover del {
    background: rgba(239, 68, 68, 0.26);
}

.sample-phase-error {
    border-left: 3px solid var(--danger-light);
    padding-left: 8px;
    background: rgba(239, 68, 68, 0.06);
    border-radius: 0.25rem;
}
.sample-error-text {
    color: var(--danger-light);
    font-size: 0.8125rem;
    white-space: pre-wrap;
}

.sample-cell-footer {
    font-size: 0.75rem;
    color: var(--text-muted-light);
    border-top: 1px dashed var(--border-light);
    padding-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.sample-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
}
.sample-badge-truncated {
    background: rgba(245, 158, 11, 0.18);
    color: #92400e;
}
html.dark .sample-badge-truncated {
    background: rgba(245, 158, 11, 0.22);
    color: #fbbf24;
}
.sample-badge-fallback {
    background: rgba(168, 85, 247, 0.18);
    color: #6b21a8;
}
html.dark .sample-badge-fallback {
    background: rgba(168, 85, 247, 0.22);
    color: #c084fc;
}
.sample-badge-error {
    background: rgba(239, 68, 68, 0.18);
    color: var(--danger-light);
}

.sample-cell-skeleton {
    height: 56px;
    border-radius: 0.5rem;
    background: linear-gradient(
        90deg,
        var(--border-light) 0%,
        var(--background-light) 50%,
        var(--border-light) 100%
    );
    background-size: 200% 100%;
    animation: sample-skeleton-shimmer 1.4s ease-in-out infinite;
}
.sample-cell-pending {
    min-height: 56px;
    border-radius: 0.5rem;
    padding: 14px 16px;
    background: var(--background-light);
    color: var(--text-muted-light);
    font-size: 0.8125rem;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px dashed var(--border-light);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sample-cell-pending:hover {
    background: var(--background-outer);
    color: var(--primary-light);
    border-color: var(--primary-light);
}
.sample-llm-block.is-disabled .sample-cell-pending,
.sample-cell-pending.is-disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
.sample-cell-pending.is-disabled:hover {
    background: var(--background-light);
    color: var(--text-muted-light);
    border-color: var(--border-light);
}
@keyframes sample-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   Quick LLM test (per-file, Translate tab)
   ======================================== */

/* Flask pill on each Selected-Files row (icon + label), grouped with remove. */
.file-test-btn {
    margin-left: auto;
    padding: 4px 10px 4px 8px;
    border: 1px solid rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.10);
    color: #4f46e5;
    cursor: pointer;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.file-test-btn + .file-remove-btn { margin-left: 8px; }
.file-test-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.55);
}
.file-test-btn .material-symbols-outlined { font-size: 16px; }
html.dark .file-test-btn { color: #a5b4fc; }

.quick-test-content { max-width: 720px; }

/* Header: title stacked over the "full test" hand-off link. */
.quick-test-header-titles {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.quick-test-compare-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    align-self: flex-start;
    padding: 0;
    border: none;
    background: none;
    color: var(--primary-light, #4f46e5);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.quick-test-compare-link:hover { opacity: 0.75; }
.quick-test-compare-link .material-symbols-outlined { font-size: 1rem; }
.quick-test-compare-link .quick-test-compare-arrow { transition: transform 0.15s ease; }
.quick-test-compare-link:hover .quick-test-compare-arrow { transform: translateX(3px); }

.quick-test-intro {
    margin: 0 0 1rem;
    color: var(--text-muted-light);
    font-size: 0.9rem;
}

.quick-test-summary {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 0.75rem;
    background: var(--background-outer);
}
.quick-test-summary-llm {
    color: var(--text-dark);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.quick-test-summary-sep { opacity: 0.5; }
.quick-test-chips {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.quick-test-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.18);
    color: #4f46e5;
    border: 1px solid rgba(99, 102, 241, 0.45);
}

.quick-test-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.quick-test-card {
    border: 1px solid var(--border-light);
    border-radius: 0.75rem;
    padding: 12px 14px;
    background: var(--background-light);
}
.quick-test-source {
    color: var(--text-muted-light);
    font-size: 0.85rem;
    font-style: italic;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--border-light);
    white-space: pre-wrap;
}
.quick-test-result .sample-output { font-size: 0.9rem; }

.quick-test-loading,
.quick-test-error {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted-light);
    font-size: 0.9rem;
}
.quick-test-error { color: #dc2626; }

.quick-test-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 6px;
    border: 2px solid var(--border-light);
    border-top-color: #4f46e5;
    border-radius: 50%;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

