.icsw {
    --icsw-cyan: #0ba5b5;
    --icsw-blue: #2563eb;
    --icsw-ink: #0a2233;
    --icsw-ink-soft: #51697e;
    --icsw-line: rgba(13, 51, 82, .14);
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.icsw-bubble {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    background: linear-gradient(115deg, var(--icsw-cyan), var(--icsw-blue));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 34px rgba(13, 51, 82, .28);
    position: relative;
    transition: transform .15s ease;
}

.icsw-bubble:hover { transform: translateY(-2px); }
.icsw-bubble svg { width: 26px; height: 26px; }
.icsw-icon-close { display: none; }
.icsw.is-open .icsw-icon-chat { display: none; }
.icsw.is-open .icsw-icon-close { display: block; }

.icsw-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e0533f;
    border: 2px solid #fff;
}

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

.icsw-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 18px;
    border: 1px solid var(--icsw-line);
    box-shadow: 0 24px 60px rgba(13, 51, 82, .22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: icsw-pop .16s ease;
}

@keyframes icsw-pop {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.icsw-header {
    padding: 16px 18px;
    background: linear-gradient(115deg, var(--icsw-cyan), var(--icsw-blue));
    color: #fff;
    flex: none;
}

.icsw-header strong { display: block; font-size: 15px; }
.icsw-header span { display: block; font-size: 12.5px; opacity: .9; margin-top: 2px; }

.icsw-thread {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

.icsw-msg {
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    max-width: 86%;
    white-space: pre-wrap;
    word-break: break-word;
}

.icsw-msg-user {
    background: linear-gradient(115deg, var(--icsw-cyan), var(--icsw-blue));
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.icsw-msg-bot,
.icsw-msg-agent {
    background: #fff;
    border: 1px solid var(--icsw-line);
    color: var(--icsw-ink);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.icsw-msg-agent { border-color: rgba(11, 165, 181, .35); }

.icsw-msg-meta {
    display: block;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--icsw-ink-soft);
    margin-bottom: 3px;
}

.icsw-typing { align-self: flex-start; color: var(--icsw-ink-soft); font-size: 12.5px; padding: 0 4px; }

.icsw-escalate {
    padding: 14px 16px;
    border-top: 1px solid var(--icsw-line);
    background: #fff;
    flex: none;
}

.icsw-escalate p { margin: 0 0 10px; font-size: 12.5px; color: var(--icsw-ink-soft); line-height: 1.5; }
.icsw-escalate label { display: block; font-size: 12px; color: var(--icsw-ink-soft); margin-bottom: 8px; }
.icsw-escalate input {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 9px 11px;
    border: 1px solid var(--icsw-line);
    border-radius: 9px;
    font: inherit;
    font-size: 13.5px;
}

.icsw-escalate-actions { display: flex; gap: 8px; margin-top: 4px; }
.icsw-btn-ghost,
.icsw-btn-primary {
    flex: 1;
    padding: 9px 10px;
    border-radius: 9px;
    border: 1px solid var(--icsw-line);
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--icsw-ink);
}

.icsw-btn-primary {
    border: 0;
    background: linear-gradient(115deg, var(--icsw-cyan), var(--icsw-blue));
    color: #fff;
}

.icsw-btn-primary:disabled { opacity: .6; cursor: default; }

.icsw-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--icsw-line);
    background: #fff;
    flex: none;
}

.icsw-composer textarea {
    flex: 1;
    resize: none;
    max-height: 90px;
    border: 1px solid var(--icsw-line);
    border-radius: 12px;
    padding: 9px 12px;
    font: inherit;
    font-size: 13.5px;
    line-height: 1.4;
}

.icsw-composer button {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(115deg, var(--icsw-cyan), var(--icsw-blue));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icsw-composer button svg { width: 17px; height: 17px; }
.icsw-composer button:disabled { opacity: .6; cursor: default; }

.icsw-talk-human {
    flex: none;
    border: 0;
    border-top: 1px solid var(--icsw-line);
    background: #f8fafc;
    color: var(--icsw-blue);
    font-size: 12.5px;
    font-weight: 600;
    padding: 10px;
    cursor: pointer;
}

.icsw-talk-human:hover { text-decoration: underline; }

.icsw-article-suggestions {
    align-self: flex-start;
    width: min(86%, 310px);
    display: grid;
    gap: 7px;
    margin: -3px 0 10px;
}

.icsw-article-suggestions-title {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--icsw-ink-soft);
    padding: 0 4px;
}

.icsw-article-suggestion {
    display: grid;
    gap: 2px;
    padding: 9px 11px;
    border: 1px solid rgba(8, 145, 178, .22);
    border-radius: 10px;
    background: #f7fcff;
    color: var(--icsw-ink);
    text-decoration: none;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.icsw-article-suggestion:hover {
    border-color: var(--icsw-cyan);
    box-shadow: 0 6px 16px rgba(8, 145, 178, .12);
    transform: translateY(-1px);
}

.icsw-article-suggestion small {
    color: var(--icsw-ink-soft);
    font-size: 10.5px;
    line-height: 1.2;
}

.icsw-article-suggestion strong {
    font-size: 12.5px;
    line-height: 1.35;
}

@media (max-width: 480px) {
    .icsw { right: 12px; bottom: 12px; }
    .icsw-panel { width: calc(100vw - 24px); bottom: 68px; }
}

@media (prefers-color-scheme: dark) {
    .icsw-panel { background: #101a24; border-color: rgba(255, 255, 255, .08); }
    .icsw-thread { background: #0b141c; }
    .icsw-msg-bot, .icsw-msg-agent { background: #16212c; border-color: rgba(255, 255, 255, .1); color: #e7edf3; }
    .icsw-msg-meta { color: #8fa4b6; }
    .icsw-escalate, .icsw-composer, .icsw-talk-human { background: #101a24; border-color: rgba(255, 255, 255, .08); }
    .icsw-escalate p, .icsw-escalate label { color: #8fa4b6; }
    .icsw-escalate input, .icsw-composer textarea { background: #0b141c; border-color: rgba(255, 255, 255, .12); color: #e7edf3; }
    .icsw-btn-ghost { background: #16212c; border-color: rgba(255, 255, 255, .12); color: #e7edf3; }
    .icsw-article-suggestion { background: #16212c; border-color: rgba(34, 211, 238, .25); color: #e7edf3; }
    .icsw-article-suggestion small, .icsw-article-suggestions-title { color: #8fa4b6; }
}
