.avto-tryon-wrap,
.avto-modal {
    --avto-front-primary: #3157d5;
    --avto-front-primary-dark: #2443aa;
    --avto-front-info: #1677c5;
    --avto-front-success: #14805e;
    --avto-front-warning: #b76e12;
    --avto-front-danger: #c13d4a;
    --avto-front-ink: #172033;
    --avto-front-muted: #687386;
    --avto-front-line: #dfe5ee;
    --avto-front-soft: #f5f7fb;
    --avto-front-white: #ffffff;
}

.avto-tryon-wrap,
.avto-tryon-wrap *,
.avto-modal,
.avto-modal * {
    box-sizing: border-box;
}

.avto-tryon-wrap {
    width: 100%;
    max-width: 430px;
    margin: 14px 0 0;
    font-family: inherit;
}

.avto-tryon-launch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 12px 20px;
    border: 2px solid var(--avto-front-primary);
    border-radius: 9px;
    box-shadow: none;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.avto-tryon-launch--solid {
    background: var(--avto-front-primary);
    color: var(--avto-front-white);
}

.avto-tryon-launch--solid:hover,
.avto-tryon-launch--solid:focus-visible {
    border-color: var(--avto-front-primary-dark);
    background: var(--avto-front-primary-dark);
    color: var(--avto-front-white);
}

.avto-tryon-launch--outline {
    background: var(--avto-front-white);
    color: var(--avto-front-primary);
}

.avto-tryon-launch--outline:hover,
.avto-tryon-launch--outline:focus-visible {
    background: #eef2ff;
    color: var(--avto-front-primary-dark);
}

.avto-tryon-launch:active {
    transform: translateY(1px);
}

.avto-tryon-launch:focus-visible,
.avto-secondary-button:focus-visible,
.avto-modal__close:focus-visible,
.avto-link-button:focus-visible,
.avto-upload:focus-within {
    outline: 3px solid rgba(22, 119, 197, .28);
    outline-offset: 2px;
}

.avto-tryon-launch__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 23px;
    height: 23px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    font-size: 13px;
}

.avto-tryon-launch--outline .avto-tryon-launch__icon {
    background: #e9edff;
}

.avto-tryon-wrap__hint {
    margin: 6px 0 0;
    color: var(--avto-front-muted);
    font-size: 12px;
    line-height: 1.45;
}

html.avto-modal-open,
body.avto-modal-open {
    overflow: hidden !important;
}

.avto-modal[hidden] {
    display: none !important;
}

.avto-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--avto-front-ink);
    font-family: inherit;
}

.avto-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .66);
    backdrop-filter: blur(3px);
}

.avto-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(960px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 18px;
    background: var(--avto-front-white);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.avto-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 26px 20px;
    border-bottom: 1px solid var(--avto-front-line);
    background: linear-gradient(135deg, #f8faff 0%, #ffffff 75%);
}

.avto-modal__eyebrow {
    display: inline-block;
    margin-bottom: 4px;
    color: var(--avto-front-primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.avto-modal__header h2 {
    margin: 0 0 6px;
    color: var(--avto-front-ink);
    font: inherit;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.25;
}

.avto-modal__header p {
    max-width: 700px;
    margin: 0;
    color: var(--avto-front-muted);
    font-size: 13px;
    line-height: 1.55;
}

.avto-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--avto-front-line);
    border-radius: 50%;
    background: var(--avto-front-white);
    color: var(--avto-front-ink);
    font: inherit;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.avto-modal__close:hover {
    background: var(--avto-front-soft);
}

.avto-modal__body {
    display: grid;
    grid-template-columns: minmax(230px, .78fr) minmax(0, 1.45fr);
    gap: 22px;
    padding: 24px 26px;
}

.avto-garment-card,
.avto-photo-panel {
    border: 1px solid var(--avto-front-line);
    border-radius: 14px;
    background: var(--avto-front-white);
}

.avto-garment-card {
    align-self: start;
    overflow: hidden;
}

.avto-garment-card__label {
    padding: 12px 14px;
    border-bottom: 1px solid var(--avto-front-line);
    background: #f7fbfe;
    color: var(--avto-front-info);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.avto-garment-card__image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 5;
    padding: 12px;
    background: #fafbfc;
}

.avto-garment-card__image {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.avto-garment-card__name {
    display: block;
    padding: 14px 14px 4px;
    color: var(--avto-front-ink);
    font-size: 14px;
    line-height: 1.4;
}

.avto-garment-card__note {
    margin: 0;
    padding: 0 14px 15px;
    color: var(--avto-front-muted);
    font-size: 11px;
    line-height: 1.45;
}

.avto-photo-panel {
    padding: 20px;
}

.avto-photo-panel__intro {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.avto-step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e9edff;
    color: var(--avto-front-primary);
    font-size: 12px;
    font-weight: 800;
}

.avto-photo-panel__intro h3 {
    margin: 0 0 4px;
    color: var(--avto-front-ink);
    font: inherit;
    font-size: 17px;
    font-weight: 800;
}

.avto-photo-panel__intro p {
    margin: 0;
    color: var(--avto-front-muted);
    font-size: 12px;
    line-height: 1.5;
}

.avto-upload {
    display: flex;
    min-height: 185px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    padding: 24px;
    border: 2px dashed #b9c4d6;
    border-radius: 12px;
    background: #fafbfe;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}

.avto-upload:hover,
.avto-upload.is-dragging {
    border-color: var(--avto-front-info);
    background: #f2f8fd;
}

.avto-upload__input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.avto-upload__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-bottom: 4px;
    border-radius: 12px;
    background: #e9edff;
    color: var(--avto-front-primary);
    font-size: 22px;
    font-weight: 700;
}

.avto-upload strong {
    color: var(--avto-front-ink);
    font-size: 14px;
}

.avto-upload > span:last-child {
    color: var(--avto-front-muted);
    font-size: 11px;
}

.avto-photo-preview {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--avto-front-line);
    border-radius: 12px;
    background: #fbfcfe;
}

.avto-photo-preview[hidden] {
    display: none !important;
}

.avto-photo-preview__image-wrap {
    overflow: hidden;
    aspect-ratio: 4 / 5;
    border-radius: 9px;
    background: #eef1f5;
}

.avto-photo-preview__image-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avto-photo-preview__meta {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    gap: 18px;
    padding: 4px 0;
}

.avto-photo-preview__label {
    display: block;
    margin-bottom: 5px;
    color: var(--avto-front-success);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.avto-photo-preview__meta strong {
    display: block;
    overflow: hidden;
    color: var(--avto-front-ink);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avto-photo-preview__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.avto-link-button {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--avto-front-info);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.avto-link-button--danger {
    color: var(--avto-front-danger);
}

.avto-message {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
}

.avto-message[hidden] {
    display: none !important;
}

.avto-message.is-success {
    background: #e8f6f1;
    color: var(--avto-front-success);
}

.avto-message.is-error {
    background: #fff0f1;
    color: var(--avto-front-danger);
}

.avto-message.is-info {
    background: #e9f4fc;
    color: var(--avto-front-info);
}

.avto-privacy-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
    padding: 12px;
    border-left: 3px solid var(--avto-front-success);
    border-radius: 8px;
    background: #f4fbf8;
}

.avto-privacy-note__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e8f6f1;
    color: var(--avto-front-success);
    font-size: 12px;
    font-weight: 800;
}

.avto-privacy-note strong,
.avto-privacy-note span {
    display: block;
}

.avto-privacy-note strong {
    margin-bottom: 2px;
    color: var(--avto-front-ink);
    font-size: 12px;
}

.avto-privacy-note span {
    color: var(--avto-front-muted);
    font-size: 11px;
    line-height: 1.45;
}

.avto-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 26px;
    border-top: 1px solid var(--avto-front-line);
    background: #fbfcfe;
}

.avto-module-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--avto-front-muted);
    font-size: 11px;
    line-height: 1.4;
}

.avto-module-status__dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--avto-front-warning);
}

.avto-secondary-button {
    min-height: 38px;
    margin: 0;
    padding: 8px 16px;
    border: 1px solid var(--avto-front-line);
    border-radius: 8px;
    background: var(--avto-front-white);
    color: var(--avto-front-ink);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.avto-secondary-button:hover {
    background: var(--avto-front-soft);
}

@media (max-width: 760px) {
    .avto-modal {
        align-items: flex-end;
        padding: 0;
    }

    .avto-modal__dialog {
        width: 100%;
        max-height: 94vh;
        border-radius: 18px 18px 0 0;
    }

    .avto-modal__body {
        grid-template-columns: 1fr;
        padding: 18px;
    }

    .avto-garment-card {
        display: grid;
        grid-template-columns: 110px minmax(0, 1fr);
        align-items: center;
    }

    .avto-garment-card__label {
        grid-column: 1 / -1;
    }

    .avto-garment-card__image-wrap {
        aspect-ratio: 1 / 1;
        padding: 8px;
    }

    .avto-garment-card__name {
        align-self: end;
        padding: 12px 12px 2px;
    }

    .avto-garment-card__note {
        align-self: start;
        padding: 3px 12px 12px;
    }

    .avto-modal__header {
        padding: 20px 18px 16px;
    }

    .avto-modal__header h2 {
        font-size: 20px;
    }

    .avto-photo-panel {
        padding: 16px;
    }

    .avto-photo-preview {
        grid-template-columns: 110px minmax(0, 1fr);
    }

    .avto-modal__footer {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
    }

    .avto-secondary-button {
        width: 100%;
    }
}

@media (max-width: 420px) {
    .avto-garment-card {
        grid-template-columns: 92px minmax(0, 1fr);
    }

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

    .avto-photo-preview__image-wrap {
        max-height: 280px;
    }
}

/* Module 4: AI generation */
.avto-consent {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid #d7deea;
    border-radius: 9px;
    background: #fbfcfe;
}

.avto-consent[hidden],
.avto-generate-row[hidden],
.avto-result[hidden] {
    display: none !important;
}

.avto-consent label {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0;
    color: var(--avto-front-ink);
    font-size: 11px;
    line-height: 1.5;
    cursor: pointer;
}

.avto-consent input {
    flex: 0 0 auto;
    margin-top: 2px;
}

.avto-generate-row {
    margin-top: 12px;
}

.avto-generate-button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    margin: 0;
    padding: 10px 18px;
    border: 1px solid var(--avto-front-primary);
    border-radius: 9px;
    background: var(--avto-front-primary);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.avto-generate-button:disabled {
    border-color: #b8c2d2;
    background: #b8c2d2;
    cursor: not-allowed;
}

.avto-generate-button__spinner {
    display: none;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255,255,255,.45);
    border-top-color: #fff;
    border-radius: 50%;
}

.avto-generate-button.is-loading .avto-generate-button__spinner {
    display: inline-block;
    animation: avto-spin .8s linear infinite;
}

@keyframes avto-spin {
    to { transform: rotate(360deg); }
}

.avto-result {
    margin-top: 14px;
    overflow: hidden;
    border: 1px solid #cfe5dc;
    border-radius: 12px;
    background: #fff;
}

.avto-result__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #dce8e3;
    background: #f4fbf8;
}

.avto-result__head strong,
.avto-result__eyebrow {
    display: block;
}

.avto-result__eyebrow {
    margin-bottom: 2px;
    color: var(--avto-front-success);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.avto-result__head strong {
    color: var(--avto-front-ink);
    font-size: 12px;
}

.avto-result__image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    padding: 12px;
    background: #f8fafc;
}

.avto-result__image-wrap img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 620px;
    object-fit: contain;
    border-radius: 8px;
}

.avto-module-status__dot.is-ready {
    background: var(--avto-front-success);
}

@media (max-width: 520px) {
    .avto-result__head {
        align-items: flex-start;
        flex-direction: column;
    }
    .avto-result__head .avto-secondary-button {
        width: 100%;
    }
}

/* Module 4.1: Customer photo guidance */
.avto-photo-guide {
    margin: -2px 0 16px;
    overflow: hidden;
    border: 1px solid #dce7f5;
    border-radius: 12px;
    background: #f8fbff;
}

.avto-photo-guide__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
}

.avto-photo-guide__summary strong,
.avto-photo-guide__summary span {
    display: block;
}

.avto-photo-guide__summary strong {
    margin-bottom: 3px;
    color: var(--avto-front-ink);
    font-size: 12px;
    font-weight: 800;
}

.avto-photo-guide__summary span {
    color: var(--avto-front-muted);
    font-size: 11px;
    line-height: 1.45;
}

.avto-photo-guide__quality {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e7f5ef;
    color: var(--avto-front-success) !important;
    font-size: 13px !important;
    font-weight: 900;
}

.avto-photo-guide__examples {
    border-top: 1px solid #dce7f5;
    background: #fff;
}

.avto-photo-guide__examples summary {
    padding: 10px 14px;
    color: var(--avto-front-info);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

.avto-photo-guide__examples summary:hover {
    background: #f7fbfe;
}

.avto-photo-guide__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 2px 14px 12px;
}

.avto-photo-example {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--avto-front-line);
    border-radius: 10px;
    background: #fff;
}

.avto-photo-example img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: #f6f8fb;
}

.avto-photo-example figcaption {
    padding: 8px 9px 10px;
}

.avto-photo-example figcaption strong,
.avto-photo-example figcaption span {
    display: block;
}

.avto-photo-example figcaption strong {
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 800;
}

.avto-photo-example figcaption span {
    color: var(--avto-front-muted);
    font-size: 10px;
    line-height: 1.4;
}

.avto-photo-example--best figcaption strong { color: var(--avto-front-success); }
.avto-photo-example--good figcaption strong { color: var(--avto-front-info); }
.avto-photo-example--avoid figcaption strong { color: var(--avto-front-danger); }

.avto-photo-guide__note {
    margin: 0;
    padding: 0 14px 13px;
    color: var(--avto-front-muted);
    font-size: 10px;
    line-height: 1.45;
}

@media (max-width: 560px) {
    .avto-photo-guide__grid {
        grid-template-columns: 1fr;
    }

    .avto-photo-example {
        display: grid;
        grid-template-columns: 90px minmax(0, 1fr);
        align-items: center;
    }

    .avto-photo-example img {
        aspect-ratio: 3 / 4;
        height: 120px;
    }
}


/* Module 5: Post-try-on commerce actions */
.avto-commerce[hidden] { display: none !important; }
.avto-commerce {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border-top: 1px solid #dce8e3;
    background: #fbfdfc;
}
.avto-commerce__copy span,
.avto-commerce__copy strong { display: block; }
.avto-commerce__eyebrow {
    margin-bottom: 3px;
    color: #5b45b5;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.avto-commerce__copy strong {
    margin-bottom: 3px;
    color: var(--avto-front-ink);
    font-size: 12px;
    line-height: 1.35;
}
.avto-commerce__copy > span:last-child {
    color: var(--avto-front-muted);
    font-size: 11px;
    line-height: 1.45;
}
.avto-commerce-button {
    display: inline-flex;
    min-width: 154px;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 0;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    box-shadow: none;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    text-decoration: none !important;
    cursor: pointer;
    transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
}
.avto-commerce-button--cart {
    border-color: #147a52;
    background: #147a52;
    color: #fff !important;
}
.avto-commerce-button--affiliate {
    border-color: #5b45b5;
    background: #5b45b5;
    color: #fff !important;
}
.avto-commerce-button:hover:not(:disabled) {
    filter: brightness(.96);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(20, 32, 52, .12);
}
.avto-commerce-button:focus-visible {
    outline: 3px solid rgba(49, 112, 227, .22);
    outline-offset: 2px;
}
.avto-commerce-button:disabled,
.avto-commerce-button.is-disabled {
    border-color: #b8c2d2;
    background: #b8c2d2;
    color: #fff !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
@media (max-width: 620px) {
    .avto-commerce { grid-template-columns: 1fr; }
    .avto-commerce-button { width: 100%; }
}

/* Module 6: privacy-safe browser-session photo reuse. */
.avto-session-photo {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-top: 12px;
    padding: 13px 14px;
    border: 1px solid #cfe4dd;
    border-radius: 11px;
    background: #f3faf7;
}

.avto-session-photo[hidden] {
    display: none !important;
}

.avto-session-photo__copy {
    min-width: 0;
}

.avto-session-photo__copy label {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0;
    color: var(--avto-front-ink);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    cursor: pointer;
}

.avto-session-photo__copy input[type="checkbox"] {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    accent-color: var(--avto-front-success);
}

.avto-session-photo__copy p {
    margin: 5px 0 0 25px;
    color: var(--avto-front-muted);
    font-size: 11px;
    line-height: 1.5;
}

.avto-session-photo > .avto-link-button {
    flex: 0 0 auto;
    margin-top: 1px;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .avto-session-photo {
        flex-direction: column;
        gap: 8px;
    }

    .avto-session-photo > .avto-link-button {
        margin-left: 25px;
    }
}
