.bent-agent-launcher {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 999;
    display: grid;
    width: 72px;
    height: 72px;
    padding: 8px;
    place-items: center;
    border: 2px solid #174d2a;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 5px 20px rgb(0 0 0 / 20%);
    cursor: pointer;
}

.bent-agent-launcher img {
    display: block;
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.bent-agent-launcher.bent-agent-consent-blocked,
.bent-agent-panel.bent-agent-consent-blocked {
    display: none !important;
}

.bent-agent-launcher:focus-visible {
    outline: 3px solid #005a28;
    outline-offset: 4px;
}

.bent-agent-panel[hidden], .bent-agent-panel [hidden] {
    display: none !important;
}

.bent-agent-panel {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(104px, calc(env(safe-area-inset-bottom) + 104px));
    z-index: 1000;
    width: min(410px, calc(100vw - 40px));
    max-height: min(640px, calc(100dvh - 128px));
    overflow: auto;
    scroll-padding: 120px 0 12px;
    color: #17261a;
    background: #fff;
    border: 1px solid #b9cbbc;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgb(0 0 0 / 25%);
    font: 16px/1.5 Arial, sans-serif;
}

body.admin-bar .bent-agent-panel { max-height: min(640px, calc(100dvh - 160px)); }

.bent-agent-panel *, .bent-agent-panel *::before, .bent-agent-panel *::after {
    box-sizing: border-box;
}

.bent-agent-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    background: #163a22;
    color: #fff;
}

.bent-agent-header strong, .bent-agent-header span {
    display: block;
    color: #fff;
}

.bent-agent-header span { font-size: 13px; }
.bent-agent-body { padding: 18px 20px; }
.bent-agent-body p { margin: 0 0 14px; }
.bent-agent-body a { color: #075d29; text-decoration: underline; }
.bent-agent-panel button { cursor: pointer; }
.bent-agent-close { border: 0; padding: 0 4px; background: transparent; color: #fff; font-size: 30px; line-height: 1; }
.bent-agent-start, .bent-agent-new-cancel, .bent-agent-history-retry, .bent-agent-form button, .bent-agent-lead-form button { padding: 10px 14px; border: 1px solid #124621; border-radius: 6px; background: #196a30; color: #fff; font-weight: 700; }
.bent-agent-new-cancel, .bent-agent-history-retry, .bent-agent-form button.bent-agent-summary, .bent-agent-form button.bent-agent-lead-toggle, .bent-agent-form button.bent-agent-new { color: #174a27; background: #fff; }
.bent-agent-new-cancel, .bent-agent-history-retry { display: block; margin-top: 8px; }
.bent-agent-panel button:disabled { cursor: wait; opacity: .65; }
.bent-agent-panel :focus-visible { outline: 3px solid #cf7a00; outline-offset: 3px; }
.bent-agent-conversation { margin: 0 0 16px; }
.bent-agent-message { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: #edf4ee; overflow-wrap: anywhere; white-space: pre-wrap; }
.bent-agent-message--user { background: #e5edf2; }
.bent-agent-message strong { display: block; margin-bottom: 4px; }
.bent-agent-form label, .bent-agent-lead-form label:not(.bent-agent-confirm) { display: block; font-weight: 700; }
.bent-agent-form textarea, .bent-agent-lead-form textarea, .bent-agent-lead-form select, .bent-agent-lead-form input:not([type="checkbox"]) { display: block; width: 100%; margin: 6px 0 12px; padding: 10px; border: 1px solid #536958; border-radius: 6px; color: #17261a; background: #fff; font: inherit; }
.bent-agent-form textarea, .bent-agent-lead-form textarea { min-height: 76px; }
.bent-agent-lead-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid #b9cbbc; }
.bent-agent-lead-form h3 { margin: 0 0 8px; color: #17261a; font-size: 18px; }
.bent-agent-confirm { display: flex; align-items: flex-start; gap: 8px; }
.bent-agent-confirm input { margin-top: 5px; flex: 0 0 auto; }
.bent-agent-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bent-agent-contact { margin-top: 16px !important; font-size: 14px; }
.bent-agent-status:empty { display: none; }
.bent-agent-status:not(:empty) { margin-top: 12px; }

.bent-agent-message button { margin-top: 8px; padding: 8px 12px; border: 1px solid #124621; border-radius: 5px; background: #fff; color: #124621; font-weight: 700; }
.bent-agent-email-offer form > label:not(.bent-agent-confirm) { display: block; font-weight: 700; }
.bent-agent-email-offer input[type="email"] { display: block; width: 100%; margin: 6px 0 12px; padding: 10px; border: 1px solid #536958; border-radius: 6px; background: #fff; color: #17261a; font: inherit; }
.bent-agent-email-offer .bent-agent-confirm { font-size: 14px; font-weight: 400; }
.bent-agent-email-offer p:empty { display: none; }
.bent-agent-email-offer p:not(:empty) { margin: 8px 0 0; }
.bent-agent-guide { margin: 12px 0; padding: 14px; border: 1px solid #b9d5c0; border-radius: 8px; background: #f2f8f3; color: #17261a; }
.bent-agent-guide strong { display: block; margin-bottom: 8px; }
.bent-agent-guide label { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; font-size: 14px; }
.bent-agent-guide label input { flex: 0 0 auto; margin-top: 4px; }
.bent-agent-guide label.bent-agent-guide-answer { display: block; font-weight: 700; }
.bent-agent-guide label.bent-agent-guide-answer[hidden] { display: none; }
.bent-agent-guide-answer textarea { display: block; box-sizing: border-box; width: 100%; margin: 6px 0 0; padding: 10px; border: 1px solid #536958; border-radius: 6px; color: #17261a; background: #fff; font: inherit; }
.bent-agent-guide button { margin: 0 8px 8px 0; padding: 9px 12px; border: 1px solid #124621; border-radius: 5px; background: #fff; color: #124621; font-weight: 700; }
.bent-homepage-preview { width: min(960px, calc(100% - 32px)); max-width: 960px; max-height: calc(100dvh - 32px); padding: 20px; border: 0; border-radius: 12px; background: #fff; color: #17261a; overflow: auto; }
.bent-homepage-preview::backdrop { background: rgba(0, 0, 0, .72); }
.bent-homepage-preview > header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.bent-homepage-preview > header h2 { margin: 0; color: #17261a; font-size: 22px; }
.bent-homepage-preview > header button { flex: 0 0 auto; padding: 9px 12px; border: 1px solid #124621; border-radius: 5px; background: #fff; color: #124621; font-weight: 700; }
.bent-homepage-preview :focus-visible { outline: 3px solid #cf7a00; outline-offset: 3px; }
.bent-homepage-preview-notice { margin: 16px 0; color: #304b38; line-height: 1.5; }
.bent-homepage-preview-mock { --preview-ink: #173d2d; --preview-accent: #bdebc5; overflow: hidden; border: 1px solid #c9d7cc; border-radius: 8px; background: #f7faf7; color: #17261a; }
.bent-homepage-preview-ocean { --preview-ink: #143f58; --preview-accent: #b9e3f0; }
.bent-homepage-preview-slate { --preview-ink: #263543; --preview-accent: #d5e5ee; }
.bent-homepage-preview-amber { --preview-ink: #503817; --preview-accent: #f4dda0; }
.bent-homepage-preview-brand { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; background: #fff; color: #17261a; font-size: 18px; font-weight: 700; }
.bent-homepage-preview-nav { color: #304b38; font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.bent-homepage-preview-hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(150px, .75fr); align-items: center; gap: 32px; padding: clamp(32px, 7vw, 72px) clamp(24px, 5vw, 48px); background: var(--preview-ink); color: #fff; }
.bent-homepage-preview-copy { min-width: 0; }
.bent-homepage-preview-hero p, .bent-homepage-preview-hero h3 { max-width: 680px; color: #fff; overflow-wrap: anywhere; }
.bent-homepage-preview-hero p:first-child { color: var(--preview-accent); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.bent-homepage-preview-hero h3 { margin: 12px 0; font-size: clamp(28px, 5vw, 48px); line-height: 1.12; }
.bent-homepage-preview-art { min-height: 220px; border: 1px solid rgba(255,255,255,.35); border-radius: 48% 48% 10px 10px; background: radial-gradient(circle at 68% 28%, var(--preview-accent) 0 12%, transparent 12.5%), linear-gradient(140deg, transparent 0 42%, rgba(255,255,255,.2) 42% 43%, transparent 43%), linear-gradient(30deg, rgba(255,255,255,.16), transparent 65%); }
.bent-homepage-preview-cta { display: inline-block; margin-top: 14px; padding: 10px 16px; border-radius: 5px; background: var(--preview-accent); color: #17261a; font-weight: 700; }
.bent-homepage-preview-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; padding: 24px; }
.bent-homepage-preview-sections section { padding: 20px; border: 1px solid #c9d7cc; border-radius: 6px; background: #fff; }
.bent-homepage-preview-sections h4 { margin: 0 0 8px; color: #17261a; font-size: 19px; }
.bent-homepage-preview-sections p { margin: 0; color: #263c2c; line-height: 1.5; }
.bent-homepage-preview-footer { display: flex; justify-content: space-between; gap: 16px; padding: 20px 24px; background: var(--preview-ink); color: #fff; font-size: 13px; }
.bent-homepage-preview-footer strong { color: #fff; overflow-wrap: anywhere; }
@media (max-width: 600px) {
    .bent-homepage-preview-nav { display: none; }
    .bent-homepage-preview-hero { grid-template-columns: 1fr; gap: 24px; }
    .bent-homepage-preview-art { min-height: 120px; border-radius: 70px 70px 8px 8px; }
}

@media (forced-colors: active) {
    .bent-agent-launcher:focus-visible, .bent-agent-panel :focus-visible {
        outline-color: Highlight;
    }
}

@media (max-width: 767px) {
    .bent-agent-launcher {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        width: 64px;
        height: 64px;
        padding: 6px;
    }

    .bent-agent-launcher img {
        width: 48px;
        height: 48px;
    }

    .bent-agent-panel {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(88px, calc(env(safe-area-inset-bottom) + 88px));
        width: calc(100vw - 32px);
        max-height: calc(100dvh - 108px);
    }

    body.admin-bar .bent-agent-panel { max-height: calc(100dvh - 150px); }
}

@media (max-height: 400px) {
    .bent-agent-launcher[aria-expanded="true"] { visibility: hidden; }

    .bent-agent-panel {
        --bent-agent-panel-bottom: max(8px, env(safe-area-inset-bottom));
        --bent-agent-panel-top: max(12px, env(safe-area-inset-top));
        bottom: var(--bent-agent-panel-bottom);
        max-height: calc(100dvh - var(--bent-agent-panel-top) - var(--bent-agent-panel-bottom));
        scroll-padding: 76px 0 8px;
    }

    body.admin-bar .bent-agent-panel {
        --bent-agent-panel-top: max(54px, env(safe-area-inset-top));
        max-height: calc(100dvh - var(--bent-agent-panel-top) - var(--bent-agent-panel-bottom));
    }

    body:has(#seopress-user-consent-edit) .bent-agent-panel {
        width: min(410px, calc(100vw - 246px));
    }

    .bent-agent-header { padding: 10px 12px; }
}

@media (max-height: 400px) and (max-width: 559px) {
    body:has(#seopress-user-consent-edit) .bent-agent-panel {
        --bent-agent-panel-bottom: max(72px, calc(env(safe-area-inset-bottom) + 64px));
        width: calc(100vw - 32px);
    }
}
