:root {
    color-scheme: light;
    --paper: #f8f7f2;
    --surface: #ffffff;
    --ink: #182024;
    --muted: #657176;
    --line: #dadfd8;
    --teal: #0f766e;
    --teal-strong: #0b5f59;
    --coral: #d85f45;
    --amber: #b78324;
    --soft-teal: #e7f3f0;
    --soft-coral: #fff0eb;
    --shadow: 0 18px 60px rgba(24, 32, 36, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background:
        linear-gradient(135deg, rgba(216, 95, 69, 0.08), transparent 32%),
        linear-gradient(315deg, rgba(15, 118, 110, 0.1), transparent 38%),
        var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

.app-shell {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: clamp(16px, 3vw, 34px);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
    gap: clamp(18px, 2vw, 28px);
    align-items: start;
}

.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    padding: 8px 2px 0;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--teal);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    max-width: 760px;
    margin-bottom: 0;
    font-size: clamp(2rem, 4vw, 4.25rem);
    line-height: 0.98;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 4px;
    font-size: 1rem;
    line-height: 1.25;
}

p {
    color: var(--muted);
    line-height: 1.5;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    font-weight: 700;
    white-space: nowrap;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--amber);
}

.status-pill.is-ready .status-dot {
    background: var(--teal);
}

.status-pill.is-warning {
    color: #7d3f19;
    background: #fff5df;
}

.notice {
    grid-column: 1 / -1;
    padding: 14px 16px;
    border: 1px solid #f0ce9d;
    border-radius: 8px;
    background: #fff7e7;
    color: #7d3f19;
    font-weight: 700;
}

.notice code {
    padding: 2px 5px;
    border-radius: 5px;
    background: rgba(125, 63, 25, 0.09);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
}

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

.input-panel,
.settings-panel,
.result-panel {
    border: 1px solid rgba(24, 32, 36, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow);
}

.input-panel,
.settings-panel {
    padding: clamp(16px, 2vw, 22px);
}

.settings-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
}

.settings-panel .panel-head,
.settings-panel .field:last-of-type,
.primary-action {
    grid-column: 1 / -1;
}

.panel-head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.panel-head p {
    margin-bottom: 0;
    font-size: 0.92rem;
}

.step-mark {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--soft-teal);
    color: var(--teal-strong);
    font-weight: 900;
}

.dropzone {
    display: grid;
    min-height: 390px;
    place-items: center;
    gap: 10px;
    padding: 16px;
    border: 1.5px dashed #b8c2bd;
    border-radius: 8px;
    background: linear-gradient(180deg, #fbfcfa, #f3f6f4);
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.dropzone.compact {
    min-height: 250px;
}

.dropzone:hover,
.dropzone.is-dragging {
    border-color: var(--teal);
    background: var(--soft-teal);
}

.dropzone:focus-within {
    outline: 3px solid rgba(15, 118, 110, 0.22);
    outline-offset: 2px;
}

.dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.preview-frame {
    display: grid;
    width: min(100%, 280px);
    aspect-ratio: 3 / 4;
    place-items: center;
    overflow: hidden;
    border-radius: 8px;
    background: #e9eeeb;
    color: var(--teal);
}

.compact .preview-frame {
    width: min(100%, 210px);
    aspect-ratio: 4 / 3;
}

.placeholder-icon {
    display: grid;
    width: 68px;
    height: 68px;
    place-items: center;
    border-radius: 999px;
    background: #ffffff;
    color: var(--teal);
    font-size: 34px;
    box-shadow: 0 12px 28px rgba(15, 118, 110, 0.12);
}

.preview-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drop-title {
    font-weight: 850;
}

.drop-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.field {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.field span,
.segmented legend {
    color: var(--ink);
    font-size: 0.88rem;
    font-weight: 800;
}

.field input,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input {
    height: 46px;
    padding: 0 13px;
}

.field textarea {
    min-height: 106px;
    resize: vertical;
    padding: 12px 13px;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.segmented legend {
    grid-column: 1 / -1;
    margin-bottom: 8px;
}

.segmented label {
    min-width: 0;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: grid;
    min-height: 44px;
    place-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 800;
    text-align: center;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.segmented input:checked + span {
    border-color: var(--teal);
    background: var(--soft-teal);
    color: var(--teal-strong);
}

.primary-action,
.secondary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
    border: 0;
    border-radius: 8px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
}

.primary-action {
    width: 100%;
    background: var(--teal);
    color: #fff;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
}

.primary-action:hover:not(:disabled) {
    background: var(--teal-strong);
}

.primary-action:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.button-icon,
.secondary-action span {
    display: inline-grid;
    place-items: center;
    font-size: 1.25rem;
}

.result-panel {
    position: sticky;
    top: 22px;
    min-height: 760px;
    overflow: hidden;
}

.result-empty,
.result-loading,
.result-error,
.result-ready {
    min-height: 760px;
}

.result-empty,
.result-loading,
.result-error {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 14px;
    padding: 28px;
    text-align: center;
}

.result-empty h2,
.result-loading h2,
.result-error h2 {
    margin-bottom: 0;
    font-size: 1.2rem;
}

.result-empty p,
.result-loading p,
.result-error p {
    max-width: 340px;
    margin-bottom: 0;
}

.result-orbit {
    position: relative;
    width: 148px;
    height: 148px;
    border-radius: 50%;
    background: var(--soft-coral);
}

.result-orbit span {
    position: absolute;
    display: block;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(24, 32, 36, 0.12);
}

.result-orbit span:nth-child(1) {
    width: 58px;
    height: 78px;
    left: 46px;
    top: 22px;
    background: var(--soft-teal);
}

.result-orbit span:nth-child(2) {
    width: 40px;
    height: 54px;
    left: 26px;
    top: 70px;
    transform: rotate(-11deg);
}

.result-orbit span:nth-child(3) {
    width: 44px;
    height: 62px;
    right: 22px;
    top: 66px;
    transform: rotate(13deg);
    background: #fff8e8;
}

.loader {
    width: 64px;
    height: 64px;
    border: 6px solid #d7ebe7;
    border-top-color: var(--coral);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

.result-ready {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #101719;
}

.result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    color: #fff;
}

.result-toolbar h2,
.result-toolbar p {
    margin-bottom: 0;
}

.result-toolbar p {
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.86rem;
}

.secondary-action {
    min-width: 132px;
    padding: 0 16px;
    background: #fff;
    color: var(--ink);
}

.result-ready img {
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: contain;
    background: #101719;
}

.result-error {
    background: var(--soft-coral);
}

.result-error h2 {
    color: #8f2d1d;
}

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

    .result-panel {
        position: static;
        min-height: 520px;
    }

    .result-empty,
    .result-loading,
    .result-error,
    .result-ready {
        min-height: 520px;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 14px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    h1 {
        font-size: 2.1rem;
    }

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

    .dropzone {
        min-height: 320px;
    }

    .settings-panel .panel-head,
    .settings-panel .field:last-of-type,
    .primary-action {
        grid-column: auto;
    }

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

    .result-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .secondary-action {
        width: 100%;
    }
}
