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

    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;

    background: #236ed8;
    color: #ffffff;

    border-radius: 7px;

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


/* ============================================================
   CROP AREA
============================================================ */

.crop-wrap {
    position: relative;

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

    overflow: hidden;

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

    border-radius: 10px;

    user-select: none;
    -webkit-user-select: none;

    touch-action: none;
}

#cropCanvas {
    position: absolute;

    left: 0;
    top: 0;

    width: 100%;
    height: 100%;

    display: block;

    touch-action: none;
}


/* ============================================================
   CROP OVERLAY
============================================================ */

.crop-overlay {
    position: absolute;

    left: 0;
    top: 0;

    width: 100%;
    height: 100%;

    overflow: hidden;

    touch-action: none;
}

.crop-box {
    position: absolute;

    left: 10%;
    top: 10%;

    width: 80%;
    height: 80%;

    border: 2px solid #ffffff;

    box-shadow:
        0 0 0 9999px
        rgba(0, 0, 0, 0.55);

    cursor: move;

    touch-action: none;
}


/* ============================================================
   CROP GRID
============================================================ */

.crop-grid {
    position: absolute;

    inset: 0;

    pointer-events: none;
}

.crop-grid span,
.crop-grid i {
    position: absolute;

    display: block;

    background:
        rgba(255, 255, 255, 0.45);
}

.crop-grid span {
    top: 0;

    width: 1px;
    height: 100%;
}

.crop-grid span:nth-child(1) {
    left: 33.3333%;
}

.crop-grid span:nth-child(2) {
    left: 66.6666%;
}

.crop-grid i {
    left: 0;

    width: 100%;
    height: 1px;
}

.crop-grid i:nth-child(3) {
    top: 33.3333%;
}

.crop-grid i:nth-child(4) {
    top: 66.6666%;
}


/* ============================================================
   CROP HANDLES
============================================================ */

.crop-handle {
    position: absolute;

    width: 28px;
    height: 28px;

    padding: 0;

    border: 0;

    background: transparent;

    touch-action: none;

    z-index: 5;
}

.crop-handle::before {
    content: "";

    position: absolute;

    width: 14px;
    height: 14px;

    border-color: #ffffff;
    border-style: solid;
}

.crop-handle-nw {
    left: -14px;
    top: -14px;

    cursor: nwse-resize;
}

.crop-handle-nw::before {
    right: 0;
    bottom: 0;

    border-width: 3px 0 0 3px;
}

.crop-handle-ne {
    right: -14px;
    top: -14px;

    cursor: nesw-resize;
}

.crop-handle-ne::before {
    left: 0;
    bottom: 0;

    border-width: 3px 3px 0 0;
}

.crop-handle-sw {
    left: -14px;
    bottom: -14px;

    cursor: nesw-resize;
}

.crop-handle-sw::before {
    right: 0;
    top: 0;

    border-width: 0 0 3px 3px;
}

.crop-handle-se {
    right: -14px;
    bottom: -14px;

    cursor: nwse-resize;
}

.crop-handle-se::before {
    left: 0;
    top: 0;

    border-width: 0 3px 3px 0;
}


/* ============================================================
   CANVAS HELP
============================================================ */

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

    background: #f6f7f8;

    border-radius: 9px;
}

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

    font-size: 15px;
}


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

.ratio-buttons {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 6px;
}

.ratio-buttons button {
    padding: 8px 5px;

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

    background: #ffffff;
    color: #333333;
}

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

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

    background: #edf4ff;

    color: #236ed8;
}


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

.range-control {
    display: block;
}

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

    display: flex;
    justify-content: space-between;
    gap: 10px;

    color: #555555;

    font-size: 13px;
}

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


/* ============================================================
   PHOTO ACTIONS
============================================================ */

.photo-actions {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 7px;
}

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

    padding: 8px 7px;

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

    background: #ffffff;
    color: #333333;

    font-size: 12px;

    line-height: 1.25;
}

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

    color: #236ed8;
}


/* ============================================================
   CROP SIZE
============================================================ */

.crop-size-info {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 8px;
}

.crop-size-info > div {
    padding: 10px 7px;

    background: #ffffff;

    border-radius: 7px;

    text-align: center;
}

.crop-size-info span {
    display: block;

    margin-bottom: 5px;

    color: #777777;

    font-size: 11px;
}

.crop-size-info strong {
    display: block;

    font-size: 14px;
}


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

.export-options {
    width: 100%;
    max-width: 500px;

    margin: 0 auto;

    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 12px;
}

.export-options label {
    color: #555555;

    font-size: 13px;
}

.export-options select {
    width: 100%;

    margin-top: 7px;
    padding: 10px;

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

    background: #ffffff;

    color: #333333;
}

.export-options label.disabled {
    opacity: 0.45;
}

.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 {
    background: #116c30;
}


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

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

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

    background: #ffffff;

    border-radius: 10px;
}

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


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

        border-radius: 7px;
    }


    .settings {
        display: grid;

        grid-template-columns:
            1fr
            1fr;

        gap: 10px;
    }


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


    .crop-handle {
        width: 36px;
        height: 36px;
    }


    .crop-handle::before {
        width: 17px;
        height: 17px;
    }


    .crop-handle-nw {
        left: -18px;
        top: -18px;
    }


    .crop-handle-ne {
        right: -18px;
        top: -18px;
    }


    .crop-handle-sw {
        left: -18px;
        bottom: -18px;
    }


    .crop-handle-se {
        right: -18px;
        bottom: -18px;
    }


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


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


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


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


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


    .settings-block {
        padding: 13px;
    }


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


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


    .small-button {
        min-height: 43px;

        font-size: 12px;
    }


    .export-options {
        grid-template-columns:
            1fr;
    }


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


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


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

}


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

@media (max-width: 360px) {

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


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


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

}