/* ============================================================
   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: 760px;
    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%;

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

    background: #edf3fc;
    color: #236ed8;

    font-size: 34px;
    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;
    align-items: center;
    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;
}

.secondary-button.danger:hover {
    border-color: #c44b4b;
}


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

.workspace {
    display: grid;

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

    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);
}


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

.image-info {
    margin-top: 11px;

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

    gap: 8px 20px;

    color: #777777;

    font-size: 12px;
}

.image-info strong {
    color: #444444;
}


/* ============================================================
   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;
}

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

    gap: 10px;
}

.settings-heading-row h3 {
    margin: 0;
}


/* ============================================================
   QUICK ROTATION
============================================================ */

.rotation-actions {
    display: grid;

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

    gap: 7px;
}

.action-button {
    min-width: 0;
    min-height: 70px;

    padding: 9px 5px;

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

    background: #ffffff;
    color: #333333;

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

    gap: 5px;

    text-align: center;

    font-size: 11px;

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

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

    background: #f8fbff;

    color: #236ed8;
}

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

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

    background: #edf4ff;
    color: #236ed8;
}

.action-icon {
    display: block;

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


/* ============================================================
   FLIP
============================================================ */

.flip-actions {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 7px;
}

.flip-actions .action-button {
    min-height: 67px;
}

.flip-icon {
    display: block;

    font-size: 25px;
    font-weight: 700;
    line-height: 1;
}

.flip-icon.horizontal {
    letter-spacing: -3px;
}

.flip-icon.vertical {
    line-height: 0.9;
}


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

.range-control {
    display: block;

    margin-top: 14px;
}

.range-control:first-child {
    margin-top: 0;
}

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

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

    gap: 10px;

    color: #555555;

    font-size: 13px;
}

.range-control strong {
    color: #333333;
}

.range-control input[type="range"] {
    display: block;

    width: 100%;

    margin: 0;

    accent-color: #236ed8;
}


/* ============================================================
   MINI BUTTON
============================================================ */

.mini-button {
    padding: 5px 8px;

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

    background: #ffffff;
    color: #555555;

    font-size: 11px;
}

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


/* ============================================================
   ANGLE INPUT
============================================================ */

.angle-input-row {
    margin-top: 12px;

    display: grid;

    grid-template-columns:
        90px
        1fr;

    align-items: center;

    gap: 8px;
}

.angle-input-row input {
    width: 100%;

    padding: 8px 9px;

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

    background: #ffffff;
    color: #333333;

    text-align: center;
}

.angle-input-row input:focus {
    border-color: #236ed8;
    outline: none;
}

.angle-input-row span {
    color: #777777;
    font-size: 12px;
}


/* ============================================================
   ANGLE PRESETS
============================================================ */

.angle-presets {
    margin-top: 11px;

    display: grid;

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

    gap: 5px;
}

.angle-presets button {
    min-width: 0;

    padding: 7px 2px;

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

    background: #ffffff;
    color: #444444;

    font-size: 11px;
}

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

.angle-presets button.active {
    border-color: #236ed8;

    background: #edf4ff;
    color: #236ed8;
}


/* ============================================================
   RADIO OPTIONS
============================================================ */

.radio-option {
    padding: 10px;

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

    background: #ffffff;

    display: flex;
    align-items: flex-start;

    gap: 9px;

    cursor: pointer;
}

.radio-option + .radio-option {
    margin-top: 8px;
}

.radio-option:hover {
    border-color: #b5c9e8;
}

.radio-option:has(input:checked) {
    border-color: #236ed8;
    background: #f7faff;
}

.radio-option input {
    width: 17px;
    height: 17px;

    margin: 1px 0 0;

    flex: 0 0 auto;

    accent-color: #236ed8;
}

.radio-option > span {
    min-width: 0;

    display: block;
}

.radio-option strong {
    display: block;

    color: #333333;

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

.radio-option small {
    display: block;

    margin-top: 4px;

    color: #777777;

    font-size: 10px;
    line-height: 1.4;
}


/* ============================================================
   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;
}


/* ============================================================
   CUSTOM BACKGROUND
============================================================ */

.custom-background {
    margin-top: 10px;

    display: grid;

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

    gap: 7px;
}

.custom-background input[type="color"] {
    width: 44px;
    height: 39px;

    padding: 2px;

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

    background: #ffffff;

    cursor: pointer;
}

.custom-background input[type="text"] {
    min-width: 0;
    width: 100%;

    padding: 9px;

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

    background: #ffffff;

    font-family:
        Consolas,
        Monaco,
        monospace;

    font-size: 12px;
}

.custom-background input[type="text"]:focus {
    border-color: #236ed8;
    outline: none;
}


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

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

    color: #777777;

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


/* ============================================================
   RESET TRANSFORM
============================================================ */

.reset-transform-button {
    display: block;

    width: 100%;

    padding: 10px;

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

    background: #ffffff;
    color: #555555;

    font-size: 12px;
}

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


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

.export-quality {
    margin-top: 15px;
}


/* ============================================================
   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;
    line-height: 1.5;
}

.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;
}

.download-button:disabled {
    cursor: wait;
    opacity: 0.65;
}


/* ============================================================
   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;
}


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

button:disabled,
input:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}


/* ============================================================
   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;
}


/* ============================================================
   FALLBACK FOR :has()
============================================================ */

@supports not selector(:has(*)) {

    .radio-option {
        transition:
            border-color 0.15s,
            background 0.15s;
    }

}


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

@media (max-width: 950px) {

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

        gap: 15px;
    }


    .rotation-actions {
        grid-template-columns:
            1fr
            1fr;
    }


    .rotation-actions
    .action-button:last-child {
        grid-column:
            1 /
            -1;
    }

}


/* ============================================================
   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 {
        min-width: 0;
    }


    .export-section {
        margin-top: 24px;
    }


    .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 {
        display: grid;

        grid-template-columns:
            1fr
            1fr;
    }


    .editor-toolbar 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;
    }


    .image-info {
        flex-direction: column;

        gap: 4px;
    }


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


    .settings-block {
        padding: 13px;
    }


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


    .rotation-actions
    .action-button:last-child {
        grid-column: auto;
    }


    .action-button {
        min-height: 68px;

        font-size: 10px;
    }


    .action-icon {
        font-size: 25px;
    }


    .angle-presets {
        gap: 4px;
    }


    .angle-presets button {
        padding:
            7px
            1px;

        font-size: 10px;
    }


    .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;
    }


    .editor-toolbar {
        grid-template-columns:
            1fr;
    }


    .rotation-actions {
        grid-template-columns:
            1fr
            1fr;
    }


    .rotation-actions
    .action-button:last-child {
        grid-column:
            1 /
            -1;
    }


    .flip-actions {
        grid-template-columns:
            1fr;
    }


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


    .angle-presets
    button:nth-child(4),
    .angle-presets
    button:nth-child(5) {
        grid-column: auto;
    }

}