* {
    box-sizing: border-box;
}

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

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: #fff;
    border-bottom: 1px solid #e2e2e2;
}

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

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

    gap: 20px;
}

.logo {
    color: #222;
    text-decoration: none;

    font-size: 22px;
    font-weight: bold;
}

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


/* PAGE */

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

    margin: 30px auto 60px;
}

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

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


/* CARD */

.editor-card {
    padding: 25px;

    background: #fff;

    border-radius: 14px;

    box-shadow:
        0 3px 18px rgba(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: .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: #777;
}

.upload-button {
    display: inline-block;

    padding: 13px 24px;

    background: #236ed8;
    color: #fff;

    border-radius: 7px;

    font-weight: bold;

    cursor: pointer;
}


/* TOOLBAR */

.editor-toolbar {
    display: flex;
    justify-content: space-between;

    gap: 10px;

    margin-bottom: 20px;
}

.secondary-button,
.small-button {
    border: 1px solid #ccc;
    background: #fff;

    border-radius: 6px;
}

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

.small-button {
    padding: 9px 10px;
}

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

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

.notice {
    margin: 0 0 12px;
    padding: 12px;

    border-radius: 7px;

    background: #fff5d8;
    color: #755b00;

    text-align: center;
}

.photo-counter {
    margin-bottom: 25px;
    padding: 10px;

    background: #f6f7f8;

    border-radius: 7px;

    text-align: center;

    color: #666;
}


/* TEMPLATE SECTION */

.control-section {
    margin-bottom: 25px;
}

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

    font-size: 20px;
    text-align: center;
}

.templates {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;

    gap: 10px;
}

.template-button {
    width: 90px;
    height: 70px;

    padding: 5px;

    border: 2px solid #ddd;
    border-radius: 8px;

    background: #fff;
}

.template-button:hover {
    border-color: #8aaee0;
}

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

    box-shadow:
        0 0 0 2px rgba(35, 110, 216, .12);
}

.template-preview {
    position: relative;

    width: 100%;
    height: 100%;

    overflow: hidden;

    background: #eee;

    border-radius: 3px;
}

.template-cell {
    position: absolute;

    background: #aeb8c5;

    border: 1px solid #fff;
}


/* WORKSPACE */

.workspace {
    display: grid;

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

    gap: 25px;

    align-items: start;
}

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

.canvas-wrap {
    width: 100%;

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

    overflow: hidden;

    padding: 15px;

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

    background-size:
        20px 20px;

    background-position:
        0 0,
        0 10px,
        10px -10px,
        -10px 0;

    border-radius: 10px;

    touch-action: none;
}

.canvas-container {
    max-width: 100%;

    touch-action: none;
}

.canvas-container canvas {
    touch-action: none;
}

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

    color: #777;

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

    grid-template-columns:
        1fr 1fr;

    gap: 6px;
}

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

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

    background: #fff;
}

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

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

.selected-photo-panel p {
    margin: 0;

    color: #777;

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

.range-control {
    display: block;

    margin-bottom: 17px;
}

.range-control > span {
    display: flex;
    justify-content: space-between;

    margin-bottom: 7px;

    color: #555;

    font-size: 13px;
}

.range-control input {
    width: 100%;
}


/* PHOTO ACTIONS */

.photo-actions {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 7px;
}

.photo-actions .danger-button {
    grid-column: 1 / -1;
}


/* COLOR */

.color-control {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    font-size: 13px;

    color: #555;
}

.color-control input {
    width: 55px;
    height: 34px;

    border: 0;

    background: transparent;
}


/* EXPORT */

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

    border-top: 1px solid #ddd;
}

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

    margin: auto;

    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 12px;
}

.export-options label {
    color: #555;

    font-size: 13px;
}

.export-options select {
    display: block;

    width: 100%;

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

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

    background: #fff;
}

.download-button {
    display: block;

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

    margin: 16px auto 0;
    padding: 15px;

    border: 0;
    border-radius: 7px;

    background: #16813b;
    color: #fff;

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


/* TEXT */

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

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

    background: #fff;

    border-radius: 10px;
}

.text-content h2 {
    margin-top: 25px;
}

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

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

    line-height: 1.65;
}


/* TABLET */

@media (max-width: 800px) {

    body {
        background: #fff;
    }

    .header-note {
        display: none;
    }

    .page {
        width: 100%;

        margin: 20px 0 0;
    }

    .intro {
        padding: 0 15px;
    }

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

    .editor-card {
        padding: 15px;

        border-radius: 0;

        box-shadow: none;
    }

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

    .settings {
        display: grid;

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

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

    .canvas-wrap {
        padding: 7px;
    }

    .template-button {
        width: 74px;
        height: 58px;
    }

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

        border-radius: 0;
    }

}


/* PHONE */

@media (max-width: 500px) {

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

    .secondary-button {
        width: 100%;
    }

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

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

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

    .upload-box {
        min-height: 230px;
    }

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

}

/* ============================================================
   COMMON INTERACTION / FOCUS
============================================================ */

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

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

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

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: .55;
}

@media (max-width: 800px) {

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

