/* Public-site skin for the shared chat. Keep widget defaults on other sites. */
body.pd-public-bg .abw-chat-panel,
body.pd-public-bg .abw-chat-trigger {
    --abw-primary: var(--accent-orange);
    --abw-primary-hover: var(--accent-orange-hover);
    --abw-primary-light: var(--accent-orange-muted);
    --abw-font: var(--font-sans);
    --abw-bg: var(--surface-1);
    --abw-text: var(--text-primary);
    --abw-border: var(--border);
    font-family: var(--abw-font);
    color-scheme: dark;
}

body.pd-public-bg .abw-chat-trigger {
    min-height: 52px;
    gap: 10px;
    padding: 13px 22px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 550;
    box-shadow: 0 8px 28px #0006;
    transition: background .2s, border-color .2s, transform .2s, opacity .2s;
}

body.pd-public-bg .abw-chat-trigger:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

body.pd-public-bg .abw-chat-trigger-icon { color: var(--accent-orange); }

/* Cult UI owns the controls and their rim animation; reuse the public palette. */
body.pd-public-bg .abw-chat-panel .cult-pro,
body.pd-public-bg .pd-support-chat-launcher {
    --pro-card: var(--surface-2);
    --pro-soft: var(--surface-hover);
    --pro-foreground: var(--text-primary);
    --pro-muted: var(--text-secondary);
    --pro-border: var(--border-strong);
    font-family: var(--font-sans);
}

body.pd-public-bg .pd-support-chat-launcher {
    position: fixed;
    z-index: var(--abw-z);
    right: 24px;
    bottom: 24px;
    max-width: calc(100vw - 32px);
    transition: opacity .2s, transform .2s;
}

body.pd-public-bg .pd-support-chat-launcher--left { left: 24px; right: auto; }
body.pd-public-bg .pd-support-chat-launcher > .abw-chat-trigger { position: relative; inset: auto; box-shadow: none; }
body.pd-public-bg .pd-support-chat-launcher:has(> .abw-chat-active) { opacity: 0; pointer-events: none; transform: scale(.92); }

body.pd-public-bg .abw-chat-panel .cult-pro-blob-1,
body.pd-public-bg .pd-support-chat-launcher .cult-pro-blob-1 {
    background: linear-gradient(90deg, var(--silver-mid), var(--accent-orange), var(--silver-light));
}

body.pd-public-bg .abw-chat-panel .cult-pro-blob-2,
body.pd-public-bg .pd-support-chat-launcher .cult-pro-blob-2 { background: var(--accent-orange); }

body.pd-public-bg .abw-chat-panel .cult-pro-blob-3,
body.pd-public-bg .pd-support-chat-launcher .cult-pro-blob-3 { background: var(--silver-mid); }

body.pd-public-bg .abw-chat-badge {
    background: var(--accent-orange);
    color: var(--brand-text);
    font-weight: 650;
    box-shadow: 0 0 0 3px var(--bg-main);
}

body.pd-public-bg .abw-chat-panel {
    width: 384px;
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    background: var(--surface-1);
    box-shadow: 0 24px 80px #0009;
    line-height: 1.5;
}

body.pd-public-bg .abw-chat-panel *,
body.pd-public-bg .abw-chat-panel *::before,
body.pd-public-bg .abw-chat-panel *::after { box-sizing: border-box; }

body.pd-public-bg .abw-chat-header {
    flex-shrink: 0;
    padding: 20px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-primary);
}

body.pd-public-bg .abw-chat-title-wrap { flex: 1; }

body.pd-public-bg .abw-chat-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -.025em;
    white-space: normal;
    overflow-wrap: anywhere;
}

body.pd-public-bg .abw-chat-subtitle {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
    opacity: 1;
}

body.pd-public-bg .abw-chat-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    transition: background .2s, color .2s, border-color .2s;
}

body.pd-public-bg .abw-chat-close:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

body.pd-public-bg .abw-chat-close svg { width: 18px; height: 18px; }
body.pd-public-bg .abw-chat-header > .cult-pro-button-wrap { flex: none; }

body.pd-public-bg .abw-chat-messages {
    min-height: 0;
    padding: 20px;
    background: var(--bg-secondary);
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

body.pd-public-bg .abw-chat-message { margin-bottom: 14px; }
body.pd-public-bg .abw-chat-message:last-child { margin-bottom: 0; }

body.pd-public-bg .abw-chat-bubble {
    min-width: 0;
    max-width: 88%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 16px 16px 16px 4px;
    background: var(--surface-2);
    color: var(--text-primary);
    box-shadow: none;
}

body.pd-public-bg .abw-chat-message-user .abw-chat-bubble {
    border-color: color-mix(in srgb, var(--accent-orange) 30%, var(--surface-2));
    border-radius: 16px 16px 4px 16px;
    background: color-mix(in srgb, var(--accent-orange) 12%, var(--surface-2));
    color: var(--text-primary);
}

body.pd-public-bg .abw-chat-message-system .abw-chat-bubble {
    max-width: 100%;
    padding: 0 0 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary);
}

body.pd-public-bg .abw-chat-text {
    font-size: 14px;
    line-height: 1.55;
    word-break: normal;
    overflow-wrap: anywhere;
}

body.pd-public-bg .abw-chat-time {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    opacity: 1;
}

body.pd-public-bg .abw-chat-time:empty { display: none; }

body.pd-public-bg .abw-chat-form {
    flex-shrink: 0;
    gap: 10px;
    padding: 14px;
    background: var(--surface-1);
    border-top: 1px solid var(--border);
}

body.pd-public-bg .abw-chat-input {
    min-width: 0;
    min-height: 48px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: 14px/22px var(--abw-font);
    caret-color: var(--accent-orange);
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

body.pd-public-bg .abw-chat-input::placeholder { color: var(--text-secondary); opacity: 1; }

body.pd-public-bg .abw-chat-input:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 2px var(--accent-orange-muted);
}

body.pd-public-bg .abw-chat-form > .cult-pro-input-wrap { flex: 1; width: auto; min-width: 0; }
body.pd-public-bg .abw-chat-form > .cult-pro-button-wrap { flex: none; }
body.pd-public-bg .abw-chat-form .cult-pro-input-surface { min-height: 48px; padding: 11px 12px; }
body.pd-public-bg .abw-chat-input.cult-pro-input-control {
    height: 24px;
    min-height: 24px;
    max-height: 96px;
    font: 14px/24px var(--font-sans);
    resize: none;
}

body.pd-public-bg .abw-chat-form .cult-pro-input-wrap:focus-within > .cult-pro-input-surface {
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 2px var(--accent-orange-muted);
}

body.pd-public-bg .abw-chat-form > .cult-pro-button-wrap:has(> .abw-chat-send) {
    --pro-card: var(--accent-orange);
    --pro-foreground: var(--brand-text);
}

body.pd-public-bg .abw-chat-send {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    background: var(--accent-orange);
    color: var(--brand-text);
    transition: background .2s, opacity .2s;
}

body.pd-public-bg .abw-chat-send:hover:not(:disabled) { background: var(--accent-orange-hover); }
body.pd-public-bg .abw-chat-send:disabled { opacity: .45; }
body.pd-public-bg .abw-chat-send svg { width: 21px; height: 21px; }
body.pd-public-bg .abw-chat-send.cult-animated-button { width: 48px; height: 48px; }

body.pd-public-bg :is(.abw-chat-trigger, .abw-chat-close, .abw-chat-send):focus-visible {
    outline: 2px solid var(--accent-orange);
    outline-offset: 4px;
}

body.pd-public-bg .abw-chat-panel ::selection {
    color: var(--text-primary);
    background: var(--accent-orange-muted);
}

/* Keep the existing chat above the public site's mobile navigation. */
@media (max-width: 1080px) {
    body.pd-public-bg .abw-chat-trigger:not(.cult-animated-button).abw-pos-bottom-right,
    body.pd-public-bg .abw-chat-trigger:not(.cult-animated-button).abw-pos-bottom-left,
    body.pd-public-bg .pd-support-chat-launcher {
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    }

    body.pd-public-bg .abw-chat-panel {
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
        height: min(520px, calc(100vh - 108px - env(safe-area-inset-bottom, 0px)));
        height: min(520px, calc(100dvh - 108px - env(safe-area-inset-bottom, 0px)));
        max-height: calc(100vh - 108px - env(safe-area-inset-bottom, 0px));
        max-height: calc(100dvh - 108px - env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 520px) {
    body.pd-public-bg .abw-chat-panel.abw-pos-bottom-right,
    body.pd-public-bg .abw-chat-panel.abw-pos-bottom-left {
        left: 12px;
        right: 12px;
        width: auto;
    }

    body.pd-public-bg .abw-chat-header { padding: 16px; }
    body.pd-public-bg .abw-chat-messages { padding: 16px; }
    body.pd-public-bg .abw-chat-form { padding: 12px; gap: 8px; }
    /* Prevent input focus from zooming the page on iOS. */
    body.pd-public-bg .abw-chat-input,
    body.pd-public-bg .abw-chat-input.cult-pro-input-control { font-size: 16px; }
    body.pd-public-bg .pd-support-chat-launcher { right: 16px; }
    body.pd-public-bg .pd-support-chat-launcher--left { left: 16px; right: auto; }
}

@media (prefers-reduced-motion: reduce) {
    body.pd-public-bg :is(.abw-chat-trigger, .abw-chat-panel, .abw-chat-close, .abw-chat-send, .abw-chat-input, .pd-support-chat-launcher) { transition: none; }
    body.pd-public-bg .abw-chat-trigger:hover { transform: none; }
}
