:root {
    --bg: #0e1726;
    --card: rgba(255, 255, 255, .10);
    --border: rgba(255, 255, 255, .20);
    --text: #eef5ff;
    --muted: #aab8ca;
    --primary: #68a8ff;
    --success: #42d392;
    --danger: #ff6b81;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, #1c3d67 0, transparent 35%),
        linear-gradient(135deg, #09111d, var(--bg));
}

.background-orb {
    position: fixed;
    z-index: -1;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .35;
}

.orb-one {
    top: 10%;
    left: 8%;
    background: #306eff;
}

.orb-two {
    right: 5%;
    bottom: 5%;
    background: #b041ff;
}

.glass {
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 5%;
}

.topbar h1,
.topbar p {
    margin: 0;
}

.topbar p {
    margin-top: 5px;
    color: var(--muted);
}

.topbar a {
    color: white;
    text-decoration: none;
}

.container {
    width: min(1200px, 92%);
    margin: 35px auto;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.drop-card,
.toolbar,
.result-panel {
    padding: 24px;
    border-radius: 22px;
}

.drop-card h2,
.result-panel h2 {
    margin-top: 0;
}

.drop-zone {
    display: grid;
    min-height: 220px;
    cursor: pointer;
    place-items: center;
    border: 2px dashed rgba(255, 255, 255, .35);
    border-radius: 18px;
    transition: .2s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(104, 168, 255, .12);
}

.drop-content {
    display: grid;
    gap: 8px;
    color: var(--muted);
    text-align: center;
}

.drop-content strong {
    color: white;
}

.upload-icon {
    color: var(--primary);
    font-size: 48px;
    line-height: 1;
}

.file-info {
    min-height: 26px;
    margin-top: 14px;
    color: var(--muted);
}

.preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-height: 500px;
    margin-top: 18px;
    overflow: auto;
}

.page-card {
    width: 120px;
    padding: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 12px;
    background: rgba(255, 255, 255, .08);
}

.page-card.selected {
    border-color: var(--success);
}

.page-card canvas {
    display: block;
    width: 100%;
    height: auto;
    background: white;
}

.page-card label {
    display: block;
    padding-top: 5px;
    color: white;
    font-size: 12px;
    text-align: center;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

button {
    padding: 12px 17px;
    cursor: pointer;
    color: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, .1);
}

button:hover:not(:disabled) {
    background: rgba(255, 255, 255, .2);
}

button:disabled {
    cursor: not-allowed;
    opacity: .45;
}

button.primary {
    border: 0;
    background: linear-gradient(135deg, #3f8cff, #8c5bff);
}

.result-panel {
    display: none;
    margin-top: 24px;
}

.result-panel.visible {
    display: block;
}

#mergedViewer {
    width: 100%;
    height: 700px;
    border: 0;
    border-radius: 14px;
    background: white;
}

.spinner-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    place-items: center;
    align-content: center;
    gap: 16px;
    background: rgba(2, 8, 18, .7);
    backdrop-filter: blur(8px);
}

.spinner-overlay.visible {
    display: grid;
}

.spinner {
    width: 58px;
    height: 58px;
    border: 5px solid rgba(255, 255, 255, .25);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.toast-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 50;
    display: grid;
    gap: 10px;
}

.toast {
    min-width: 250px;
    padding: 14px 17px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(21, 33, 51, .94);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--danger);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, .65);
}

.modal.visible {
    display: grid;
}

.modal-box {
    position: relative;
    width: min(500px, 100%);
    padding: 26px;
    border-radius: 20px;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: transparent;
    font-size: 25px;
}

form {
    display: grid;
    gap: 15px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
}

input,
textarea,
select {
    width: 100%;
    padding: 12px;
    color: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: rgba(0, 0, 0, .2);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

@media (max-width: 750px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}