.hidden {
    display: none !important;
}

svg {
    fill: none;
}

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;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-screen.active {
    opacity: 1;
    pointer-events: all;
}

.loading-bar-container {
    width: 300px;
    height: 4px;
    background: #e0e0e0;
    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: 15px;
    color: #666;
    font-weight: 500;
}

.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);
}

#upload-label.drag-over {
    background-color: #e5554a;
    transform: scale(1.05);
}

#upload-label {
    outline: none;
}

.upload-content {
    text-align: center;
}

.upload-icon {
    display: none;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

input[type="file"] {
    display: none;
}

/* Progress Bar */
#progress-container {
    margin-top: 1.5rem;
    width: 100%;
    max-width: 510px;
    margin-left: auto;
    margin-right: auto;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background-color: transparent;
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid #e5e7eb;
}

#progress-bar {
    width: 0;
    height: 100%;
    background-color: #ff6154;
    transition: width 0.3s ease;
}

#progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 0.875rem;
    color: #6b7280;
}

/* 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);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.selection-panel.active {
    opacity: 1;
    visibility: visible;
}

.selection-content {
    display: flex;
    gap: 0;
    align-items: stretch;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Left side - Pages Preview */
.pages-preview-section {
    flex: 1;
    background: none;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    overflow-y: auto;
    margin-right: 450px;
    box-sizing: border-box;
}

.pages-header {
    margin-bottom: 32px;
    max-width: 700px;
    width: 100%;
    text-align: left;
}

.pages-header h2 {
    margin: 0 0 8px 0;
    font-size: 1.75rem;
    color: #1f2937;
    font-weight: 700;
}

.selection-subtitle {
    margin: 0;
    font-size: 1rem;
    color: #6b7280;
    font-weight: 400;
}

/* Preview Panel */
.preview-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    max-width: 700px;
    width: 100%;
    margin-bottom: 40px;
}

/* Custom scrollbar for preview panel */
.preview-panel::-webkit-scrollbar {
    display: none;
}

.page-thumbnail-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.page-thumbnail {
    position: relative;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.10);
    border: none;
}

.page-thumbnail:hover {
    box-shadow: 0 12px 12px rgba(0, 0, 0, 0.18);
    transform: translateY(-4px);
}

.page-thumbnail.selected {
    box-shadow: 0 0 0 3px #ff6154, 0 8px 12px rgba(255, 97, 84, 0.4);
    transform: translateY(-4px);
}

.page-thumbnail canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    border-radius: 4px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid #d1d5db;
    background: white;
    transition: all 0.2s ease;
}

.page-checkbox:checked {
    background: #ff6154;
    border-color: #ff6154;
}

.page-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.thumbnail-label {
    text-align: center;
    font-size: 0.9rem;
    color: #374151;
    font-weight: 600;
}

.page-thumbnail.selected + .thumbnail-label {
    color: #ff6154;
}

/* Right side - Controls Panel (Fixed Overlay) */
.controls-panel {
    position: fixed;
    right: 0;
    top: 81px;
    width: 450px;
    box-sizing: border-box;
    padding: 40px;
    padding-top: 20px;
    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;
}

.controls-sticky {
    padding: 40px 32px;
}

.page-count-badge {
    background: none;
    color: #000;
    padding: 0;
    margin-top: 10px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    justify-content: left;
}

.page-count-badge svg {
    width: 20px;
    height: 20px;
    stroke: #ff6154;
}

/* Control Sections */
.control-section {
    margin-bottom: 24px;
}

.control-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 12px 0;
}

.control-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-control-full {
    width: 100%;
    background: #f7f8f9;
    color: #374151;
    border: 2px solid #e5e7eb;
    padding: 12px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-control-full:hover {
    background: #fff5f4;
    border-color: #ff6154;
    color: #ff6154;
}

.btn-control-full svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* Range Selection */
.range-selector-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.range-inputs-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.range-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.range-input-group label {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 600;
}

.range-input-full {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
    background: white;
}

.range-input-full:focus {
    outline: none;
    border-color: #ff6154;
}

.btn-apply {
    background: #ff6154;
    color: white;
    border-color: #ff6154;
}

.btn-apply:hover {
    background: #e5554a;
    border-color: #e5554a;
    color: white;
}

/* Controls Divider */
.controls-divider {
    height: 2px;
    background: linear-gradient(to right, #e5e7eb 0%, #e5e7eb 50%, transparent 50%);
    background-size: 8px 2px;
    margin: 24px 0;
}

/* Extract Actions Vertical */
.extract-actions-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-extract {
    width: 100%;
    padding: 16px 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;
}

.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.separate {
    background-color: transparent;
    color: #374151;
    border: 2px solid #e5e7eb;
}

.btn-extract.separate:hover:not(:disabled) {
    background: #fff5f4;
    border-color: #ff6154;
    color: #ff6154;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.15);
    transform: translateY(-2px);
}

.btn-extract:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-extract svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    flex-shrink: 0;
}

.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-extract.separate .btn-extract-desc {
    color: #6b7280;
}

.btn-extract.separate:hover:not(:disabled) .btn-extract-desc {
    color: #ff6154;
}

/* Loading State */
.loading-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    color: #6b7280;
    grid-column: 1 / -1;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #ff6154;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-preview p {
    font-size: 1rem;
    font-weight: 500;
}

/* Download Screen Styles */
.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);
}

/* Left side - PDF Preview (scrollable) */
.pdf-preview-section {
    flex: 1;
    background: #f8f9fa;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    margin-right: 450px;
    height: calc(100vh - 81px);
    box-sizing: border-box;
}

.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;
    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;
    z-index: 10;
}

.preview-controls {
    display: none;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .preview-canvas-container {
        gap: 0;
    }
    
    .preview-page-wrapper {
        display: none;
    }
    
    .preview-page-wrapper.active {
        display: block;
    }
    
    .page-number-badge {
        display: none;
    }
    
    .preview-controls {
        display: flex;
    }
}

.preview-controls button {
    padding: 10px 18px;
    font-size: 0.9rem;
    background: white;
    border: 2px solid #e5e7eb;
    color: #374151;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    cursor: pointer;
}

.preview-controls button svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.preview-controls button:hover:not(:disabled) {
    border-color: #ff6154;
    background: #fff5f4;
    color: #ff6154;
}

.preview-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.preview-page-info {
    color: #374151;
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* Right side - Actions (Fixed Panel) */
.download-actions-section {
    position: fixed;
    right: 0;
    top: 81px;
    width: 450px;
    height: calc(100vh - 81px);
    background: white;
    border-left: 2px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 40px 32px;
    overflow-y: auto;
    box-sizing: border-box;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
}

.back-button {
    background: transparent;
    color: #6b7280;
    border: none;
    padding: 12px 20px;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-weight: 500;
    position: absolute;
    margin-top: -10px;
    left: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: none;
    color: #ff6154;
    box-shadow: none;
    transform: translateX(-2px);
    border-radius: 8px;
}

.back-button svg {
    width: 18px;
    height: 18px;
}

/* Files Preview List */
#files-preview-list {
    margin-top: 50px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    padding-right: 8px;
}

#files-preview-list::-webkit-scrollbar {
    width: 6px;
}

#files-preview-list::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 10px;
}

#files-preview-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

#files-preview-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Single File Card (for merged/single PDF) */
.single-file-card {
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.single-file-icon {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.single-file-icon svg {
    width: 28px;
    height: 28px;
    stroke: #ff6154;
    fill: none;
}

.single-file-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.single-file-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.single-file-info {
    font-size: 0.875rem;
    color: #6b7280;
}

.done-button {
    background: #10b981;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.done-button svg {
    width: 16px;
    height: 16px;
    stroke: white;
    fill: none;
}

/* Multiple Files Card */
.file-preview-card {
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.file-preview-card:hover {
    border-color: #ff6154;
    background: #fff5f4;
}

.file-preview-card.active {
    border-color: #ff6154;
    background: #fff5f4;
}

.file-preview-icon {
    width: 42px;
    height: 42px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.file-preview-icon svg {
    width: 24px;
    height: 24px;
    stroke: #ff6154;
}

.file-preview-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.file-preview-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-info {
    font-size: 0.8rem;
    color: #6b7280;
}

.file-download-btn {
    background: transparent;
    border: 2px solid #e5e7eb;
    color: #6b7280;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.file-download-btn:hover {
    border-color: #ff6154;
    color: #ff6154;
    background: white;
}

.file-download-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* Download Button with Dropdown */
.download-button-wrapper {
    position: relative;
    margin-bottom: 16px;
}

/* Download button container */
.download-button-group {
    display: flex;
    gap: 0;
}

/* Primary download button */
.download-primary {
    flex: 1;
    padding: 16px 32px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #ff6154;
    color: white;
    border: none;
    border-radius: 12px 0 0 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.download-primary:hover {
    background: #e5554a;
}

.download-primary svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
}

/* Dropdown trigger button */
.download-dropdown-btn {
    padding: 16px 20px;
    background-color: #ff6154;
    color: white;
    border: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.download-dropdown-btn.visible {
    display: flex;
}

.download-dropdown-btn:hover {
    background: #e5554a;
}

.download-dropdown-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
    fill: none;
}

/* Dropdown menu */
.download-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    min-width: 240px;
    margin-top: 8px;
    overflow: hidden;
}

.download-dropdown-menu.active {
    display: block;
}

.download-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: #374151;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-weight: 500;
    border-bottom: 1px solid #f3f4f6;
}

.download-dropdown-item:last-child {
    border-bottom: none;
}

.download-dropdown-item:hover {
    background: #f8f9fa;
}

.download-dropdown-item svg {
    width: 20px;
    height: 20px;
    stroke: #6b7280;
    fill: none;
    flex-shrink: 0;
}

.download-dropdown-item:hover svg {
    stroke: #ff6154;
}

.download-dropdown-item-text {
    flex: 1;
    color: #374151;
    font-weight: 500;
}

.download-dropdown-item:hover .download-dropdown-item-text {
    color: #ff6154;
}

.download-dropdown-item-size {
    font-size: 0.8rem;
    color: #9ca3af;
    font-weight: 400;
}

/* Action buttons */
.action-buttons-grid {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    margin-top: -6px;
    margin-bottom: 10px;
}

.action-button {
    background: #f7f8f9;
    border: none;
    color: #374151;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
}

#share-action {
    flex: 2;
}

#print-action,
#delete-action {
    flex: 1;
}

.action-button:hover {
    border-color: #ff6154;
    background: #fff5f4;
}

.action-button svg {
    width: 24px;
    height: 24px;
    stroke: #6b7280;
}

.action-button:hover svg {
    stroke: #ff6154;
}

/* Merge Another Button */
.merge-another {
    background: transparent;
    color: #ff6154;
    border: 2px solid #ff6154;
    width: 100%;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.merge-another:hover {
    background: #fff5f4;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.2);
}

/* Hide elements when showing download screen */
.content-hidden {
    display: none !important;
}

/* Custom scrollbar for controls panel */
.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.controls-panel::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Custom scrollbar for pages preview section */
.pages-preview-section::-webkit-scrollbar {
    width: 6px;
}

.pages-preview-section::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.pages-preview-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.pages-preview-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Custom scrollbar for PDF preview section (download screen) */
.pdf-preview-section::-webkit-scrollbar {
    width: 6px;
}

.pdf-preview-section::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.pdf-preview-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.pdf-preview-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Custom scrollbar for download actions section */
.download-actions-section::-webkit-scrollbar {
    width: 6px;
}

.download-actions-section::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.download-actions-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.download-actions-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .controls-panel {
        width: 380px;
    }
    
    .pages-preview-section {
        margin-right: 380px;
    }
    
    .download-actions-section {
        width: 380px;
    }
    
    .pdf-preview-section {
        margin-right: 380px;
    }
    
    .preview-panel {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
    }
}

@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);
    }
    
    .controls-sticky {
        padding: 32px 24px;
    }
    
    .pages-preview-section {
        margin-right: 0;
        height: auto;
        order: 2;
        padding: 32px 24px;
        overflow-y: visible;
    }
    
    .controls-panel {
        order: 2;
    }
    
    .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;
    }
    
    .pages-preview-section {
        padding: 24px 16px 40px 16px;
        min-height: auto;
    }
    
    .pages-header {
        margin-bottom: 24px;
    }
    
    .pages-header h2 {
        font-size: 1.5rem;
    }
    
    .selection-subtitle {
        font-size: 0.9rem;
    }
    
    .controls-sticky {
        padding: 24px 16px;
    }
    
    .preview-panel {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 16px;
        margin-bottom: 24px;
    }
    
    .pdf-preview-section {
        padding: 80px 16px 24px 16px;
    }
    
    .download-actions-section {
        padding: 24px 16px;
    }
    
    .back-button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    #files-preview-list {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .preview-panel {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .page-count-badge {
        font-size: 0.9rem;
        padding: 12px 16px;
    }
    
    .control-section-title {
        font-size: 0.95rem;
    }
    
    .btn-control-full {
        font-size: 0.9rem;
        padding: 11px 16px;
    }
    
    .btn-extract {
        padding: 14px 16px;
    }
    
    .btn-extract-title {
        font-size: 0.95rem;
    }
    
    .btn-extract-desc {
        font-size: 0.75rem;
    }
}