.clc-shell,
.clc-shell * {
    box-sizing: border-box;
}

.clc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.clc-presence {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted, #475569);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.clc-presence::before {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    content: "";
}

.clc-presence.clc-online::before {
    background: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .14);
}

.clc-typing {
    min-height: 20px;
    color: var(--primary2, #0f766e);
    font-size: 12px;
    font-weight: 700;
}

.clc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    min-height: 96px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--line, #d4e2f0);
    border-radius: 8px;
    background: #f6f9fc;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

/* Webkit fallback for browsers that do not support scrollbar-width. */
.clc-list::-webkit-scrollbar {
    width: 8px;
}

.clc-list::-webkit-scrollbar-thumb {
    background: var(--line, #d4e2f0);
    border-radius: 8px;
}

.clc-msg {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    width: fit-content;
    max-width: min(82%, 620px);
    padding: 8px 11px;
    border: 1px solid #d8e4ee;
    border-radius: 8px 8px 8px 2px;
    background: #fff;
    color: #172033;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.clc-msg.clc-mine {
    align-self: flex-end;
    border-color: #9bd8cf;
    border-radius: 8px 8px 2px 8px;
    background: #e8f7f4;
}

.clc-sender {
    margin-bottom: 2px;
    color: #0369a1;
    font-size: 11px;
    font-weight: 800;
}

.clc-body {
    white-space: pre-wrap;
}

.clc-meta {
    align-self: flex-end;
    margin-top: 3px;
    color: #64748b;
    font-size: 10px;
}

.clc-tick {
    color: #64748b;
    font-weight: 900;
}

.clc-tick.clc-read {
    color: #0284c7;
}

.clc-audio {
    width: min(270px, 100%);
    margin-top: 6px;
}

.clc-empty,
.clc-error {
    align-self: center;
    margin: auto;
    color: var(--muted, #475569);
    font-size: 13px;
}

.clc-error {
    color: #b91c1c;
}

.clc-compose {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.clc-compose textarea,
.clc-compose input[type="text"] {
    flex: 1;
    min-width: 0;
    resize: vertical;
}

.clc-compose .btn {
    flex: 0 0 auto;
}

.clsw {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 9550;
    direction: rtl;
    font-family: var(--font-body, "Tajawal", sans-serif);
}

.clsw-launcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 9px 14px;
    border: 1px solid #0f766e;
    border-radius: 8px;
    background: #0f766e;
    box-shadow: 0 12px 26px rgba(15, 118, 110, .25);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
}

.clsw-launcher:focus-visible,
.clsw button:focus-visible,
.clsw input:focus-visible,
.clsw textarea:focus-visible,
.clsw select:focus-visible {
    outline: 3px solid rgba(2, 132, 199, .28);
    outline-offset: 2px;
}

.clsw[data-open="true"] .clsw-launcher {
    display: none;
}

.clsw-panel {
    display: none;
    width: min(390px, calc(100vw - 24px));
    height: min(590px, calc(100vh - 32px));
    overflow: hidden;
    border: 1px solid #cbdbe7;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
}

.clsw[data-open="true"] .clsw-panel {
    display: flex;
    flex-direction: column;
}

.clsw-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 54px;
    padding: 10px 12px;
    background: #0f766e;
    color: #fff;
}

.clsw-title {
    flex: 1;
    min-width: 0;
    font-size: 15px;
}

.clsw-icon-btn {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
}

.clsw-view {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    padding: 12px;
}

.clsw-ticket-list {
    display: grid;
    gap: 8px;
    overflow-y: auto;
}

.clsw-ticket {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    width: 100%;
    padding: 10px;
    border: 1px solid #d4e2f0;
    border-radius: 7px;
    background: #f8fbff;
    color: #172033;
    cursor: pointer;
    text-align: right;
}

.clsw-ticket:hover {
    border-color: #0f766e;
    background: #effaf8;
}

.clsw-ticket small {
    color: #64748b;
}

.clsw-new-form {
    display: grid;
    gap: 9px;
}

.clsw-new-form label {
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

.clsw-new-form input,
.clsw-new-form select,
.clsw-new-form textarea {
    width: 100%;
    margin-top: 3px;
}

.clsw-chat .clc-list {
    flex: 1;
    max-height: none;
}

.clsw-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

@media (max-width: 560px) {
    .clsw {
        left: 12px;
        bottom: 12px;
    }

    .clsw-panel {
        width: calc(100vw - 24px);
        height: min(620px, calc(100dvh - 24px));
    }

    .clc-msg {
        max-width: 90%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .clsw *,
    .clc-shell * {
        scroll-behavior: auto !important;
    }
}