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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: #09090b;
    color: #f4f4f5;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    line-height: 1.5;
}


/* =========================
   HEADER
========================= */

.tool-header {
    width: 100%;
    min-height: 72px;

    display: flex;
    align-items: center;

    padding: 14px 20px;

    border-bottom: 1px solid #27272a;

    background: #0d0d0f;
}

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

    min-height: 42px;
    padding: 0 16px;

    border: 1px solid #303036;
    border-radius: 10px;

    color: #f4f4f5;
    background: #151518;

    text-decoration: none;

    font-size: 14px;
    font-weight: 600;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.back-button:hover {
    background: #1d1d21;
    border-color: #44444b;
}

.back-button:active {
    transform: scale(0.97);
}

.brand {
    margin-left: 16px;
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.brand-subtitle {
    margin-top: 1px;

    color: #a1a1aa;

    font-size: 12px;
}


/* =========================
   MAIN
========================= */

.container {
    width: min(100% - 30px, 900px);

    margin: 0 auto;

    padding: 35px 0 60px;
}


/* =========================
   HERO
========================= */

.hero {
    text-align: center;

    margin-bottom: 28px;
}

.hero-icon {
    width: 64px;
    height: 64px;

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

    margin: 0 auto 14px;

    border: 1px solid #303036;
    border-radius: 18px;

    background: #111114;

    font-size: 30px;
}

.hero h1 {
    font-size: clamp(28px, 6vw, 40px);
    line-height: 1.15;

    margin-bottom: 10px;
}

.hero p {
    max-width: 620px;

    margin: 0 auto;

    color: #a1a1aa;

    font-size: 15px;
}

.privacy-note {
    display: inline-block;

    margin-top: 13px;

    padding: 7px 12px;

    border: 1px solid #27272a;
    border-radius: 999px;

    color: #d4d4d8;
    background: #111114;

    font-size: 12px;
}


/* =========================
   CARD
========================= */

.tool-card {
    margin-bottom: 18px;

    padding: 22px;

    border: 1px solid #27272a;
    border-radius: 16px;

    background: #101012;

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

.tool-card h2 {
    margin-bottom: 5px;

    font-size: 18px;
}

.tool-card h3 {
    font-size: 15px;
}


/* =========================
   UPLOAD AREA
========================= */

.upload-area {
    min-height: 270px;

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

    padding: 30px 20px;

    border: 1.5px dashed #3f3f46;
    border-radius: 14px;

    background: #0c0c0e;

    text-align: center;

    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        transform 0.2s ease;
}

.upload-area.drag-over {
    border-color: #71717a;
    background: #151518;

    transform: scale(1.01);
}

.upload-icon {
    margin-bottom: 12px;

    font-size: 42px;
}

.upload-area h2 {
    margin-bottom: 7px;

    font-size: 20px;
}

.upload-area p {
    color: #a1a1aa;

    font-size: 13px;
}

.upload-help {
    margin-top: 14px;

    color: #71717a !important;

    font-size: 12px !important;
}


/* =========================
   BUTTONS
========================= */

button {
    font-family: inherit;

    cursor: pointer;
}

.primary-button,
.secondary-button,
.download-button,
.convert-button {
    border-radius: 10px;

    font-weight: 600;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease,
        opacity 0.2s ease;
}

.primary-button {
    min-height: 44px;

    margin-top: 18px;

    padding: 0 20px;

    border: 1px solid #52525b;

    color: #fafafa;
    background: #27272a;

    font-size: 14px;
}

.primary-button:hover {
    background: #3f3f46;
}

.secondary-button {
    min-height: 40px;

    padding: 0 14px;

    border: 1px solid #303036;

    color: #e4e4e7;
    background: #17171a;

    font-size: 13px;
}

.secondary-button:hover {
    background: #222225;
    border-color: #45454d;
}

.download-button {
    min-height: 44px;

    padding: 0 15px;

    border: 1px solid #303036;

    color: #f4f4f5;
    background: #17171a;

    font-size: 13px;
}

.download-button:hover:not(:disabled) {
    background: #242428;
    border-color: #52525b;
}

.convert-button {
    width: 100%;
    min-height: 52px;

    border: 1px solid #52525b;

    color: #ffffff;
    background: #27272a;

    font-size: 15px;
}

.convert-button:hover:not(:disabled) {
    background: #3f3f46;
}

button:active:not(:disabled) {
    transform: scale(0.98);
}

button:disabled {
    cursor: not-allowed;

    opacity: 0.4;
}


/* =========================
   FILE SECTION
========================= */

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    margin-bottom: 18px;
}

.section-heading p {
    margin-top: 3px;

    color: #71717a;

    font-size: 12px;
}


/* =========================
   IMAGE LIST
========================= */

.image-list {
    display: grid;

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

    gap: 12px;
}

.image-item {
    overflow: hidden;

    border: 1px solid #27272a;
    border-radius: 12px;

    background: #0c0c0e;
}

.image-preview {
    width: 100%;
    height: 140px;

    display: block;

    object-fit: contain;

    background:
        linear-gradient(
            45deg,
            #18181b 25%,
            transparent 25%
        ),
        linear-gradient(
            -45deg,
            #18181b 25%,
            transparent 25%
        ),
        linear-gradient(
            45deg,
            transparent 75%,
            #18181b 75%
        ),
        linear-gradient(
            -45deg,
            transparent 75%,
            #18181b 75%
        );

    background-size: 18px 18px;

    background-position:
        0 0,
        0 9px,
        9px -9px,
        -9px 0;
}

.image-item-info {
    padding: 10px;
}

.image-item-name {
    overflow: hidden;

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

    color: #e4e4e7;

    font-size: 13px;
    font-weight: 600;
}

.image-item-size {
    margin-top: 3px;

    color: #71717a;

    font-size: 11px;
}


/* =========================
   SETTINGS
========================= */

.settings-grid {
    display: grid;

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

    gap: 18px;

    margin-top: 18px;
}

.setting-group {
    min-width: 0;
}

.setting-group label {
    display: block;

    margin-bottom: 8px;

    color: #d4d4d8;

    font-size: 13px;
    font-weight: 600;
}

.select-input {
    width: 100%;
    height: 44px;

    padding: 0 12px;

    border: 1px solid #303036;
    border-radius: 10px;

    outline: none;

    color: #f4f4f5;
    background: #17171a;

    font-family: inherit;
    font-size: 13px;
}

.select-input:focus {
    border-color: #52525b;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.label-row label {
    margin-bottom: 0;
}

#qualityValue {
    color: #a1a1aa;

    font-size: 12px;
}

input[type="range"] {
    width: 100%;

    margin-top: 13px;

    accent-color: #a1a1aa;
}

.setting-help {
    margin-top: 7px;

    color: #71717a;

    font-size: 11px;
}


/* =========================
   ACTION
========================= */

.action-section {
    margin: 20px 0;
}


/* =========================
   PROGRESS
========================= */

.progress-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 10px;

    color: #d4d4d8;

    font-size: 13px;
}

.progress-track {
    width: 100%;
    height: 8px;

    overflow: hidden;

    border-radius: 999px;

    background: #27272a;
}

.progress-bar {
    width: 0;
    height: 100%;

    border-radius: inherit;

    background: #a1a1aa;

    transition: width 0.2s ease;
}


/* =========================
   SELECTION CONTROLS
========================= */

.selection-controls {
    display: flex;
    flex-wrap: wrap;

    gap: 8px;

    margin-bottom: 12px;
}


/* =========================
   DOWNLOAD GRID
========================= */

.download-grid {
    display: grid;

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

    gap: 10px;

    margin-bottom: 20px;
}


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

.results-container {
    display: grid;

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

    gap: 14px;
}

.result-card {
    overflow: hidden;

    border: 1px solid #27272a;
    border-radius: 14px;

    background: #0c0c0e;
}

.result-image {
    width: 100%;
    height: 180px;

    display: block;

    object-fit: contain;

    background:
        linear-gradient(
            45deg,
            #18181b 25%,
            transparent 25%
        ),
        linear-gradient(
            -45deg,
            #18181b 25%,
            transparent 25%
        ),
        linear-gradient(
            45deg,
            transparent 75%,
            #18181b 75%
        ),
        linear-gradient(
            -45deg,
            transparent 75%,
            #18181b 75%
        );

    background-size: 18px 18px;

    background-position:
        0 0,
        0 9px,
        9px -9px,
        -9px 0;
}

.result-content {
    padding: 12px;
}

.result-top {
    display: flex;
    align-items: flex-start;

    gap: 10px;
}

.result-checkbox {
    width: 18px;
    height: 18px;

    flex-shrink: 0;

    margin-top: 2px;

    accent-color: #a1a1aa;
}

.result-name {
    overflow: hidden;

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

    color: #f4f4f5;

    font-size: 13px;
    font-weight: 600;
}

.result-size {
    margin-top: 4px;

    color: #71717a;

    font-size: 11px;
}

.result-download {
    width: 100%;

    min-height: 38px;

    margin-top: 12px;

    border: 1px solid #303036;
    border-radius: 9px;

    color: #e4e4e7;
    background: #17171a;

    font-size: 12px;
    font-weight: 600;
}

.result-download:hover {
    background: #242428;
}


/* =========================
   FOOTER
========================= */

.tool-footer {
    padding: 30px 20px 40px;

    border-top: 1px solid #1f1f23;

    text-align: center;
}

.tool-footer p {
    color: #d4d4d8;

    font-size: 13px;
    font-weight: 600;
}

.tool-footer span {
    display: block;

    margin-top: 4px;

    color: #52525b;

    font-size: 11px;
}


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

@media (max-width: 650px) {

    .tool-header {
        padding: 12px 14px;
    }

    .brand {
        margin-left: 11px;
    }

    .brand-name {
        font-size: 15px;
    }

    .brand-subtitle {
        font-size: 11px;
    }

    .container {
        width: min(100% - 20px, 900px);

        padding-top: 25px;
    }

    .hero {
        margin-bottom: 22px;
    }

    .hero h1 {
        font-size: 29px;
    }

    .hero p {
        font-size: 13px;
    }

    .tool-card {
        padding: 16px;

        border-radius: 14px;
    }

    .upload-area {
        min-height: 235px;

        padding: 25px 15px;
    }

    .settings-grid {
        grid-template-columns: 1fr;

        gap: 16px;
    }

    .download-grid {
        grid-template-columns: 1fr;
    }

    .image-list {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .results-container {
        grid-template-columns: 1fr;
    }

    .result-image {
        height: 210px;
    }

    .section-heading {
        align-items: flex-start;
    }

    .section-heading .secondary-button {
        flex-shrink: 0;
    }
}


/* =========================
   VERY SMALL SCREENS
========================= */

@media (max-width: 380px) {

    .back-button {
        min-height: 38px;

        padding: 0 11px;

        font-size: 12px;
    }

    .brand-name {
        font-size: 14px;
    }

    .hero h1 {
        font-size: 26px;
    }

    .image-list {
        grid-template-columns: 1fr;
    }

    .selection-controls {
        flex-direction: column;
    }

    .selection-controls button {
        width: 100%;
    }
}