.hidden {
    display: none !important;
}

.hero {
    padding: 40px 40px 80px;
}

svg {
    fill: none;
}

body {
    overflow-x: hidden;
}

body.selection-active {
    overflow-y: hidden;
}


/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-screen.active {
    opacity: 1;
    pointer-events: all;
}

.loading-center-group {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-bar-container {
    width: 300px;
    height: 5px;
    background: #fff;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-bar {
    position: absolute;
    height: 100%;
    background: #ff6154;
    border-radius: 2px;
    width: 40%;
    will-change: transform;
    animation: loading 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(200%); }
    100% { transform: translateX(500%); }
}

.loading-text {
    font-size: 1.05rem;
    color: #1f2937;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

.loading-subtext {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #9ca3af;
    font-weight: 400;
    min-height: 18px;
    margin-top: 16px;
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

.loading-percent {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    color: #999;
    font-weight: 500;
    min-height: 18px;
    font-variant-numeric: tabular-nums;
    margin-top: 40px;
    white-space: nowrap;
}

/* Upload progress mode */
.loading-bar-container.progress-mode .loading-bar {
    animation: none;
    width: 0%;
    transition: width 0.2s ease;
}

/* Upload Overlay */
.upload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.97);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.upload-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.upload-overlay.hidden {
    display: none;
}

.upload-overlay-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: uploadCardIn 0.5s cubic-bezier(0.32, 0.72, 0, 1) both;
}

.upload-center-group {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

@keyframes uploadCardIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Ring progress */
.upload-ring-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    overflow: hidden;
    transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.7s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.upload-ring-track {
    fill: none;
    stroke: #fff;
    stroke-width: 5;
}

.upload-ring-fill {
    fill: none;
    stroke: #ff6154;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 263.89;
    stroke-dashoffset: 263.89;
    transition: stroke-dashoffset 0.3s ease;
}

.upload-ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.upload-ring-percent {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    font-variant-numeric: tabular-nums;
}

.upload-phase {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2937;
    transition: opacity 0.3s ease;
}

.upload-file-name {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #9ca3af;
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 12px;
    transition: opacity 0.3s ease;
}

/* Morphing: ring-wrap shrinks to bar */
.upload-overlay-card.morphing .upload-ring-wrap {
    width: 300px;
    height: 4px;
    border-radius: 2px;
}

.upload-overlay-card.morphing .upload-ring {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.upload-overlay-card.morphing .upload-ring-center {
    opacity: 0;
}

.upload-overlay-card.morphing .upload-phase,
.upload-overlay-card.morphing .upload-file-name {
    opacity: 0;
}

.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

/* Import-screen vertical centering — body flex column at step 1
   with auto margins on hero + container so they center as a pair.
   Matches step-based tools' rhythm for cross-tool consistency.
   Grayscale has 4 step-2/3 body classes covering single-file and
   batch flows: selection-active, download-active, batch-mode,
   batch-result-active. Step 1 = none of these. */
body:not(.selection-active):not(.download-active):not(.batch-mode):not(.batch-result-active) {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
body:not(.selection-active):not(.download-active):not(.batch-mode):not(.batch-result-active) .hero {
    margin-top: auto;
}
body:not(.selection-active):not(.download-active):not(.batch-mode):not(.batch-result-active) .container {
    margin-bottom: auto;
}

/* Upload area */
.upload-area {
    max-width: 400px;
    margin: 40px auto 1.5rem;
}

.file-input-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ff6154;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input-label:hover {
    background: #e5554a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.4);
}

.upload-content {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.upload-icon {
    position: absolute;
    width: 24px;
    height: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    transition: opacity 0.3s ease;
}

.file-input-label:hover .upload-icon {
    opacity: 1;
}

.file-input-label:hover .upload-text {
    opacity: 0;
    visibility: hidden;
}

.file-input, #fileInput {
    display: none;
}

.error-message {
    color: #d93025;
    background: #fce8e6;
    border-radius: 12px;
    padding: 16px;
    margin: 20px auto;
    display: none;
    max-width: 400px;
}

/* Selection Panel - Split View Layout */
.selection-panel {
    margin-top: 0;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    position: fixed;
    top: 81px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 81px);
}

.selection-content {
    display: flex;
    gap: 0;
    align-items: stretch;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Left side - Files Preview */
.files-preview-section {
    flex: 1;
    /* Soft designed backdrop so the left side feels like a real workspace,
       not a small card floating in empty space. */
    background: linear-gradient(160deg, #f7f8fa 0%, #eef1f5 100%);
    padding: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    height: 100%;
    overflow-y: auto;
    margin-right: 420px;
    box-sizing: border-box;
}

/* Large File Preview Card */
.file-preview-large {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 48px;
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.file-preview-large:hover {
    border-color: #ff6154;
    box-shadow: 0 8px 24px rgba(255, 97, 84, 0.12);
}

.file-preview-thumbnail {
    width: 100%;
    max-width: 180px;
    background: #f8f9fa;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
}

.file-preview-thumbnail canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    position: relative;
    z-index: 1;
    border: 1px solid #e5e7eb;
}

.file-preview-details {
    width: 100%;
}

.file-preview-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    word-break: break-word;
    line-height: 1.4;
}

.file-preview-size {
    font-size: 1rem;
    color: #6b7280;
    font-weight: 500;
}

.file-change-btn {
    background: transparent;
    border: 2px solid #e5e7eb;
    color: #6b7280;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.file-change-btn:hover {
    border-color: #ff6154;
    color: #ff6154;
    background: #fff5f4;
}

.file-change-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* Custom Dropdown Styles */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-dropdown-trigger:hover {
    border-color: #ffc9c3;
    background: #fff5f4;
}

.custom-dropdown.open .custom-dropdown-trigger {
    border-color: #ff6154;
    background: #fff5f4;
}

.dropdown-selected {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-selected-text {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}

.dropdown-selected-desc {
    font-size: 0.8rem;
    color: #9ca3af;
}

.dropdown-selected-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #ff6154;
    background: #ffe5e2;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 4px;
    width: fit-content;
}

.dropdown-arrow {
    width: 20px;
    height: 20px;
    stroke: #6b7280;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.custom-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.custom-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
    margin-top: 8px;
    display: none;
    max-height: 280px;
    overflow: hidden;
}

.custom-dropdown.open .custom-dropdown-menu {
    display: block;
    overflow-y: auto;
}

.dropdown-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid #f3f4f6;
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option:hover {
    background: #f8f9fa;
}

.dropdown-option.selected {
    background: #fff5f4;
}

.dropdown-option-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-option-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
}

.dropdown-option.selected .dropdown-option-name {
    color: #ff6154;
}

.dropdown-option-desc {
    font-size: 0.8rem;
    color: #9ca3af;
}

.dropdown-option-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: #ff6154;
    background: #ffe5e2;
    padding: 4px 10px;
    border-radius: 10px;
}

/* Dropdown Scrollbar */
.custom-dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
    border: 2px solid white;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Right side - Controls Panel (Fixed) */
.controls-panel {
    position: fixed;
    right: 0;
    top: 81px;
    width: 420px;
    box-sizing: border-box;
    padding: 40px;
    padding-bottom: 0;
    height: calc(100vh - 81px);
    background: white;
    border-left: 2px solid #e5e7eb;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

/* Wrapper for options - centers content vertically */
.controls-options-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
}

.controls-options-wrapper .control-section {
    margin-bottom: 0;
}

/* Control Sections */
.control-section {
    margin-bottom: 24px;
}

.control-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 16px 0;
}

/* Convert button section - sticks to bottom */
.controls-panel > .control-section:last-child {
    margin-top: auto;
}

/* Extract Actions */
.extract-actions-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-extract {
    width: 100%;
    padding: 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    position: relative;
}

.btn-extract.single {
    background-color: #ff6154;
    color: white;
}

.btn-extract.single:hover:not(:disabled) {
    background: #e5554a;
    box-shadow: 0 6px 16px rgba(255, 97, 84, 0.4);
    transform: translateY(-2px);
}

.btn-extract:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-arrow {
    width: 24px;
    height: 24px;
    stroke: white;
    flex-shrink: 0;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.btn-extract:hover .btn-arrow {
    transform: translateX(4px);
}

.btn-extract-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.btn-extract-title {
    font-size: 1rem;
    font-weight: 700;
}

.btn-extract-desc {
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 400;
}

/* Button spinner */
.btn-spinner {
    display: none;
    width: 24px;
    height: 24px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto;
}

.btn-extract.btn-loading .btn-spinner {
    display: block;
    animation: btn-spinner 0.7s linear infinite;
}

.btn-extract.btn-loading .btn-arrow {
    display: none;
}

.btn-extract.btn-loading {
    pointer-events: none;
}

.btn-extract.btn-loading:disabled {
    opacity: 1;
    cursor: default;
}

.btn-extract.btn-loading .btn-extract-content {
    visibility: hidden;
}

@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

/* Download Screen */
.download-screen {
    display: none;
    padding: 0;
    max-width: 100%;
    margin: 0;
    min-height: calc(100vh - 81px);
    background: #f5f6f8;
}

.download-screen.active {
    display: block;
}

.download-content {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 81px);
}

.pdf-preview-section {
    flex: 1;
    background: #f5f6f8;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    margin-right: 420px;
    height: calc(100vh - 81px);
    box-sizing: border-box;
}

.preview-canvas-container {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.preview-page-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    position: relative;
}

.preview-page-wrapper canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-number-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10;
}

/* Right side - Actions Sidebar */
.download-actions-section {
    position: fixed;
    right: 0;
    top: 81px;
    width: 420px;
    height: calc(100vh - 81px);
    background: white;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 40px;
    overflow-y: auto;
    box-sizing: border-box;
}

.back-button {
    background: none;
    color: #8e96a7;
    border: none;
    padding: 0;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-weight: 500;
    position: absolute;
    margin-top: -10px;
    left: 40px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.back-button:hover {
    background: none;
    color: #374151;
    box-shadow: none;
    transform: none;
}

.back-button svg {
    width: 18px;
    height: 18px;
    background: #f9f9f9;
    padding: 6px;
    border-radius: 8px;
    box-sizing: content-box;
    transition: background 0.15s ease;
}

.back-button:hover svg {
    background: #f0f0f0;
}

#download-files-list {
    margin-top: 50px;
    margin-bottom: 24px;
}

.single-file-card {
    background: none;
    border: none;
    border-radius: 12px;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.single-file-thumb {
    width: 68px;
    height: 82px;
    background: white;
    border-radius: 6px;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.single-file-thumb canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.single-file-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.single-file-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.single-file-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    background: #f9f9f9;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.single-file-name:hover {
    background: #f0f1f3;
}

.single-file-name-base {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.single-file-name-ext {
    white-space: nowrap;
    flex-shrink: 0;
    color: #9ca3af;
    margin-left: auto;
}

.file-more-btn {
    background: #f9f9f9;
    border: none;
    border-radius: 8px;
    padding: 8px 6px;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.file-more-btn:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.single-file-info {
    font-size: 0.7rem;
    color: #9ca3af;
}

.done-button {
    background: #10b981;
    color: white;
    padding: 2px 7px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 3px;
}

.done-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: white;
}

.download-primary {
    width: 100%;
    padding: 18px 32px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #ff6154;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.download-primary:hover {
    background: #e5554a;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.35);
    transform: translateY(-1px);
}

.download-primary svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
    transition: opacity 0.18s ease;
}

/* Loading state — same as flatten's "Download All" button:
   white background, hairline border, narrow coral progress line
   that fades in after the content fades out. */
.download-primary.loading {
    pointer-events: none;
    position: relative;
    background-color: #fff;
    box-shadow: 0 0 0 1px #e5e7eb;
    transform: none;
    color: transparent;
}
.download-primary.loading svg { opacity: 0; }
.download-primary.loading::after {
    content: '';
    position: absolute;
    left: 30%;
    width: 40%;
    height: 5px;
    background: #fff;
    border-radius: 4px;
    opacity: 0;
    animation: btnLoadingFadeIn 0.18s 0.15s ease forwards;
}
.download-primary.loading::before {
    content: '';
    position: absolute;
    left: 30%;
    width: 0%;
    height: 5px;
    background: #ff6154;
    z-index: 1;
    border-radius: 4px;
    opacity: 0;
    animation: btnLoadingFadeIn 0.18s 0.15s ease forwards,
               btnLoadingFill 2s 0.15s ease-out forwards;
}
@keyframes btnLoadingFadeIn { to { opacity: 1; } }
@keyframes btnLoadingFill {
    0%   { width: 0%; }
    30%  { width: 20%; }
    50%  { width: 28%; }
    70%  { width: 33%; }
    85%  { width: 36%; }
    100% { width: 40%; }
}

/* Convert Another Button */
.extract-another-btn {
    width: 100%;
    padding: 13px 32px;
    margin-top: 12px;
    background: transparent;
    color: #ff6154;
    border: 1.5px solid #ff6154;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.another-btn-text,
.another-btn-arrow {
    transition: opacity 0.25s ease;
}

.another-btn-arrow {
    position: absolute;
    opacity: 0;
}

.extract-another-btn:hover {
    background: #fff5f4;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.2);
}

.extract-another-btn:hover .another-btn-text {
    opacity: 0;
}

.extract-another-btn:hover .another-btn-arrow {
    opacity: 1;
}

/* File More Modal */
.file-more-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    animation: modalFadeIn 0.15s ease;
}

.file-more-overlay.hidden {
    display: none !important;
}

.file-more-sheet {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: sheetSlideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheetSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

.file-more-group {
    background: white;
    border-radius: 16px;
    overflow: hidden;
}

.file-more-action {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.15s;
}

.file-more-action:hover {
    background: #f9fafb;
}

/* Disabled state — used in batch mode for actions that don't apply to
   multi-file output. The cursor stays default (not banned) so the
   disabled look isn't aggressive. */
.file-more-action.is-disabled {
    cursor: default;
    opacity: 0.5;
}
.file-more-action.is-disabled:hover {
    background: none;
}
.file-more-action.is-disabled .file-more-action-desc {
    color: #c0c0c0;
}

.file-more-action-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-more-action-icon svg {
    color: #374151;
}

.file-more-action-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.file-more-action-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: #1f2937;
}

.file-more-action-desc {
    font-size: 0.75rem;
    color: #9ca3af;
}

.file-more-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 0 18px;
}

.file-more-cancel {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: white;
    color: #6b7280;
    font-size: 0.92rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.file-more-cancel:hover {
    background: #f9fafb;
    color: #374151;
}

/* Rename Modal */
.popup-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.15s ease;
}

.popup-modal-overlay.hidden {
    display: none !important;
}

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

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

.rename-modal-card {
    background: white;
    border-radius: 24px;
    padding: 24px;
    width: 320px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
    animation: modalSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.rename-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 16px;
}

.rename-modal-input-wrap {
    display: flex;
    align-items: center;
    background: #f5f6f8;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 16px;
    overflow: hidden;
}

.rename-modal-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    color: #1f2937;
    outline: none;
    min-width: 0;
}

.rename-modal-ext {
    padding: 12px 14px 12px 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: #9ca3af;
    flex-shrink: 0;
}

.rename-modal-actions {
    display: flex;
    gap: 8px;
}

.rename-modal-cancel {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: #f5f6f8;
    color: #6b7280;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.rename-modal-cancel:hover {
    background: #f9fafb;
    color: #374151;
}

.rename-modal-save {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: #1f2937;
    color: white;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.rename-modal-save:hover {
    background: #374151;
}


/* Responsive */
@media (max-width: 968px) {
    body.selection-active {
        overflow-y: auto;
    }

    /* Reset top:81px from the desktop fixed-position rule. When
       position flips to relative here, top:81 stays in effect and
       shifts the panel 81px DOWN from its natural document-flow
       position (creates a blank gap below the header). */
    .selection-panel {
        position: relative;
        top: auto;
        height: auto;
        min-height: calc(100vh - 81px);
    }

    .selection-content {
        flex-direction: column;
        height: auto;
    }

    .files-preview-section {
        margin-right: 0;
        height: auto;
        min-height: 300px;
    }

    .controls-panel {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 2px solid #e5e7eb;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.06);
    }

    .download-content {
        flex-direction: column;
    }

    .pdf-preview-section {
        margin-right: 0;
        height: auto;
        min-height: 300px;
    }

    .download-actions-section {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 1px solid #e5e7eb;
    }
}

@media (max-width: 768px) {
    .file-preview-large {
        padding: 32px;
    }

    .controls-panel {
        padding: 24px;
    }

    .download-actions-section {
        padding: 24px;
    }
}

/* Global Scrollbar Styling */
.controls-panel::-webkit-scrollbar,
.files-preview-section::-webkit-scrollbar,
.pdf-preview-section::-webkit-scrollbar,
.download-actions-section::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.controls-panel::-webkit-scrollbar-track,
.files-preview-section::-webkit-scrollbar-track,
.pdf-preview-section::-webkit-scrollbar-track,
.download-actions-section::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.controls-panel::-webkit-scrollbar-thumb,
.files-preview-section::-webkit-scrollbar-thumb,
.pdf-preview-section::-webkit-scrollbar-thumb,
.download-actions-section::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.controls-panel::-webkit-scrollbar-thumb:hover,
.files-preview-section::-webkit-scrollbar-thumb:hover,
.pdf-preview-section::-webkit-scrollbar-thumb:hover,
.download-actions-section::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ── Fullscreen drop zone (matches compress-pdf) ── */
.drop-zone-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.drop-zone-overlay.active { opacity: 1; pointer-events: all; }
.dz-bg {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    box-sizing: border-box;
}
.dz-bg::before {
    content: '';
    position: absolute;
    inset: 14px;
    border-radius: 16px;
    background-image:
        repeating-linear-gradient(0deg,   #1f2937 0, #1f2937 8px, transparent 8px, transparent 16px),
        repeating-linear-gradient(90deg,  #1f2937 0, #1f2937 8px, transparent 8px, transparent 16px),
        repeating-linear-gradient(180deg, #1f2937 0, #1f2937 8px, transparent 8px, transparent 16px),
        repeating-linear-gradient(270deg, #1f2937 0, #1f2937 8px, transparent 8px, transparent 16px);
    background-size: 2px 100%, 100% 2px, 2px 100%, 100% 2px;
    background-position: 0 0, 0 0, 100% 0, 0 100%;
    background-repeat: no-repeat;
    opacity: 0.14;
    animation: dzMarch 0.8s linear infinite;
}
@keyframes dzMarch {
    to { background-position: 0 16px, -16px 0, 100% -16px, 16px 100%; }
}
.dz-pill {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #1f2937;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 10px;
    transform: translateY(6px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
.dz-pill svg {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    stroke: rgba(255, 255, 255, 0.7);
    animation: dzPulse 1.8s ease-in-out infinite;
}
.drop-zone-overlay.active .dz-pill { transform: translateY(0); opacity: 1; }
@keyframes dzPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.1); }
}

/* Locked-PDF state — modifier on the shared error modal (mirrors compress-pdf).
   Swaps the icon to a grey lock + amber badge, demotes the Cancel button to a
   secondary outline, and reveals an "Unlock PDF" primary CTA via
   #rateLimitActions. */
.error-modal-overlay.locked-pdf .error-modal-icon > svg {
    stroke: #9ca3af;
}
.error-modal-icon-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #fff;
    border-radius: 8px;
    padding: 4px;
    box-sizing: content-box;
    width: 14px;
    height: 14px;
    color: #f59e0b;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}
.error-modal-icon {
    position: relative;
}
.error-modal-icon-badge svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    animation: none;
}
.rate-limit-actions {
    display: none;
    width: 100%;
    margin-bottom: 10px;
}
.rate-limit-actions.active { display: block; }
.upgrade-btn {
    display: inline-block;
    background: #1f2937;
    color: white;
    border: none;
    border-radius: 14px;
    padding: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    width: 100%;
    box-sizing: border-box;
}
.upgrade-btn:hover { background: #374151; }
.error-modal-overlay.locked-pdf .error-modal-btn {
    background: transparent;
    color: #6b7280;
    border: 2px solid #e5e7eb;
    box-shadow: none;
}
.error-modal-overlay.locked-pdf .error-modal-btn:hover {
    border-color: #ff6154;
    color: #ff6154;
    background: #fff5f4;
    box-shadow: none;
}

/* "Batch · convert up to N PDFs" hint under the upload button. */
.upload-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    margin-top: -16px;
    letter-spacing: 0.01em;
    min-height: 20px;
    opacity: 0;
}
.upload-hint-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f3f4f6;
    color: #374151;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 0.7rem;
}
.upload-hint-badge svg { flex-shrink: 0; color: #6b7280; }
.upload-hint:empty { visibility: hidden; }
.upload-hint:not(:empty) { animation: hintFadeIn 0.4s ease forwards; }
@keyframes hintFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Batch mode ── */
body.batch-mode .single-file-card,
body.batch-result-active .single-file-card { display: none !important; }

/* ── Batch deck — mirrors compress-pdf exactly ──
   .batch-deck-page divs sit directly inside .file-preview-thumbnail (no
   separate wrapper element); negative z-index pushes them BEHIND the canvas
   so the stack peeks out below + below-right of the live thumbnail. */
.file-preview-thumbnail.batch-deck {
    position: relative;
    overflow: visible;
    z-index: 1;
    margin-bottom: 24px;
}
.batch-deck-page {
    position: absolute;
    inset: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.batch-deck-page:nth-child(1) { z-index: -1; transform: translateY(5px)  scale(0.98); }
.batch-deck-page:nth-child(2) { z-index: -2; transform: translateY(10px) scale(0.96); border-color: #eaeaea; }
.batch-deck-page:nth-child(3) { z-index: -3; transform: translateY(15px) scale(0.94); border-color: #efefef; opacity: 0.85; }
.batch-deck-page:nth-child(4) { z-index: -4; transform: translateY(19px) scale(0.92); border-color: #f3f3f3; opacity: 0.6;  }
.batch-deck-page:nth-child(5) { z-index: -5; transform: translateY(22px) scale(0.90); border-color: #f5f5f5; opacity: 0.35; }

/* "and N other files" link — appears inside the file-name block. */
.batch-others-link {
    color: #ff6154;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s;
}
.batch-others-link:hover {
    color: #e5554a;
    text-decoration: underline;
}

/* ── Batch files modal — full queue list ── */
.batch-files-modal-card {
    background: #fff;
    border-radius: 24px;
    width: 480px;
    max-width: calc(100vw - 32px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 48px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.04);
    overflow: hidden;
    animation: graySlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes graySlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.batch-files-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #f3f4f6;
}
.batch-files-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111;
    letter-spacing: -0.01em;
}
.batch-files-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fafafa;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.batch-files-modal-close:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #111;
}
.batch-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.batch-modal-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #f0f0f0;
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
}
.batch-modal-row.is-failed { background: #fef2f2; border-color: #fecaca; }
.batch-modal-row-thumb {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #ececec;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #94a3b8;
}
.batch-modal-row-thumb canvas { max-width: 100%; max-height: 100%; }
.batch-modal-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.batch-modal-row-name {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.batch-modal-row-size {
    font-size: 11.5px;
    color: #94a3b8;
}
.batch-modal-row-remove {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.batch-modal-row-remove:hover { background: #fef2f2; color: #dc2626; }

/* ── Batch result list — mirrors compress-pdf exactly: vertical list of
   .file-preview-card rows, click-to-preview into the left .pdf-preview-section.
   Single-file (.single-file-card) is hidden in batch via the rule above; the
   container layout below applies to both modes since flex-column with one
   child collapses to the same shape as no flex. */
#download-files-list {
    margin-top: 50px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    padding-right: 8px;
}
#download-files-list::-webkit-scrollbar { width: 6px; }
#download-files-list::-webkit-scrollbar-track { background: #f3f4f6; border-radius: 10px; }
#download-files-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
#download-files-list::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.file-preview-card {
    background: none;
    border: none;
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.15s ease;
    cursor: pointer;
}
.file-preview-card:hover { background: #f5f5f5; }
.file-preview-card.active { background: #f0f1f3; }

.file-preview-thumb {
    width: 48px;
    height: 58px;
    background: #fff;
    border-radius: 4px;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
}
.file-preview-thumb canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.file-preview-card .file-preview-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}
.file-preview-card .file-preview-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    min-width: 0;
}
.file-preview-card .file-preview-name-base {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.file-preview-card .file-preview-name-ext {
    white-space: nowrap;
    flex-shrink: 0;
    color: #9ca3af;
    margin-left: auto;
}
.file-preview-card .file-preview-info {
    font-size: 0.7rem;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-download-btn,
.file-preview-card .file-more-btn {
    background: #f9f9f9;
    border: none;
    color: #9ca3af;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.file-download-btn:hover {
    background: #f3f4f6;
    color: #6b7280;
}
.file-preview-card .file-more-btn { padding: 6px; }
.file-preview-card .file-more-btn:hover { background: #f3f4f6; }

.batch-result-failed {
    font-size: 0.78rem;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    margin-top: 6px;
}

/* ── Wrong-format error modal ── */
.error-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.error-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.error-modal {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
    transform: scale(0.9);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.error-modal-overlay.active .error-modal { transform: scale(1); }
.error-modal-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.error-modal-icon svg {
    width: 40px;
    height: 40px;
    stroke: #f59e0b;
    animation: errorModalPulse 0.5s ease-out;
}
@keyframes errorModalPulse {
    0%   { transform: scale(0.8); opacity: 0; }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
.error-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
}
.error-modal-message {
    font-size: 0.88rem;
    color: #6b7280;
    line-height: 1.4;
    margin: 0 0 20px 0;
}
.error-modal-btn {
    background: #1f2937;
    color: white;
    border: none;
    border-radius: 14px;
    padding: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
}
.error-modal-btn:hover { background: #374151; }

/* ============================================================
   MOBILE & TABLET OVERRIDES — added 2026-05-07
   Same architecture as sign/redact (fixed sidebars desktop,
   stacked mobile). The existing ≤968 block already inverts the
   border/shadow for the bottom-positioned controls panel; this
   block adds the standard iOS-zoom + safe-area + modal-bounds
   fixes plus the merge-style ≤970 full-screen download recipe.
   ============================================================ */

/* ---- Tablet & phone (≤968px) — controls-panel layout adjustments ----
   Two desktop rules expect the panel to be a fixed-height column
   that fills the right sidebar:
     • .controls-options-wrapper { flex: 1; justify-content: center }
       grows + centers its content vertically.
     • .controls-panel > .control-section:last-child { margin-top: auto }
       pushes the Convert button to the bottom of the column.
   When the panel collapses below the preview on mobile, both rules
   conspire to leave a large gap between the option cards and the
   Convert button (the wrapper grows past its content; the auto
   margin still resolves to a non-zero value because flex column
   distributes the panel's available height). Reset both so the
   sections sit flush in natural document flow. */
@media (max-width: 968px) {
    /* Kill the entire flex-column distribution on mobile. Desktop
       expects: controls-panel (flex column, fills sidebar height)
       → wrapper (flex:1, justify-center) takes available space and
       vertical-centers the option cards → last .control-section
       has margin-top:auto pushing the Convert button to the bottom.
       On mobile we want sections to flow as plain blocks with no
       artificial gap between cards and button. Strip flex+height
       from every level. */
    .selection-content {
        overflow: visible !important;
    }
    .controls-panel {
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
    .controls-options-wrapper {
        display: block !important;
        flex: none !important;
        height: auto !important;
        min-height: 0 !important;
    }
    .controls-options-wrapper .control-section + .control-section {
        margin-top: 24px;
    }
    .controls-panel > .control-section:last-child {
        margin-top: 0 !important;
    }
    /* Direct margin-top on .btn-extract — sets the gap between the
       option cards above and the Convert button explicitly. */
    .btn-extract { margin-top: 16px !important; }

    /* Files-preview-section — also drop overflow-y:auto on mobile.
       Desktop has it as a scrollable left column inside a fixed
       sidebar layout; on mobile we want the section to flow normally
       in document flow, scrolling at the body level instead. */
    .files-preview-section {
        margin-right: 0 !important;
        overflow: visible !important;
        height: auto !important;
    }
}

/* ---- Phone (≤768px) ---- */
@media (max-width: 768px) {
    /* iOS auto-zoom prevention. .rename-modal-input is 0.92rem
       (~14.7px) — triggers Safari's input-focus zoom. */
    input, textarea, select { font-size: 16px; }
    .rename-modal-input { font-size: 16px !important; }

    /* Safe-area inset on bottom-anchored UI for iPhone home
       indicator. Apply button sits at the bottom of the controls
       panel when stacked below the preview. */
    .controls-panel {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    .file-more-sheet {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* Rename modal card has a hard 320px width — overflows on the
       smallest phones. Cap to viewport. */
    .rename-modal-card {
        width: calc(100% - 24px) !important;
        max-width: 360px;
        margin: 12px;
    }
}

/* ---- Tablet & narrow desktop — download view full-screen (≤970px) ----
   Mirrors the merge/sign/redact recipe: hide the PDF preview canvas
   (saves battery + memory on phone), hide the page hero (the JS
   doesn't hide it during the download view), full-bleed actions
   section with content capped to 480px and centered. */
@media (max-width: 970px) {
    .download-screen .pdf-preview-section { display: none !important; }

    /* Hero ("Grayscale PDF" + subtitle) sits above the download
       screen in the DOM; without this it remains visible during the
       success state and pushes the back button far down the page. */
    body.download-active .hero { display: none !important; }

    .download-screen { background: white !important; }
    .download-content {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 81px) !important;
        background: white;
    }
    .download-actions-section {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: calc(100vh - 81px) !important;
        padding: 32px 20px max(32px, env(safe-area-inset-bottom)) !important;
        border: none !important;
        box-shadow: none !important;
        background: white;
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        box-sizing: border-box;
    }

    .download-actions-section > * {
        width: 100%;
        max-width: 480px;
    }
    .download-primary,
    #download-files-list,
    .single-file-card,
    .extract-another-btn {
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Back button into normal flow at top of column, left-aligned
       with content. Desktop has it absolute at top:-10/left:40
       which overlaps content in the full-screen layout. */
    .back-button {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        margin: 0 auto 32px !important;
        width: 100%;
        max-width: 480px !important;
        justify-content: flex-start;
    }

    /* Vertical rhythm: back → 32 → file row → 40 → Download
       → 12 → Grayscale Another. Override desktop's 50px top
       margin on #download-files-list which assumed an absolute
       back-button. */
    #download-files-list {
        margin-top: 0 !important;
        margin-bottom: 40px !important;
    }
    .single-file-card { margin: 0 !important; }
    .download-primary { margin-bottom: 0 !important; }
    .extract-another-btn { margin-top: 12px !important; }
}
/* ── Enhance adjustment sliders ──
   Uses the site-standard .config-field-row + .range-slider pattern from the
   page-numbers tool (label · slider · value on a light pill row, Material-3
   range slider with coral two-tone track driven by --fill). */
.enh-sliders { display: flex; flex-direction: column; gap: 10px; }

/* Primary control (Whiten Background) — heavier weight via bolder label and a
   bit more size; set apart at the top. Same neutral card as the others. */
.enh-row-primary {
    padding: 13px 16px !important;
    gap: 12px !important;
}
.enh-row-primary .config-label {
    flex: 1 1 auto !important;
    font-size: 0.84rem; font-weight: 700; color: #1a1a1a;
}
.enh-row-primary .range-slider { flex: 0 0 130px !important; }

/* Quiet "Fine-tune" group label + grouped secondary rows. */
.enh-finetune-label {
    margin: 14px 0 2px; padding-left: 2px;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.07em;
    text-transform: uppercase; color: #9aa0a6;
}
.enh-finetune-group { display: flex; flex-direction: column; gap: 8px; }
.enh-finetune-group .config-field-row { background: #f8fafc; }
.enh-finetune-group .config-label { font-weight: 600; color: #5f6368; }

.config-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.config-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
}
.config-field.config-field-row {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 10px;
}
.config-field.config-field-row .config-label { flex: 0 0 72px; line-height: 1.25; }
.config-field.config-field-row .range-slider { flex: 1 1 auto; margin: 0; }
.config-field.config-field-row .config-label-value {
    flex: 0 0 auto;
    min-width: 36px;
    text-align: right;
    margin-left: 0;
}

/* Range slider — Material 3 style. --fill (0–100%) is set by JS on input. */
.range-slider {
    --fill: 75%;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;             /* hit-area; visible track is 6px */
    background: transparent;
    cursor: pointer;
    margin: 0;
    outline: none;
}
.range-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right,
        #ff6154 0%,
        #ff6154 var(--fill),
        #e7e0ec var(--fill),
        #e7e0ec 100%);
}
.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 4px;
    height: 24px;
    margin-top: -9px;
    border-radius: 999px;
    background: #ff6154;
    border: none;
    cursor: pointer;
    box-shadow: 0 0 0 0 rgba(255, 97, 84, 0);
    transition: box-shadow 0.18s ease, width 0.12s ease;
}
.range-slider:hover::-webkit-slider-thumb {
    box-shadow: 0 0 0 10px rgba(255, 97, 84, 0.10);
}
.range-slider:active::-webkit-slider-thumb,
.range-slider:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 12px rgba(255, 97, 84, 0.16);
    width: 6px;
}
.range-slider::-moz-range-track {
    height: 6px; border-radius: 999px; background: #e7e0ec;
}
.range-slider::-moz-range-progress {
    height: 6px; border-radius: 999px; background: #ff6154;
}
.range-slider::-moz-range-thumb {
    width: 4px; height: 24px; border-radius: 999px;
    background: #ff6154; border: none; cursor: pointer;
    box-shadow: 0 0 0 0 rgba(255, 97, 84, 0);
    transition: box-shadow 0.18s ease;
}
.range-slider:hover::-moz-range-thumb {
    box-shadow: 0 0 0 10px rgba(255, 97, 84, 0.10);
}
.range-slider:active::-moz-range-thumb,
.range-slider:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 12px rgba(255, 97, 84, 0.16);
}
.config-label-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: #ff6154;
    font-variant-numeric: tabular-nums;
}
/* Section header: title left, Reset button right. */
.enh-section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.enh-section-head .control-section-title { margin: 0; }
.enh-reset-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px; border-radius: 8px;
    background: #f4f5f7; border: 1px solid #e5e7eb;
    font-size: 12px; font-weight: 600; color: #5f6368; cursor: pointer;
    transition: all 0.15s ease;
}
.enh-reset-btn:hover {
    background: #fff; border-color: #ff6154; color: #ff6154;
    box-shadow: 0 2px 8px rgba(255, 97, 84, 0.15);
}
.enh-reset-btn:active { transform: scale(0.97); }



/* ════════════════════════════════════════════════════════════════════
   Enhance — before/after compare
   (the .files-preview-section layout lives at the top of this file; this
   block only styles the compare component + meta row inside it)

   Robust stacking: both canvases are 100% width at the same spot so they
   align by construction. The BEFORE canvas is clipped with clip-path,
   driven by the --pos custom property on .enh-compare.
   ════════════════════════════════════════════════════════════════════ */
.enh-compare {
    position: relative;
    /* Size to the page: the AFTER canvas inside is constrained by both a max
       width and a max height, so portrait document pages grow tall to fill the
       left panel (instead of floating as a small card) without overflowing. */
    display: inline-flex;
    margin: 0 auto;
    border-radius: 18px; overflow: hidden;
    background: #fff;
    box-shadow: 0 18px 50px rgba(16,24,40,0.16), 0 2px 6px rgba(16,24,40,0.08);
    user-select: none; touch-action: none; cursor: ew-resize;
    --pos: 50%;
}

/* The AFTER (enhanced) canvas sizes the box. width:auto + a height cap means a
   tall portrait page fills the panel height; the width cap handles wide pages. */
.enh-canvas-after {
    position: relative; display: block;
    width: auto; height: auto;
    max-width: min(540px, 100%);
    max-height: calc(100vh - 260px);
    z-index: 1;
}
/* The BEFORE (original) canvas OVERLAYS exactly on top, clipped to the
   left of the divider position. Same width => perfect alignment. */
.enh-canvas-before {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; display: block; z-index: 2;
    clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}

/* corner tags */
.enh-tag {
    position: absolute; top: 14px; z-index: 4;
    font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
    text-transform: uppercase; color: #fff;
    background: rgba(17,17,17,0.55); padding: 5px 11px; border-radius: 20px;
    pointer-events: none; backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.enh-tag-before { left: 14px; }
.enh-tag-after  { right: 14px; }

/* The draggable divider sits at left:var(--pos). It's a zero-width vertical
   rail; the line and the circular grip are absolutely centered on it so the
   grip can never be stretched into an oval by flex sizing. */
.enh-handle {
    position: absolute; top: 0; bottom: 0; left: var(--pos);
    width: 0; z-index: 5; cursor: ew-resize;
}
.enh-handle-line {
    position: absolute; top: 0; bottom: 0; left: 0;
    width: 2px; margin-left: -1px;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 0 6px rgba(0,0,0,0.22), 0 0 0 1px rgba(0,0,0,0.06);
}
.enh-handle-grip {
    /* slim vertical pill, centered on the rail, immune to parent layout */
    position: absolute; top: 50%; left: 0;
    width: 26px; height: 40px;
    margin: -20px 0 0 -13px;           /* center exactly on the rail */
    border-radius: 13px; box-sizing: border-box;
    background: #ffffff;
    display: grid; place-items: center;
    box-shadow: 0 4px 12px rgba(16,24,40,0.24), 0 0 0 1px rgba(16,24,40,0.06),
                inset 0 0 0 1px rgba(255,255,255,0.9);
    transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.enh-compare:hover .enh-handle-grip {
    transform: scale(1.06);
    box-shadow: 0 6px 16px rgba(16,24,40,0.28), 0 0 0 1px rgba(255,97,84,0.30);
}
.enh-handle-grip:active { transform: scale(0.96); }

/* 2-column × 3-row dot grid (the drag-grip dots) */
.enh-grip-dots {
    display: grid;
    grid-template-columns: repeat(2, 3px);
    grid-template-rows: repeat(3, 3px);
    gap: 4px;
}
.enh-grip-dots i {
    width: 3px; height: 3px; border-radius: 50%;
    background: #c2c7cf; transition: background 0.14s ease;
}
.enh-compare:hover .enh-grip-dots i { background: #ff6154; }

/* meta row under the image */
.enh-preview-meta {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; text-align: center;
}
.enh-preview-name { font-size: 14px; font-weight: 600; color: #1a1a1a; word-break: break-word; max-width: 480px; }
.enh-preview-size { font-size: 12.5px; color: #80868b; }
.enh-remove-btn {
    margin-top: 10px; background: rgba(255,255,255,0.7); border: 1px solid #e2e5ea;
    padding: 8px 18px; border-radius: 9px;
    font-size: 12.5px; font-weight: 600; color: #5f6368; cursor: pointer;
    transition: all 0.15s ease;
}
.enh-remove-btn:hover { background: #fff; border-color: #ff6154; color: #ff6154; box-shadow: 0 2px 8px rgba(255,97,84,0.18); }
