/* ── Bottom furniture budget ──────────────────────────────────────────────
   Four independent layers anchor themselves to the bottom of the viewport:
   this assistant, the expert FAB, the PWA install prompt, and page-owned
   sticky CTA bars (e.g. the course-intro enrol bar). Each was authored
   without knowledge of the others, so they piled up — the install prompt sat
   right on top of the "buy" button on every course sales page.
   `--bd-bottom-furniture` is the height already claimed by the page-owned
   bar; the global layers lift themselves clear of it. It is published by
   floating-assistant.js, which measures the bar live.

   ── Dock columns ──
   Clearing the page's own bar is only half the problem: the launchers also
   collided with EACH OTHER, because more than one of them claims the same
   corner (the expert FAB and the استاد هوشمند coach FAB are both pinned to
   the physical left). So every fixed launcher now declares which column it
   belongs to and where in that column it sits:

       data-bd-dock="left|right"   data-bd-dock-order="<n>"   (0 = bottom-most)
       data-bd-dock-anchor="<sel>" optional: the child whose box is the real
                                   visible size, when the container is inflated
                                   by an invisible teaser/label

   floating-assistant.js measures each visible launcher and publishes
   `--bd-dock-offset` on it (the stacked height of everything below it in the
   same column) plus `--bd-dock-left-height` / `--bd-dock-right-height` on
   :root for full-width layers. Every docked launcher therefore reads:

       bottom: calc(<base> + var(--bd-bottom-furniture, 0px) + var(--bd-dock-offset, 0px))

   The fallbacks mean a launcher still renders correctly if the manager never
   runs. */
:root {
    --bd-bottom-furniture: 0px;
    --bd-dock-left-height: 0px;
    --bd-dock-right-height: 0px;
    /* Shared puck size: plus FAB and «ارتباط با کارشناس» stay visually equal. */
    --bd-fab-size: 60px;
}

.bd-floating-assistant {
    position: fixed;
    right: 18px;
    bottom: calc(22px + var(--bd-bottom-furniture, 0px) + var(--bd-dock-offset, 0px));
    z-index: 99999;
    direction: rtl;
    font-family: inherit;
    /* NO `filter` on this container. A filtered element becomes a *backdrop
       root*, and a descendant's `backdrop-filter` may only sample what is
       painted inside that root — i.e. nothing. The old
       `filter: drop-shadow(...)` here silently neutralised the frosted glass on
       every menu item, leaving them as flat 34%-white panes that the page bled
       straight through (labels unreadable over the homepage hero). Shadows now
       live on each surface as real box-shadows instead. */
    pointer-events: none;

    /* Menu ink/surface tokens — one dark, self-sufficient contrast base so the
       labels stay legible over ANY background, blur or no blur. */
    --bd-fa-ink: #f3f7ff;
    --bd-fa-ink-dim: rgba(226, 236, 252, 0.72);
}

.bd-floating-assistant .bd-floating-main-btn,
.bd-floating-assistant.is-open .bd-floating-actions {
    pointer-events: auto;
}

/* Soft vignette that lifts the open menu off a busy hero. Purely decorative:
   it inherits pointer-events:none from the container, so taps fall through to
   the document listener that closes the menu. */
.bd-floating-assistant::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0;
    pointer-events: none;
    background: radial-gradient(125% 95% at 100% 100%,
        rgba(6, 14, 30, 0.44) 0%,
        rgba(6, 14, 30, 0.26) 34%,
        rgba(6, 14, 30, 0.08) 56%,
        rgba(6, 14, 30, 0) 72%);
    transition: opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.bd-floating-assistant.is-open::before {
    opacity: 1;
}

/* A full-screen navigation drawer owns the screen while it is open — floating
   launchers must not hover over its controls. */
body.bd-profile-sidebar-open .bd-floating-assistant,
body.bd-profile-sidebar-open .bd-expert-fab {
    opacity: 0;
    pointer-events: none;
}

.bd-floating-actions {
    position: absolute;
    right: 0;
    bottom: calc(var(--bd-fab-size, 60px) + 10px);
    display: grid;
    gap: 10px;
    max-height: min(72vh, 440px);
    /* overflow-y:auto computes overflow-x to auto too, which would clip the
       items' shadows and focus rings — padding (cancelled by an equal negative
       margin) gives them room without moving the stack. */
    padding: 10px 12px;
    margin: -10px -12px;
    overflow-y: auto;
    scrollbar-width: none;
    pointer-events: none;
    visibility: hidden;
    transition: visibility 0s linear 0.34s;
}

.bd-floating-actions::-webkit-scrollbar { display: none; }

.bd-floating-assistant.is-open .bd-floating-actions {
    pointer-events: auto;
    visibility: visible;
    transition-delay: 0s;
}

.bd-floating-action-btn {
    /* Per-item accent, overridden by the modifier classes below. */
    --bd-fa-accent: #7fb2ff;
    --bd-fa-accent-soft: rgba(127, 178, 255, 0.22);
    --bd-fa-accent-line: rgba(127, 178, 255, 0.5);

    position: relative;
    isolation: isolate;
    border: 1px solid rgba(255, 255, 255, 0.17);
    /* Deep, ~88% opaque glass. The 12% window keeps a real frosted feel now
       that backdrop-filter works again, while the dark base guarantees ≈11:1
       contrast for the label against ANY page behind it — that is the whole
       point: legibility must not depend on what the hero looks like. */
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0) 48%),
        linear-gradient(135deg, rgba(15, 29, 57, 0.9), rgba(28, 50, 92, 0.88));
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-radius: 17px;
    color: var(--bd-fa-ink, #f3f7ff);
    text-shadow: 0 1px 2px rgba(4, 10, 22, 0.45);
    box-shadow:
        0 16px 32px rgba(7, 18, 40, 0.34),
        0 3px 8px rgba(7, 18, 40, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
    min-width: 208px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    padding: 0 14px 0 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13.5px;
    font-family: inherit;
    text-align: right;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px) scale(0.94);
    transition:
        opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.24s ease,
        border-color 0.24s ease,
        background 0.2s ease;
}

/* Accent aura behind the label, anchored on the icon (inline-start = right in
   RTL). z-index:-1 inside the item's own stacking context paints it over the
   background but under the text. */
.bd-floating-action-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: radial-gradient(115% 135% at 100% 50%, var(--bd-fa-accent-soft), transparent 64%);
    pointer-events: none;
}

.bd-floating-action-btn--chatroom {
    --bd-fa-accent: #6fc2ff;
    --bd-fa-accent-soft: rgba(111, 194, 255, 0.24);
    --bd-fa-accent-line: rgba(111, 194, 255, 0.55);
}

.bd-floating-action-btn--chatbot {
    --bd-fa-accent: #b49bff;
    --bd-fa-accent-soft: rgba(180, 155, 255, 0.24);
    --bd-fa-accent-line: rgba(180, 155, 255, 0.55);
}

.bd-floating-action-btn--leitner {
    --bd-fa-accent: #ffc46b;
    --bd-fa-accent-soft: rgba(255, 196, 107, 0.22);
    --bd-fa-accent-line: rgba(255, 196, 107, 0.55);
}

/* Staggered reveal, counted from the item nearest the FAB so the menu unfurls
   away from the thumb. */
.bd-floating-assistant.is-open .bd-floating-action-btn {
    opacity: 1;
    transform: none;
}

.bd-floating-assistant.is-open .bd-floating-action-btn:nth-last-child(1) { transition-delay: 0.02s; }
.bd-floating-assistant.is-open .bd-floating-action-btn:nth-last-child(2) { transition-delay: 0.07s; }
.bd-floating-assistant.is-open .bd-floating-action-btn:nth-last-child(3) { transition-delay: 0.12s; }
.bd-floating-assistant.is-open .bd-floating-action-btn:nth-last-child(n + 4) { transition-delay: 0.17s; }

/* Collapse without the stagger. */
.bd-floating-assistant:not(.is-open) .bd-floating-action-btn {
    transition-delay: 0s;
}

@media (hover: hover) {
    .bd-floating-assistant.is-open .bd-floating-action-btn:hover {
        transform: translateX(-4px);
        border-color: var(--bd-fa-accent-line);
        background:
            linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 48%),
            linear-gradient(135deg, rgba(20, 38, 72, 0.94), rgba(35, 61, 110, 0.92));
        box-shadow:
            0 22px 42px rgba(7, 18, 40, 0.42),
            0 4px 12px rgba(7, 18, 40, 0.26),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
}

.bd-floating-assistant.is-open .bd-floating-action-btn:active {
    transform: scale(0.975);
}

.bd-floating-action-btn.has-unread {
    border-color: var(--bd-fa-accent-line);
    box-shadow:
        0 18px 36px rgba(7, 18, 40, 0.4),
        0 0 0 1px var(--bd-fa-accent-line),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.bd-floating-action-btn.has-unread-pulse::after {
    content: '';
    position: absolute;
    inset: -4px;
    /* concentric with the item's 17px radius */
    border-radius: 21px;
    border: 2px solid var(--bd-fa-accent-line);
    animation: bdFloatingUnreadPulse 1.8s ease-out infinite;
    pointer-events: none;
}

.bd-floating-action-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff6b6b, #e03d5a);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    margin-inline-start: auto;
    text-shadow: none;
    box-shadow:
        0 0 0 2px rgba(13, 25, 48, 0.75),
        0 6px 14px rgba(190, 40, 66, 0.45);
}

@keyframes bdFloatingUnreadPulse {
    0% {
        opacity: 0;
        transform: scale(0.96);
    }
    30% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: scale(1.08);
    }
}

.bd-floating-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
    border: 1px solid var(--bd-fa-accent-line);
    color: var(--bd-fa-accent);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 4px 12px rgba(5, 12, 28, 0.28);
    flex-shrink: 0;
    transition: background 0.18s ease, box-shadow 0.24s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) {
    .bd-floating-action-btn:hover .bd-floating-action-icon {
        background: linear-gradient(150deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08));
        transform: scale(1.06);
    }
}

.bd-floating-action-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.bd-floating-main-btn {
    width: var(--bd-fab-size, 60px);
    height: var(--bd-fab-size, 60px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.26);
    /* Opaque brand gradient rather than white glass: the launcher used to sit
       almost invisibly on the light homepage hero. */
    background: linear-gradient(145deg, #3b86ec 0%, #1f56c4 58%, #17409e 100%);
    color: #ffffff;
    cursor: pointer;
    box-shadow:
        0 20px 40px rgba(14, 46, 110, 0.42),
        0 4px 12px rgba(14, 46, 110, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.34);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.24s ease, background 0.28s ease;
    position: relative;
}

.bd-floating-main-btn::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 25px;
    border: 1.5px solid rgba(93, 156, 245, 0.45);
    animation: bdFloatingRingPulse 2.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes bdFloatingRingPulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

.bd-floating-main-btn:hover {
    box-shadow:
        0 26px 48px rgba(14, 46, 110, 0.5),
        0 6px 16px rgba(14, 46, 110, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.bd-floating-main-btn svg {
    width: 28px;
    height: 28px;
    display: block;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Open = the button is now a close affordance: it drops the brand blue and
   joins the dark menu it belongs to. */
.bd-floating-assistant.is-open .bd-floating-main-btn {
    transform: rotate(45deg);
    background: linear-gradient(145deg, #26395c 0%, #182742 60%, #111d33 100%);
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow:
        0 16px 32px rgba(7, 18, 40, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.bd-floating-assistant.is-open .bd-floating-main-btn::before {
    opacity: 0;
    animation: none;
}

.bd-leitner-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
}

.bd-leitner-modal.is-open {
    display: block;
}

.bd-leitner-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 12, 22, 0.42);
    backdrop-filter: blur(4px);
}

.bd-leitner-modal-card {
    position: absolute;
    right: 20px;
    bottom: 96px;
    width: min(92vw, 430px);
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.2));
    box-shadow: 0 30px 55px rgba(9, 21, 44, 0.32);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    padding: 16px;
    color: #101a2f;
}

.bd-leitner-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.bd-leitner-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
}

.bd-leitner-subtitle {
    margin: 4px 0 0;
    color: #364564;
    font-size: 12px;
    line-height: 1.55;
}

.bd-leitner-close {
    border: 0;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.52);
    cursor: pointer;
    color: #102743;
    font-size: 19px;
}

.bd-leitner-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.bd-leitner-mode-wrap {
    margin-bottom: 8px;
    display: grid;
    gap: 4px;
}

.bd-leitner-mode-label {
    font-size: 12px;
    color: #34486a;
    font-weight: 700;
}

.bd-leitner-mode-select {
    height: 38px;
    border: 1px solid rgba(15, 34, 65, 0.16);
    border-radius: 11px;
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.74);
    color: #0d1f3b;
    font-size: 13px;
    font-family: inherit;
}

.bd-leitner-input {
    height: 44px;
    border: 1px solid rgba(15, 34, 65, 0.16);
    border-radius: 13px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.74);
    color: #0d1f3b;
    font-size: 14px;
}

.bd-leitner-primary-btn,
.bd-leitner-secondary-btn {
    border: 0;
    border-radius: 13px;
    padding: 0 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.bd-leitner-primary-btn {
    background: linear-gradient(135deg, #1f8f7a, #1d6ce0);
    color: #fff;
    height: 44px;
}

.bd-leitner-secondary-btn {
    height: 42px;
    background: rgba(255, 255, 255, 0.68);
    color: #143156;
    border: 1px solid rgba(17, 45, 84, 0.2);
}

.bd-leitner-status {
    min-height: 21px;
    margin: 10px 2px 8px;
    font-size: 12px;
    color: #1b4f97;
}

.bd-leitner-status.is-error {
    color: #b72f57;
}

.bd-leitner-status.is-success {
    color: #0f8b5f;
}

/* --- ارتباط با کارشناس (contact-expert modal) --- */
.bd-expert-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
}

.bd-expert-modal.is-open {
    display: block;
}

.bd-expert-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 12, 22, 0.42);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.bd-expert-modal-card {
    position: absolute;
    right: 20px;
    bottom: 96px;
    width: min(92vw, 400px);
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.24));
    box-shadow: 0 30px 55px rgba(9, 21, 44, 0.32);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    padding: 16px;
    color: #101a2f;
}

.bd-expert-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.bd-expert-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
}

.bd-expert-subtitle {
    margin: 6px 0 0;
    color: #364564;
    font-size: 12px;
    line-height: 1.6;
}

.bd-expert-close {
    border: 0;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.52);
    cursor: pointer;
    color: #102743;
    font-size: 19px;
    flex: 0 0 auto;
}

.bd-expert-form {
    display: grid;
    gap: 10px;
}

.bd-expert-input,
.bd-expert-textarea {
    width: 100%;
    border: 1px solid rgba(15, 34, 65, 0.16);
    border-radius: 13px;
    padding: 11px 12px;
    background: rgba(255, 255, 255, 0.78);
    color: #0d1f3b;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.bd-expert-textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.6;
}

.bd-expert-input:focus,
.bd-expert-textarea:focus {
    outline: none;
    border-color: rgba(31, 143, 122, 0.6);
    box-shadow: 0 0 0 3px rgba(31, 143, 122, 0.16);
}

.bd-expert-submit {
    border: 0;
    border-radius: 13px;
    padding: 0 14px;
    height: 46px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    background: linear-gradient(135deg, #1f8f7a, #1d6ce0);
    color: #fff;
    font-size: 14px;
}

.bd-expert-submit:disabled {
    opacity: 0.65;
    cursor: default;
}

.bd-expert-status {
    min-height: 18px;
    font-size: 12px;
    color: #1b4f97;
    line-height: 1.6;
}

.bd-expert-status.is-error {
    color: #b72f57;
}

.bd-expert-status.is-success {
    color: #0f8b5f;
}

.bd-expert-cta {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    padding: 8px 12px;
    border: 1px solid #1f4b82;
    border-radius: 10px;
    background: #eef4ff;
    color: #1f4b82;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.bd-expert-cta[hidden] {
    display: none;
}

.bd-leitner-result-list {
    display: grid;
    gap: 8px;
    max-height: 44vh;
    overflow: auto;
    padding: 2px;
}

.bd-leitner-result-card {
    border: 1px solid rgba(18, 42, 76, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.68);
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bd-leitner-result-card.is-selected {
    border-color: rgba(32, 124, 235, 0.58);
    box-shadow: 0 0 0 2px rgba(37, 126, 241, 0.2);
}

.bd-leitner-result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.bd-leitner-word {
    font-size: 15px;
    font-weight: 800;
    color: #102341;
}

.bd-leitner-meaning {
    margin-top: 4px;
    font-size: 13px;
    color: #32435f;
}

.bd-leitner-meta {
    margin-top: 6px;
    display: grid;
    gap: 4px;
}

.bd-leitner-meta-row {
    font-size: 12px;
    color: #223a5f;
    line-height: 1.5;
    text-align: right;
}

.bd-leitner-meta-label {
    font-weight: 700;
    margin-left: 4px;
}

.bd-leitner-meta-value {
    font-weight: 500;
}

.bd-leitner-example {
    margin-top: 6px;
    font-size: 12px;
    color: #3c5d8d;
    direction: ltr;
    text-align: left;
}

.bd-leitner-foot {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

body.bd-floating-chatroom-is-open {
    overflow: hidden;
}

.bd-floating-chatroom-modal {
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: none;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.bd-floating-chatroom-modal.is-open {
    display: block;
    opacity: 1;
}

.bd-floating-chatroom-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 12, 22, 0.52);
    backdrop-filter: blur(14px) saturate(130%);
    -webkit-backdrop-filter: blur(14px) saturate(130%);
}

.bd-floating-chatroom-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(96vw, 1380px);
    height: min(94vh, 960px);
    border-radius: 30px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.38);
    background: linear-gradient(160deg, rgba(247, 250, 255, 0.95), rgba(235, 245, 255, 0.88));
    box-shadow: 0 40px 100px rgba(10, 26, 52, 0.36), 0 8px 24px rgba(10, 26, 52, 0.16);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    animation: bdFloatingChatroomEnter 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bdFloatingChatroomEnter {
    from {
        opacity: 0;
        transform: translate(-50%, calc(-50% + 18px)) scale(0.976);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.bd-floating-chatroom-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 22px;
    border-bottom: 1px solid rgba(183, 206, 236, 0.4);
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(247,252,255,0.78));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.bd-floating-chatroom-head-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bd-floating-chatroom-head-copy {
    display: grid;
    gap: 3px;
}

.bd-floating-chatroom-head-copy strong {
    font-size: 1rem;
    font-weight: 800;
    color: #0f2644;
    letter-spacing: -0.01em;
}

.bd-floating-chatroom-head-copy span {
    font-size: 0.76rem;
    color: #5a7599;
}

.bd-floating-chatroom-close,
.bd-floating-chatroom-minimize {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(175, 200, 232, 0.4);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    color: #2a4e7a;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.bd-floating-chatroom-close:hover {
    background: rgba(255, 236, 238, 0.9);
    border-color: rgba(225, 155, 160, 0.5);
    color: #a83a40;
    transform: scale(1.08);
}

.bd-floating-chatroom-minimize:hover {
    background: rgba(235, 245, 255, 0.9);
    border-color: rgba(155, 190, 235, 0.6);
    transform: scale(1.08);
}

.bd-floating-chatroom-shell {
    display: flex;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.bd-floating-chatroom-shell > .bd-chatroom {
    flex: 1 1 auto;
    min-height: 0;
}

.bd-floating-chatroom-modal.is-minimized {
    display: block;
    opacity: 1;
    pointer-events: none;
}

.bd-floating-chatroom-modal.is-minimized .bd-floating-chatroom-backdrop,
.bd-floating-chatroom-modal.is-minimized .bd-floating-chatroom-shell,
.bd-floating-chatroom-modal.is-minimized .bd-floating-chatroom-head-copy span {
    display: none;
}

.bd-floating-chatroom-modal.is-minimized .bd-floating-chatroom-panel {
    pointer-events: auto;
    width: auto;
    height: auto;
    min-width: 220px;
    left: auto;
    right: 18px;
    top: auto;
    bottom: 94px;
    transform: none;
    border-radius: 20px;
    grid-template-rows: auto;
    box-shadow: 0 24px 50px rgba(10, 26, 52, 0.26);
}

.bd-floating-chatroom-modal.is-minimized .bd-floating-chatroom-head {
    border-bottom: 0;
    padding: 12px 14px;
}

.bd-floating-chatroom-modal.is-minimized .bd-floating-chatroom-head-copy {
    gap: 0;
}

.bd-floating-chatroom-modal.is-minimized .bd-floating-chatroom-head-copy strong {
    font-size: 0.9rem;
}

.bd-floating-chatroom-shell .bd-chatroom {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 12px;
    gap: 12px;
}

.bd-floating-chatroom-shell .bd-chatroom-layout,
.bd-floating-chatroom-shell .bd-chatroom-sidebar,
.bd-floating-chatroom-shell .bd-chatroom-main {
    min-height: 0;
    max-height: none;
    height: 100%;
}

.bd-floating-chatroom-shell .bd-chatroom-thread-list,
.bd-floating-chatroom-shell .bd-chatroom-messages {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
}

.bd-floating-chatroom-shell .bd-chatroom-header,
.bd-floating-chatroom-shell .bd-chatroom-guidance,
.bd-floating-chatroom-shell .bd-chatroom-policy-note,
.bd-floating-chatroom-shell .bd-chatroom-dashboard-strip,
.bd-floating-chatroom-shell .bd-chatroom-header-actions,
.bd-floating-chatroom-shell .bd-chatroom-sidebar-head span {
    display: none;
}

.bd-floating-chatroom-shell .bd-chatroom {
    grid-template-rows: minmax(0, 1fr);
}

.bd-floating-chatroom-shell .bd-chatroom-layout {
    grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
    gap: 10px;
}

.bd-floating-chatroom-shell .bd-chatroom-sidebar {
    padding: 12px;
    grid-template-rows: auto auto minmax(0, 1fr);
}

.bd-floating-chatroom-shell .bd-chatroom-sidebar-head {
    padding: 0;
}

.bd-floating-chatroom-shell .bd-chatroom-sidebar-head strong {
    font-size: 0.9rem;
}

.bd-floating-chatroom-shell .bd-chatroom-filter-row {
    gap: 6px;
}

.bd-floating-chatroom-shell .bd-chatroom-pill,
.bd-floating-chatroom-shell .bd-chatroom-btn {
    min-height: 38px;
}

.bd-floating-chatroom-shell .bd-chatroom-main {
    border-radius: 20px;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.bd-floating-chatroom-shell .bd-chatroom-topbar {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 12px;
    gap: 10px;
}

.bd-floating-chatroom-shell .bd-chatroom-thread-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
}

.bd-floating-chatroom-shell .bd-chatroom-thread-summary strong {
    font-size: 0.92rem;
}

.bd-floating-chatroom-shell .bd-chatroom-topbar-actions {
    gap: 8px;
}

.bd-floating-chatroom-shell .bd-chatroom-action-group {
    gap: 6px;
}

.bd-floating-chatroom-shell .bd-chatroom.is-admin-view .bd-chatroom-main {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bd-floating-chatroom-shell .bd-chatroom.is-admin-view .bd-chatroom-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 12px calc(var(--bd-mobile-composer-space, 120px) + 16px);
}

.bd-floating-chatroom-shell .bd-chatroom.is-admin-view .bd-chatroom-composer {
    position: relative;
    bottom: auto;
    z-index: auto;
    flex: 0 0 auto;
}

.bd-floating-chatroom-shell .bd-chatroom-messages {
    min-height: 0;
    padding: 12px;
    gap: 10px;
}

.bd-floating-chatroom-shell .bd-chatroom-message {
    max-width: min(88%, 760px);
}

.bd-floating-chatroom-shell .bd-chatroom-composer {
    padding: 10px 12px;
    border-top: 1px solid rgba(188, 207, 235, 0.32);
    border-radius: 0;
    border-inline: 0;
    border-bottom: 0;
    background: linear-gradient(180deg, rgba(252, 253, 255, 0.95), rgba(245, 249, 255, 0.9));
}

.bd-floating-chatroom-shell .bd-chatroom-compose-row {
    align-items: end;
}

.bd-floating-chatroom-shell .bd-chatroom-compose-row textarea {
    min-height: 48px;
    max-height: 160px;
}

.bd-floating-chatroom-shell .bd-chatroom-files,
.bd-floating-chatroom-shell .bd-chatroom-pinned,
.bd-floating-chatroom-shell .bd-chatroom-typing,
.bd-floating-chatroom-shell .bd-chatroom-call-panel,
.bd-floating-chatroom-shell .bd-chatroom-screen-panel {
    margin-inline: 12px;
    margin-top: 10px;
}

@media (max-width: 640px) {
    .bd-floating-assistant {
        right: 14px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--bd-bottom-furniture, 0px) + var(--bd-dock-offset, 0px));
    }

    .bd-leitner-modal-card,
    .bd-expert-modal-card {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: 82px;
    }

    .bd-floating-action-btn {
        min-width: 194px;
        /* Never let a long label push the stack off the viewport edge. */
        max-width: calc(100vw - 44px);
        height: 54px;
        font-size: 13px;
        padding: 0 12px;
    }

    .bd-floating-action-icon {
        width: 34px;
        height: 34px;
    }

    .bd-floating-chatroom-panel {
        inset: 8px;
        width: auto;
        height: auto;
        transform: none;
        left: 8px;
        top: 8px;
        border-radius: 22px;
    }

    .bd-floating-chatroom-head {
        padding: 14px 16px;
    }

    .bd-floating-chatroom-modal.is-minimized .bd-floating-chatroom-panel {
        right: 10px;
        bottom: 82px;
        min-width: 190px;
    }

    .bd-floating-chatroom-shell .bd-chatroom {
        padding: 8px;
    }

    .bd-floating-chatroom-shell .bd-chatroom-layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr);
        min-height: 0;
        height: 100%;
    }

    .bd-floating-chatroom-shell .bd-chatroom.is-admin-view .bd-chatroom-layout {
        grid-template-rows: minmax(160px, 34vh) minmax(0, 1fr);
    }

    .bd-floating-chatroom-shell .bd-chatroom.is-admin-view .bd-chatroom-sidebar {
        display: grid !important;
        grid-template-rows: auto auto minmax(0, 1fr);
        max-height: min(34vh, 260px);
        min-height: 0;
        padding: 10px;
        gap: 8px;
    }

    .bd-floating-chatroom-shell .bd-chatroom.is-user-view .bd-chatroom-sidebar {
        display: none !important;
    }

    .bd-floating-chatroom-shell .bd-chatroom-main {
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    .bd-floating-chatroom-shell .bd-chatroom-filter-row,
    .bd-floating-chatroom-shell .bd-chatroom-search-inline,
    .bd-floating-chatroom-shell [data-chatroom-call-toggle],
    .bd-floating-chatroom-shell [data-chatroom-load-files],
    .bd-floating-chatroom-shell [data-chatroom-screen-toggle],
    .bd-floating-chatroom-shell [data-chatroom-archive-thread],
    .bd-floating-chatroom-shell .bd-chatroom-topbar,
    .bd-floating-chatroom-shell .bd-chatroom-guidance,
    .bd-floating-chatroom-shell .bd-chatroom-policy-note,
    .bd-floating-chatroom-shell .bd-chatroom-pinned,
    .bd-floating-chatroom-shell .bd-chatroom-typing,
    .bd-floating-chatroom-shell .bd-chatroom-dashboard-strip {
        display: none !important;
    }

    .bd-floating-chatroom-shell .bd-chatroom-action-group-primary,
    .bd-floating-chatroom-shell .bd-chatroom-action-group-secondary {
        display: none !important;
    }

    .bd-floating-chatroom-shell .bd-chatroom-action-group {
        display: none !important;
    }

    .bd-floating-chatroom-shell .bd-chatroom-messages {
        padding: 10px 10px calc(var(--bd-mobile-composer-space, 164px) + 18px + env(safe-area-inset-bottom));
        min-height: 0;
        overflow-y: auto;
    }

    .bd-floating-chatroom-shell .bd-chatroom-message {
        max-width: 94%;
    }

    .bd-floating-chatroom-shell .bd-chatroom-composer {
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .bd-floating-chatroom-shell .bd-chatroom-compose-actions {
        width: 100%;
        display: grid;
        grid-template-columns: auto auto auto minmax(92px, 1fr);
    }
}

/* ─── Focus-visible keyboard navigation ─── */
.bd-floating-main-btn:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, 0.9),
        0 0 0 6px rgba(47, 111, 229, 0.65),
        0 16px 32px rgba(14, 46, 110, 0.36);
}

.bd-floating-action-btn:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 2px rgba(9, 19, 38, 0.9),
        0 0 0 5px var(--bd-fa-accent),
        0 16px 32px rgba(7, 18, 40, 0.36);
}

/* ─── Prefers reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
    .bd-floating-assistant::before,
    .bd-floating-actions,
    .bd-floating-action-btn,
    .bd-floating-action-icon,
    .bd-floating-main-btn {
        transition: none !important;
        animation: none !important;
        transition-delay: 0s !important;
    }

    .bd-floating-assistant.is-open .bd-floating-action-btn:hover,
    .bd-floating-assistant.is-open .bd-floating-action-btn:active {
        transform: none;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
   ارتباط با کارشناس — standalone floating launcher
   Lives in the bottom-inline-end corner (physically left on this RTL site),
   opposite the assistant FAB, and anchors the live-chat panel that pops from
   the same corner. Independent of .bd-floating-assistant on purpose.
   ══════════════════════════════════════════════════════════════════════════ */

.bd-expert-fab {
    position: fixed;
    left: 18px;
    bottom: calc(22px + var(--bd-bottom-furniture, 0px) + var(--bd-dock-offset, 0px));
    z-index: 99998;
    direction: rtl;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    /* Container sits against the viewport's left edge; inside a direction:rtl
       flex column, flex-end IS that left edge — keep the stack flush with it. */
    align-items: flex-end;
    gap: 10px;
    opacity: 0;
    transform: translateY(18px) scale(0.94);
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* The container must stay pointer-transparent even when ready. It is stretched
   to ~261x108 by the `opacity: 0` teaser bubble, and at z-index 99998 that
   invisible box sits on top of everything below it — it was swallowing taps on
   the last two items of the profile drawer (بان میت and خروج از حساب), which
   land in exactly that region on a phone. Only the real controls opt back in. */
.bd-expert-fab.is-ready {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* The teaser opts itself back in via its own `.is-visible` rule below, so only
   the launcher button is re-enabled here. A descendant may set
   `pointer-events: auto` even when an ancestor is `none`. */
.bd-expert-fab.is-ready .bd-expert-fab-btn {
    pointer-events: auto;
}

/* Get out of the way while the expert conversation itself is on screen. */
body.bd-ec-open .bd-expert-fab,
body.bd-expert-form-open .bd-expert-fab {
    opacity: 0;
    transform: translateY(12px) scale(0.94);
    pointer-events: none;
}

.bd-expert-fab-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 11px;
    height: var(--bd-fab-size, 60px);
    padding: 0 20px 0 16px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    /* Teal end lands under the avatar (inline-start in RTL) so the online dot's
       teal ring blends; blue tail echoes the chat panel header. */
    background: linear-gradient(225deg, #1f8f7a 0%, #1d6ce0 100%);
    color: #fff;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 18px 38px rgba(16, 72, 96, 0.34), 0 4px 12px rgba(12, 27, 55, 0.16), inset 0 1px 1px rgba(255, 255, 255, 0.24);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.24s ease, filter 0.2s ease;
}

.bd-expert-fab-btn:hover {
    transform: translateY(-2px);
    filter: saturate(115%);
    box-shadow: 0 24px 48px rgba(16, 72, 96, 0.42), 0 6px 16px rgba(12, 27, 55, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.bd-expert-fab-btn:active {
    transform: translateY(0) scale(0.98);
}

.bd-expert-fab-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(51, 144, 236, 0.35), 0 18px 38px rgba(16, 72, 96, 0.34);
}

/* Attention ring — a slow breath, never a strobe. */
.bd-expert-fab-btn::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 999px;
    border: 1.5px solid rgba(45, 178, 156, 0.35);
    animation: bdExpertFabRing 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes bdExpertFabRing {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.045); }
}

.bd-expert-fab-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.32);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.bd-expert-fab-avatar svg {
    width: 21px;
    height: 21px;
    display: block;
    color: #fff;
}

.bd-expert-fab-dot {
    position: absolute;
    inset-inline-start: -2px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3ddc84;
    border: 2px solid #1a7f8f;
    animation: bdExpertFabPulse 2.4s ease-out infinite;
}

@keyframes bdExpertFabPulse {
    0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.6); }
    70% { box-shadow: 0 0 0 7px rgba(61, 220, 132, 0); }
    100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); }
}

.bd-expert-fab-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.3;
    min-width: 0;
    text-align: right;
}

.bd-expert-fab-label {
    font-size: 13.5px;
    font-weight: 800;
    white-space: nowrap;
}

.bd-expert-fab-sub {
    font-size: 10.5px;
    font-weight: 600;
    opacity: 0.82;
    white-space: nowrap;
}

.bd-expert-fab-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ff4d5e;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 6px 14px rgba(255, 77, 94, 0.4);
}

.bd-expert-fab-badge[hidden] {
    display: none;
}

.bd-expert-fab.has-unread .bd-expert-fab-btn {
    animation: bdExpertFabNudge 1.6s ease-in-out infinite;
}

@keyframes bdExpertFabNudge {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* ── teaser bubble ── */
.bd-expert-fab-teaser {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: min(78vw, 260px);
    padding: 10px 12px;
    border-radius: 16px 16px 16px 6px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    box-shadow: 0 16px 32px rgba(12, 27, 55, 0.18);
    color: #123055;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    pointer-events: none;
    transform-origin: bottom left;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.bd-expert-fab-teaser.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.bd-expert-fab-teaser-text {
    border: 0;
    background: none;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.6;
    color: inherit;
    text-align: right;
    cursor: pointer;
}

.bd-expert-fab-teaser-close {
    flex: 0 0 auto;
    /* The visible puck stays 20px; the box is padded out to a 32px hit area so
       the dismiss target is not a sub-finger-width dot. */
    width: 32px;
    height: 32px;
    margin: -6px -6px -6px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background-clip: content-box;
    padding: 6px;
    background: rgba(18, 48, 85, 0.08);
    color: #123055;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.16s ease;
}

.bd-expert-fab-teaser-close:hover {
    background: rgba(18, 48, 85, 0.16);
}

/* While the PWA install card sits in the expert FAB's corner, hide the
   expert launcher (button + teaser) so the prompt is the only control
   there. Dismiss/install removes `bd-pwa-banner-open` and the FAB returns.
   The plus FAB lives in the opposite corner and stays usable. */
body.bd-pwa-banner-open .bd-expert-fab {
    opacity: 0 !important;
    visibility: hidden;
    pointer-events: none !important;
    transform: none;
}

@media (max-width: 640px) {
    .bd-expert-fab {
        left: 14px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--bd-bottom-furniture, 0px) + var(--bd-dock-offset, 0px));
    }

    :root {
        --bd-fab-size: 56px;
    }

    .bd-floating-main-btn svg {
        width: 24px;
        height: 24px;
    }

    /* Icon-only puck on phones — the label would crowd the FAB. */
    .bd-expert-fab-btn {
        height: var(--bd-fab-size, 56px);
        width: var(--bd-fab-size, 56px);
        padding: 0;
        justify-content: center;
    }

    .bd-expert-fab-copy {
        display: none;
    }

    /* Physical right: the puck hugs the viewport's left edge, so a badge on the
       inline-end (= left in RTL) side would sit half off-screen. */
    .bd-expert-fab-badge {
        position: absolute;
        top: -2px;
        right: -4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bd-expert-fab,
    .bd-expert-fab-btn,
    .bd-expert-fab-teaser {
        transition: none !important;
    }

    .bd-expert-fab-btn::before,
    .bd-expert-fab-dot,
    .bd-expert-fab.has-unread .bd-expert-fab-btn {
        animation: none !important;
    }

    .bd-expert-fab-btn:hover {
        transform: none;
    }
}
