/* ============================================================
   BASE
============================================================ */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: #f4f5f7;
    color: #242424;
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}


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

.site-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e2e2;
}

.header-inner {
    width: calc(100% - 30px);
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo {
    color: #222222;
    text-decoration: none;
    font-size: 22px;
    font-weight: 700;
}

.header-note {
    color: #777777;
    font-size: 13px;
}


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

.page {
    width: calc(100% - 30px);
    max-width: 1180px;
    margin: 30px auto 60px;
}


/* ============================================================
   INTRO
============================================================ */

.intro {
    margin-bottom: 20px;
    text-align: center;
}

.intro h1 {
    margin: 0 0 12px;
    font-size: 32px;
}

.intro p {
    max-width: 720px;
    margin: 7px auto;

    color: #5e5e5e;

    line-height: 1.55;
}

.privacy-note {
    font-size: 13px;
}


/* ============================================================
   TOOLS NAVIGATION
============================================================ */

.tools-nav {
    margin: 0 0 20px;

    display: flex;
    flex-wrap: wrap;
    justify-content: center;

    gap: 7px;
}

.tool-link {
    padding: 8px 12px;

    border: 1px solid #d7d7d7;
    border-radius: 7px;

    background: #ffffff;

    color: #444444;
    text-decoration: none;

    font-size: 13px;

    transition:
        border-color 0.15s,
        background 0.15s,
        color 0.15s;
}

.tool-link:hover {
    border-color: #236ed8;
    color: #236ed8;
}

.tool-link.active {
    border-color: #236ed8;

    background: #edf4ff;

    color: #236ed8;
}


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

.editor-card {
    padding: 25px;

    background: #ffffff;

    border-radius: 14px;

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


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

.upload-box {
    min-height: 300px;

    padding: 25px;

    border: 3px dashed #c6c6c6;
    border-radius: 12px;

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

    gap: 12px;

    text-align: center;

    transition:
        border-color 0.15s,
        background 0.15s;
}

.upload-box.drag {
    border-color: #236ed8;
    background: #f4f8ff;
}

.upload-icon {
    width: 55px;
    height: 55px;

    border-radius: 50%;

    background: #edf3fc;
    color: #236ed8;

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

    font-size: 35px;
    line-height: 1;
}

.upload-box strong {
    font-size: 21px;
}

.upload-box span,
.upload-box small {
    color: #777777;
}

.upload-button {
    display: inline-block;

    padding: 13px 24px;

    border-radius: 7px;

    background: #236ed8;
    color: #ffffff;

    font-weight: 700;

    cursor: pointer;

    transition:
        background 0.15s,
        transform 0.05s;
}

.upload-button:hover {
    background: #185fbe;
}

.upload-button:active {
    transform: translateY(1px);
}


/* ============================================================
   EDITOR TOOLBAR
============================================================ */

.editor-toolbar {
    margin-bottom: 20px;

    display: flex;
    justify-content: space-between;

    gap: 10px;
}

.secondary-button {
    padding: 10px 15px;

    border: 1px solid #cccccc;
    border-radius: 6px;

    background: #ffffff;
    color: #333333;
}

.secondary-button:hover {
    border-color: #236ed8;
}

.secondary-button.danger {
    color: #a42a2a;
}

.full-button {
    width: 100%;
}


/* ============================================================
   WORKSPACE
============================================================ */

.workspace {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        290px;

    gap: 25px;

    align-items: start;
}

.canvas-column {
    min-width: 0;
}


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

.preview-wrap {
    position: relative;

    width: 100%;
    height: min(68vw, 700px);
    min-height: 500px;

    padding: 25px;

    overflow: hidden;

    border-radius: 10px;

    background:
        repeating-conic-gradient(
            #e7e7e7 0% 25%,
            #f5f5f5 0% 50%
        )
        50% / 24px 24px;

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

#previewCanvas {
    display: block;

    max-width: 100%;
    max-height: 100%;

    background: transparent;

    box-shadow:
        0 2px 14px
        rgba(0, 0, 0, 0.18);
}

.canvas-help {
    margin: 10px 0 0;

    color: #777777;

    text-align: center;

    font-size: 12px;
    line-height: 1.5;
}


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

.settings {
    display: flex;
    flex-direction: column;

    gap: 12px;
}

.settings-block {
    padding: 15px;

    border-radius: 9px;

    background: #f6f7f8;
}

.settings-block h3 {
    margin: 0 0 13px;

    font-size: 15px;
}


/* ============================================================
   IMAGE INFO
============================================================ */

.image-info {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 8px;
}

.image-info > div {
    min-width: 0;

    padding: 10px 7px;

    border-radius: 7px;

    background: #ffffff;

    text-align: center;
}

.image-info > div:first-child {
    grid-column:
        1 /
        -1;
}

.image-info span {
    display: block;

    margin-bottom: 5px;

    color: #777777;

    font-size: 11px;
}

.image-info strong {
    display: block;

    overflow: hidden;

    font-size: 13px;

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


/* ============================================================
   SELECT
============================================================ */

.full-select {
    display: block;

    width: 100%;

    padding: 10px;

    border: 1px solid #cccccc;
    border-radius: 6px;

    background: #ffffff;
    color: #333333;
}

.full-select:hover {
    border-color: #aaaaaa;
}

.full-select:focus {
    border-color: #236ed8;
    outline: none;
}


/* ============================================================
   SETTING HINT
============================================================ */

.setting-hint {
    margin: 10px 0 0;

    color: #777777;

    font-size: 11px;
    line-height: 1.45;
}


/* ============================================================
   QUALITY RANGE
============================================================ */

.range-control {
    display: block;
}

.range-control > span {
    margin-bottom: 8px;

    display: flex;
    justify-content: space-between;

    gap: 10px;

    color: #555555;

    font-size: 13px;
}

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

    margin: 0;
}


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

.quality-buttons {
    margin-top: 12px;

    display: grid;

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

    gap: 6px;
}

.quality-buttons button {
    padding: 8px 4px;

    border: 1px solid #cccccc;
    border-radius: 5px;

    background: #ffffff;
    color: #333333;

    font-size: 12px;
}

.quality-buttons button:hover {
    border-color: #236ed8;
}

.quality-buttons button.active {
    border-color: #236ed8;

    background: #edf4ff;

    color: #236ed8;
}


/* ============================================================
   DISABLED QUALITY
============================================================ */

#qualityBlock.disabled {
    opacity: 0.55;
}

#qualityBlock.disabled
input[type="range"],
#qualityBlock.disabled
.quality-buttons button {
    cursor: not-allowed;
}


/* ============================================================
   RESULT SUMMARY
============================================================ */

.result-summary {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        25px
        minmax(0, 1fr);

    align-items: center;

    gap: 4px;
}

.result-summary > div:not(.result-arrow) {
    min-width: 0;

    padding: 10px 5px;

    border-radius: 7px;

    background: #ffffff;

    text-align: center;
}

.result-summary span {
    display: block;

    margin-bottom: 5px;

    color: #777777;

    font-size: 11px;
}

.result-summary strong {
    display: block;

    overflow: hidden;

    font-size: 13px;

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

.result-arrow {
    color: #888888;

    text-align: center;

    font-size: 17px;
}


/* ============================================================
   SAVING
============================================================ */

.saving-box {
    margin-top: 8px;
    padding: 10px;

    border-radius: 7px;

    background: #ffffff;

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

    gap: 10px;
}

.saving-box span {
    color: #777777;

    font-size: 12px;
}

.saving-box strong {
    color: #16813b;

    font-size: 14px;
}

.saving-box.no-saving strong {
    color: #a42a2a;
}


/* ============================================================
   RESULT STATUS
============================================================ */

.result-status {
    min-height: 31px;
}


/* ============================================================
   PROCESSING
============================================================ */

.settings.processing {
    pointer-events: none;
}

.settings.processing::after {
    content: "";
}

.download-button:disabled {
    cursor: wait;

    opacity: 0.65;
}


/* ============================================================
   EXPORT
============================================================ */

.export-section {
    margin-top: 30px;
    padding-top: 25px;

    border-top: 1px solid #dddddd;
}

.export-section h2 {
    margin: 0 0 14px;

    text-align: center;

    font-size: 20px;
}

.result-info {
    min-height: 18px;

    margin: 10px auto 0;

    color: #777777;

    text-align: center;

    font-size: 12px;
}

.download-button {
    display: block;

    width: 100%;
    max-width: 500px;

    margin: 16px auto 0;

    padding: 15px;

    border: 0;
    border-radius: 7px;

    background: #16813b;
    color: #ffffff;

    font-size: 17px;
    font-weight: 700;
}

.download-button:hover:not(:disabled) {
    background: #116c30;
}


/* ============================================================
   TEXT CONTENT
============================================================ */

.text-content {
    width: 100%;
    max-width: 850px;

    margin: 35px auto 0;
    padding: 25px;

    border-radius: 10px;

    background: #ffffff;
}

.text-content h2 {
    margin: 25px 0 10px;

    font-size: 22px;
}

.text-content h2:first-child {
    margin-top: 0;
}

.text-content p,
.text-content li {
    color: #555555;

    line-height: 1.65;
}

.text-content ol {
    padding-left: 22px;
}


/* ============================================================
   FOCUS
============================================================ */

button:focus-visible,
select:focus-visible,
input:focus-visible,
.upload-button:focus-visible,
.tool-link:focus-visible {
    outline: 2px solid #236ed8;
    outline-offset: 2px;
}


/* ============================================================
   TABLET
============================================================ */

@media (max-width: 900px) {

    .workspace {
        grid-template-columns:
            minmax(0, 1fr)
            250px;

        gap: 15px;
    }

}


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

@media (max-width: 800px) {

    body {
        background: #ffffff;
    }


    .header-inner {
        padding: 13px 0;
    }


    .header-note {
        display: none;
    }


    .page {
        width: 100%;

        margin:
            20px
            0
            0;
    }


    .intro {
        padding:
            0
            15px;
    }


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


    .tools-nav {
        padding:
            0
            15px;

        justify-content: flex-start;

        flex-wrap: nowrap;

        overflow-x: auto;

        -webkit-overflow-scrolling: touch;

        scrollbar-width: thin;
    }


    .tool-link {
        flex: 0 0 auto;

        white-space: nowrap;
    }


    .editor-card {
        padding: 15px;

        border-radius: 0;

        box-shadow: none;
    }


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

        gap: 18px;
    }


    .preview-wrap {
        height: min(105vw, 620px);
        min-height: 420px;

        padding: 18px;

        border-radius: 7px;
    }


    .settings {
        display: grid;

        grid-template-columns:
            1fr
            1fr;

        gap: 10px;
    }


    .settings-block:last-child {
        grid-column:
            1 /
            -1;
    }


    .text-content {
        margin-top: 20px;

        border-radius: 0;
    }

}


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

@media (max-width: 520px) {

    .page {
        margin-top: 16px;
    }


    .intro {
        margin-bottom: 16px;
    }


    .intro h1 {
        font-size: 24px;
    }


    .intro p {
        font-size: 14px;
    }


    .editor-card {
        padding: 12px;
    }


    .editor-toolbar {
        flex-direction: column;
    }


    .secondary-button {
        width: 100%;
    }


    .upload-box {
        min-height: 240px;

        padding:
            25px
            15px;
    }


    .upload-box strong {
        font-size: 19px;
    }


    .preview-wrap {
        height: min(112vw, 520px);
        min-height: 330px;

        padding: 12px;
    }


    .canvas-help {
        padding:
            0
            5px;
    }


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


    .settings-block:last-child {
        grid-column: auto;
    }


    .settings-block {
        padding: 13px;
    }


    .quality-buttons {
        grid-template-columns:
            repeat(3, 1fr);
    }


    .download-button {
        font-size: 16px;
    }


    .text-content {
        padding:
            20px
            16px;
    }


    .text-content h2 {
        font-size: 20px;
    }

}


/* ============================================================
   VERY SMALL MOBILE
============================================================ */

@media (max-width: 360px) {

    .preview-wrap {
        min-height: 290px;
    }


    .quality-buttons {
        grid-template-columns:
            1fr
            1fr;
    }


    .result-summary {
        grid-template-columns:
            1fr;
    }


    .result-arrow {
        transform: rotate(90deg);
    }

}