/* Haman AI Chatbot — widget stylesheet.
 * Loaded twice on purpose: once as a normal wp_enqueue_style() <link> in the
 * host page (so it's a real, cacheable, versioned asset per WordPress
 * convention), and a second time via a <link> the widget script creates
 * inside its own Shadow DOM root — that second load is what actually
 * isolates these rules from the host theme's CSS (and isolates the host
 * theme's CSS from these rules). The browser serves the second load from
 * cache, so this costs nothing extra over the network.
 *
 * :host{} rules below target the shadow *host* element (the plain div the
 * script attaches the shadow root to) from inside the shadow tree — that's
 * the standard way to style the widget's own outer box from its own
 * stylesheet.
 *
 * Brand redesign (2026-09-23): the widget runs on a CUSTOMER's site, an
 * origin we don't control, so its fonts cannot assume the host theme loaded
 * anything useful — these @font-face rules point at hamanai.com, a domain
 * we do control, the same files laravel-backend/public/css/brand.css
 * self-hosts for the landing page and panels (already served with
 * Access-Control-Allow-Origin: *, which cross-origin @font-face requires).
 * Not Google Fonts or any third-party CDN, for the same reason brand.css
 * gives: this platform is used from Iran, where a CDN being unreachable is
 * routine, and a font request that hangs is worse than one that never
 * arrives. Same unicode-range split as brand.css too — a Persian-only
 * conversation never fetches the Latin-only Poppins/Roboto files at all.
 */
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    src: url('https://hamanai.com/fonts/poppins-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    src: url('https://hamanai.com/fonts/poppins-700.woff2') format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
    src: url('https://hamanai.com/fonts/roboto-variable.woff2') format('woff2-variations'), url('https://hamanai.com/fonts/roboto-variable.woff2') format('woff2');
}
@font-face {
    font-family: 'Vazirmatn';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('https://hamanai.com/fonts/vazirmatn-variable.woff2') format('woff2-variations'), url('https://hamanai.com/fonts/vazirmatn-variable.woff2') format('woff2');
}

/* Which corner the widget occupies is controlled by :host's own
 * data-position attribute (set from widget_config in haman-widget.js),
 * never by `dir` — text direction and on-page position are independent
 * settings. A Persian chatbot must be able to stay bottom-right (the
 * common convention) and vice versa. Physical `right`/`left` (not
 * inset-inline-*) so the corner doesn't silently flip when dir changes. */
:host {
    all: initial;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2147483000;
    /* Brand blue (config('haman.brand.primary_color') on the server side —
     * see check-widget-brand-defaults.php, which fails the build if this
     * literal and that config value ever disagree again). haman-widget.js
     * overwrites this immediately from the chatbot's own configured color,
     * so it is only ever visible for the first paint before that runs, or
     * if a merchant has never set one — never a value they chose. */
    --hm-primary: #0098F8;
    --hm-primary-contrast: #ffffff;
    /* Set alongside --hm-primary by haman-widget.js's gradientFor(): the
     * exact brand gradient (#0098F8 → #4870F8 → #7050F8) when the color is
     * still ours, or a lighter shade of the merchant's OWN color otherwise
     * — a gradient effect that never introduces a hue they didn't choose. */
    --hm-gradient: linear-gradient(135deg, #0098F8, #4870F8, #7050F8);
    --hm-font-heading: 'Poppins', 'Vazirmatn', sans-serif;
    --hm-font-body: 'Roboto', 'Vazirmatn', sans-serif;
    font-family: var(--hm-font-body);
    display: block;
}

:host([data-position="bottom-left"]) {
    right: auto;
    left: 24px;
}

:host * {
    box-sizing: border-box;
}

/* align-items: flex-end/flex-start here is a physical choice (which side
 * of :host the button/window hug), not a text-direction one — it must
 * follow data-position, not #hm-w's own `dir` attribute, or the button
 * would drift to the wrong side whenever dir and position disagree. */
#hm-w {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

:host([data-position="bottom-left"]) #hm-w {
    align-items: flex-start;
}

#hm-box {
    display: none;
    flex-direction: column;
    width: 376px;
    height: 560px;
    max-height: 82vh;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 1px 2px rgba(0, 16, 48, .06), 0 16px 48px rgba(0, 16, 48, .16);
    overflow: hidden;
    margin-bottom: 16px;
}

#hm-box.hm-open {
    display: flex;
}

#hm-hdr {
    background: var(--hm-primary);
    color: var(--hm-primary-contrast);
    padding: 18px 20px;
    display: flex;
    gap: 12px;
    justify-content: flex-start;
    align-items: center;
    flex-shrink: 0;
}

#hm-hdr h3 {
    margin: 0;
    font-family: var(--hm-font-heading);
    font-size: 15.5px;
    font-weight: 600;
}

#hm-hdr-text {
    flex: 1;
    min-width: 0;
}

/* One persistent container, always rendered, whichever of the two it
 * currently holds — a plain <img> (customer's own avatar_url, set at
 * first paint or swapped in later by applyWidgetConfig()) or the brand
 * mark SVG (renderAvatarSlot() in haman-widget.js). A container that only
 * exists in the DOM once an avatar_url is already known could never be
 * found later to swap an image into if the FIRST paint had none — this
 * one is always there to update. */
#hm-avatar-hdr {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(255, 255, 255, .16);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#hm-avatar-hdr img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#hm-avatar-hdr svg {
    width: 22px;
    height: 22px;
}

#hm-hdr span {
    font-size: 12px;
    opacity: .8;
}

#hm-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
}

#hm-close:hover, #hm-close:focus-visible {
    background: rgba(255, 255, 255, .16);
}

#hm-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    background: #FAFBFF;
}

.hm-msg {
    max-width: 82%;
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 16, 48, .04);
}

.hm-msg.user {
    background: var(--hm-gradient);
    color: var(--hm-primary-contrast);
    align-self: flex-end;
    border-end-end-radius: 6px;
}

.hm-msg.bot {
    background: #fff;
    border: 1px solid #E9ECF5;
    color: #001030;
    align-self: flex-start;
    border-end-start-radius: 6px;
    padding-inline-end: 36px;
}

.hm-msg-copy {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    color: #707898;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .6;
}

.hm-msg-copy:hover, .hm-msg-copy:focus-visible {
    opacity: 1;
    background: rgba(0, 16, 48, .06);
}

/* ── Product cards (recommend_products) ────────────────────────────── */
/* A horizontally-scrolling strip rather than a fixed grid — this is what
 * actually makes it render correctly at any width (the ~376px desktop
 * popup and the full-viewport mobile sheet use the exact same rule, no
 * separate mobile override needed) instead of squeezing columns until
 * they're unreadable. */
.hm-product-cards {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    align-self: stretch;
    padding-bottom: 2px;
}

.hm-product-card {
    flex: 0 0 138px;
    width: 138px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #E9ECF5;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 2px rgba(0, 16, 48, .04);
}

.hm-product-card img {
    width: 100%;
    height: 92px;
    object-fit: cover;
    display: block;
    background: #F4F6FB;
}

.hm-product-card-noimg {
    width: 100%;
    height: 92px;
    background: #F4F6FB;
}

.hm-product-card-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hm-product-name {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    color: #001030;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hm-product-price {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--hm-primary);
}

.hm-stock-badge {
    font-size: 10px;
    padding: 3px 7px;
    border-radius: 8px;
    align-self: start;
    font-weight: 600;
}

.hm-stock-badge.hm-instock {
    background: #DCFCE7;
    color: #166534;
}

.hm-stock-badge.hm-outofstock {
    background: #FEE2E2;
    color: #991B1B;
}

/* ── Comparison table (compare_products) ───────────────────────────── */
/* Same horizontal-scroll strategy as the card strip above — a table that
 * scrolls sideways inside its own wrapper stays legible at any container
 * width instead of forcing columns to shrink. */
.hm-compare-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    align-self: stretch;
    border-radius: 14px;
    border: 1px solid #E9ECF5;
}

.hm-compare-table {
    border-collapse: collapse;
    font-size: 12px;
    width: 100%;
}

.hm-compare-table th, .hm-compare-table td {
    border-inline-start: 1px solid #E9ECF5;
    border-bottom: 1px solid #E9ECF5;
    padding: 8px 10px;
    text-align: start;
    white-space: nowrap;
}

.hm-compare-table th:first-child, .hm-compare-table td:first-child {
    border-inline-start: none;
}

.hm-compare-table thead th {
    background: #F4F6FB;
    vertical-align: top;
}

.hm-compare-table thead img {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border-radius: 10px;
    display: block;
    margin-bottom: 5px;
}

.hm-compare-name {
    font-weight: 600;
    color: #001030;
    white-space: normal;
    max-width: 120px;
}

.hm-compare-price {
    color: var(--hm-primary);
    font-weight: 700;
}

.hm-compare-table thead a {
    display: inline-block;
    margin-top: 4px;
    color: var(--hm-primary);
    font-size: 11px;
    text-decoration: underline;
}

.hm-compare-table tbody th {
    background: #F4F6FB;
    font-weight: 600;
    white-space: normal;
}

/* ── Markdown tables written directly in a reply's own text (mdToHtml) ──
 * Separate from .hm-compare-table above: that one is a structured
 * product_compare widget_block; this is a plain "| a | b |" table the
 * model wrote in prose, which the tool-based compare table doesn't cover
 * every time (the model can still choose to write one, or the compare_
 * products tool may not have fired this turn at all). Same horizontal-
 * scroll strategy so a wide table never breaks the widget's own width. */
.hm-md-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 6px 0;
    border-radius: 10px;
    border: 1px solid #E9ECF5;
}

.hm-md-table {
    border-collapse: collapse;
    font-size: 12px;
    width: 100%;
}

.hm-md-table th, .hm-md-table td {
    border-inline-start: 1px solid #E9ECF5;
    border-bottom: 1px solid #E9ECF5;
    padding: 6px 10px;
    text-align: start;
    white-space: nowrap;
}

.hm-md-table th:first-child, .hm-md-table td:first-child {
    border-inline-start: none;
}

.hm-md-table thead th {
    background: #F4F6FB;
    font-weight: 600;
}

/* ── Cart links (build_cart_url) ────────────────────────────────────── */
/* Real buttons, not a text link — clicking one navigates to the store's
 * own ?add-to-cart=ID URL, which WooCommerce itself handles; nothing here
 * adds anything on its own. */
.hm-cart-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: stretch;
}

.hm-cart-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--hm-gradient);
    color: var(--hm-primary-contrast);
    border-radius: 11px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    min-height: 38px;
}

.hm-cart-link-btn:hover, .hm-cart-link-btn:focus-visible {
    opacity: .92;
}

/* ── Inline add-to-cart (add_to_cart, Store API) ────────────────────── */
/* The Store API call fires the instant this renders (see autoAddToCart()
 * in haman-widget.js) — the customer already gave explicit consent by
 * asking for this, so there's no button, just .hm-atc-status moving from
 * "adding..." to a real confirmed result (or an error plus a fallback
 * link via .hm-atc-fallback-link). */
.hm-atc-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: stretch;
}

.hm-atc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    background: #F8FAFC;
    border: 1px solid #E9ECF5;
    border-radius: 12px;
    padding: 9px 12px;
}

.hm-atc-name {
    font-size: 13px;
    color: #001030;
    flex: 1 1 auto;
    min-width: 0;
}

.hm-atc-status {
    font-size: 12px;
    color: #4B5565;
}

.hm-atc-status a {
    color: var(--hm-primary);
    text-decoration: underline;
    margin-inline-start: 6px;
}

.hm-atc-status.hm-atc-success {
    color: #166534;
}

.hm-atc-status.hm-atc-error {
    color: #991B1B;
}

.hm-atc-fallback-link {
    margin-inline-start: 6px;
}

/* ── Payment link preview (create_payment_link) ─────────────────────── */
/* The real WooCommerce order is only ever created from .hm-payment-
 * confirm-btn's own click handler (handleConfirmPaymentClick() in
 * haman-widget.js) — never automatically when this card renders. */
.hm-payment-preview {
    align-self: stretch;
    background: #F8FAFC;
    border: 1px solid #E9ECF5;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hm-payment-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hm-payment-items li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: #001030;
}

.hm-payment-total {
    font-size: 13px;
    color: #001030;
    border-top: 1px dashed #E9ECF5;
    padding-top: 8px;
}

.hm-payment-confirm-btn {
    align-self: flex-start;
    background: var(--hm-gradient);
    color: var(--hm-primary-contrast);
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 38px;
}

.hm-payment-confirm-btn:disabled {
    opacity: .6;
    cursor: default;
}

.hm-payment-status {
    font-size: 12px;
    color: #166534;
}

.hm-payment-status a {
    color: var(--hm-primary);
    font-weight: 600;
    text-decoration: underline;
}

.hm-payment-status.hm-payment-error {
    color: #991B1B;
}

/* get_order_status: the send-code confirm, the code field, and the
   status/tracking/items list shown once the code is verified. */
.hm-order-status,
.hm-order-list {
    align-self: stretch;
    background: #F8FAFC;
    border: 1px solid #E9ECF5;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hm-order-status-prompt {
    font-size: 13px;
    color: #334155;
}

.hm-order-status-btn {
    align-self: flex-start;
    background: var(--hm-gradient);
    color: var(--hm-primary-contrast);
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 38px;
}

.hm-order-status-btn:disabled {
    opacity: .6;
    cursor: default;
}

.hm-order-status-verify {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hm-order-status-input {
    align-self: flex-start;
    width: 144px;
    padding: 9px 10px;
    font-size: 15px;
    letter-spacing: 2px;
    text-align: center;
    border: 1px solid #D7DBEA;
    border-radius: 10px;
    direction: ltr;
}

.hm-order-status-msg {
    font-size: 12px;
    color: #166534;
}

.hm-order-status-msg.hm-order-status-error {
    color: #991B1B;
}

.hm-order-card {
    border-bottom: 1px dashed #E9ECF5;
    padding-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hm-order-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.hm-order-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #001030;
}

.hm-order-state {
    font-weight: 500;
    color: var(--hm-primary);
}

.hm-order-meta {
    font-size: 12px;
    color: #707898;
}

.hm-order-items {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 12px;
    color: #334155;
}

/* Typing indicator: three animated dots shown while waiting for a response. */
.hm-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #E9ECF5;
    border-radius: 18px;
    border-end-start-radius: 6px;
    padding: 11px 15px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.hm-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--hm-primary);
    opacity: .55;
    animation: hm-typing-bounce 1.2s infinite ease-in-out;
}

.hm-typing span:nth-child(2) { animation-delay: .15s; }
.hm-typing span:nth-child(3) { animation-delay: .3s; }

/* Shown next to the dots once a reply is taking long enough (see
   CHECKING_LABEL_DELAY_MS in haman-widget.js) that a customer might wonder
   if anything is happening — most often while a stock/price tool call is
   in flight on a slow store. */
.hm-typing-label {
    font-size: 12px;
    color: #8A93A6;
}

@keyframes hm-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

#hm-scroll-bottom {
    position: absolute;
    bottom: 12px;
    inset-inline-end: 16px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #E9ECF5;
    background: #fff;
    color: var(--hm-primary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 16, 48, .1);
}

#hm-scroll-bottom.hm-visible {
    display: flex;
}

#hm-qq {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 0 18px 12px;
    flex-shrink: 0;
}

#hm-qq button {
    background: #fff;
    border: 1px solid #E9ECF5;
    color: var(--hm-primary);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    text-align: start;
    min-height: 44px;
}

#hm-qq button:hover, #hm-qq button:focus-visible {
    border-color: var(--hm-primary);
    background: #F4F8FF;
}

#hm-in-row {
    padding: 14px 16px;
    border-top: 1px solid #E9ECF5;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #fff;
}

#hm-in {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid #D7DBEA;
    border-radius: 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: calc(1.4em * 4 + 20px);
    line-height: 1.4;
    background: #FAFBFF;
}

#hm-in:focus-visible {
    border-color: var(--hm-primary);
    background: #fff;
}

#hm-send {
    background: var(--hm-gradient);
    color: var(--hm-primary-contrast);
    border: none;
    border-radius: 14px;
    padding: 11px 18px;
    cursor: pointer;
    font-size: 14px;
    min-width: 46px;
    min-height: 46px;
}

#hm-send:disabled {
    opacity: .5;
    cursor: default;
}

#hm-powered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: var(--hm-font-heading);
    font-size: 11px;
    color: #707898;
    padding: 9px 6px;
    background: #FAFBFF;
    border-top: 1px solid #F0F2F9;
    flex-shrink: 0;
}

#hm-powered svg, #hm-powered img { width: 13px; height: 15px; flex-shrink: 0; object-fit: contain; }

#hm-powered a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #001030;
    font-weight: 600;
    text-decoration: none;
}

#hm-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--hm-gradient);
    color: var(--hm-primary-contrast);
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 8px 28px rgba(0, 16, 48, .28);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform .15s ease;
}

#hm-btn:hover {
    transform: translateY(-2px);
}

/* Same pattern as #hm-avatar-hdr above — always present, holds an <img>
 * or the brand mark SVG. */
#hm-avatar-btn {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
}

#hm-avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#hm-avatar-btn svg {
    width: 30px;
    height: 35px;
}

#hm-btn:focus-visible {
    outline: 2px solid var(--hm-primary);
    outline-offset: 3px;
}

#hm-unread-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #EF4444;
    border: 2.5px solid #fff;
    display: none;
}

:host([data-position="bottom-left"]) #hm-unread-dot {
    right: auto;
    left: 2px;
}

#hm-unread-dot.hm-visible {
    display: block;
}

/* ── Mobile: full-screen sheet below 480px ─────────────────────────── */
@media (max-width: 480px) {
    /* Scoped to .hm-mobile-open (set on the host itself by openWidget()/
     * closeWidget() in haman-widget.js) — NOT a bare :host. An
     * unconditional :host here would size the shadow host to the full
     * viewport at all times below 480px, and since a plain box (no
     * pointer-events:none) captures clicks across its whole bounding
     * rect regardless of visible content, that silently made the entire
     * page unclickable on mobile even while the widget was closed. */
    :host(.hm-mobile-open) {
        bottom: 0;
        inset-inline-end: 0;
        inset-inline-start: 0;
        top: 0;
    }

    #hm-w {
        align-items: stretch;
        height: 100%;
    }

    #hm-box {
        display: none;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        margin-bottom: 0;
        position: fixed;
        inset: 0;
    }

    #hm-box.hm-open {
        display: flex;
    }

    #hm-hdr {
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
    }

    #hm-in-row {
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    #hm-btn {
        position: fixed;
        bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        right: calc(24px + env(safe-area-inset-right, 0px));
    }

    :host([data-position="bottom-left"]) #hm-btn {
        right: auto;
        left: calc(24px + env(safe-area-inset-left, 0px));
    }

    /* Widget open on mobile: the floating button sits behind the fullscreen
       sheet anyway, but hiding it avoids it flashing above the keyboard. */
    #hm-w.hm-mobile-open #hm-btn {
        display: none;
    }
}
