.fiwork-support-widget {
    position: fixed;
    right: 82px;
    bottom: 30px;
    z-index: 100;
    font-family: var(--font-family), Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* The one-time theme hint now sits above both floating controls. */
.fiwork-theme-tip {
    right: 30px;
    bottom: 82px;
    border-radius: 14px;
}

.fiwork-theme-tip__arrow {
    display: none;
}

.fiwork-support-launcher {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border: 1px solid #e5e7e9;
    border-radius: 50%;
    color: #626970;
    background: #f8f8f9;
    box-shadow: none;
    font: inherit;
    cursor: pointer;
    transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.fiwork-support-launcher:hover,
.fiwork-support-launcher[aria-expanded="true"] {
    border-color: #e5e7e9;
    color: #202124;
    background: #f1f2f3;
    box-shadow: none;
}

.fiwork-support-launcher:active {
    transform: scale(.97);
}

.fiwork-support-launcher:focus-visible,
.fiwork-support-panel button:focus-visible,
.fiwork-support-panel a:focus-visible,
.fiwork-support-composer input:focus-visible {
    outline: 3px solid rgba(1, 136, 255, .2);
    outline-offset: 2px;
}

.fiwork-support-launcher > svg {
    width: 21px;
    height: 21px;
    display: block;
}

.fiwork-support-panel {
    position: absolute;
    right: -52px;
    bottom: 54px;
    width: min(330px, calc(100vw - 32px));
    overflow: hidden;
    border: 1px solid #e3e7eb;
    border-radius: 18px;
    color: #202633;
    background: #fff;
    box-shadow: 0 22px 60px rgba(21, 30, 43, .18);
    opacity: 0;
    transform: translateY(10px) scale(.985);
    transform-origin: right bottom;
    transition: opacity .18s ease, transform .18s ease;
}

.fiwork-support-panel[hidden] {
    display: none;
}

.fiwork-support-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.fiwork-support-panel__header {
    box-sizing: border-box;
    width: 100%;
    min-height: 52px;
    padding: 7px 11px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    border-bottom: 1px solid #edf0f2;
    background: #fbfcfd;
}

.fiwork-support-panel__avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    overflow: hidden;
}

.fiwork-support-panel__avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.fiwork-support-panel__heading {
    min-width: 0;
    min-height: 30px;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
}

.fiwork-support-panel__heading strong {
    display: block;
    margin: 0;
    font-size: 13px;
    font-weight: 650;
    line-height: 17px;
}

.fiwork-support-panel__heading small {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    color: #7b8490;
    font-size: 10.5px;
    font-weight: 400;
    line-height: 13px;
}

.fiwork-support-panel__heading small i {
    width: 6px;
    height: 6px;
    flex: 0 0 6px;
    display: block;
    border-radius: 50%;
    background: #23c366;
}

.fiwork-support-panel__close {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    margin-left: auto;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #717985;
    background: transparent;
    cursor: pointer;
}

.fiwork-support-panel__close:hover {
    color: #202633;
    background: #f3f5f7;
}

.fiwork-support-panel__close svg {
    width: 16px;
    height: 16px;
}

.fiwork-support-panel__body {
    height: 250px;
    padding: 13px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: auto;
    overscroll-behavior: contain;
    background: #f6f7f8;
    scrollbar-width: thin;
    scrollbar-color: #cfd5dc transparent;
}

.fiwork-support-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.fiwork-support-message--user {
    justify-content: flex-end;
}

.fiwork-support-message__avatar {
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    overflow: hidden;
}

.fiwork-support-message__avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.fiwork-support-message > div {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 14px 14px 14px 5px;
    color: #353c47;
    background: #fff;
    box-shadow: 0 1px 0 rgba(18, 27, 40, .04);
}

.fiwork-support-message--user > div {
    border-radius: 14px 14px 5px 14px;
    color: #fff;
    background: #0188ff;
}

.fiwork-support-message p {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.fiwork-support-message--typing > div {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
}

.fiwork-support-message--typing i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #9ba3ad;
    animation: fiwork-support-typing 1s ease-in-out infinite;
}

.fiwork-support-message--typing i:nth-child(2) { animation-delay: .12s; }
.fiwork-support-message--typing i:nth-child(3) { animation-delay: .24s; }

@keyframes fiwork-support-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .55; }
    30% { transform: translateY(-3px); opacity: 1; }
}

.fiwork-support-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-left: 33px;
}

.fiwork-support-quick button {
    min-height: 31px;
    padding: 6px 10px;
    border: 1px solid #dce2e7;
    border-radius: 16px;
    color: #4c5663;
    background: #fff;
    font: inherit;
    font-size: 11px;
    font-weight: 550;
    cursor: pointer;
}

.fiwork-support-quick button:hover {
    border-color: #b9c7d4;
    color: #087ee6;
}

.fiwork-support-composer {
    padding: 11px 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 8px;
    border-top: 1px solid #edf0f2;
    background: #fff;
}

.fiwork-support-composer input {
    width: 100%;
    height: 38px;
    min-width: 0;
    padding: 0 13px;
    border: 1px solid #dfe4e8;
    border-radius: 12px;
    color: #202633;
    background: #f7f8f9;
    font: inherit;
    font-size: 12px;
}

.fiwork-support-composer input::placeholder {
    color: #9299a2;
}

.fiwork-support-composer input:focus {
    border-color: #9db6cc;
    background: #fff;
}

.fiwork-support-composer button {
    width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: #0188ff;
    cursor: pointer;
}

.fiwork-support-composer button:hover {
    background: #0079e4;
}

.fiwork-support-composer button svg {
    width: 18px;
    height: 18px;
}

.fiwork-support-panel__human {
    min-height: 42px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-top: 1px solid #edf0f2;
    color: #087ee6;
    background: #fff;
    font-size: 12px;
    font-weight: 650;
    text-decoration: none;
}

.fiwork-support-panel__human:hover {
    color: #006fce;
    background: #fafbfc;
}

.fiwork-support-panel__human svg {
    width: 16px;
    height: 16px;
}

html[data-theme="dark"] .fiwork-support-launcher {
    border-color: var(--fi-border);
    color: var(--fi-text);
    background: var(--fi-surface-raised);
    box-shadow: none;
}

html[data-theme="dark"] .fiwork-support-launcher:hover,
html[data-theme="dark"] .fiwork-support-launcher[aria-expanded="true"] {
    border-color: var(--fi-border);
    background: var(--fi-surface-hover);
}

html[data-theme="dark"] .fiwork-support-panel {
    border-color: var(--fi-border);
    color: var(--fi-text);
    background: var(--fi-surface);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .42);
}

html[data-theme="dark"] .fiwork-support-panel__header,
html[data-theme="dark"] .fiwork-support-composer,
html[data-theme="dark"] .fiwork-support-panel__human {
    border-color: var(--fi-border-soft);
    background: var(--fi-surface);
}

html[data-theme="dark"] .fiwork-support-panel__heading small {
    color: var(--fi-text-muted);
}

html[data-theme="dark"] .fiwork-support-panel__close {
    color: var(--fi-text-secondary);
}

html[data-theme="dark"] .fiwork-support-panel__close:hover {
    color: var(--fi-text);
    background: var(--fi-surface-hover);
}

html[data-theme="dark"] .fiwork-support-panel__body {
    background: var(--fi-bg-soft);
}

html[data-theme="dark"] .fiwork-support-message > div,
html[data-theme="dark"] .fiwork-support-quick button {
    border-color: var(--fi-border);
    color: var(--fi-text-secondary);
    background: var(--fi-surface-raised);
    box-shadow: none;
}

html[data-theme="dark"] .fiwork-support-message--user > div {
    color: #fff;
    background: #087fdb;
}

html[data-theme="dark"] .fiwork-support-quick button:hover {
    border-color: #536170;
    color: var(--fi-text);
}

html[data-theme="dark"] .fiwork-support-composer input {
    border-color: var(--fi-border);
    color: var(--fi-text);
    background: var(--fi-bg-soft);
}

html[data-theme="dark"] .fiwork-support-composer input:focus {
    border-color: #536b84;
    background: var(--fi-surface-raised);
}

html[data-theme="dark"] .fiwork-support-panel__human {
    color: var(--fi-text-secondary);
}

html[data-theme="dark"] .fiwork-support-panel__human:hover {
    color: var(--fi-text);
    background: var(--fi-surface-hover);
}

@media (max-width: 767px) {
    .fiwork-support-widget {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fiwork-support-panel,
    .fiwork-support-launcher,
    .fiwork-support-message--typing i {
        animation: none !important;
        transition: none !important;
    }
}
