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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 100%);
}

/* ============================================
   UPLOAD PAGE STYLES
   ============================================ */

.upload-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

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

.upload-container {
    background: white;
    padding: 28px;
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    width: 100%;
    max-width: 540px;
}

.upload-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.upload-header h1 {
    font-size: 26px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.upload-header h1 .header-icon {
    height: 28px;
    width: auto;
    border-radius: 6px;
    flex-shrink: 0;
}

.upload-header h1 span {
    background: linear-gradient(135deg, #27AE60 0%, #229954 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.upload-dropzones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.file-input-group {
    position: relative;
}

.file-input-group input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-input-group label {
    display: block;
    cursor: pointer;
}

.file-drop-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    padding: 20px;
    background: linear-gradient(135deg, #e8f8f0 0%, #d5f4e6 100%);
    border: 2px dashed #d1d5db;
    border-radius: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.file-drop-area.has-file {
    background: #e8f8f0;
    border-color: #27AE60;
    border-style: solid;
}

.file-drop-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #27AE6015 0%, #22995415 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.file-drop-area:hover, .file-drop-area.drag-over {
    border-color: #27AE60;
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(39, 174, 96, 0.18);
}

.file-drop-area:hover::before, .file-drop-area.drag-over::before {
    opacity: 1;
}

.file-drop-area:active {
    transform: translateY(0);
}

.upload-icon {
    color: #9ca3af;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    width: 36px;
    height: 36px;
}

.file-drop-area:hover .upload-icon {
    color: #27AE60;
    transform: scale(1.15);
}

.file-label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    font-size: 14px;
}

.file-name {
    display: block;
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
    line-height: 1.4;
    word-break: break-word;
    max-width: 100%;
}

.file-drop-area.has-file .file-name {
    color: #27AE60;
    font-weight: 600;
    font-size: 22px;
}

.file-size-info {
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 16px;
}

.upload-page .settings-section {
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
}

.upload-page .settings-section summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    cursor: pointer;
    outline: none;
    font-weight: 600;
    color: #4b5563;
    list-style: none;
}

.upload-page .settings-section summary::-webkit-details-marker {
    display: none;
}

.chevron-icon {
    transition: transform 0.3s ease;
    color: #9ca3af;
}

.upload-page .settings-section[open] summary .chevron-icon {
    transform: rotate(90deg);
}

.upload-page .settings-section[open] summary {
    border-bottom: 1px solid #e5e7eb;
}

.upload-page .settings-content {
    padding: 0 14px;
}

.upload-page .settings-section[open] .settings-content {
    padding: 14px;
}

.upload-page .settings-section label {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
    color: #4b5563;
    font-size: 14px;
    transition: color 0.2s ease;
}

.upload-page .settings-section label:hover {
    color: #1f2937;
}

.upload-page .settings-section label:last-child {
    margin-bottom: 0;
}

.upload-page .settings-section input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #27AE60;
}

.compare-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #27AE60 0%, #229954 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.35);
}

.compare-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.45);
}

.compare-btn:active:not(:disabled) {
    transform: translateY(0);
}

.compare-btn:disabled {
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

.status {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.status.hidden {
    display: none;
}

.status.error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.status.info {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0369a1;
    border: 1px solid #7dd3fc;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* New comparison button in toolbar */
.new-comparison-btn {
    padding: 6px 14px;
    background-color: #34495e;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.new-comparison-btn:hover {
    background-color: #415a77;
    border-color: rgba(255, 255, 255, 0.4);
}

/* ============================================
   END UPLOAD PAGE STYLES
   ============================================ */

.viewer-container.hidden {
    display: none !important;
}

/* Rating Styles */
.full-stars {
    display: flex;
    align-items: center;
}

.full-stars .rating-group {
    display: inline-flex;
    flex-direction: row-reverse; /* This fixes the highlighting issue */
    gap: 2px; /* Reduced gap between stars */
}

.full-stars input {
    position: absolute;
    left: -9999px;
}

.full-stars label {
    margin: 0;
    cursor: pointer;
    position: relative;
}

.full-stars label a svg {
    margin: 0;
    height: 20px; /* Reduced from 30px */
    width: 20px; /* Reduced from 30px */
    fill: #ddd; /* Default gray color */
    transition: fill 0.3s;
}

/* Highlight stars and all stars to the left when hovering */
.full-stars label:hover a svg,
.full-stars label:hover ~ label a svg {
    fill: #ff8400;
}

/* Highlight selected star and all stars to the left */
.full-stars input:checked ~ label a svg {
    fill: #ffc711;
}

/* When hovering over the group, highlight all stars up to the hovered one */
.full-stars .rating-group:hover label a svg {
    fill: #ddd;
}

.full-stars .rating-group:hover label:hover a svg,
.full-stars .rating-group:hover label:hover ~ label a svg {
    fill: #ff8400;
}

.rating-section {
    padding: 10px;
    border-top: 1px solid #eee;
    transition: opacity 0.2s ease;
}

.rating-section.hidden {
    display: none;
}

.rating-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px; /* Gap between text and stars */
}

.rate-text {
    font-family: arial, sans-serif;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

.full-stars {
    display: flex;
    align-items: center;
}

.viewer-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #2c3e50;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toolbar h1 {
    font-size: 18px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar h1 .header-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
    border: 1px solid white;
    border-radius: 4px;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#file-names {
    font-size: 12px;
    color: #bdc3c7;
}

.nav-btn,
.zoom-btn {
    padding: 6px 12px;
    background-color: #34495e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.nav-btn:hover,
.zoom-btn:hover {
    background-color: #415a77;
}

.nav-btn:active,
.zoom-btn:active {
    background-color: #2c3e50;
}

.separator {
    color: #7f8c8d;
    margin: 0 5px;
}

.zoom-controls-synced {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.zoom-controls-dual {
    display: none;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Show dual controls when body has class */
body.zoom-unsynced .zoom-controls-synced {
    display: none;
    opacity: 0;
    transform: scale(0.95);
}

body.zoom-unsynced .zoom-controls-dual {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

.zoom-group-left,
.zoom-group-right {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    background-color: #34495e;
    border-radius: 4px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.zoom-group-left:hover,
.zoom-group-right:hover {
    background-color: #415a77;
}

.zoom-group-label {
    font-size: 11px;
    font-weight: 700;
    color: #bdc3c7;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.8;
    min-width: 12px;
}

.zoom-separator-vertical {
    width: 1px;
    height: 24px;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.15) 20%,
        rgba(255, 255, 255, 0.15) 80%,
        rgba(255, 255, 255, 0)
    );
}

.zoom-input-container {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    padding: 2px 6px;
    height: 24px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.zoom-controls-synced .zoom-input-container {
    background-color: #34495e;
    height: 28px;
}

.zoom-input-container:focus-within {
    background-color: rgba(52, 152, 219, 0.2);
}

#zoom-level,
#zoom-level-left,
#zoom-level-right {
    width: 40px;
    background-color: transparent;
    border: none;
    color: white;
    text-align: right;
    font-size: 14px;
    font-family: inherit;
    padding: 0;
    margin: 0;
    padding-right: 2px;
    transition: color 0.2s ease;
}

#zoom-level:focus,
#zoom-level-left:focus,
#zoom-level-right:focus {
    outline: none;
    color: #3498db;
}

.zoom-input-container span {
    font-size: 13px;
    margin-left: 2px;
    color: #95a5a6;
    transition: color 0.2s ease;
}

.zoom-input-container:focus-within span {
    color: #bdc3c7;
}

.zoom-btn-small {
    padding: 4px 8px !important;
    font-size: 12px !important;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 8px;
    background-color: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
}

.legend-color {
    width: 20px;
    height: 12px;
    border-radius: 2px;
}

.legend-color.red {
    background-color: rgba(255, 0, 0, 0.3);
    border: 1px solid rgba(255, 0, 0, 0.5);
}

.legend-color.green {
    background-color: rgba(0, 255, 0, 0.3);
    border: 1px solid rgba(0, 255, 0, 0.5);
}

.legend-color.blue {
    background-color: rgba(0, 127, 255, 0.3);
    border: 1px solid rgba(0, 127, 255, 0.5);
}

.legend-color.orange {
    background-color: rgba(243, 156, 18, 0.3);
    border: 1px solid rgba(243, 156, 18, 0.5);
}

.panes-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Add spacing between left and right panes */
#pane-left {
    border-right: 1px solid #525252;
}

#pane-right {
    border-left: 1px solid #525252;
}

#pane-left .canvas-container {
    border-right: 7px solid #525252;
}

#pane-right .canvas-container {
    border-left: 7px solid #525252;
}

/* Page controls inside pane headers */
.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 10px;
    background-color: #f4f6f7;
    font-weight: 600;
}

.pane-title {
    color: #2c3e50;
}

.pane-title-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pane-title-text {
    color: #2c3e50;
    transition: color 0.3s ease;
}

.pane-title-text.file-replaced {
    color: #059669;
    font-weight: 700;
}

.exchange-file-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.exchange-file-btn:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(1.1);
}

.exchange-file-btn:active {
    transform: scale(0.95);
}

.exchange-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.recompare-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
    margin-right: 12px;
}

.recompare-btn:hover {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
    box-shadow: 0 4px 8px rgba(5, 150, 105, 0.3);
    transform: translateY(-1px);
}

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

.recompare-btn.hidden {
    display: none;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-btn {
    padding: 2px 8px;
    background-color: #e9ecef;
    color: #2c3e50;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.page-btn:hover {
    background-color: #dee2e6;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.page-indicator {
    font-size: 12px;
    color: #4a5568;
    min-width: 60px;
    text-align: center;
}

/* Changes panel */
.changes-panel {
    width: 350px;
    min-width: 300px;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
    border-left: 2px solid #bdc3c7;
    overflow: hidden;
    /* transition: width 0.2s ease, min-width 0.2s ease; */
}

.changes-panel.collapsed {
    width: 20px;
    min-width: 20px;
}

.changes-panel-header {
    height: 32px;
    padding: 6px 15px;
    background-color: #34495e;
    color: white;
    border-bottom: 2px solid #2c3e50;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
}

.changes-panel.collapsed .changes-panel-header {
    padding: 6px 0;
    justify-content: center;
}

.changes-header-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.changes-panel.collapsed .changes-header-content {
    display: none;
}

.changes-nav {
    display: flex;
    gap: 8px;
}

.changes-nav .nav-btn {
    padding: 2px 8px;
    font-size: 12px;
}

.changes-stats {
    font-size: 12px;
    color: #bdc3c7;
}

.collapse-btn {
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.collapse-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.collapse-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 5px solid white;
    transition: transform 0.2s ease;
}

.collapse-text {
    display: inline-block;
    font-size: 13px;
    transition: opacity 0.2s ease;
}

.changes-panel.collapsed .collapse-text {
    display: none;
}

.changes-panel.collapsed .collapse-icon {
    transform: scaleX(-1);
}

.changes-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    opacity: 1;
    transition: opacity 0.15s ease;
}

.changes-panel.collapsed .changes-list {
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.change-item {
    padding: 12px 20px;
    margin: 0 10px 8px 10px;
    background-color: white;
    border-radius: 6px;
    border-left: 4px solid #7f8c8d;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.change-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.change-item.active {
    background-color: #e8f4f8;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.change-item.removed {
    border-left-color: #e74c3c;
}

.change-item.added {
    border-left-color: #27ae60;
}

.change-item.moved {
    border-left-color: #3498db;
}

.change-item.replaced {
    border-left-color: #f39c12;
}

.change-type {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.change-type.removed {
    color: #e74c3c;
}

.change-type.added {
    color: #27ae60;
}

.change-type.moved {
    color: #3498db;
}

.change-type.replaced {
    color: #f39c12;
}

.change-type-badge {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.change-type.removed .change-type-badge {
    background-color: #e74c3c;
}

.change-type.added .change-type-badge {
    background-color: #27ae60;
}

.change-type.moved .change-type-badge {
    background-color: #3498db;
}

.change-type.replaced .change-type-badge {
    background-color: #f39c12;
}

.change-text {
    font-size: 13px;
    color: #2c3e50;
    line-height: 1.4;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.change-text-label {
    font-size: 11px;
    font-weight: 600;
    color: #7f8c8d;
    margin-top: 8px;
    margin-bottom: 2px;
}

.change-location {
    font-size: 11px;
    color: #7f8c8d;
    margin-top: 4px;
}

.change-replaced {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.change-before, .change-after {
    display: flex;
    flex-direction: column;
}

.changes-list::-webkit-scrollbar {
    width: 8px;
}

.changes-list::-webkit-scrollbar-track {
    background: #ecf0f1;
}

.changes-list::-webkit-scrollbar-thumb {
    background: #95a5a6;
    border-radius: 4px;
}

.changes-list::-webkit-scrollbar-thumb:hover {
    background: #7f8c8d;
}

/* (Deprecated) Old pane header styles removed in favor of new layout above */

.canvas-container {
    flex: 1;
    overflow: hidden;
    background-color: #525252;
    position: relative;
    cursor: text;
}

/* PDF.js viewer layout overrides (minimal) */
#viewerContainer-left {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow-x: hidden; /* Horizontal scroll handled by inner wrapper */
    overflow-y: scroll; /* always show vertical scrollbar for consistent centering */
}
#viewerContainer-right {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow-x: auto;
    overflow-y: scroll; /* always show vertical scrollbar for consistent centering */
}

/* Place vertical scrollbar on the left side for left container */
#viewerContainer-left {
    direction: rtl;
}

/* Reset direction for content inside left container */
#viewerContainer-left > #viewerScrollX-left > #viewer-left,
#viewerContainer-left > #viewer-left {
    direction: ltr;
}

/* Remove default PDF.js tiny scrollbars caused by page box shadow/spacing */
#viewer-left .page, #viewer-right .page {
    margin: 15px auto !important; /* Increased from 5px to 15px to account for canvas box-shadow (0 4px 8px = 12px) */
    max-width: none !important; /* Allow full page width without clipping */
    display: block !important; /* ensure block display for auto margins */
    border: none !important; /* remove any PDF.js default borders */
    box-sizing: border-box !important; /* ensure consistent box model */
}

/* First page has minimal top margin */
#viewer-left .page:first-child, #viewer-right .page:first-child {
    margin-top: 15px !important;
}

/* Ensure canvas wrapper doesn't clip content */
#viewer-left .canvasWrapper, #viewer-right .canvasWrapper {
    overflow: visible !important;
}

/* Make PDF.js annotations non-interactive to allow smooth text selection */
.annotationLayer, .annotationLayer * {
    pointer-events: none !important;
}

/* Inner viewer scroller */
#viewer-left.pdfViewer, #viewer-right.pdfViewer {
    position: relative;
    overflow: visible; /* allow horizontal overflow; scrolling handled by container */
    outline: none;
    width: max-content; /* expand to fit widest page for horizontal overflow */
    text-align: center; /* center pages horizontally */
    padding: 0; /* remove any default padding */
    margin-left: auto;  /* center the whole viewer when narrower than container */
    margin-right: auto; /* center the whole viewer when narrower than container */
}

.pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 8px;
}

canvas {
    display: block;
    background-color: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Page wrapper for canvas + text layer */
.page-wrapper {
    position: relative;
    display: inline-block;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Text layer styles - required for PDF.js text selection */
.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 1;
    line-height: 1.0;
    -webkit-text-size-adjust: none;
       -moz-text-size-adjust: none;
            text-size-adjust: none;
    forced-color-adjust: none;
    transform-origin: 0 0;
}

/* Hover layer for interactive word highlighting */
.hoverLayer {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 5;
}

.hover-word {
    position: absolute;
    background-color: transparent;
    border: none;
    pointer-events: none;
    cursor: text;
    z-index: 10;
}

.hover-word:hover {
    border: 1px solid rgba(52, 152, 219, 0.4) !important;
    box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.2) !important;
}

/* Pinned highlight boxes - grouped word highlights */
.pinned-highlight-box {
    position: absolute;
    background-color: transparent;
    border: 2px solid #e74c3c;
    box-shadow: 0 0 0 1px rgba(231, 76, 60, 0.4);
    border-radius: 2px;
    pointer-events: none;
    z-index: 4;
}

/* Merged annotation layer - replicates backend PDF annotation appearance */
.mergedAnnotationLayer {
    position: absolute;
    pointer-events: none;
    z-index: 3;
}

.merged-highlight {
    position: absolute;
    pointer-events: none;
    opacity: 0.3;
}

.merged-highlight-red {
    background-color: rgb(255, 0, 0);
}

.merged-highlight-green {
    background-color: rgb(0, 255, 0);
}

.merged-highlight-blue {
    background-color: rgb(0, 128, 255);
}

.merged-highlight-orange {
    background-color: rgba(243, 156, 18, 0.3);
    border: 1px solid rgba(243, 156, 18, 0.5);
}

.textLayer span,
.textLayer br {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
    /* Let PDF.js set font-family and font-size inline */
}

/* Disable text rendering optimizations that can cause misalignment */
.textLayer span {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Make text visible when selected */
.textLayer ::selection {
    background: rgba(0, 123, 255, 0.3);
    color: rgb(0, 0, 0);
}

.textLayer ::-moz-selection {
    background: rgba(0, 123, 255, 0.3);
    color: rgb(0, 0, 0);
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #ecf0f1;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    margin-top: 20px;
    font-size: 16px;
    color: #2c3e50;
}

/* Scrollbar styling - thin elegant scrollbars */
#viewerContainer-left::-webkit-scrollbar,
#viewerContainer-right::-webkit-scrollbar,
#viewerScrollX-left::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

/* Hide only the native horizontal scrollbar for the left horizontal scroller */
#viewerScrollX-left::-webkit-scrollbar:horizontal {
    height: 0; /* keep H-scroll functional but hide native bar */
}

#viewerContainer-left::-webkit-scrollbar-track,
#viewerContainer-right::-webkit-scrollbar-track,
#viewerScrollX-left::-webkit-scrollbar-track {
    background: #2c3e50;
    border-radius: 3px;
}

#viewerContainer-left::-webkit-scrollbar-thumb,
#viewerContainer-right::-webkit-scrollbar-thumb,
#viewerScrollX-left::-webkit-scrollbar-thumb {
    background: #7f8c8d;
    border-radius: 3px;
    transition: background 0.2s ease;
}

#viewerContainer-left::-webkit-scrollbar-thumb:hover,
#viewerContainer-right::-webkit-scrollbar-thumb:hover,
#viewerScrollX-left::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

#viewerContainer-left::-webkit-scrollbar-thumb:active,
#viewerContainer-right::-webkit-scrollbar-thumb:active,
#viewerScrollX-left::-webkit-scrollbar-thumb:active {
    background: #bdc3c7;
}

/* Cursor overrides for colored words */
#viewerContainer-left.cursor-pointer,
#viewerContainer-right.cursor-pointer,
#viewerContainer-left.cursor-pointer *,
#viewerContainer-right.cursor-pointer * {
    cursor: pointer !important;
}

#viewerContainer-left.cursor-text,
#viewerContainer-right.cursor-text,
#viewerContainer-left.cursor-text *,
#viewerContainer-right.cursor-text * {
    cursor: text !important;
}

/* Ensure tooltip shows hand cursor even when containers force text cursor */
#viewerContainer-left.cursor-text button.copy-tooltip,
#viewerContainer-right.cursor-text button.copy-tooltip,
#viewerContainer-left.cursor-pointer button.copy-tooltip,
#viewerContainer-right.cursor-pointer button.copy-tooltip,
#viewerContainer-left button.copy-tooltip,
#viewerContainer-right button.copy-tooltip {
    cursor: pointer !important;
}

/* Floating copy tooltip */
.copy-tooltip {
    position: absolute;
    z-index: 30; /* above page overlays */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;  /* compact circular icon */
    height: 40px;
    color: #2c3e50;
    background: #ffffff;
    border: 1px solid #d0d7de;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    cursor: pointer !important; /* override container-wide cursor */
    pointer-events: auto; /* ensure clickable above non-interactive overlays */
    user-select: none;
    transition: background-color 120ms ease, box-shadow 120ms ease, transform 100ms ease, border-color 120ms ease;
    transform-origin: top left;
}

.copy-tooltip:hover {
    background: #f6f8fa;
    border-color: #b8c2cc;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    transform: translateY(-2px) scale(1.03);
    cursor: pointer !important;
}

.copy-tooltip:active {
    transform: translateY(0) scale(0.99);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.copy-tooltip svg {
    width: 22px;
    height: 22px;
    display: block;
    pointer-events: none; /* let button receive hover/click */
}

/* Stronger cursor override when containers enforce text cursor over all children */
#viewerContainer-left.cursor-text button.copy-tooltip,
#viewerContainer-right.cursor-text button.copy-tooltip,
#viewerContainer-left.cursor-pointer button.copy-tooltip,
#viewerContainer-right.cursor-pointer button.copy-tooltip,
#viewerContainer-left button.copy-tooltip,
#viewerContainer-right button.copy-tooltip {
    cursor: pointer !important;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    width: 90%;
    max-width: 1400px;
    height: 80%;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #2c3e50;
    color: white;
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    font-size: 18px;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.modal-body {
    flex: 1;
    padding: 20px;
    overflow: hidden;
}

.text-columns {
    display: flex;
    gap: 20px;
    height: 100%;
}

.text-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.text-column h3 {
    font-size: 16px;
    margin: 0 0 8px 0;
    color: #2c3e50;
}

.text-stats {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.text-column textarea {
    flex: 1;
    width: 100%;
    padding: 10px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    background-color: #f8f9fa;
}

.text-column textarea:focus {
    outline: none;
    border-color: #3498db;
}

/* Settings Dropdown Menu */
.settings-menu {
    position: absolute;
    top: 50px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 250px;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.settings-menu.hidden {
    display: none;
    opacity: 0;
    transform: translateY(-10px);
}

.settings-menu-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
}

.settings-checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    padding: 10px 12px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.settings-checkbox-label:hover {
    background-color: #f8f9fa;
}

.settings-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.settings-checkbox-label span {
    font-weight: 500;
    color: #2c3e50;
}

/* Custom horizontal scrollbar for left pane */
.custom-scrollbar {
    height: 8px; /* Match native scrollbar height */
    background-color: #2c3e50; /* Match track color */
    position: relative;
    display: none; /* Show only when there is horizontal overflow */
    border-top: 1px solid #415a77;
}

.custom-scrollbar-thumb {
    height: 100%;
    background-color: #7f8c8d; /* Match thumb color */
    border-radius: 3px;
    position: absolute;
    cursor: grab;
    transition: background-color 0.2s ease;
}

/* Inner horizontal scroller wrapper for the left pane */
#viewerScrollX-left {
    overflow-x: auto;
    overflow-y: hidden;
    direction: ltr; /* keep horizontal math simple */
    width: 100%; /* ensure centering relative to full container width */
}

.custom-scrollbar-thumb:hover {
    background-color: #95a5a6;
}

.custom-scrollbar-thumb:active {
    background-color: #bdc3c7;
    cursor: grabbing;
}

.selection_highlighter_scroll_markers {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}