:root {
    color-scheme: light;
    --page-bg: #f4f7fb;
    --panel-bg: #ffffff;
    --ink: #152033;
    --muted: #64748b;
    --line: #dbe3ef;
    --focus: #2563eb;
    --danger: #b42318;
    --success: #087443;
    --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
    gap: 24px;
    align-items: start;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel--form {
    padding: 24px;
}

.brand-row,
.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.eyebrow {
    margin: 0 0 6px;
    color: #2563eb;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(1.7rem, 2.6vw, 2.45rem);
    line-height: 1.05;
}

.status-pill {
    flex: 0 0 auto;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    padding: 7px 11px;
    background: #f0fdf4;
    color: #166534;
    font-size: 0.82rem;
    font-weight: 700;
}

.alert {
    margin-top: 18px;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert--success {
    background: #ecfdf5;
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.alert--danger {
    background: #fef3f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.poster-form {
    margin-top: 22px;
}

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

label,
fieldset {
    min-width: 0;
}

label span,
legend {
    display: block;
    margin-bottom: 7px;
    color: #334155;
    font-size: 0.88rem;
    font-weight: 800;
}

input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    background: #fbfdff;
    color: var(--ink);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea {
    resize: vertical;
    min-height: 108px;
}

select {
    min-height: 47px;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position: calc(100% - 18px) 20px, calc(100% - 12px) 20px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

input:focus,
textarea:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

small {
    display: block;
    margin-top: 6px;
    color: var(--danger);
    font-size: 0.78rem;
}

.field-wide {
    grid-column: 1 / -1;
}

.template-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0 0;
    padding: 0;
    border: 0;
}

.template-picker legend {
    grid-column: 1 / -1;
    width: 100%;
}

.template-picker label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 13px;
    background: #f8fafc;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
}

.template-picker label.is-selected {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.template-picker label:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.color-grid input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
    background: #ffffff;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 18px;
    text-decoration: none;
    font-weight: 850;
    cursor: pointer;
}

.button--primary {
    background: #2563eb;
    color: #ffffff;
}

.button:disabled {
    cursor: wait;
    opacity: 0.68;
}

.button--ghost {
    background: #ffffff;
    border-color: var(--line);
    color: #1e293b;
}

.export-status {
    min-height: 22px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.preview-area {
    position: sticky;
    top: 20px;
    display: grid;
    gap: 14px;
}

.poster {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 5;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    border-radius: 8px;
    background: var(--poster-bg);
    color: var(--poster-text);
    box-shadow: var(--shadow);
}

.poster--rendered {
    background: transparent;
}

.poster--rendered .poster__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.poster--rendered::before,
.poster--rendered::after {
    display: none;
}

.poster::before,
.poster::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    background: var(--accent);
}

.poster::before {
    width: 42%;
    height: 34%;
    right: -12%;
    top: -10%;
    opacity: 0.95;
}

.poster::after {
    width: 54%;
    height: 42%;
    left: -22%;
    bottom: -16%;
    opacity: 0.5;
}

.poster__shine {
    position: absolute;
    inset: 8%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
}

.poster__content {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100%;
    flex-direction: column;
    padding: clamp(24px, 6vw, 52px);
}

.poster__business {
    margin: 0 0 auto;
    font-size: clamp(0.8rem, 1.4vw, 1rem);
    font-weight: 900;
    text-transform: uppercase;
}

.poster h2 {
    margin-top: clamp(54px, 10vw, 96px);
    max-width: 10ch;
    font-size: clamp(2.3rem, 7.2vw, 4.9rem);
    line-height: 0.95;
    overflow-wrap: anywhere;
}

.poster__description {
    width: min(100%, 390px);
    margin: 22px 0 0;
    font-size: clamp(0.96rem, 1.7vw, 1.18rem);
    line-height: 1.55;
}

.poster__price {
    width: fit-content;
    max-width: 100%;
    margin-top: 28px;
    border-radius: 8px;
    padding: 13px 16px;
    background: var(--accent);
    color: #ffffff;
    font-size: clamp(1.05rem, 2vw, 1.45rem);
    font-weight: 950;
    overflow-wrap: anywhere;
}

.poster__footer {
    display: grid;
    gap: 6px;
    margin-top: auto;
    border-radius: 8px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.95);
    color: #101827;
}

.poster__footer span {
    font-size: clamp(1.05rem, 2vw, 1.35rem);
    font-weight: 950;
}

.poster__footer small {
    margin: 0;
    color: #334155;
}

.poster__date {
    margin: 12px 0 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.88rem;
}

.export-note {
    display: grid;
    gap: 3px;
    max-width: 520px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 0.9rem;
}

.export-note strong {
    color: var(--ink);
}

.history-section {
    margin-top: 26px;
    padding: 24px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.section-heading span {
    color: var(--muted);
    font-weight: 800;
}

.empty-state {
    margin: 18px 0 0;
    color: var(--muted);
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.history-card {
    display: grid;
    gap: 7px;
    min-height: 132px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
    text-decoration: none;
}

.history-card span,
.history-card small {
    color: var(--muted);
}

.history-card strong {
    overflow-wrap: anywhere;
}

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

    .preview-area {
        position: static;
    }

    .history-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .app-shell {
        width: min(100% - 20px, 1180px);
        padding: 10px 0 28px;
    }

    .panel--form,
    .history-section {
        padding: 16px;
    }

    .brand-row,
    .section-heading {
        display: grid;
    }

    .status-pill {
        width: fit-content;
    }

    .field-grid,
    .color-grid,
    .history-grid {
        grid-template-columns: 1fr;
    }

    .template-picker {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .actions {
        display: grid;
    }

    .button {
        width: 100%;
    }

    .poster__content {
        padding: 24px;
    }
}
