.hidden {
    display: none !important;
}

svg {
    fill: none;
}

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

body {
    overflow-x: hidden;
}

body.download-active {
    height: calc(100vh - 81px);
    overflow-y: visible;
}

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;
}

/* Progress mode: bar fills left-to-right based on width, no animation */
.loading-bar-container.progress-mode .loading-bar {
    animation: none;
    width: 0%;
    transition: width 0.2s ease;
}

.container {
    background-color: transparent;
    box-sizing: border-box;
    padding: 20px;
    border-radius: 16px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto 10px auto;
    overflow: visible;
}

/* Upload Area */
.upload-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 12px;
    flex-wrap: wrap;
}

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

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

.file-input-label.drag-over {
    background-color: #e5554a;
    transform: scale(1.05);
}

.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;
}

input[type="file"] {
    display: none;
}

/* 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 - Crop Preview */
.files-preview-section {
    flex: 1;
    background-color: #f5f6f8;
    background-image: radial-gradient(circle, #e0e2e6 1px, transparent 1px);
    background-size: 20px 20px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    overflow-y: auto;
    margin-right: 420px;
    box-sizing: border-box;
    position: relative;
}

.files-preview-section.full-preview-mode {
    justify-content: flex-start;
    padding-top: 56px;
}

/* Preview Mode Toggle */
.preview-mode-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 6px 12px;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    z-index: 10;
}

.preview-mode-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.toggle-switch.active {
    background: #ff6154;
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(20px);
}

/* Full Preview Mode */
.preview-full-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
}

.preview-full-container .preview-page-outer {
    position: relative;
}

.preview-full-container .preview-page-wrapper {
    background: white;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    overflow: clip;
    position: relative;
}

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

.preview-full-container .preview-page-outer > .page-number-badge {
    position: absolute;
    top: 14px;
    right: -28px;
    left: auto;
    background: #1f2937;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    z-index: 5;
}

/* Full preview crop overlay */
.crop-overlay-full {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    pointer-events: none;
}

.crop-box-full {
    position: absolute;
    border: 2px solid rgba(255, 97, 84, 0.9);
    background: transparent;
    cursor: move;
    pointer-events: auto;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
    transition: none;
}

/* Rule-of-thirds grid inside crop box */
.crop-box-full::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(to right, rgba(255,255,255,0.15) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.15) 1px, transparent 1px);
    background-size: 33.333% 33.333%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.crop-box-full.dragging::before,
.crop-box-full:hover::before {
    opacity: 1;
}

/* Full preview handles - matching compact mode */
.crop-handle-full {
    position: absolute;
    z-index: 10;
    pointer-events: auto;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.crop-handle-full:hover {
    transform: scale(1.2);
}

/* Corner handles */
.crop-handle-full.top-left,
.crop-handle-full.top-right,
.crop-handle-full.bottom-left,
.crop-handle-full.bottom-right {
    width: 16px;
    height: 16px;
    background: white;
    border: 2.5px solid #ff6154;
    border-radius: 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.crop-handle-full.top-left { top: -8px; left: -8px; cursor: nw-resize; }
.crop-handle-full.top-right { top: -8px; right: -8px; cursor: ne-resize; }
.crop-handle-full.bottom-left { bottom: -8px; left: -8px; cursor: sw-resize; }
.crop-handle-full.bottom-right { bottom: -8px; right: -8px; cursor: se-resize; }

.crop-handle-full.top-left:hover,
.crop-handle-full.top-right:hover,
.crop-handle-full.bottom-left:hover,
.crop-handle-full.bottom-right:hover {
    box-shadow: 0 2px 8px rgba(255, 97, 84, 0.4);
    transform: scale(1.15);
}

/* Edge handles - pill shaped */
.crop-handle-full.top,
.crop-handle-full.bottom {
    width: 32px;
    height: 6px;
    background: white;
    border: 2px solid #ff6154;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.crop-handle-full.left,
.crop-handle-full.right {
    width: 6px;
    height: 32px;
    background: white;
    border: 2px solid #ff6154;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.crop-handle-full.top { top: -4px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle-full.bottom { bottom: -4px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle-full.left { top: 50%; left: -4px; transform: translateY(-50%); cursor: w-resize; }
.crop-handle-full.right { top: 50%; right: -4px; transform: translateY(-50%); cursor: e-resize; }

.crop-handle-full.top:hover { transform: translateX(-50%) scaleY(1.4); }
.crop-handle-full.bottom:hover { transform: translateX(-50%) scaleY(1.4); }
.crop-handle-full.left:hover { transform: translateY(-50%) scaleX(1.4); }
.crop-handle-full.right:hover { transform: translateY(-50%) scaleX(1.4); }

.crop-preview-area {
    max-width: 600px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.crop-canvas-wrapper {
    position: relative;
    display: inline-block;
    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: clip;
    line-height: 0;
    max-width: 100%;
}

.crop-canvas-wrapper canvas {
    display: block;
}

/* Auto-crop scan overlay */
.autocrop-scan-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border-radius: 8px;
    overflow: hidden;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-favicon {
    width: 36px; height: 36px;
    object-fit: contain;
    animation: scanPulse 1.4s ease-in-out infinite;
}

@keyframes scanPulse {
    0%, 100% {
        filter: grayscale(100%);
        opacity: 0.4;
        transform: scale(0.95);
    }
    50% {
        filter: grayscale(0%);
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.crop-box {
    position: absolute;
    border: 2px solid rgba(255, 97, 84, 0.9);
    background: transparent;
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
    transition: none;
}

/* Rule-of-thirds grid inside crop box */
.crop-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(to right, rgba(255,255,255,0.15) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.15) 1px, transparent 1px);
    background-size: 33.333% 33.333%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.crop-box.dragging::before,
.crop-box:hover::before {
    opacity: 1;
}

/* Corner handles - larger, square with rounded corners */
.crop-handle {
    position: absolute;
    z-index: 10;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.crop-handle:hover {
    transform: scale(1.2);
}

/* Corner handles */
.crop-handle.top-left,
.crop-handle.top-right,
.crop-handle.bottom-left,
.crop-handle.bottom-right {
    width: 16px;
    height: 16px;
    background: white;
    border: 2.5px solid #ff6154;
    border-radius: 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.crop-handle.top-left { top: -8px; left: -8px; cursor: nw-resize; }
.crop-handle.top-right { top: -8px; right: -8px; cursor: ne-resize; }
.crop-handle.bottom-left { bottom: -8px; left: -8px; cursor: sw-resize; }
.crop-handle.bottom-right { bottom: -8px; right: -8px; cursor: se-resize; }

.crop-handle.top-left:hover,
.crop-handle.top-right:hover,
.crop-handle.bottom-left:hover,
.crop-handle.bottom-right:hover {
    box-shadow: 0 2px 8px rgba(255, 97, 84, 0.4);
    transform: scale(1.15);
}

/* Edge handles - pill shaped */
.crop-handle.top,
.crop-handle.bottom {
    width: 32px;
    height: 6px;
    background: white;
    border: 2px solid #ff6154;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.crop-handle.left,
.crop-handle.right {
    width: 6px;
    height: 32px;
    background: white;
    border: 2px solid #ff6154;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.crop-handle.top { top: -4px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle.bottom { bottom: -4px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle.left { top: 50%; left: -4px; transform: translateY(-50%); cursor: w-resize; }
.crop-handle.right { top: 50%; right: -4px; transform: translateY(-50%); cursor: e-resize; }

.crop-handle.top:hover { transform: translateX(-50%) scaleY(1.4); }
.crop-handle.bottom:hover { transform: translateX(-50%) scaleY(1.4); }
.crop-handle.left:hover { transform: translateY(-50%) scaleX(1.4); }
.crop-handle.right:hover { transform: translateY(-50%) scaleX(1.4); }

.crop-dimensions {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Page Navigation */
.page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 6px 8px;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.page-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}

.page-nav-btn:hover:not(:disabled) {
    background: #f3f4f6;
    color: #ff6154;
}

.page-nav-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.page-nav-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.page-info {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Right side - Controls Panel (Fixed Overlay) */
.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;
}

.control-section {
    margin-bottom: 24px;
}

.control-section:last-child {
    margin-top: auto;
    margin-bottom: 0;
    padding-bottom: 45px;
}

.control-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px 0;
}

/* Visual Margin Diagram */
.margin-visual {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.margin-visual-page {
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 14px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.margin-visual-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.margin-visual-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    background: white;
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
}

.margin-visual-content {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
}

.margin-visual-content svg {
    stroke: #d1d5db;
}

.margin-visual-input {
    display: flex;
    align-items: center;
    justify-content: center;
}

.margin-visual-input.top-input,
.margin-visual-input.bottom-input {
    width: 80px;
}

.margin-visual-input.left-input,
.margin-visual-input.right-input {
    width: 64px;
    flex-shrink: 0;
}

.margin-input {
    width: 100%;
    padding: 7px 6px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1f2937;
    background: white;
    transition: all 0.2s ease;
    box-sizing: border-box;
    text-align: center;
    -moz-appearance: textfield;
}

.margin-input::-webkit-inner-spin-button,
.margin-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.margin-input:focus {
    outline: none;
    border-color: #ff6154;
    box-shadow: 0 0 0 3px rgba(255, 97, 84, 0.1);
}

.margin-unit-label {
    font-size: 0.65rem;
    color: #b0b5bc;
    text-align: center;
    font-weight: 500;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    width: 100%;
}

.quick-action-btn:hover {
    border-color: #ff6154;
    background: #fff5f4;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.12);
}

.quick-action-btn:active {
    transform: translateY(0);
}

.quick-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.quick-action-icon svg {
    width: 26px;
    height: 26px;
    stroke: #ff6154;
}

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

.quick-action-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1f2937;
}

.quick-action-desc {
    font-size: 0.72rem;
    color: #9ca3af;
    font-weight: 500;
}

.preset-row {
    display: flex;
    gap: 6px;
}

.preset-btn {
    flex: 1;
    padding: 9px 10px;
    background: white;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

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

.preset-btn:active {
    transform: scale(0.97);
}

.preset-btn.reset {
    color: #9ca3af;
}

.preset-btn.reset svg {
    stroke: #9ca3af;
}

.preset-btn.reset:hover {
    color: #6b7280;
    border-color: #d1d5db;
    background: #f3f4f6;
}

.preset-btn.reset:hover svg {
    stroke: #6b7280;
}

/* Apply Toggle (segmented control) */
.apply-toggle {
    display: flex;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.apply-toggle-btn {
    flex: 1;
    padding: 8px 6px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.apply-toggle-btn:hover:not(.active) {
    color: #374151;
    background: rgba(255,255,255,0.5);
}

.apply-toggle-btn.active {
    background: white;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.custom-range-wrapper {
    margin-top: 8px;
}

.page-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    background: #f8f9fa;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.page-input::placeholder {
    color: #9ca3af;
    font-weight: 500;
}

.page-input:focus {
    outline: none;
    border-color: #ff6154;
    box-shadow: 0 0 0 3px rgba(255, 97, 84, 0.1);
    background: white;
}

/* 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: 14px;
    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;
}

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

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

.btn-extract:hover:not(:disabled) .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;
}

.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 .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: #f8f9fa;
}

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

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

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

.pdf-preview-section::-webkit-scrollbar {
    width: 6px;
}

.pdf-preview-section::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 10px;
}

.pdf-preview-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.pdf-preview-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.preview-canvas-container {
    width: 100%;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    margin-bottom: 20px;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.preview-page-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    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;
}

.download-actions-section {
    position: fixed;
    right: 0;
    top: 81px;
    width: 420px;
    height: calc(100vh - 81px);
    background: white;
    border-left: 2px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 40px;
    overflow-y: auto;
    box-sizing: border-box;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
}

.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;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    padding-right: 8px;
}

.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 {
    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;
}

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

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

.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;
}

.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: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.download-primary:hover {
    background: #e5554a;
    box-shadow: 0 6px 16px rgba(255, 97, 84, 0.4);
    transform: translateY(-2px);
}

.download-primary svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
}

/* 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 Action Sheet */
.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;
}

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

.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;
}

.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;
}

.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;
}

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

/* Hide elements when showing download screen */
.content-hidden {
    display: none !important;
}

.controls-panel::-webkit-scrollbar,
.files-preview-section::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-track,
.files-preview-section::-webkit-scrollbar-track {
    background: #f3f4f6;
}

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

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

@media (max-width: 1200px) {
    .controls-panel {
        width: 380px;
    }

    .files-preview-section {
        margin-right: 380px;
    }

    .download-actions-section {
        width: 380px;
    }

    .pdf-preview-section {
        margin-right: 380px;
    }
}

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

    .selection-panel {
        position: relative;
        height: auto;
        min-height: calc(100vh - 81px);
    }

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

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

    .files-preview-section {
        margin-right: 0;
        height: auto;
        order: 1;
        padding: 32px 24px;
        overflow-y: visible;
    }

    .download-screen {
        position: relative;
        height: auto;
        min-height: calc(100vh - 81px);
    }

    .download-content {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 81px);
    }

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

    .pdf-preview-section {
        margin-right: 0;
        padding: 100px 20px 20px 20px;
        height: auto;
        min-height: 50vh;
    }

    .back-button {
        top: 20px;
        left: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .files-preview-section {
        padding: 24px 16px 40px 16px;
        min-height: auto;
    }

    .controls-panel {
        padding: 24px 16px;
    }

    .pdf-preview-section {
        padding: 80px 16px 24px 16px;
    }

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

    .back-button {
        font-size: 0.9rem;
    }

    #download-files-list {
        max-height: none;
    }

    .margin-inputs {
        grid-template-columns: 1fr 1fr;
    }
}
