:root {
    --sa-bg: #eef3f5;
    --sa-white: #ffffff;
    --sa-accent: #54798c;
    --sa-accent-dark: #3f6274;
    --sa-accent-light: #dce8ee;
    --sa-text: #2d3136;
    --sa-muted: #6f7b85;
    --sa-border: #d7e0e5;
}

.string-art-page {
    min-height: calc(100dvh - 72px);
    padding: 18px 0 32px;
    background:
        radial-gradient(circle at top right, rgba(84, 121, 140, .12), transparent 35%),
        linear-gradient(180deg, #f9fbfc 0%, var(--sa-bg) 100%);
}

.string-art-container {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
}

.string-art-compact-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 14px;
}

.string-art-compact-title h1 {
    margin: 3px 0 0;
    color: var(--sa-text);
    font-size: clamp(26px, 3vw, 38px);
    line-height: 1.1;
}

.string-art-compact-title p {
    max-width: 420px;
    margin: 0;
    color: var(--sa-muted);
    font-size: 14px;
    text-align: right;
}

.string-art-kicker {
    color: var(--sa-accent-dark);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.steps-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 0 14px;
}

.progress-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sa-muted);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.progress-item span {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 1px solid var(--sa-border);
    border-radius: 50%;
    background: #fff;
    font-size: 13px;
    font-weight: 700;
}

.progress-item.active {
    color: var(--sa-accent-dark);
}

.progress-item.active span {
    border-color: var(--sa-accent);
    background: var(--sa-accent);
    color: #fff;
}

.progress-item:focus-visible,
.crop-option:focus-within {
    outline: 3px solid rgba(84, 121, 140, .25);
    outline-offset: 3px;
}

.progress-line {
    width: 74px;
    height: 1px;
    margin: 0 10px;
    background: var(--sa-border);
}

.generator-window {
    min-height: 620px;
    overflow: hidden;
    border: 1px solid var(--sa-border);
    border-radius: 18px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 12px 35px rgba(55, 74, 87, .08);
}

.generator-step {
    display: none;
    min-height: 620px;
    grid-template-columns: minmax(300px, 1fr) 500px;
    grid-template-rows: 1fr auto;
    column-gap: 36px;
    padding: 30px 38px 26px;
    animation: step-fade .22s ease;
}

.generator-step.active-step {
    display: grid;
}

@keyframes step-fade {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

.step-content {
    min-width: 0;
}

.step-heading {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
}

.step-number {
    width: 42px;
    height: 42px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px;
    background: var(--sa-accent-light);
    color: var(--sa-accent-dark);
    font-size: 13px;
    font-weight: 700;
}

.step-heading h2 {
    margin: 0 0 5px;
    color: var(--sa-text);
    font-size: clamp(22px, 2.3vw, 29px);
    line-height: 1.18;
}

.step-heading p {
    margin: 0;
    color: var(--sa-muted);
    font-size: 14px;
}

.file-select {
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--sa-border);
    border-radius: 10px;
    background: #f9fbfc;
    color: var(--sa-text);
    cursor: pointer;
    transition: .2s ease;
}

.file-select:hover {
    border-color: var(--sa-accent);
    background: #fff;
}

.file-select-icon {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: var(--sa-accent-light);
    color: var(--sa-accent-dark);
    font-size: 18px;
    font-weight: 700;
}

.file-select-text {
    font-weight: 700;
}

.file-select-name {
    margin-left: auto;
    overflow: hidden;
    color: var(--sa-muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crop-choice {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 18px 0;
    padding: 0;
    border: 0;
}

.crop-choice legend {
    width: 100%;
    margin-bottom: 9px;
    color: var(--sa-text);
    font-size: 14px;
    font-weight: 700;
}

.crop-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--sa-border);
    border-radius: 9px;
    background: #f9fbfc;
    color: var(--sa-text);
    font-size: 14px;
    cursor: pointer;
}

.crop-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.crop-option-mark {
    width: 15px;
    height: 15px;
    border: 2px solid var(--sa-muted);
    border-radius: 50%;
}

.crop-option input:checked + .crop-option-mark {
    border-color: var(--sa-accent);
    box-shadow: inset 0 0 0 3px #fff;
    background: var(--sa-accent);
}

.range-controls {
    display: grid;
    gap: 13px;
}

.range-control {
    padding: 12px 14px 14px;
    border: 1px solid var(--sa-border);
    border-radius: 10px;
    background: #f9fbfc;
}

.range-label {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--sa-text);
    font-size: 14px;
    font-weight: 700;
}

.range-label output {
    color: var(--sa-accent-dark);
    font-size: 13px;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    margin: 0;
    appearance: none;
    border-radius: 999px;
    background: #d8e0e4;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    width: 17px;
    height: 17px;
    appearance: none;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--sa-accent);
    box-shadow: 0 1px 4px rgba(45, 49, 54, .25);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--sa-accent);
    box-shadow: 0 1px 4px rgba(45, 49, 54, .25);
    cursor: pointer;
}

.parameters-grid,
.generation-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-top: 16px;
}

.number-control {
    display: grid;
    gap: 7px;
    color: var(--sa-text);
    font-size: 14px;
    font-weight: 700;
}

.number-control input {
    min-height: 45px;
    padding: 9px 11px;
    border: 1px solid var(--sa-border);
    border-radius: 9px;
    background: #fff;
    color: var(--sa-text);
    font: inherit;
    outline: none;
}

.number-control input:focus {
    border-color: var(--sa-accent);
    box-shadow: 0 0 0 3px rgba(84, 121, 140, .12);
}

.generation-info div {
    padding: 13px;
    border: 1px solid var(--sa-border);
    border-radius: 10px;
    background: #f9fbfc;
}

.generation-info span {
    display: block;
    margin-bottom: 3px;
    color: var(--sa-muted);
    font-size: 12px;
}

.generation-info strong {
    color: var(--sa-accent-dark);
    font-size: 16px;
}

.preview-column {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.preview-frame {
    position: relative;
    width: 500px;
    height: 500px;
    flex: 0 0 500px;
    overflow: hidden;
    border: 2px solid var(--sa-text);
    border-radius: 50%;
    background:
        linear-gradient(45deg, #f7fafb 25%, transparent 25%) 0 0 / 22px 22px,
        linear-gradient(-45deg, #f7fafb 25%, transparent 25%) 0 0 / 22px 22px,
        #fff;
}

.preview-frame.square-preview {
    border-radius: 12px;
}

.preview-frame::after {
    position: absolute;
    inset: 16px;
    border: 1px dashed rgba(84, 121, 140, .35);
    border-radius: inherit;
    content: "";
    pointer-events: none;
}

.preview-frame.has-image::after {
    display: none;
}

.preview-frame img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    display: none;
    object-fit: cover;
    transform: translate(-50%, -50%);
    transform-origin: center;
}

.preview-frame img.visible {
    display: block;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--sa-muted);
    font-size: 15px;
    text-align: center;
}

.preview-frame.has-image .preview-placeholder,
.preview-placeholder.hidden {
    display: none;
}

.preview-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border: 1px solid var(--sa-border);
    border-radius: 50%;
    background: #fff;
    color: var(--sa-accent);
    font-size: 34px;
}

.step-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 22px;
}

.step-actions-between {
    justify-content: space-between;
}

.step-actions .btn-primary,
.step-actions .btn-outline {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#save-button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

@media (max-width: 1100px) {
    .generator-step {
        grid-template-columns: minmax(280px, 1fr) 440px;
        column-gap: 24px;
        padding: 28px;
    }

    .preview-frame {
        width: 440px;
        height: 440px;
        flex-basis: 440px;
    }
}

@media (max-width: 820px) {
    /* На телефоне не фиксируем высоту: все элементы доступны ниже. */
    .string-art-page {
        min-height: auto;
        padding-bottom: 28px;
    }

    .string-art-container {
        width: min(100% - 28px, 620px);
    }

    .string-art-compact-title {
        display: block;
    }

    .string-art-compact-title p {
        margin-top: 8px;
        text-align: left;
    }

    .generator-window {
        min-height: 0;
        overflow: visible;
    }

    .generator-step,
    .generator-step.active-step {
        min-height: 0;
        display: none;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 20px;
        padding: 20px 15px;
    }

    .generator-step.active-step {
        display: grid;
    }

    .preview-column {
        grid-row: 2;
        width: 100%;
    }

    .preview-frame {
        width: min(500px, calc(100vw - 58px));
        height: min(500px, calc(100vw - 58px));
        flex-basis: auto;
    }

    .step-actions {
        grid-column: auto;
        grid-row: 3;
        margin-top: 0;
    }
}

@media (max-width: 520px) {
    .steps-progress {
        justify-content: space-between;
    }

    .progress-item b {
        display: none;
    }

    .progress-line {
        width: auto;
        flex: 1;
        margin: 0 7px;
    }

    .step-heading {
        margin-bottom: 18px;
    }

    .step-number {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        font-size: 12px;
    }

    .step-heading h2 {
        font-size: 21px;
    }

    .crop-choice {
        flex-wrap: wrap;
        gap: 8px;
    }

    .parameters-grid,
    .generation-info {
        grid-template-columns: 1fr;
    }

    .step-actions-between {
        flex-direction: column-reverse;
    }

    .step-actions .btn-primary,
    .step-actions .btn-outline {
        width: 100%;
    }

    .file-select-name {
        max-width: 120px;
    }
}


