:root {
    --im-accent: #6658ff;
    --im-accent-2: #fc6432;
    --im-text: #111216;
    --im-muted: #60656f;
    --im-border: #e7e8ed;
    --im-soft: #f7f7fb;
    --im-panel: #ffffff;
    --im-dark: #101119;
    --im-error: #d89400;
}

body.image-maker-page {
    background:
        radial-gradient(circle at 10% 0%, rgba(102, 88, 255, 0.12), transparent 30%),
        radial-gradient(circle at 95% 12%, rgba(252, 100, 50, 0.1), transparent 28%),
        #ffffff;
    color: var(--im-text);
}

.im-shell {
    max-width: 1180px;
}

.im-main {
    padding-top: 24px;
    padding-bottom: 24px;
}

.im-hero {
    display: grid;
    gap: 10px;
    max-width: 820px;
    margin-bottom: 22px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--im-border);
}

.im-eyebrow {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 9px;
    margin: 0;
    color: var(--im-muted);
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.status-dot--purple {
    background-color: var(--im-accent);
    box-shadow: 0 0 0 5px rgba(102, 88, 255, 0.12);
}

.im-title {
    margin: 0;
    color: var(--im-text);
    font-family: 'Hanken Grotesk', sans-serif;
    font-size: clamp(48px, 8vw, 92px);
    font-weight: 900;
    line-height: 0.88;
    letter-spacing: 0;
}

.im-subtitle {
    max-width: 560px;
    margin: 0;
    color: var(--im-muted);
    font-size: 15px;
    line-height: 1.6;
}

.im-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 0.86fr);
    gap: 22px;
    align-items: start;
}

.im-control-panel,
.im-output-panel {
    min-width: 0;
}

.im-output-panel {
    position: sticky;
    top: 92px;
}

.im-section {
    margin-bottom: 18px;
    animation: fadeIn 0.35s ease-out;
}

.im-section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.im-step {
    margin: 0;
    color: var(--im-accent);
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.im-section-title {
    margin: 0;
    color: var(--im-text);
    font-family: 'Hanken Grotesk', sans-serif;
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
}

.im-template-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.im-tpl-card {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 78px;
    padding: 12px;
    border: 1px solid var(--im-border);
    border-radius: 8px;
    background: var(--im-panel);
    color: var(--im-text);
    cursor: pointer;
    text-align: left;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.im-tpl-card:hover {
    border-color: rgba(102, 88, 255, 0.34);
    box-shadow: 0 10px 28px rgba(17, 18, 22, 0.06);
    transform: translateY(-1px);
}

.im-tpl-card.active {
    border-color: var(--im-accent);
    background: rgba(102, 88, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(102, 88, 255, 0.2);
}

.im-tpl-icon {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(102, 88, 255, 0.14);
    border-radius: 8px;
    background: rgba(102, 88, 255, 0.08);
    color: var(--im-accent);
    font-size: 17px;
}

.im-tpl-card.active .im-tpl-icon {
    background: var(--im-accent);
    color: #ffffff;
}

.im-tpl-info {
    min-width: 0;
}

.im-tpl-info h3 {
    overflow: hidden;
    margin: 0 0 6px;
    color: inherit;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.im-tpl-badge {
    display: inline-flex;
    min-height: 20px;
    align-items: center;
    padding: 0 8px;
    border-radius: 999px;
    background: #f0f1f5;
    color: var(--im-muted);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
}

.im-card {
    border: 1px solid var(--im-border);
    border-radius: 8px;
    background: var(--im-panel);
    box-shadow: 0 12px 32px rgba(17, 18, 22, 0.05);
}

.im-form {
    padding: 16px;
}

.im-form-fields {
    display: grid;
    gap: 14px;
    margin-bottom: 16px;
}

.im-field {
    display: grid;
    gap: 8px;
}

.im-field label {
    color: var(--im-text);
    font-size: 13px;
    font-weight: 900;
}

.im-field input[type="text"] {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--im-border);
    border-radius: 8px;
    background: var(--im-soft);
    color: var(--im-text);
    font: inherit;
    font-size: 14px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.im-field input[type="text"]:focus {
    outline: none;
    border-color: var(--im-accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(102, 88, 255, 0.12);
}

.im-field.error input[type="text"],
.im-field.error .im-upload-area {
    border-color: var(--im-error);
}

.im-error-text {
    display: none;
    color: var(--im-error);
    font-size: 12px;
    font-weight: 700;
}

.im-field.error .im-error-text {
    display: block;
}

.im-upload-area {
    position: relative;
    min-height: 148px;
    padding: 18px;
    border: 1px dashed #cfd2da;
    border-radius: 8px;
    background: var(--im-soft);
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease;
}

.im-upload-area:hover {
    border-color: var(--im-accent);
    background: rgba(102, 88, 255, 0.07);
}

.im-upload-area.has-file {
    border-style: solid;
    background: #ffffff;
}

.im-upload-content,
.im-upload-preview {
    display: flex;
    min-height: 110px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.im-upload-icon {
    color: var(--im-accent);
    font-size: 28px;
}

.im-upload-text {
    margin: 0;
    color: var(--im-text);
    font-size: 14px;
    font-weight: 900;
}

.im-upload-hint {
    margin: 0;
    color: var(--im-muted);
    font-size: 12px;
}

.im-upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.im-upload-preview {
    display: none;
}

.im-upload-area.has-file .im-upload-content {
    display: none;
}

.im-upload-area.has-file .im-upload-preview {
    display: flex;
}

.im-preview-img {
    width: 112px;
    height: 112px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 8px 22px rgba(17, 18, 22, 0.12);
}

.im-preview-change {
    color: var(--im-accent);
    font-size: 13px;
    font-weight: 900;
}

.btn {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    transition: filter 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.btn--block {
    width: 100%;
}

.btn--primary,
.btn--purple {
    background: var(--im-accent);
    color: #ffffff;
}

.btn--primary:hover,
.btn--purple:hover {
    filter: brightness(0.94);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.btn--outline {
    border: 1px solid var(--im-border);
    background: #ffffff;
    color: var(--im-text);
}

.btn--outline:hover {
    border-color: #c8cad2;
    background: var(--im-soft);
}

.im-result-card {
    overflow: hidden;
    padding: 12px;
    background: var(--im-dark);
}

.im-result-stage {
    position: relative;
    display: flex;
    width: 100%;
    min-height: clamp(380px, 58vh, 580px);
    overflow: hidden;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(102, 88, 255, 0.13), transparent 34%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 14px),
        #0c0d14;
}

.im-result-content,
.im-loading,
.im-error {
    width: 100%;
    height: 100%;
    min-height: inherit;
}

.im-result-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.im-result-content img,
.im-result-content video {
    display: block;
    width: 100%;
    height: 100%;
    max-height: clamp(380px, 58vh, 580px);
    object-fit: contain;
    border-radius: 6px;
}

.im-result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.im-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 14px;
    color: #ffffff;
}

.im-loading p {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    font-weight: 900;
}

.im-skeleton {
    width: min(100%, 520px);
    min-height: clamp(320px, 52vh, 520px);
    border-radius: 8px;
    background:
        linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.1) 48%, transparent 66%),
        linear-gradient(135deg, rgba(102, 88, 255, 0.2), rgba(252, 100, 50, 0.13)),
        #171925;
    background-size: 200% 100%, auto, auto;
    animation: shimmer 1.35s infinite linear;
}

@keyframes shimmer {
    from {
        background-position: 200% 0, 0 0, 0 0;
    }
    to {
        background-position: -200% 0, 0 0, 0 0;
    }
}

.im-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    color: #ffffff;
    text-align: center;
}

.im-error i {
    color: var(--im-error);
    font-size: 36px;
}

.im-error p {
    max-width: 320px;
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 14px;
    line-height: 1.45;
}

.im-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 1000;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--im-dark);
    color: #ffffff;
    box-shadow: 0 14px 32px rgba(17, 18, 22, 0.22);
    font-size: 13px;
    font-weight: 800;
    opacity: 0;
    transform: translateX(-50%) translateY(24px);
    transition: opacity 220ms ease, transform 220ms ease;
}

.im-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .im-workspace {
        grid-template-columns: 1fr;
    }

    .im-output-panel {
        position: static;
    }
}

@media (max-width: 640px) {
    .im-main {
        padding-top: 16px;
    }

    .im-hero {
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .im-title {
        font-size: 46px;
    }

    .im-subtitle {
        font-size: 14px;
    }

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

    .im-result-stage {
        min-height: 340px;
    }

    .im-skeleton {
        min-height: 300px;
    }

    .im-result-content img,
    .im-result-content video {
        max-height: 340px;
    }

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