:root {
    --d3-primary: #6366f1;
    --d3-primary-dark: #4f46e5;
    --d3-ink: #18181b;
    --d3-muted: #667085;
    --d3-surface: #ffffff;
    --d3-canvas: #f7f8fc;
    --d3-border: #e4e7ec;
    --d3-danger: #b42318;
    --d3-radius: 18px;
    --d3-shadow: 0 24px 64px rgba(16, 24, 40, 0.12);
}

.d3-onboarding,
.d3-onboarding * {
    box-sizing: border-box;
}

.d3-onboarding [hidden] {
    display: none !important;
}

.d3-onboarding {
    min-height: calc(100vh - 90px);
    margin: -20px;
    padding: 36px clamp(20px, 4vw, 64px) 56px;
    color: var(--d3-ink);
    background: var(--d3-canvas);
    font-family: Poppins, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.d3-onboarding__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    width: min(1240px, 100%);
    margin: 0 auto 28px;
    gap: 24px;
}

.d3-onboarding__header h1 {
    margin: 12px 0 6px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.15;
    letter-spacing: -0.035em;
}

.d3-onboarding__header p {
    max-width: 680px;
    margin: 0;
    color: var(--d3-muted);
    font-size: 16px;
    line-height: 1.6;
}

.d3-onboarding__back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    gap: 6px;
    color: #475467;
    font-weight: 600;
    text-decoration: none;
}

.d3-onboarding__back svg,
.d3-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.d3-onboarding__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
    align-items: start;
    width: min(1240px, 100%);
    margin: 0 auto;
    gap: clamp(28px, 4vw, 56px);
}

.d3-builder {
    min-width: 0;
    padding: clamp(24px, 4vw, 44px);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 24px;
    background: var(--d3-surface);
    box-shadow: 0 10px 35px rgba(16, 24, 40, 0.06);
}

.d3-progress {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto;
    align-items: center;
    margin-bottom: 44px;
}

.d3-progress__step {
    display: grid;
    justify-items: center;
    min-width: 84px;
    min-height: 64px;
    padding: 0;
    border: 0;
    color: #98a2b3;
    background: transparent;
    cursor: pointer;
}

.d3-progress__step span {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 2px solid #d0d5dd;
    border-radius: 999px;
    background: #fff;
    font-size: 14px;
    font-weight: 700;
}

.d3-progress__step strong {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.d3-progress__step.is-active,
.d3-progress__step.is-complete {
    color: var(--d3-primary-dark);
}

.d3-progress__step.is-active span,
.d3-progress__step.is-complete span {
    border-color: var(--d3-primary);
    color: #fff;
    background: var(--d3-primary);
}

.d3-progress__line {
    height: 2px;
    margin: 0 8px 24px;
    background: #e4e7ec;
}

.d3-progress__line.is-complete {
    background: var(--d3-primary);
}

.d3-step[hidden] {
    display: none;
}

.d3-step.is-active {
    animation: d3-step-in 220ms ease-out;
}

.d3-step__intro {
    margin-bottom: 28px;
}

.d3-eyebrow {
    color: var(--d3-primary-dark);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.d3-step__intro h2 {
    margin: 8px 0;
    font-size: clamp(24px, 3vw, 32px);
    line-height: 1.25;
    letter-spacing: -0.025em;
}

.d3-step__intro p,
.d3-color-picker p,
.d3-preview__hint {
    margin: 0;
    color: var(--d3-muted);
    font-size: 14px;
    line-height: 1.6;
}

.d3-form-grid,
.d3-upload-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.d3-field label,
.d3-color-picker legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #344054;
    font-size: 14px;
    font-weight: 600;
}

.d3-optional {
    color: #98a2b3;
    font-size: 11px;
    font-weight: 500;
}

.d3-field input {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    outline: none;
    color: var(--d3-ink);
    background: #fff;
    font: inherit;
    font-size: 16px;
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.d3-field input:focus {
    border-color: var(--d3-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
}

.d3-field input[aria-invalid="true"] {
    border-color: var(--d3-danger);
}

.d3-field__error {
    min-height: 20px;
    margin: 5px 0 0;
    color: var(--d3-danger);
    font-size: 12px;
}

.d3-upload {
    display: grid;
    min-height: 174px;
    padding: 24px;
    place-items: center;
    align-content: center;
    border: 1.5px dashed #b8c0cc;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.d3-upload:hover,
.d3-upload:focus-within {
    border-color: var(--d3-primary);
    background: #f5f3ff;
}

.d3-upload__icon {
    display: grid;
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    place-items: center;
    border-radius: 999px;
    color: var(--d3-primary-dark);
    background: #eef2ff;
}

.d3-upload__icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.d3-upload small {
    margin-top: 4px;
    color: var(--d3-muted);
}

.d3-upload input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.d3-color-picker {
    margin: 28px 0 0;
    padding: 0;
    border: 0;
}

.d3-color-picker__options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0;
}

.d3-color-picker__options label {
    position: relative;
    display: block;
    width: 44px;
    height: 44px;
    cursor: pointer;
}

.d3-color-picker__options input {
    position: absolute;
    opacity: 0;
}

.d3-color-picker__options label > span:first-of-type {
    display: block;
    width: 44px;
    height: 44px;
    border: 4px solid #fff;
    border-radius: 999px;
    background: var(--swatch);
    box-shadow: 0 0 0 1px #d0d5dd;
}

.d3-color-picker__options input:checked + span,
.d3-color-picker__options input:focus-visible + span {
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--d3-primary);
}

.d3-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 36px;
    gap: 12px;
}

.d3-button,
.d3-preview-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 11px 20px;
    border: 1px solid transparent;
    border-radius: 12px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    gap: 8px;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.d3-button--primary {
    color: #fff;
    background: var(--d3-primary);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.24);
}

.d3-button--primary:hover {
    background: var(--d3-primary-dark);
}

.d3-button--secondary,
.d3-preview-toggle {
    border-color: #d0d5dd;
    color: #344054;
    background: #fff;
}

.d3-button:focus-visible,
.d3-preview-toggle:focus-visible,
.d3-onboarding__back:focus-visible,
.d3-progress__step:focus-visible {
    outline: 3px solid rgba(99, 102, 241, 0.4);
    outline-offset: 3px;
}

.d3-classic-link {
    margin: 24px 0 0;
    color: var(--d3-muted);
    font-size: 13px;
    text-align: center;
}

.d3-classic-link a {
    color: var(--d3-primary-dark);
    font-weight: 600;
}

.d3-preview {
    position: sticky;
    top: 24px;
}

.d3-preview__label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    color: var(--d3-muted);
    font-size: 12px;
    font-weight: 600;
}

.d3-phone-shell {
    width: min(390px, 100%);
    min-height: 690px;
    margin: 0 auto;
    padding: 12px;
    border: 1px solid #23252a;
    border-radius: 42px;
    background: #0f1115;
    box-shadow: var(--d3-shadow);
}

.d3-card-preview {
    --preview-accent: #6366f1;
    min-height: 664px;
    overflow: hidden;
    border-radius: 31px;
    background: #fff;
}

.d3-card-preview__cover {
    height: 150px;
    background: linear-gradient(135deg, var(--preview-accent), color-mix(in srgb, var(--preview-accent), #ffffff 42%));
    background-position: center;
    background-size: cover;
}

.d3-card-preview__body {
    position: relative;
    padding: 70px 28px 32px;
}

.d3-card-preview__avatar {
    position: absolute;
    top: -52px;
    display: grid;
    width: 104px;
    height: 104px;
    overflow: hidden;
    place-items: center;
    border: 5px solid #fff;
    border-radius: 999px;
    color: #fff;
    background-color: var(--preview-accent);
    background-position: center;
    background-size: cover;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
    font-size: 28px;
    font-weight: 700;
}

.d3-card-preview__body h3 {
    margin: 0 0 4px;
    font-size: 26px;
    line-height: 1.25;
    letter-spacing: -0.025em;
}

.d3-card-preview__body > p {
    margin: 3px 0;
    color: var(--d3-muted);
    font-size: 14px;
}

.d3-card-preview__details {
    display: grid;
    margin-top: 34px;
    gap: 12px;
}

.d3-preview-detail {
    display: flex;
    align-items: center;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid #eaecf0;
    border-radius: 14px;
    gap: 12px;
}

.d3-preview-detail > span {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 999px;
    color: #fff;
    background: var(--preview-accent);
    font-weight: 700;
}

.d3-preview-detail > span svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.d3-preview-detail p {
    min-width: 0;
    margin: 0;
}

.d3-preview-detail strong,
.d3-preview-detail small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d3-preview-detail strong {
    color: #344054;
    font-size: 12px;
}

.d3-preview-detail small {
    color: #98a2b3;
    font-size: 10px;
}

.d3-preview__hint {
    max-width: 390px;
    margin: 16px auto 0;
    text-align: center;
}

.d3-preview-toggle {
    display: none;
}

@keyframes d3-step-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
    .d3-onboarding__layout {
        grid-template-columns: minmax(0, 1fr) 340px;
        gap: 24px;
    }

    .d3-phone-shell {
        min-height: 610px;
    }

    .d3-card-preview {
        min-height: 584px;
    }
}

@media (max-width: 900px) {
    .d3-onboarding__layout {
        display: block;
    }

    .d3-onboarding__header {
        align-items: center;
    }

    .d3-preview-toggle {
        display: inline-flex;
        flex: 0 0 auto;
    }

    .d3-preview {
        position: fixed;
        z-index: 1050;
        inset: 0;
        display: none;
        overflow-y: auto;
        padding: 30px 20px;
        background: rgba(15, 17, 21, 0.84);
        backdrop-filter: blur(10px);
    }

    .d3-preview.is-open {
        display: block;
    }

    .d3-preview__label,
    .d3-preview__hint {
        color: #fff;
    }
}

@media (max-width: 640px) {
    .d3-onboarding {
        margin: -20px -12px;
        padding: 22px 14px 40px;
    }

    .d3-onboarding__header {
        align-items: flex-start;
    }

    .d3-onboarding__header p {
        display: none;
    }

    .d3-preview-toggle {
        padding-inline: 14px;
    }

    .d3-builder {
        padding: 22px 18px;
        border-radius: 18px;
    }

    .d3-progress {
        margin-bottom: 32px;
    }

    .d3-progress__step {
        min-width: 44px;
    }

    .d3-progress__step strong {
        display: none;
    }

    .d3-progress__line {
        margin-bottom: 0;
    }

    .d3-form-grid,
    .d3-upload-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .d3-actions {
        position: sticky;
        bottom: 0;
        z-index: 4;
        margin: 32px -18px -22px;
        padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--d3-border);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
    }

    .d3-button {
        flex: 1;
    }

    .d3-phone-shell {
        min-height: 610px;
    }

    .d3-card-preview {
        min-height: 584px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .d3-onboarding *,
    .d3-onboarding *::before,
    .d3-onboarding *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
