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

body {
    font-family: 'Inter', sans-serif;
    background: #ffffff;
    color: #0f172a;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 72rem;
    margin: 0 auto;
}

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

/* ── Password state ── */
.inv-pw-input {
    width: 100%;
    max-width: 20rem;
    margin: 0 auto 1rem;
    display: block;
    padding: .7rem .9rem;
    border: 1.5px solid #e2e8f0;
    border-radius: .75rem;
    font-size: .9375rem;
    font-family: inherit;
}
.inv-pw-input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* ── Smart recommendation banner ── */
.inv-recommend {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 1rem;
    padding: .875rem 1.125rem;
    margin-bottom: 1.5rem;
    font-size: .8125rem;
    color: #1e40af;
}
.inv-recommend b { color: #1d4ed8; }
.inv-recommend-icon { flex-shrink: 0; width: 1.75rem; height: 1.75rem; }

/* ── Mode selector ── */
.inv-mode-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 720px) {
    .inv-mode-grid { grid-template-columns: repeat(2, 1fr); }
}

.inv-mode-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 1rem;
    padding: .875rem .75rem;
    text-align: left;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.inv-mode-card:hover { border-color: #c7d2fe; background: #fafafe; }
.inv-mode-card.active {
    border-color: #6366f1;
    background: #f5f5ff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}
.inv-mode-card.recommended::after {
    content: 'Recommended';
    display: inline-block;
    margin-top: .4rem;
    font-size: .625rem;
    font-weight: 700;
    color: #059669;
    background: #ecfdf5;
    padding: .1rem .45rem;
    border-radius: 9999px;
}
.inv-mode-swatch {
    width: 2rem;
    height: 2rem;
    border-radius: .5rem;
    margin-bottom: .5rem;
}
.inv-mode-name { font-size: .8125rem; font-weight: 700; color: #0f172a; }
.inv-mode-desc { font-size: .6875rem; color: #64748b; margin-top: .2rem; line-height: 1.45; }

/* ── Custom / dark-intensity controls ── */
.inv-controls {
    background: #f8fafc;
    border: 1.5px solid #e8ecf0;
    border-radius: 1rem;
    padding: 1rem 1.125rem;
    margin-bottom: 1.25rem;
}
.inv-slider-row { margin-bottom: .75rem; }
.inv-slider-row:last-child { margin-bottom: 0; }
.inv-slider-label {
    display: flex;
    justify-content: space-between;
    font-size: .75rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: .3rem;
}
.inv-slider-label span:last-child { color: #6366f1; font-weight: 700; }
.inv-slider-row input[type="range"] { width: 100%; accent-color: #6366f1; }
.inv-toggle-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .8125rem;
    font-weight: 600;
    color: #334155;
}
.inv-toggle-row input { accent-color: #6366f1; width: 1rem; height: 1rem; }

/* ── Quality + page-range bar ── */
.inv-optionbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .875rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 640px) {
    .inv-optionbar { grid-template-columns: 1fr; }
}
.inv-option-card {
    background: #fff;
    border: 1.5px solid #e8ecf0;
    border-radius: 1rem;
    padding: .875rem 1rem;
}
.inv-option-title {
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
    margin-bottom: .5rem;
}
.inv-quality-bar { display: flex; gap: .4rem; flex-wrap: wrap; }
.inv-quality-btn {
    flex: 1;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    color: #475569;
    font-size: .75rem;
    font-weight: 700;
    padding: .45rem .5rem;
    border-radius: .625rem;
    cursor: pointer;
    transition: all .2s;
}
.inv-quality-btn.active {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    border-color: transparent;
    color: #fff;
}
.inv-range-radios { display: flex; gap: 1rem; margin-bottom: .5rem; }
.inv-radio-lbl { display: flex; align-items: center; gap: .35rem; font-size: .8125rem; font-weight: 600; color: #334155; cursor: pointer; }
.inv-radio-lbl input { accent-color: #6366f1; }
.inv-range-input {
    width: 100%;
    padding: .5rem .7rem;
    border: 1.5px solid #e2e8f0;
    border-radius: .625rem;
    font-size: .8125rem;
    font-family: inherit;
}
.inv-range-input:disabled { background: #f8fafc; color: #94a3b8; }
.inv-range-error { font-size: .6875rem; color: #dc2626; margin-top: .35rem; display: none; }
.inv-range-error.show { display: block; }
.inv-large-doc-warn {
    font-size: .6875rem; color: #b45309; background: #fffbeb; border: 1px solid #fde68a;
    border-radius: .625rem; padding: .5rem .75rem; margin-top: .625rem;
}

/* ── Stats ── */
.inv-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
    margin-bottom: 1.75rem;
}
@media(max-width:640px) { .inv-stats { grid-template-columns: repeat(2, 1fr); } }
.inv-stat { background: #fff; border: 1px solid #e8ecf0; border-radius: .875rem; padding: .875rem .5rem; text-align: center; }
.inv-stat-val { font-size: 1.125rem; font-weight: 800; color: #0f172a; }
.inv-stat-lbl { font-size: .625rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8; margin-top: .2rem; }

/* ── Before/after viewer ── */
.inv-viewer {
    background: #fff;
    border: 1.5px solid #e8ecf0;
    border-radius: 1.25rem;
    padding: 1.5rem;
    margin-bottom: 1.75rem;
}
.inv-compare {
    position: relative;
    margin: 0 auto;
    max-width: 30rem;
    border-radius: .75rem;
    overflow: hidden;
    background: #f1f5f9;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .1);
    user-select: none;
    min-height: 12rem;
}
.inv-compare canvas { display: block; width: 100%; height: auto; }
.inv-compare-after { position: absolute; top: 0; left: 0; width: 50%; height: 100%; overflow: hidden; }
.inv-compare-after canvas { width: var(--inv-cw); max-width: none; }
.inv-compare-handle {
    position: absolute; top: 0; bottom: 0; left: 50%; width: 3px;
    background: #6366f1; cursor: ew-resize; transform: translateX(-50%);
}
.inv-compare-handle::after {
    content: '\2194'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 2.25rem; height: 2.25rem; background: #fff; border-radius: 50%;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .25); display: flex; align-items: center; justify-content: center;
    font-size: .875rem; color: #6366f1; font-weight: 700;
}
.inv-compare-handle:focus-visible { outline: 2px solid #6366f1; outline-offset: 3px; }
.inv-compare-label {
    position: absolute; bottom: .5rem; font-size: .625rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; background: rgba(15, 23, 42, .65); color: #fff; padding: .2rem .55rem; border-radius: 9999px;
}
.inv-compare-loading {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.65);
}
.inv-mini-spin {
    width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 3px solid #e0e7ff;
    border-top-color: #6366f1; animation: spin .8s linear infinite;
}
.inv-range-slider-a11y {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.inv-viewer-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }
.inv-nav-btn {
    background: #f1f5f9; border: 1px solid #e2e8f0; width: 2.25rem; height: 2.25rem; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center; color: #475569;
}
.inv-use-page-btn {
    font-size: .75rem; font-weight: 700; color: #6366f1; background: none; border: none; cursor: pointer;
    text-decoration: underline;
}

/* ── Page grid ── */
.inv-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: .875rem;
    margin-bottom: 1.75rem;
}
.inv-page-card {
    background: #fff; border: 1.5px solid #e8ecf0; border-radius: .875rem; overflow: hidden;
    transition: border-color .2s, box-shadow .2s, opacity .2s; cursor: pointer;
}
.inv-page-card.selected { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
.inv-page-card.excluded { opacity: .4; }
.inv-page-thumb-wrap {
    background: #f8fafc; padding: .5rem; display: flex; align-items: center; justify-content: center;
    border-bottom: 1px solid #eef2f7; min-height: 6.5rem; position: relative;
}
.inv-page-thumb-wrap img { max-width: 100%; max-height: 5.75rem; box-shadow: 0 2px 10px rgba(15, 23, 42, .12); }
.inv-page-num { font-size: .6875rem; font-weight: 700; color: #0f172a; text-align: center; padding: .4rem 0 .5rem; }
.inv-page-excluded-badge {
    position: absolute; top: .25rem; right: .25rem; background: rgba(15,23,42,.7); color: #fff;
    font-size: .5625rem; font-weight: 700; padding: .1rem .4rem; border-radius: 9999px;
}

/* ── Actions ── */
.inv-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.inv-btn-primary {
    display: inline-flex; align-items: center; gap: .5rem; background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff; font-weight: 700; padding: .875rem 2.25rem; border-radius: 9999px; font-size: .9375rem;
    cursor: pointer; box-shadow: 0 4px 14px rgba(99, 102, 241, .35); border: none; transition: all .25s;
}
.inv-btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.inv-btn-secondary {
    background: #f1f5f9; color: #475569; font-weight: 600; padding: .875rem 1.75rem; border-radius: 9999px;
    font-size: .875rem; cursor: pointer; border: 1px solid #e2e8f0;
}

/* ── Progress ── */
.inv-progress-track { background: #f1f5f9; border-radius: 9999px; height: .5rem; overflow: hidden; margin: 1rem 0 .5rem; }
.inv-progress-fill { background: linear-gradient(90deg, #3b82f6, #8b5cf6); height: 100%; width: 0%; transition: width .2s; border-radius: 9999px; }

.inv-failed-note {
    font-size: .75rem; color: #b45309; background: #fffbeb; border: 1px solid #fde68a;
    border-radius: .625rem; padding: .625rem .875rem; margin-top: .875rem; text-align: left;
}
