.apb-wrap {
    --apb-border: #e5e7eb;
    --apb-text: #172033;
    --apb-muted: #667085;
    --apb-surface: #ffffff;
    --apb-soft: #f7f8fb;
    --apb-accent: #5b4bdb;
    --apb-accent-dark: #4938c7;
    max-width: 1080px;
    margin: 32px auto;
    color: var(--apb-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.55;
}

.apb-wrap *,
.apb-wrap *::before,
.apb-wrap *::after {
    box-sizing: border-box;
}

.apb-card {
    background: var(--apb-surface);
    border: 1px solid var(--apb-border);
    border-radius: 20px;
    box-shadow: 0 16px 50px rgba(16, 24, 40, 0.08);
    overflow: hidden;
}

.apb-header {
    padding: 40px 40px 28px;
    background: linear-gradient(135deg, #f8f7ff 0%, #ffffff 70%);
    border-bottom: 1px solid var(--apb-border);
}

.apb-badge {
    display: inline-block;
    margin-bottom: 10px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eeecff;
    color: var(--apb-accent-dark);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
}

.apb-header h2,
.apb-output h3,
.apb-box-heading h4,
.apb-stage h4 {
    margin: 0;
    color: var(--apb-text);
}

.apb-header h2 {
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.12;
    letter-spacing: -.03em;
}

.apb-header p {
    max-width: 760px;
    margin: 14px 0 0;
    color: var(--apb-muted);
    font-size: 16px;
}

.apb-form,
.apb-output {
    padding: 32px 40px 40px;
}

.apb-field {
    position: relative;
    margin-bottom: 22px;
}

.apb-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
}

.apb-field select,
.apb-field textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    background: #fff;
    color: var(--apb-text);
    font: inherit;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.apb-field select {
    min-height: 48px;
    padding: 10px 13px;
}

.apb-field textarea {
    min-height: 150px;
    padding: 14px;
    resize: vertical;
}

.apb-field select:focus,
.apb-field textarea:focus {
    border-color: var(--apb-accent);
    box-shadow: 0 0 0 3px rgba(91, 75, 219, .12);
}

.apb-field textarea.apb-error {
    border-color: #d92d20;
    box-shadow: 0 0 0 3px rgba(217, 45, 32, .1);
}

.apb-counter {
    margin-top: 5px;
    color: var(--apb-muted);
    font-size: 12px;
    text-align: right;
}

.apb-button,
.apb-small-button {
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.apb-button:hover,
.apb-small-button:hover {
    transform: translateY(-1px);
}

.apb-primary {
    width: 100%;
    padding: 14px 18px;
    background: var(--apb-accent);
    color: #fff;
    box-shadow: 0 8px 20px rgba(91, 75, 219, .2);
}

.apb-primary:hover {
    background: var(--apb-accent-dark);
}

.apb-secondary,
.apb-small-button {
    padding: 9px 12px;
    background: var(--apb-soft);
    color: var(--apb-text);
    border: 1px solid var(--apb-border);
}

.apb-output-header,
.apb-box-heading,
.apb-stage-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.apb-output-header {
    margin-bottom: 24px;
}

.apb-output h3 {
    margin-top: 3px;
    font-size: 26px;
}

.apb-progress {
    margin-bottom: 26px;
}

.apb-progress-label {
    display: block;
    margin-bottom: 7px;
    color: var(--apb-muted);
    font-size: 12px;
    font-weight: 700;
}

.apb-progress-track {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #ececf3;
}

.apb-progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--apb-accent);
}

.apb-master-box {
    margin-bottom: 22px;
    padding: 20px;
    border: 1px solid #dcd9ff;
    border-radius: 14px;
    background: #faf9ff;
}

.apb-box-heading {
    align-items: center;
    margin-bottom: 14px;
}

.apb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.apb-master-box pre,
.apb-stage-prompt-wrap pre {
    margin: 0;
    padding: 16px;
    overflow: auto;
    border-radius: 10px;
    background: #111827;
    color: #f9fafb;
    font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.apb-stages {
    display: grid;
    gap: 12px;
}

.apb-stage {
    padding: 18px;
    border: 1px solid var(--apb-border);
    border-radius: 14px;
    background: #fff;
}

.apb-stage-number {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: #eeecff;
    color: var(--apb-accent-dark);
    font-weight: 800;
}

.apb-stage h4 {
    margin-bottom: 4px;
    font-size: 16px;
}

.apb-stage p {
    margin: 0;
    color: var(--apb-muted);
    font-size: 14px;
}

.apb-stage details {
    margin-top: 14px;
    border-top: 1px solid var(--apb-border);
    padding-top: 12px;
}

.apb-stage summary {
    cursor: pointer;
    color: var(--apb-accent-dark);
    font-size: 13px;
    font-weight: 700;
}

.apb-stage-prompt-wrap {
    margin-top: 12px;
}

.apb-stage-prompt-wrap .apb-small-button {
    margin-top: 10px;
}

.apb-wrap button:focus-visible,
.apb-wrap select:focus-visible,
.apb-wrap textarea:focus-visible,
.apb-wrap summary:focus-visible {
    outline: 3px solid rgba(91, 75, 219, .3);
    outline-offset: 2px;
}

@media (max-width: 700px) {
    .apb-wrap {
        margin: 16px auto;
    }

    .apb-header,
    .apb-form,
    .apb-output {
        padding: 24px 18px;
    }

    .apb-output-header,
    .apb-box-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .apb-secondary {
        width: 100%;
    }

    .apb-stage-top {
        gap: 12px;
    }
}

.apb-box-description {
    margin: 5px 0 0;
    color: var(--apb-muted);
    font-size: 13px;
    font-weight: 400;
}

.apb-seo-box {
    margin: 22px 0;
    padding: 20px;
    border: 1px solid #cfe2ff;
    border-radius: 14px;
    background: #f8fbff;
}

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

.apb-seo-item {
    padding: 14px;
    border: 1px solid var(--apb-border);
    border-radius: 10px;
    background: #fff;
}

.apb-seo-item span {
    display: block;
    margin-bottom: 5px;
    color: var(--apb-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.apb-seo-item strong {
    display: block;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.apb-ad-footer {
    max-width: 1080px;
    min-height: 90px;
    margin: 18px auto 0;
    padding: 10px;
    border: 1px solid var(--apb-border);
    border-radius: 12px;
    background: #fafafa;
    text-align: center;
}

.apb-ad-label {
    margin-bottom: 5px;
    color: #98a2b3;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.apb-ad-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    overflow: hidden;
}

@media (max-width: 700px) {
    .apb-seo-grid {
        grid-template-columns: 1fr;
    }

    .apb-ad-footer {
        min-height: 70px;
    }
}
