:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #f43f5e;
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --glass-blur: 12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #0f172a 100%);
    z-index: -1;
}

.container {
    max-width: 900px;
    width: 95%;
    margin: 2rem auto;
    padding: 1.5rem 2rem;
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.6s ease-out;
    position: relative; /* For absolute children */
}

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

.hero {
    text-align: center;
    margin-bottom: 0.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-actions {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 0.8rem;
    z-index: 10;
}

.hero h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 0;
    width: 100%;
}

.icon-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.75rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

.icon-btn svg {
    width: 1.5rem;
    height: 1.5rem;
}

.hero span {
    background: linear-gradient(to right, #818cf8, #c084fc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-top: 1rem;
}

.drop-zone {
    border: none;
    border-radius: 1.5rem;
    padding: 1.2rem;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    cursor: pointer;
    margin-bottom: 0.5rem;
    position: relative;
    overflow: hidden;
}

.drop-zone:hover {
    background: rgba(255, 255, 255, 0.05);
}

.drop-zone.dragging {
    background: rgba(99, 102, 241, 0.1);
}

.upload-btn {
    display: inline-block;
    white-space: nowrap;
    background: var(--primary-color);
    color: white;
    padding: 0.8rem 2.2rem;
    border-radius: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    animation: blink 2.5s infinite ease-in-out;
}

@keyframes blink {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 25px 10px rgba(99, 102, 241, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.drop-zone:hover .upload-btn {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.3);
    animation-play-state: paused;
}

.preview-container {
    padding: 1rem;
    position: relative;
}

.preview-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.remove-btn {
    position: absolute;
    top: 1.5rem;   /* Adjusted to align better inside padding */
    right: 1.5rem; /* Adjusted to align better inside padding */
    background: var(--secondary-color);
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    z-index: 300;   /* Ensure it's above viewer-actions and PDF viewer */
}

.process-control {
    margin-top: 2rem;
    text-align: center;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.primary-btn-sm {
    background: var(--primary-color);
    color: white;
    border: 1px solid transparent; /* Added to match secondary-btn height */
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px; /* Standardize height */
}

.primary-btn-sm:hover {
    background: var(--primary-hover);
}

.secondary-btn-sm {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px; /* Standardize height */
    width: 38px;  /* Make it square */
}

.secondary-btn-sm:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--primary-color);
}

.secondary-btn-sm svg {
    width: 1.2rem;
    height: 1.2rem;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1.25rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.status-message {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    margin: 2rem auto;
    width: 40px;
    height: 40px;
    position: relative;
    text-align: center;
}

.double-bounce1, .double-bounce2 {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--primary-color);
    opacity: 0.6;
    position: absolute;
    top: 0;
    left: 0;
    animation: bounce 2s infinite ease-in-out;
}

.double-bounce2 {
    animation-delay: -1.0s;
}

@keyframes bounce {
    0%, 100% { transform: scale(0.0); }
    50% { transform: scale(1.0); }
}

.results-section {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.8s ease;
}

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

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.5rem;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.results-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
}

.table-container {
    overflow-x: auto;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.01);
}

th {
    text-align: left;
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
    color: var(--text-color);
}

tr.sent {
    background: rgba(16, 185, 129, 0.15);
    transition: background 0.5s ease;
}

.action-cell {
    text-align: center;
    width: 50px;
}

.delete-row-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 0.4rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.delete-row-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    transform: scale(1.1);
}

.delete-row-btn svg {
    width: 14px;
    height: 14px;
}

tr.sent .delete-row-btn {
    color: rgba(16, 185, 129, 0.4);
}

.hidden {
    display: none !important;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: #1e293b;
    padding: 2rem;
    border-radius: 1.25rem;
    width: 90%;
    max-width: 450px;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    margin-bottom: 1.2rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    color: white;
    font-family: inherit;
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.action-header {
    text-align: center;
    width: 60px;
    padding: 0.5rem !important;
}

.trash-btn-header {
    background: none;
    border: none;
    color: rgba(239, 68, 68, 0.6);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 0.4rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.trash-btn-header:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    transform: scale(1.1);
}

.trash-btn-header svg {
    width: 16px;
    height: 16px;
}

.modal-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
        margin: 0.5rem;
    }
    .drop-zone {
        padding: 1.5rem 0.8rem;
    }
}

.viewer-actions {
    margin-top: 0.25rem;
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    gap: 2rem; /* Increased space between buttons */
    position: sticky;
    bottom: 0rem;
    z-index: 200;
}

.pdf-viewer {
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.primary-btn-lg {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem; /* Micro padding */
    font-size: 0.8rem;       /* Micro font */
    font-weight: 700;
    border-radius: 0.5rem;
    cursor: pointer;
    box-shadow: 0 5px 12px rgba(99, 102, 241, 0.3);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 180px; /* Force equal width */
    text-align: center;
}

.primary-btn-lg:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.5);
}

.primary-btn-lg:active {
    transform: translateY(0) scale(0.98);
}

.primary-btn-lg:disabled {
    background: #475569;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
    filter: saturate(0);
}

.pdf-page-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdf-page-container:hover {
    transform: translateY(-5px);
}

.pdf-page-container:active {
    transform: scale(0.98);
}

.pdf-page-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95) 0%, rgba(129, 140, 248, 0.95) 100%);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    letter-spacing: 0.05em;
}

.pdf-page-canvas {
    max-width: 100%;
    height: auto !important;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    background: white;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transition: all 0.3s ease;
}

.pdf-page-container:hover .pdf-page-canvas {
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.4);
    border: 1px solid rgba(99, 102, 241, 0.5);
}

/* --- CLICK FEEDBACK --- */
.pulse-highlight {
    animation: pulseBorder 0.6s ease-out;
}

@keyframes pulseBorder {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.8); border-color: var(--primary-color); }
    70% { box-shadow: 0 0 0 15px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.active-row .mapping-range, 
.active-row .mapping-class {
    border-color: var(--primary-color) !important;
    background: rgba(99, 102, 241, 0.1) !important;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.page-extract-btn {
    position: relative;
    margin-bottom: 1.5rem;
    background: var(--primary-color);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    width: auto;
    min-width: 150px;
}

.page-extract-btn:hover {
    transform: translateY(-2px) scale(1.02);
    background: var(--primary-hover);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5);
}

.page-extract-btn.loading {
    background: #475569;
    cursor: wait;
}


.page-extract-btn.success {
    background: #10b981;
}

/* --- CLASS SELECTION --- */
.class-selection-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.class-selection-container label {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

#class-select, .mapping-class, .mapping-range {
    height: 3.5rem; /* Explicit height for alignment */
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.85rem 1.25rem;
    border-radius: 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
    display: flex;
    align-items: center;
}

#class-select, .mapping-class {
    flex: 1;
    cursor: text;
    padding-right: 1.25rem; /* Reset padding to match left side */
    text-align: center;
    text-transform: uppercase;
}

#class-select:focus, .mapping-class:focus, .mapping-range:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

#class-select option, .mapping-class option {
    background: #1a1a1a;
    color: white;
    padding: 10px;
}

/* --- MAPPING UI --- */
.mapping-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.2rem;
    border-radius: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.mapping-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-bottom: 0.6rem;
}

.mapping-header label {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    flex: 1;
}

.mapping-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.mapping-row {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    animation: slideInRow 0.3s ease-out;
}

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

.mapping-range {
    width: 120px;
    text-align: center;
}

.mapping-range:focus {
    border-color: var(--primary-color);
    outline: none;
}

.add-btn-circular, .remove-mapping-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.add-btn-circular {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.add-btn-circular:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.remove-mapping-btn {
    background: rgba(244, 63, 94, 0.1);
    color: var(--secondary-color);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.remove-mapping-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: scale(1.1);
}

.add-btn-circular svg, .remove-mapping-btn svg, .refresh-btn-circular svg {
    width: 18px;
    height: 18px;
}

/* --- SUCCESS TOAST --- */
.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-content {
    background: rgba(16, 185, 129, 0.15);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 1.25rem 2rem;
    border-radius: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
}

.toast-icon {
    width: 32px;
    height: 32px;
    background: #10B981;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.toast-icon svg {
    width: 18px;
    height: 18px;
}

.toast-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 600px) {
    .container {
        padding: 1.5rem;
        width: 95%;
        border-radius: 1.5rem;
    }

    .hero {
        margin-bottom: 2rem;
        padding-top: 3.5rem; /* Space for buttons at the top */
    }

    .hero-actions {
        top: 0;
        right: 50%;
        transform: translateX(50%); /* Center buttons on mobile */
    }

    .hero h1 {
        font-size: 1.6rem;
        line-height: 1.2;
    }

    .mapping-row {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0.8rem;
        background: rgba(255, 255, 255, 0.02);
        border-radius: 1rem;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .mapping-range {
        flex: 1;
        width: auto !important;
        min-width: 80px;
        order: 1;
    }

    .mapping-class {
        width: 100% !important;
        flex: none !important;
        order: 3;
    }

    .add-btn-circular, .remove-mapping-btn {
        order: 2;
        width: 42px !important; /* Slightly larger for easier tap */
        height: 42px !important;
    }

    .class-selection-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem;
    }

    .class-selection-container label {
        font-size: 0.9rem;
    }

    #class-select {
        width: 100%;
    }

    .drop-zone {
        padding: 1.5rem;
    }

    .drop-zone p {
        font-size: 0.9rem;
    }

    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .results-header h2 {
        text-align: center;
        font-size: 1.3rem;
    }

    .action-buttons {
        flex-direction: row; /* Ensure they stay on the same line */
        gap: 0.8rem;
        justify-content: center;
    }

    .primary-btn-sm {
        width: auto; /* Remove 100% width to allow side-by-side */
        flex: 1;    /* Allow it to fill space if needed */
        padding: 0.8rem 1.25rem;
    }

    .secondary-btn-sm {
        flex: 0 0 auto; /* Keep the copy button compact */
        height: 100%; /* Match height with sheets button if possible */
    }

    .table-container {
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 450px;
    }

    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    .toast {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        transform: translateY(-100px);
    }

    .toast.show {
        transform: translateY(0);
    }

    .toast-content {
        padding: 0.8rem 1rem;
        justify-content: center;
    }
}

/* --- DYNAMIC CLASS REFRESH REMOVED --- */


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

/* --- PAGE RANGE INPUT (Styled as Button) --- */
.range-input-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    padding: 0.4rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 5px 12px rgba(99, 102, 241, 0.3);
    min-width: 180px;
    justify-content: center;
    border: none;
}

.range-input-container label {
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: white; /* Changed to white to match button text */
    letter-spacing: 0.05em;
    cursor: default;
}

#page-range {
    background: rgba(255, 255, 255, 0.15); /* Slightly lighter for input area */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.3rem;
    padding: 0.25rem 0.5rem;
    color: white;
    font-family: inherit;
    font-size: 0.8rem;
    width: 80px; /* Slimmer */
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
}

#page-range:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: white;
}

@media (max-width: 600px) {
    .viewer-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .range-input-container {
        justify-content: space-between;
    }
    
    #page-range {
        flex: 1;
        max-width: none;
    }
}

/* --- MODAL OVERLAY --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.success-popup-content {
    background: rgba(30, 30, 50, 0.85);
    backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 3rem;
    border-radius: 2rem;
    text-align: center;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: popupFadeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.success-icon {
    width: 80px;
    height: 80px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: #818cf8;
    animation: iconBounce 1.2s infinite alternate;
}

@keyframes iconBounce {
    from { transform: translateY(0); box-shadow: 0 0 0 rgba(99, 102, 241, 0); }
    to { transform: translateY(-10px); box-shadow: 0 15px 25px rgba(99, 102, 241, 0.2); }
}

.success-popup-content h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: white;
    margin-bottom: 0.75rem;
    letter-spacing: 0.1em;
}

.success-popup-content p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2rem;
}

#close-success-btn {
    width: 100%;
}
