/* Container */
.hibww-chat-container {
    max-width: 450px;
    margin: 30px auto;
    border-radius: var(--hibww-border-radius, 20px);
    font-family: var(--hibww-font-family, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    background: var(--hibww-bg, #ffffff);
    backdrop-filter: var(--hibww-backdrop, none);
    -webkit-backdrop-filter: var(--hibww-backdrop, none);
    box-shadow: var(--hibww-box-shadow, 0 10px 40px rgba(0, 0, 0, 0.08));
    border: var(--hibww-border-width, 1px) solid var(--hibww-border-color, rgba(128, 128, 128, 0.15));
    display: flex;
    flex-direction: column;
    height: min(600px, calc(100vh - var(--hibww-offset-y, 30px) - var(--hibww-offset-y, 30px)));
    overflow: hidden;
    color: var(--hibww-text-color, #111);
}

/* Header */
 .hibww-chat-header {
    background: var(--hibww-header-bg, #ffffff);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(128, 128, 128, 0.15);
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.hibww-chat-is-dragging .hibww-chat-header {
    cursor: grabbing;
}

.hibww-chat-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--hibww-header-text, #111);
    font-weight: 600;
    letter-spacing: -0.3px;
}

.hibww-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}


.hibww-restart-btn, .hibww-close-btn {
    background: transparent;
    border: none;
    color: var(--hibww-header-icon, #888);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 0;
}

.hibww-restart-btn:hover {
    color: var(--hibww-header-icon-hover, var(--hibww-header-text, #111));
    transform: rotate(-180deg);
}

.hibww-close-btn:hover {
    color: var(--hibww-header-icon-hover, var(--hibww-header-text, #111));
    transform: scale(1.1) rotate(90deg);
}

/* Messages area */
.hibww-chat-messages {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    
    /* Soft edge masking for smooth fade out at scrollport limits */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 6%, black 94%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 6%, black 94%, transparent 100%);
}

/* Bubbles */
.hibww-message {
    display: flex;
    max-width: 85%;
    animation: airwFadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}

.hibww-bot {
    align-self: flex-start;
    flex-direction: row;
    max-width: 95%;
    gap: 10px;
}

.hibww-bot-content {
	display: flex;
	flex-direction: column;
}

.hibww-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	align-self: flex-end;
}

.hibww-user {
    align-self: flex-end;
    flex-direction: column;
}

.hibww-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Bot minimalist bubble */
.hibww-bot .hibww-bubble {
    background: #9c205e;
    color: #ffffff;
    border: none;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* User minimalist bubble */
.hibww-user .hibww-bubble {
    background: #1b7187;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Lenker inni meldinger */
.hibww-bubble a {
    color: #ffffff !important;
    text-decoration: underline !important;
    font-weight: 500;
}
.hibww-bubble a:hover {
    color: #e0f0ff !important;
}
.hibww-user .hibww-bubble a {
    color: #8ab4f8 !important;
}
.hibww-user .hibww-bubble a:hover {
    color: #aecbfa !important;
}

.hibww-bubble strong {
    font-weight: 600;
}

/* Options */
.hibww-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.hibww-option-btn {
    background: transparent;
    border: 1px solid currentColor;
    color: var(--hibww-text-color, #333);
    padding: 10px 16px;
    border-radius: 100px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(8px);
    animation: airwFadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Staggered entrance animation for suggestion option buttons */
.hibww-options .hibww-option-btn:nth-child(1) { animation-delay: 0.04s; }
.hibww-options .hibww-option-btn:nth-child(2) { animation-delay: 0.08s; }
.hibww-options .hibww-option-btn:nth-child(3) { animation-delay: 0.12s; }
.hibww-options .hibww-option-btn:nth-child(4) { animation-delay: 0.16s; }
.hibww-options .hibww-option-btn:nth-child(5) { animation-delay: 0.20s; }
.hibww-options .hibww-option-btn:nth-child(6) { animation-delay: 0.24s; }
.hibww-options .hibww-option-btn:nth-child(7) { animation-delay: 0.28s; }
.hibww-options .hibww-option-btn:nth-child(8) { animation-delay: 0.32s; }

.hibww-option-btn:hover:not(:disabled) {
    background: var(--hibww-text-color, #111);
    color: var(--hibww-bg, #fff);
    border-color: var(--hibww-text-color, #111);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hibww-option-btn:focus-visible {
    outline: 2px solid var(--hibww-text-color, #111);
    outline-offset: 2px;
}

.hibww-option-btn:disabled {
    opacity: 0.3 !important;
    cursor: default;
    transform: none !important;
    box-shadow: none !important;
    transition: opacity 0.4s ease;
}

/* Sources */
.hibww-sources {
    margin-top: 12px;
    font-size: 12px;
    border-top: 1px solid #eaeaea;
    padding-top: 10px;
}
.hibww-sources ul { margin: 6px 0 0 16px; padding: 0; }
.hibww-sources a { color: #555; text-decoration: none; border-bottom: 1px solid #ccc; transition: color 0.2s; }
.hibww-sources a:hover { color: #111; border-color: #111; }

/* Input area */
.hibww-chat-input-area {
    display: flex;
    padding: 16px 24px;
    background: transparent;
    border-top: 1px solid rgba(128, 128, 128, 0.15);
    gap: 12px;
    align-items: center;
}

.hibww-chat-input-area input {
    flex-grow: 1;
    padding: 14px 20px;
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 100px;
    font-size: 16px; /* Viktig: Må være minst 16px for å unngå auto-zoom på iOS/iPhone */
    outline: none;
    background: var(--hibww-input-bg, rgba(128, 128, 128, 0.05));
    color: var(--hibww-text-color, #111);
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.hibww-chat-input-area input:focus {
    background: var(--hibww-input-bg, rgba(128, 128, 128, 0.1));
    border-color: var(--hibww-text-color, rgba(128, 128, 128, 0.4));
    box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.15); /* Soft premium focus ring */
}

.hibww-chat-input-area input::placeholder {
    color: var(--hibww-text-color, #111);
    opacity: 0.6;
}

/* Submit Button States */
.hibww-chat-submit {
    background: var(--hibww-text-color, #111);
    color: var(--hibww-bg, white);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.9);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

.hibww-chat-submit.hibww-submit-active {
    opacity: 1;
    cursor: pointer;
    pointer-events: auto;
    transform: scale(1);
}

.hibww-chat-submit.hibww-submit-active:hover {
    transform: scale(1.08);
}

.hibww-chat-submit.hibww-submit-active:active {
    transform: scale(0.95);
}

.hibww-chat-submit:focus-visible {
    outline: 2px solid var(--hibww-text-color, #111);
    outline-offset: 2px;
}

.hibww-chat-submit svg {
    margin-left: -2px; /* optical centering */
}

/* Loader / Typing Indicator */
.hibww-loading-indicator {
    display: none; /* controlled by JS display property */
    gap: 10px;
    max-width: 95%;
    align-self: flex-start;
    flex-direction: row;
    padding: 4px 24px 16px 24px;
    background: transparent;
    animation: airwFadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hibww-typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: var(--hibww-bot-bubble) !important;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.hibww-typing-bubble .hibww-dot {
    width: 6px;
    height: 6px;
    background-color: var(--hibww-bot-text, #ffffff);
    border: none;
    box-sizing: border-box;
    border-radius: 50%;
    display: inline-block;
    animation: airwBlink 1.4s infinite both;
}

.hibww-typing-bubble .hibww-dot:nth-child(1) { animation-delay: 0s; }
.hibww-typing-bubble .hibww-dot:nth-child(2) { animation-delay: 0.2s; }
.hibww-typing-bubble .hibww-dot:nth-child(3) { animation-delay: 0.4s; }

/* Animations */
@keyframes airwBlink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

@keyframes airwFadeUp {
    to { opacity: 1; transform: translateY(0); }
}

/* Side Squeeze: reflow the page beside the drawer on larger screens. */
@media (min-width: 768px) {
    html.hibww-squeeze-ready {
        --hibww-squeeze-size: clamp(320px, 34vw, 420px);
    }

    html.hibww-squeeze-ready body {
        box-sizing: border-box;
        padding-left: var(--hibww-page-padding-left, 0px) !important;
        padding-right: var(--hibww-page-padding-right, 0px) !important;
        transition: padding-left 0.52s cubic-bezier(0.16, 1, 0.3, 1),
                    padding-right 0.52s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    html.hibww-squeeze-ready.hibww-squeeze-active.hibww-squeeze-left body {
        padding-left: calc(var(--hibww-page-padding-left, 0px) + var(--hibww-squeeze-size)) !important;
    }

    html.hibww-squeeze-ready.hibww-squeeze-active.hibww-squeeze-right body {
        padding-right: calc(var(--hibww-page-padding-right, 0px) + var(--hibww-squeeze-size)) !important;
    }

    .hibww-floating-wrapper.hibww-drawer-layer.hibww-mode-squeeze:is(.hibww-edge-left, .hibww-edge-right) .hibww-floating-chat-container {
        width: var(--hibww-squeeze-size, clamp(320px, 34vw, 420px));
    }

    .hibww-floating-wrapper.hibww-drawer-layer.hibww-mode-squeeze .hibww-modal-backdrop {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .hibww-floating-wrapper.hibww-drawer-layer.hibww-mode-squeeze .hibww-floating-chat-container {
        width: 100vw !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
    }
}

@media (max-width: 600px) {
    .hibww-chat-container {
        border-radius: 20px;
        height: 80vh;
        max-height: 80vh;
        margin: 5vh auto;
    }
}

/* Floating Mode Styles */
.hibww-floating-wrapper {
    position: fixed;
    bottom: var(--hibww-offset-y, 30px);
    right: var(--hibww-offset-x, 30px);
    z-index: 2147483647;
    font-family: var(--hibww-font-family, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.hibww-floating-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px 10px 10px;
    border-radius: 50px; /* Keep pill shape */
    background: var(--hibww-bg, rgba(255, 255, 255, 0.7));
    backdrop-filter: var(--hibww-backdrop, blur(16px));
    -webkit-backdrop-filter: var(--hibww-backdrop, blur(16px));
    border: var(--hibww-border-width, 1px) solid var(--hibww-border-color, rgba(128, 128, 128, 0.2));
    box-shadow: var(--hibww-box-shadow, 0 8px 32px rgba(0, 0, 0, 0.1));
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--hibww-text-color, #111);
    overflow: hidden;
    white-space: nowrap;
    max-width: 300px; /* Safe upper limit */
}

/* Draggable Bubble Cursor & States */
.hibww-floating-bubble.hibww-draggable-bubble {
    cursor: grab;
    touch-action: none; /* Prevents page scrolling while dragging on touch devices */
    user-select: none;
    -webkit-user-select: none;
}

.hibww-floating-bubble.hibww-draggable-bubble:active,
.hibww-floating-bubble.hibww-is-dragging {
    cursor: grabbing !important;
    transition: none !important;
}

.hibww-floating-wrapper.hibww-is-dragging {
    transition: none !important;
}

.hibww-floating-bubble.hibww-collapsed {
    padding: 10px; /* Circle padding */
    gap: 0;
    max-width: 66px; /* Just enough for img 44px + pad 20px + border 2px */
}

.hibww-floating-bubble:hover {
    box-shadow: var(--hibww-box-shadow, 0 12px 40px rgba(0, 0, 0, 0.15));
    transform: scale(1.02);
}

.hibww-floating-bubble.hibww-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.hibww-floating-bubble img.hibww-bubble-avatar {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none;
}

.hibww-bubble-text {
    font-weight: 600;
    font-size: 15px;
    opacity: 1;
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
    display: inline-block;
    transition: opacity 0.2s ease, max-width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.hibww-floating-bubble.hibww-collapsed .hibww-bubble-text {
    opacity: 0;
    max-width: 0;
}

.hibww-floating-chat-container {
    box-sizing: border-box;
    position: fixed;
    bottom: var(--hibww-offset-y, 30px);
    right: var(--hibww-offset-x, 30px);
    width: 400px;
    max-width: calc(100vw - 40px);
    opacity: 0;
    pointer-events: none;
    z-index: 2147483647;
}

.hibww-floating-chat-container.hibww-open {
    opacity: 1;
    pointer-events: auto;
}

.hibww-floating-chat-container .hibww-chat-container {
    margin: 0;
    height: min(600px, calc(100vh - var(--hibww-offset-y, 30px) - var(--hibww-offset-y, 30px)));
    max-height: calc(100vh - var(--hibww-offset-y, 30px) - var(--hibww-offset-y, 30px));
    box-shadow: 0 15px 50px rgba(0,0,0,0.15);
    
    /* Initially transparent background and blur to enable smooth transition without pop */
    background: rgba(255, 255, 255, 0) !important;
    backdrop-filter: blur(0px) !important;
    -webkit-backdrop-filter: blur(0px) !important;
    border-color: rgba(128, 128, 128, 0) !important;
    transition: background 0.35s ease, backdrop-filter 0.35s ease, -webkit-backdrop-filter 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

.hibww-floating-chat-container.hibww-open .hibww-chat-container {
    background: var(--hibww-bg, #ffffff) !important;
    backdrop-filter: var(--hibww-backdrop, none) !important;
    -webkit-backdrop-filter: var(--hibww-backdrop, none) !important;
    border-color: var(--hibww-border-color, rgba(128, 128, 128, 0.15)) !important;
}

/* Animate the inner elements inside the chat container for bubble layout */
.hibww-floating-chat-container .hibww-chat-header,
.hibww-floating-chat-container .hibww-chat-messages,
.hibww-floating-chat-container .hibww-chat-input-area {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.hibww-floating-chat-container.hibww-open .hibww-chat-header,
.hibww-floating-chat-container.hibww-open .hibww-chat-messages,
.hibww-floating-chat-container.hibww-open .hibww-chat-input-area {
    opacity: 1;
    transform: translateY(0);
}

/* 8-Directional Position Presets */
.hibww-floating-wrapper.hibww-pos-bottom-right {
    bottom: var(--hibww-offset-y, 30px);
    right: var(--hibww-offset-x, 30px);
    top: auto;
    left: auto;
}
.hibww-floating-wrapper.hibww-pos-bottom-right .hibww-floating-chat-container {
    box-sizing: border-box;
    bottom: var(--hibww-offset-y, 30px);
    right: var(--hibww-offset-x, 30px);
    top: auto;
    left: auto;
}

.hibww-floating-wrapper.hibww-pos-bottom-left {
    bottom: var(--hibww-offset-y, 30px);
    left: var(--hibww-offset-x, 30px);
    top: auto;
    right: auto;
}
.hibww-floating-wrapper.hibww-pos-bottom-left .hibww-floating-chat-container {
    box-sizing: border-box;
    bottom: var(--hibww-offset-y, 30px);
    left: var(--hibww-offset-x, 30px);
    top: auto;
    right: auto;
}

.hibww-floating-wrapper.hibww-pos-bottom-center {
    bottom: var(--hibww-offset-y, 30px);
    left: 50%;
    right: auto;
    top: auto;
    transform: translateX(-50%);
}
.hibww-floating-wrapper.hibww-pos-bottom-center .hibww-floating-chat-container {
    box-sizing: border-box;
    bottom: var(--hibww-offset-y, 30px);
    left: 50%;
    right: auto;
    top: auto;
    transform: translateX(-50%);
}

.hibww-floating-wrapper.hibww-pos-top-right {
    top: var(--hibww-offset-y, 30px);
    right: var(--hibww-offset-x, 30px);
    bottom: auto;
    left: auto;
}
.hibww-floating-wrapper.hibww-pos-top-right .hibww-floating-chat-container {
    box-sizing: border-box;
    top: var(--hibww-offset-y, 30px);
    right: var(--hibww-offset-x, 30px);
    bottom: auto;
    left: auto;
}

.hibww-floating-wrapper.hibww-pos-top-left {
    top: var(--hibww-offset-y, 30px);
    left: var(--hibww-offset-x, 30px);
    bottom: auto;
    right: auto;
}
.hibww-floating-wrapper.hibww-pos-top-left .hibww-floating-chat-container {
    box-sizing: border-box;
    top: var(--hibww-offset-y, 30px);
    left: var(--hibww-offset-x, 30px);
    bottom: auto;
    right: auto;
}

.hibww-floating-wrapper.hibww-pos-top-center {
    top: var(--hibww-offset-y, 30px);
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
}
.hibww-floating-wrapper.hibww-pos-top-center .hibww-floating-chat-container {
    box-sizing: border-box;
    top: var(--hibww-offset-y, 30px);
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
}

.hibww-floating-wrapper.hibww-pos-middle-right {
    top: 50%;
    right: var(--hibww-offset-x, 30px);
    bottom: auto;
    left: auto;
    transform: translateY(-50%);
}
.hibww-floating-wrapper.hibww-pos-middle-right .hibww-floating-chat-container {
    box-sizing: border-box;
    top: 50%;
    right: var(--hibww-offset-x, 30px);
    bottom: auto;
    left: auto;
    transform: translateY(-50%);
}

.hibww-floating-wrapper.hibww-pos-middle-left {
    top: 50%;
    left: var(--hibww-offset-x, 30px);
    bottom: auto;
    right: auto;
    transform: translateY(-50%);
}
.hibww-floating-wrapper.hibww-pos-middle-left .hibww-floating-chat-container {
    box-sizing: border-box;
    top: 50%;
    left: var(--hibww-offset-x, 30px);
    bottom: auto;
    right: auto;
    transform: translateY(-50%);
}

/* Backward compatibility for legacy .hibww-left */
.hibww-floating-wrapper.hibww-left:not([class*="hibww-pos-"]) {
    right: auto;
    left: var(--hibww-offset-x, 30px);
}

.hibww-floating-wrapper.hibww-left:not([class*="hibww-pos-"]) .hibww-floating-chat-container {
    box-sizing: border-box;
    right: auto;
    left: var(--hibww-offset-x, 30px);
}


@media (max-width: 600px) {
    .hibww-floating-wrapper {
        bottom: 20px;
        right: 20px;
    }
    .hibww-floating-wrapper.hibww-left {
        right: auto;
        left: 20px;
    }
    .hibww-floating-chat-container {
        height: 100dvh !important;
    box-sizing: border-box;
        position: fixed !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        z-index: 2147483647 !important;
    }
    .hibww-floating-chat-container .hibww-chat-container {
        height: 100% !important;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }
    .hibww-floating-chat-container .hibww-chat-header {
        padding-top: max(20px, env(safe-area-inset-top));
    }
}

/* Edge Drawer / Off-Canvas Mode */
/* The launcher is independent from the viewport-level drawer surface. */
.hibww-floating-wrapper.hibww-mode-offcanvas {
    position: fixed;
    inset: auto !important;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    transform: none !important;
    pointer-events: none;
    z-index: 2147483647;
}

.hibww-floating-wrapper.hibww-mode-offcanvas .hibww-floating-bubble {
    position: fixed;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    max-width: 46px;
    height: auto;
    white-space: nowrap;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    pointer-events: auto;
    background: var(--hibww-bg, #ffffff) !important;
    color: var(--hibww-text-color, #111111) !important;
    border: var(--hibww-border-width, 1px) solid var(--hibww-border-color, rgba(128, 128, 128, 0.2)) !important;
    backdrop-filter: var(--hibww-backdrop, none);
    -webkit-backdrop-filter: var(--hibww-backdrop, none);
    transition:
        transform 0.42s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.32s ease;
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-right .hibww-floating-bubble {
    right: 0;
    border-right: none !important;
    border-radius: 10px 0 0 10px;
    transform-origin: right center;
    box-shadow: -4px 0 18px rgba(0, 0, 0, 0.12) !important;
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-left .hibww-floating-bubble {
    left: 0;
    border-left: none !important;
    border-radius: 0 10px 10px 0;
    transform-origin: left center;
    box-shadow: 4px 0 18px rgba(0, 0, 0, 0.12) !important;
}

.hibww-floating-wrapper.hibww-mode-offcanvas:is(.hibww-edge-left, .hibww-edge-right):is(.hibww-pos-top-left, .hibww-pos-top-right) .hibww-floating-bubble {
    top: max(16px, var(--hibww-offset-y, 30px));
    transform: translateY(0);
}

.hibww-floating-wrapper.hibww-mode-offcanvas:is(.hibww-edge-left, .hibww-edge-right):is(.hibww-pos-middle-left, .hibww-pos-middle-right) .hibww-floating-bubble {
    top: 50%;
    transform: translateY(-50%);
}

.hibww-floating-wrapper.hibww-mode-offcanvas:is(.hibww-edge-left, .hibww-edge-right):is(.hibww-pos-bottom-left, .hibww-pos-bottom-right) .hibww-floating-bubble {
    bottom: max(16px, var(--hibww-offset-y, 30px));
    transform: translateY(0);
}

.hibww-floating-wrapper.hibww-mode-offcanvas:is(.hibww-edge-top, .hibww-edge-bottom) .hibww-floating-bubble {
    left: 50%;
    padding: 8px 16px;
    max-width: min(300px, calc(100vw - 40px));
    writing-mode: horizontal-tb;
    transform: translateX(-50%);
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-top .hibww-floating-bubble {
    top: 0;
    border-top: none !important;
    border-radius: 0 0 12px 12px;
    transform-origin: center top;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12) !important;
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-bottom .hibww-floating-bubble {
    bottom: 0;
    border-bottom: none !important;
    border-radius: 12px 12px 0 0;
    transform-origin: center bottom;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.12) !important;
}

.hibww-floating-wrapper.hibww-mode-offcanvas:is(.hibww-edge-left, .hibww-edge-right):is(.hibww-pos-middle-left, .hibww-pos-middle-right) .hibww-floating-bubble:hover {
    transform: translateY(-50%) scale(1.025);
}

.hibww-floating-wrapper.hibww-mode-offcanvas:is(.hibww-edge-top, .hibww-edge-bottom) .hibww-floating-bubble:hover {
    transform: translateX(-50%) scale(1.025);
}

.hibww-floating-wrapper.hibww-mode-offcanvas .hibww-floating-bubble.hibww-hidden {
    opacity: 0;
    pointer-events: none;
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-right .hibww-floating-bubble.hibww-hidden {
    transform: translateX(100%);
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-left .hibww-floating-bubble.hibww-hidden {
    transform: translateX(-100%);
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-right:is(.hibww-pos-middle-right) .hibww-floating-bubble.hibww-hidden {
    transform: translateY(-50%) translateX(100%);
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-left:is(.hibww-pos-middle-left) .hibww-floating-bubble.hibww-hidden {
    transform: translateY(-50%) translateX(-100%);
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-top .hibww-floating-bubble.hibww-hidden {
    transform: translateX(-50%) translateY(-100%);
}

.hibww-floating-wrapper.hibww-mode-offcanvas.hibww-edge-bottom .hibww-floating-bubble.hibww-hidden {
    transform: translateX(-50%) translateY(100%);
}

.hibww-floating-wrapper.hibww-mode-offcanvas .hibww-floating-bubble img.hibww-bubble-avatar {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    max-width: 22px !important;
}

.hibww-floating-wrapper.hibww-mode-offcanvas .hibww-bubble-text {
    display: inline-block;
    width: auto !important;
    margin: 0;
    padding: 0;
    opacity: 1 !important;
    font-size: 11px !important;
    line-height: 1;
    letter-spacing: 0.5px;
}

/* Viewport-level drawer surface. */
.hibww-floating-wrapper.hibww-drawer-layer {
    position: fixed;
    inset: 0 !important;
    width: 0;
    height: 0;
    transform: none !important;
    pointer-events: none;
    z-index: 2147483000;
}

.hibww-floating-wrapper.hibww-drawer-layer .hibww-modal-backdrop {
    top: 0;
    height: 100vh;
    height: 100dvh;
    background: rgba(8, 14, 25, 0.36);
    overscroll-behavior: contain;
    touch-action: none;
}

.hibww-floating-wrapper.hibww-drawer-layer .hibww-floating-chat-container {
    position: fixed !important;
    display: block !important;
    margin: 0 !important;
    max-width: none;
    max-height: none;
    overflow: hidden;
    opacity: 1 !important;
    pointer-events: none;
    background: var(--hibww-bg, #ffffff);
    backdrop-filter: var(--hibww-backdrop, none);
    -webkit-backdrop-filter: var(--hibww-backdrop, none);
    will-change: transform;
    contain: layout paint;
    box-shadow: none;
    transition: transform 0.52s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.32s ease !important;
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-edge-right .hibww-floating-chat-container,
.hibww-floating-wrapper.hibww-drawer-layer.hibww-edge-left .hibww-floating-chat-container {
    top: 0 !important;
    bottom: auto !important;
    width: min(420px, 100vw);
    height: 100vh;
    height: 100dvh;
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-edge-right .hibww-floating-chat-container {
    right: 0 !important;
    left: auto !important;
    transform: translate3d(100%, 0, 0) !important;
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-edge-left .hibww-floating-chat-container {
    right: auto !important;
    left: 0 !important;
    transform: translate3d(-100%, 0, 0) !important;
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-edge-top .hibww-floating-chat-container,
.hibww-floating-wrapper.hibww-drawer-layer.hibww-edge-bottom .hibww-floating-chat-container {
    right: 0 !important;
    left: 0 !important;
    width: auto !important;
    max-width: none !important;
    height: min(70dvh, 640px);
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-edge-top .hibww-floating-chat-container {
    top: 0 !important;
    bottom: auto !important;
    transform: translate3d(0, -100%, 0) !important;
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-edge-bottom .hibww-floating-chat-container {
    top: auto !important;
    bottom: 0 !important;
    transform: translate3d(0, 100%, 0) !important;
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-open .hibww-floating-chat-container {
    pointer-events: auto;
    transform: translate3d(0, 0, 0) !important;
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-open.hibww-edge-right .hibww-floating-chat-container {
    box-shadow: -18px 0 60px rgba(0, 0, 0, 0.22);
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-open.hibww-edge-left .hibww-floating-chat-container {
    box-shadow: 18px 0 60px rgba(0, 0, 0, 0.22);
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-open.hibww-edge-top .hibww-floating-chat-container {
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-open.hibww-edge-bottom .hibww-floating-chat-container {
    box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.22);
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-mode-squeeze.hibww-open.hibww-edge-right .hibww-floating-chat-container {
    box-shadow: -3px 0 12px rgba(0, 0, 0, 0.11) !important;
}

.hibww-floating-wrapper.hibww-drawer-layer.hibww-mode-squeeze.hibww-open.hibww-edge-left .hibww-floating-chat-container {
    box-shadow: 3px 0 12px rgba(0, 0, 0, 0.11) !important;
}

.hibww-floating-wrapper.hibww-drawer-layer .hibww-floating-chat-container > .hibww-chat-container {
    box-sizing: border-box;
    width: 100%;
    height: 100% !important;
    max-height: 100% !important;
    margin: 0 auto;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.hibww-floating-wrapper.hibww-drawer-layer:is(.hibww-edge-top, .hibww-edge-bottom) .hibww-floating-chat-container > .hibww-chat-container {
    width: 100% !important;
    max-width: none !important;
}

.hibww-floating-wrapper.hibww-drawer-layer:is(.hibww-edge-top, .hibww-edge-bottom) .hibww-chat-header {
    box-sizing: border-box;
    width: 100% !important;
    max-width: none !important;
}

.hibww-floating-wrapper.hibww-drawer-layer:is(.hibww-edge-top, .hibww-edge-bottom) :is(.hibww-chat-messages, .hibww-chat-input-area, .hibww-loading-indicator) {
    box-sizing: border-box;
    width: 100%;
    max-width: 720px;
    margin-inline: auto;
}

@media (max-width: 600px) {
    .hibww-floating-wrapper.hibww-drawer-layer .hibww-floating-chat-container {
        width: 100vw !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
    }

    .hibww-floating-wrapper.hibww-mode-offcanvas .hibww-floating-bubble {
        width: 36px;
        height: 36px;
        padding: 6px !important;
        gap: 0 !important;
    }

    .hibww-floating-wrapper.hibww-mode-offcanvas .hibww-bubble-text {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    html.hibww-squeeze-ready body {
        transition-duration: 0.01ms !important;
    }

    .hibww-floating-wrapper.hibww-mode-offcanvas .hibww-floating-bubble,
    .hibww-floating-wrapper.hibww-drawer-layer .hibww-floating-chat-container,
    .hibww-floating-wrapper.hibww-drawer-layer .hibww-modal-backdrop {
        transition-duration: 0.01ms !important;
    }
}

/* Modal Backdrop Overlay */
.hibww-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    z-index: 2147483646;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                backdrop-filter 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                -webkit-backdrop-filter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}
.hibww-modal-backdrop.hibww-active {
    opacity: 1;
    backdrop-filter: var(--hibww-page-backdrop, blur(10px));
    -webkit-backdrop-filter: var(--hibww-page-backdrop, blur(10px));
}

/* Centered Pop-up Modal Styles */
.hibww-floating-wrapper.hibww-mode-modal .hibww-floating-chat-container {
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    width: 450px;
    height: 650px;
    max-height: calc(100vh - 80px);
    max-width: calc(100vw - 40px);
    z-index: 2147483647;
    pointer-events: none;
    opacity: 0;
}

.hibww-floating-wrapper.hibww-mode-modal.hibww-open .hibww-floating-chat-container {
    box-sizing: border-box;
    opacity: 1;
    pointer-events: auto;
}

.hibww-floating-wrapper.hibww-mode-modal .hibww-floating-chat-container .hibww-chat-container {
    height: 100%;
    max-height: 100%;
    border-radius: var(--hibww-border-radius, 20px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

/* Animate the inner elements inside the chat container for modal layout */
.hibww-floating-wrapper.hibww-mode-modal .hibww-floating-chat-container .hibww-chat-header,
.hibww-floating-wrapper.hibww-mode-modal .hibww-floating-chat-container .hibww-chat-messages,
.hibww-floating-wrapper.hibww-mode-modal .hibww-floating-chat-container .hibww-chat-input-area {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.hibww-floating-wrapper.hibww-mode-modal.hibww-open .hibww-floating-chat-container .hibww-chat-header,
.hibww-floating-wrapper.hibww-mode-modal.hibww-open .hibww-floating-chat-container .hibww-chat-messages,
.hibww-floating-wrapper.hibww-mode-modal.hibww-open .hibww-floating-chat-container .hibww-chat-input-area {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile responsive overrides for Off-Canvas & Modal */
@media (max-width: 600px) {
    /* Always full screen size on mobile viewports */
    .hibww-floating-wrapper.hibww-mode-modal .hibww-floating-chat-container {
    box-sizing: border-box;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
    }
    
    /* Modal closed position on mobile viewports (slide up from bottom) */
    .hibww-floating-wrapper.hibww-mode-modal:not(.hibww-open) .hibww-floating-chat-container {
    box-sizing: border-box;
        top: 100% !important;
        bottom: -100% !important;
        opacity: 0 !important;
        transform: none !important;
    }

    .hibww-floating-wrapper.hibww-mode-modal.hibww-open .hibww-floating-chat-container {
    box-sizing: border-box;
        top: 0 !important;
        bottom: 0 !important;
        opacity: 1 !important;
        transform: none !important;
        transition: top 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease !important;
    }
    
    .hibww-floating-wrapper.hibww-mode-modal .hibww-floating-chat-container .hibww-chat-container {
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }


}

/* HIBWW bubble-origin morph motion */
.hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container {
    transition: opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container > .hibww-chat-container {
    opacity: 0.35;
    transform: translate(var(--hibww-morph-x, 0), var(--hibww-morph-y, 24px)) scale(0.18);
    transform-origin: var(--hibww-origin-x, 100%) var(--hibww-origin-y, 100%);
    filter: blur(7px);
    border-radius: 999px;
    will-change: transform, opacity, filter;
    transition:
        transform 0.52s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        border-radius 0.46s cubic-bezier(0.16, 1, 0.3, 1),
        background 0.35s ease,
        backdrop-filter 0.35s ease,
        -webkit-backdrop-filter 0.35s ease,
        border-color 0.35s ease,
        box-shadow 0.35s ease;
}

.hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container.hibww-open > .hibww-chat-container {
    opacity: 1;
    transform: translate(0, 0) scale(1);
    filter: blur(0);
    border-radius: var(--hibww-border-radius, 20px);
}

.hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container.hibww-preparing > .hibww-chat-container,
.hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container.hibww-chat-is-dragging > .hibww-chat-container {
    transition: none !important;
}

.hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container.hibww-chat-is-dragging > .hibww-chat-container {
    transform: translate(0, 0) scale(1);
    filter: none;
}

@media (max-width: 600px) {
    .hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container > .hibww-chat-container {
        transform: translateY(18px) scale(0.985);
        transform-origin: center bottom;
        filter: none;
        border-radius: 24px 24px 0 0;
        transition-duration: 0.38s;
    }

    .hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container.hibww-open > .hibww-chat-container {
        transform: translateY(0) scale(1);
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container,
    .hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container > .hibww-chat-container,
    .hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container .hibww-chat-header,
    .hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container .hibww-chat-messages,
    .hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container .hibww-chat-input-area {
        transition-duration: 0.01ms !important;
    }

    .hibww-floating-wrapper:is(.hibww-mode-bubble, .hibww-mode-focus) .hibww-floating-chat-container > .hibww-chat-container {
        transform: none !important;
        filter: none !important;
    }
}

/* HIBWW Focus Mode */
html.hibww-focus-active {
    overflow: hidden;
    scrollbar-gutter: stable;
}

.hibww-floating-wrapper.hibww-mode-focus .hibww-modal-backdrop {
    background: rgba(8, 14, 25, 0.46);
}

.hibww-floating-wrapper.hibww-mode-focus .hibww-floating-chat-container {
    position: fixed;
    inset: 0;
    width: 400px;
    height: min(600px, calc(100vh - 64px));
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 64px);
    margin: auto;
    transform: none !important;
}

.hibww-floating-wrapper.hibww-mode-focus .hibww-floating-chat-container > .hibww-chat-container {
    height: 100%;
    max-height: 100%;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

@media (max-width: 600px) {
    .hibww-floating-wrapper.hibww-mode-focus .hibww-floating-chat-container,
    .hibww-floating-wrapper.hibww-mode-focus:not(.hibww-open) .hibww-floating-chat-container,
    .hibww-floating-wrapper.hibww-mode-focus.hibww-open .hibww-floating-chat-container {
        inset: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        transform: none !important;
        transition: opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1) !important;
    }
}

/* HIBWW Focus Mode reduced motion */
@media (prefers-reduced-motion: reduce) {
    .hibww-floating-wrapper.hibww-mode-focus .hibww-floating-chat-container,
    .hibww-floating-wrapper.hibww-mode-focus .hibww-floating-chat-container > .hibww-chat-container {
        transition-duration: 0.01ms !important;
    }
}

/* Print isolation: the assistant is an interactive screen control and must never
   appear in browser printouts or leave drawer/focus layout offsets behind. */
@media print {
    #hibww-floating-wrapper,
    .hibww-floating-wrapper,
    #hibww-floating-bubble,
    .hibww-floating-bubble,
    #hibww-floating-chat-container,
    .hibww-floating-chat-container,
    .hibww-modal-backdrop,
    .hibww-drawer-layer {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    html.hibww-focus-active,
    html.hibww-squeeze-ready,
    html.hibww-squeeze-active {
        overflow: visible !important;
        scrollbar-gutter: auto !important;
    }

    html.hibww-squeeze-ready body,
    html.hibww-squeeze-ready.hibww-squeeze-active.hibww-squeeze-left body,
    html.hibww-squeeze-ready.hibww-squeeze-active.hibww-squeeze-right body {
        padding-left: var(--hibww-page-padding-left, 0px) !important;
        padding-right: var(--hibww-page-padding-right, 0px) !important;
        overflow: visible !important;
    }
}
