body {
    font-family: Arial, sans-serif;
    text-align: center;
    background: #f2f2f2;
    margin: 0;
}


/* Heading */

h1 {
    color: #2563eb;
    margin-top: 25px;
}

h2 {
    margin-top: 30px;
}


/* Upload Area */

.upload-box {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    margin: 35px auto;
}


/* Choose Button */

.choose-button {
    background: #2864e8;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
}

#images {
    display: none;
}


/* Add Button */

.add-wrapper {
    position: relative;
    width: 50px;
    height: 50px;
}


.add-button {
    background: #ef302b;
    color: white;
    border: none;

    width: 50px;
    height: 50px;

    border-radius: 50%;

    font-size: 30px;
    cursor: pointer;

    margin: 0;
    padding: 0;
}


.add-button:hover {
    background: #d92521;
}


/* Image Count Badge */

#image-count {
    position: absolute;

    top: -7px;
    right: -7px;

    min-width: 20px;
    height: 20px;

    padding: 2px;

    border-radius: 50%;

    background: #333;
    color: white;

    font-size: 11px;

    display: flex;
    justify-content: center;
    align-items: center;

    box-sizing: border-box;
}


/* Convert Button */

.convert-button {
    background: #2864e8;
    color: white;

    border: none;

    padding: 12px 20px;

    border-radius: 8px;

    font-size: 16px;

    cursor: pointer;

    margin: 0;
}


.convert-button:hover {
    background: #1d4ed8;
}


/* Orientation */

.orientation-title {
    margin-top: 20px;
    margin-bottom: 15px;
}


.orientation-box {
    display: flex;
    justify-content: center;
    gap: 14px;

    margin-bottom: 25px;
}


.orientation-option {
    width: 180px;
    height: 95px;

    background: white;

    color: #555;

    border: 2px solid transparent;

    border-radius: 12px;

    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.10);

    display: flex;
    flex-direction: column;

    justify-content: center;
    align-items: center;

    gap: 8px;

    cursor: pointer;

    padding: 10px;
}


.orientation-option:hover {
    background: #fafafa;
}


.orientation-option.active {
    border-color: #2864e8;
    color: #2864e8;
}


.orientation-icon {
    font-size: 28px;
}


/* Preview */

#preview {
    width: 90%;
    max-width: 1200px;

    margin: 25px auto 35px;

    display: grid;

    grid-template-columns:
        repeat(auto-fill, minmax(170px, 1fr));

    gap: 20px;
}


/* Image Card */

.image-card {
    position: relative;

    width: 100%;

    padding: 10px;

    background: white;

    border-radius: 12px;

    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.10);

    box-sizing: border-box;

    cursor: grab;

    transition: 0.2s;
}


.image-card:active {
    cursor: grabbing;
}


.image-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}


/* Image */

.image-card img {
    width: 100%;

    height: 170px;

    object-fit: contain;

    border-radius: 8px;

    display: block;

    transition: 0.3s;
}


/* Portrait Preview */

.image-card.portrait-preview img {
    height: 210px;
}


/* Landscape Preview */

.image-card.landscape-preview img {
    height: 120px;
}


/* File Name */

.image-card p {
    margin: 8px 3px 2px;

    font-size: 12px;

    color: #555;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


/* Remove Button */

.remove-button {
    position: absolute;

    top: -8px;
    right: -8px;

    width: 30px;
    height: 30px;

    padding: 0;
    margin: 0;

    border-radius: 50%;

    background: #2864e8;

    color: white;

    font-size: 18px;

    line-height: 30px;

    cursor: pointer;
}


.remove-button:hover {
    background: #1d4ed8;
}


/* Rotate Button */

.rotate-button {
    position: absolute;

    top: -8px;
    left: -8px;

    width: 30px;
    height: 30px;

    padding: 0;
    margin: 0;

    border-radius: 50%;

    background: white;

    color: #555;

    border: 1px solid #ddd;

    font-size: 18px;

    cursor: pointer;
}


.rotate-button:hover {
    background: #f5f5f5;
}


/* Mobile */

@media (max-width: 600px) {

    .orientation-box {
        gap: 8px;
    }

    .orientation-option {
        width: 30%;
        height: 85px;
    }

    #preview {
        width: 92%;

        grid-template-columns:
            repeat(2, 1fr);

        gap: 12px;
    }

    .image-card img {
        height: 140px;
    }

}

/* =========================
   IMAGE COMPRESSOR
========================= */

.image-upload {
    display: flex;
    flex-direction: column;
    align-items: center;

    width: 100%;
    margin-bottom: 20px;
}

/* Hide original browser file input */

#image {
    display: none;
}

/* Choose Image Button */

.choose-image {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: #2864e8;
    color: white;

    padding: 11px 20px;

    border-radius: 8px;

    font-size: 15px;
    font-weight: 500;

    cursor: pointer;

    box-shadow:
        0 3px 8px rgba(40, 100, 232, 0.18);

    transition: 0.2s;
}

.choose-image:hover {
    background: #1d4ed8;

    transform: translateY(-1px);

    box-shadow:
        0 5px 12px rgba(40, 100, 232, 0.25);
}

/* Selected File Name */

#file-name {
    width: 90%;
    max-width: 350px;

    margin-top: 10px;

    padding: 8px 12px;

    background: #f5f7fb;

    border: 1px solid #e1e5ec;

    border-radius: 7px;

    color: #666;

    font-size: 13px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================
   PDF TO IMAGE
========================= */

.pdf-upload-box {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    margin: 35px auto;
}

#pdf-file {
    display: none;
}

.add-pdf-wrapper {
    position: relative;
    width: 50px;
    height: 50px;
}

#pdf-count {
    position: absolute;

    top: -7px;
    right: -7px;

    min-width: 20px;
    height: 20px;

    padding: 2px;

    border-radius: 50%;

    background: #333;
    color: white;

    font-size: 11px;

    display: flex;
    justify-content: center;
    align-items: center;

    box-sizing: border-box;
}


/* PDF information */

#pdf-info {
    width: 90%;
    max-width: 700px;
    margin: 20px auto;
}

.pdf-card {
    background: white;

    border-radius: 12px;

    padding: 15px 20px;

    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.10);

    display: flex;

    align-items: center;

    gap: 15px;

    text-align: left;
}

.pdf-icon {
    font-size: 35px;
}

.pdf-details {
    display: flex;

    flex-direction: column;

    gap: 5px;

    flex: 1;
}

.pdf-details strong {
    color: #333;
}

.pdf-details span {
    color: #777;
    font-size: 13px;
}

.remove-pdf {
    width: 30px;
    height: 30px;

    border: none;

    border-radius: 50%;

    background: #2864e8;

    color: white;

    font-size: 20px;

    cursor: pointer;
}

.remove-pdf:hover {
    background: #1d4ed8;
}


/* Section */

.section-title {
    margin-top: 30px;
    margin-bottom: 15px;
}


/* Options */

.option-box {
    width: 90%;
    max-width: 700px;

    margin: 0 auto 20px;

    display: flex;

    justify-content: center;

    gap: 15px;
}

.option {
    flex: 1;

    min-height: 80px;

    background: white;

    border: 2px solid transparent;

    border-radius: 12px;

    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.08);

    cursor: pointer;

    padding: 15px;

    color: #444;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    gap: 6px;
}

.option strong {
    font-size: 15px;
}

.option span {
    font-size: 12px;
    color: #777;
}

.option:hover {
    background: #fafafa;
}

.option.active {
    border-color: #2864e8;
    color: #2864e8;
}

.option.active span {
    color: #2864e8;
}


/* Selected page input */

.page-selection {
    width: 90%;
    max-width: 700px;
    margin: 0 auto 20px;
    display: none;
}

.page-selection input {
    width: 100%;

    box-sizing: border-box;

    padding: 13px 15px;

    border: 2px solid #ddd;

    border-radius: 8px;

    font-size: 14px;

    outline: none;
}

.page-selection input:focus {
    border-color: #2864e8;
}

.page-selection p {
    margin-top: 7px;

    font-size: 12px;

    color: #777;
}


/* Small options */

.small-options {
    max-width: 600px;
}


/* Convert */

.pdf-convert-button {
    display: block;

    margin: 35px auto;

    background: #2864e8;

    color: white;

    border: none;

    padding: 14px 35px;

    border-radius: 9px;

    font-size: 17px;

    cursor: pointer;
}

.pdf-convert-button:hover {
    background: #1d4ed8;
}


/* PDF preview */

.pdf-preview {
    width: 90%;
    max-width: 900px;

    margin: 20px auto 35px;

    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(170px, 1fr));

    gap: 20px;
}

.preview-card {
    background: white;

    padding: 10px;

    border-radius: 12px;

    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.10);
}

.preview-card img {
    width: 100%;

    height: 210px;

    object-fit: contain;

    border-radius: 7px;

    display: block;
}

.preview-card span {
    display: block;

    margin-top: 8px;

    font-size: 12px;

    color: #555;
}

.more-pages {
    display: flex;

    align-items: center;

    justify-content: center;

    background: white;

    border-radius: 12px;

    min-height: 230px;

    color: #777;

    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.08);
}


/* Loading */

.loading {
    margin: 30px;

    color: #2864e8;

    font-size: 16px;
}


/* Results */

.result-header {
    width: 90%;
    max-width: 1000px;

    margin: 30px auto 15px;

    display: flex;

    justify-content: space-between;

    align-items: center;
}

.result-header h3 {
    margin: 0;
}

.download-all {
    background: #2864e8;

    color: white;

    border: none;

    padding: 10px 16px;

    border-radius: 8px;

    cursor: pointer;
}

.download-all:hover {
    background: #1d4ed8;
}


.result-grid {
    width: 90%;
    max-width: 1000px;

    margin: 0 auto 40px;

    display: grid;

    grid-template-columns:
        repeat(auto-fill, minmax(180px, 1fr));

    gap: 20px;
}

.result-card {
    background: white;

    padding: 10px;

    border-radius: 12px;

    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.10);
}

.result-card img {
    width: 100%;

    height: 220px;

    object-fit: contain;

    border-radius: 7px;
}

.result-card p {
    font-size: 13px;

    color: #555;

    margin: 8px;
}

.result-card button {
    background: #2864e8;

    color: white;

    border: none;

    padding: 8px 14px;

    border-radius: 7px;

    cursor: pointer;
}

.result-card button:hover {
    background: #1d4ed8;
}


/* Mobile */

@media (max-width: 600px) {

    .option-box {
        flex-direction: column;
    }

    .pdf-upload-box {
        gap: 10px;
    }

    .result-header {
        flex-direction: column;
        gap: 12px;
    }

}

/* =========================
   MERGE PDF
========================= */

/* Top bar */

.top-bar {
    width: 92%;
    max-width: 1200px;
    margin: 0 auto 25px;

    display: flex;
    align-items: center;
}

.select-all {
    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 16px;
    cursor: pointer;
}

.select-all input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2864e8;
}

/* File input */

#pdfInput {
    display: none;
}

/* PDF container */

.pdf-container {
    width: 92%;
    max-width: 1200px;

    margin: 0 auto;

    display: flex;
    flex-wrap: wrap;

    gap: 32px;

    align-items: flex-start;
}

/* PDF item */

.pdf-item {
    width: 210px;

    position: relative;

    text-align: center;

    cursor: grab;

    transition: 0.2s;
}

.pdf-item:active {
    cursor: grabbing;
}

.pdf-item.dragging {
    opacity: 0.45;
    transform: scale(0.96);
}

/* Checkbox */

.pdf-item .checkbox {
    position: absolute;

    top: -9px;
    left: -9px;

    width: 28px;
    height: 28px;

    background: white;

    border-radius: 7px;

    display: flex;
    justify-content: center;
    align-items: center;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.16);

    z-index: 5;
}

.pdf-item .checkbox input {
    width: 18px;
    height: 18px;

    cursor: pointer;

    accent-color: #2864e8;
}

/* PDF card */

.pdf-container .pdf-card {
    width: 210px;
    height: 275px;

    background: white;

    border-radius: 14px;

    padding: 12px;

    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.08);

    position: relative;

    display: flex;
    justify-content: center;
    align-items: center;

    overflow: hidden;

    text-align: center;

    transition: 0.2s;
}

.pdf-item:hover .pdf-card {
    transform: translateY(-3px);

    box-shadow:
        0 7px 20px rgba(0, 0, 0, 0.12);
}

.pdf-item.dragging .pdf-card {
    box-shadow:
        0 0 0 3px #2864e8;
}

.pdf-container .pdf-card canvas {
    max-width: 100%;
    max-height: 100%;

    object-fit: contain;

    border-radius: 5px;
}

/* Remove button */

.pdf-item .remove-button {
    position: absolute;

    top: -9px;
    right: -9px;

    width: 30px;
    height: 30px;

    padding: 0;
    margin: 0;

    border: none;
    border-radius: 50%;

    background: #2864e8;

    color: white;

    font-size: 18px;
    line-height: 30px;

    cursor: pointer;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.15);

    z-index: 5;
}

.pdf-item .remove-button:hover {
    background: #1d4ed8;
}

/* File name */

.pdf-name {
    margin-top: 10px;

    font-size: 13px;
    font-weight: 500;

    color: #333;

    max-width: 210px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Page count */

.page-count {
    margin-top: 4px;

    font-size: 12px;

    color: #777;
}

/* Add PDF card */

.add-card {
    width: 210px;
    height: 275px;

    border: 2px dashed #8fb0f5;

    border-radius: 14px;

    background: #f8faff;

    display: flex;
    flex-direction: column;

    justify-content: center;
    align-items: center;

    cursor: pointer;

    color: #2864e8;

    transition: 0.2s;
}

.add-card:hover {
    background: #eef4ff;

    border-color: #2864e8;

    transform: translateY(-3px);
}

.add-icon {
    width: 48px;
    height: 48px;

    border-radius: 50%;

    background: #2864e8;

    color: white;

    display: flex;
    justify-content: center;
    align-items: center;

    font-size: 28px;

    margin-bottom: 12px;

    box-shadow:
        0 4px 10px rgba(40, 100, 232, 0.25);
}

.add-card p {
    margin: 0;

    font-size: 14px;

    line-height: 1.5;
}

/* Bottom bar */

.bottom-bar {
    width: 92%;
    max-width: 1200px;

    margin: 40px auto;

    text-align: center;
}

/* Merge button */

.merge-button {
    min-width: 170px;

    background: #2864e8;

    color: white;

    border: none;

    padding: 14px 30px;

    border-radius: 9px;

    font-size: 17px;
    font-weight: 500;

    cursor: pointer;

    box-shadow:
        0 4px 10px rgba(40, 100, 232, 0.18);

    transition: 0.2s;
}

.merge-button:hover:not(:disabled) {
    background: #1d4ed8;

    transform: translateY(-2px);

    box-shadow:
        0 6px 15px rgba(40, 100, 232, 0.25);
}

.merge-button:disabled {
    background: #aaa;

    cursor: not-allowed;

    box-shadow: none;

    transform: none;
}

/* Merge PDF mobile */

@media (max-width: 600px) {

    .pdf-container {
        width: 92%;
        justify-content: center;
        gap: 18px;
    }

    .pdf-item,
    .pdf-container .pdf-card,
    .add-card {
        width: 170px;
    }

    .pdf-container .pdf-card,
    .add-card {
        height: 235px;
    }

    .pdf-container .pdf-card {
        padding: 8px;
    }

    .pdf-name {
        max-width: 170px;
    }

    .bottom-bar {
        margin: 30px auto;
    }

    .merge-button {
        width: auto;
        min-width: 160px;
    }
}

/* =========================
   SPLIT PDF
========================= */

.split-upload {
    width: 92%;
    max-width: 1200px;
    margin: 30px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

/* Hide original file input */

#pdfInput {
    display: none;
}

/* Choose PDF */

.choose-pdf {
    width: 150px;
    height: 45px;

    padding: 0;

    background: #2864e8;
    color: white;

    border: none;
    border-radius: 8px;

    font-size: 15px;
    font-weight: 500;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 6px;

    cursor: pointer;

    white-space: nowrap;
}

.choose-pdf:hover {
    background: #1d4ed8;
}

/* File name */

#fileName {
    color: #555;
    font-size: 14px;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* =========================
   PDF INFORMATION
========================= */

#pdfInfo {
    text-align: center;
    margin: 20px auto;
    background: white;
    width: 220px;
    padding: 12px;
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.10);
}


/* =========================
   SPLIT OPTIONS
========================= */

.split-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 25px auto;
}

.option {
    width: 220px;
    height: 70px;

    flex: none;

    background: white;
    color: #555;

    border: 2px solid transparent;
    border-radius: 12px;

    box-shadow: 0 3px 12px rgba(0,0,0,0.10);

    cursor: pointer;

    font-size: 15px;

    transition: 0.2s;
}

.option:hover {
    background: #fafafa;
}

.option.active {
    border-color: #2864e8;
    color: #2864e8;
}


/* =========================
   PAGE INPUT
========================= */

#pageInputBox {
    text-align: center;
    margin: 20px auto;
}

#pageInput {
    width: 280px;
    max-width: 80%;

    padding: 11px 14px;

    border: 1px solid #ccc;
    border-radius: 8px;

    font-size: 14px;
    outline: none;
}

#pageInput:focus {
    border-color: #2864e8;
}


/* =========================
   PDF PREVIEW
========================= */

#preview {
    width: 92%;
    max-width: 1200px;

    margin: 30px auto;

    display: grid;

    grid-template-columns:
        repeat(auto-fill, minmax(170px, 1fr));

    gap: 20px;
}

.page-card {
    position: relative;

    background: white;

    padding: 10px;

    border-radius: 12px;

    box-shadow:
        0 3px 12px rgba(0,0,0,0.10);

    text-align: center;

    cursor: pointer;

    transition: 0.2s;
}

.page-card.selected {
    border: 3px solid #2864e8 !important;

    box-shadow:
        0 0 0 3px rgba(40, 100, 232, 0.18),
        0 5px 18px rgba(40, 100, 232, 0.25) !important;

    background: #f5f8ff;

    transform: translateY(-3px);
}

.page-card:hover {
    transform: translateY(-3px);
}

.page-card canvas {
    width: 100%;
    height: 210px;

    object-fit: contain;

    border-radius: 6px;
}

.page-card p {
    margin: 8px 0 2px;

    font-size: 13px;

    color: #555;
}


/* =========================
   SPLIT BUTTON
========================= */

#splitButton {
    display: block;

    margin: 30px auto;

    background: #2864e8;
    color: white;

    border: none;

    padding: 13px 28px;

    border-radius: 8px;

    font-size: 16px;

    cursor: pointer;
}

#splitButton:hover {
    background: #1d4ed8;
}

#splitButton:disabled {
    background: #aaa;
    cursor: not-allowed;
}


/* =========================
   RESULTS
========================= */

#results {
    width: 92%;
    max-width: 700px;

    margin: 30px auto;

    text-align: center;
}

#results a {
    display: inline-block;

    margin: 7px;

    padding: 10px 16px;

    background: #20a05a;

    color: white;

    text-decoration: none;

    border-radius: 7px;

    font-size: 14px;
}

#results a:hover {
    background: #168447;
}


/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {

    .split-upload {
        flex-direction: column;
    }

    .split-options {
        gap: 8px;
    }

    .option {
        width: 145px;
        height: 80px;
    }

    #preview {
        grid-template-columns:
            repeat(2, 1fr);

        gap: 12px;
    }

    .page-card canvas {
        height: 170px;
    }

}

/* =========================
   SPLIT PDF UPLOAD ROW
========================= */

.split-upload {
    display: flex;
    flex-direction: column;
    align-items: center;

    margin: 35px auto;
}

.button-row {
    display: flex;
    justify-content: center;
    align-items: center;

    gap: 15px;
}

#pdfInput {
    display: none;
}

.choose-pdf,
#splitButton {
    width: 150px;
    height: 45px;

    padding: 0;

    border-radius: 8px;

    font-size: 15px;

    text-align: center;

    cursor: pointer;
    box-sizing: border-box;
}

.choose-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    background: #2864e8;
    color: white;
    border: none;
}

.choose-pdf:hover {
    background: #1d4ed8;
}

#splitButton {
    background: #2864e8;
    color: white;

    border: none;
}

#splitButton:hover {
    background: #1d4ed8;
}

#splitButton:disabled {
    background: #aaa;
    cursor: not-allowed;
}

#fileName {
    display: block;
    margin: 10px auto 0;

    color: #555;

    font-size: 14px;

    text-align: center;

    width: 315px;
    max-width: 90%;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}