.wchat-widget,
.wchat-inbox {
    --wchat-ink: #183244;
    --wchat-muted: #506778;
    --wchat-blue: #126478;
    --wchat-line: #d6e4ea;
    --wchat-surface: #f4f8fa;
}

.wchat-widget [hidden],
.wchat-inbox [hidden] {
    display: none !important;
}

.wchat-widget {
    --wchat-right-edge: max(22px, env(safe-area-inset-right, 0px));
    --wchat-launch-offset: 60px;
    position: fixed;
    right: calc(var(--wchat-right-edge) + var(--wchat-launch-offset));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 1010;
    color: var(--wchat-ink);
}

.wchat-widget :focus-visible,
.wchat-inbox :focus-visible {
    outline: 2px solid #237e9b;
    outline-offset: 2px;
}

.wchat-widget .wchat-launch,
.wchat-compose button {
    border: 1px solid #126478;
    border-radius: .65rem;
    background: var(--wchat-blue);
    color: white;
    font: inherit;
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: normal;
    text-transform: none;
}

.wchat-widget .wchat-launch {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    gap: .5rem;
    padding: .6rem .95rem;
    border: 1px solid #fff9;
    border-radius: 999px;
    box-shadow: 0 6px 20px #153a4b26;
    white-space: nowrap;
    list-style: none;
    cursor: pointer;
}

.wchat-launch::-webkit-details-marker { display: none; }
.wchat-widget:not([open]) > .wchat-panel { display: none; }

.wchat-widget .wchat-launch:hover,
.wchat-compose button:hover:enabled {
    background: #104b5e;
    color: white;
}

.wchat-panel {
    position: absolute;
    right: calc(-1 * var(--wchat-launch-offset));
    bottom: calc(100% + 12px);
    display: flex;
    width: min(360px, calc(100vw - var(--wchat-right-edge) - max(22px, env(safe-area-inset-left, 0px))));
    height: min(480px, calc(100vh - 110px));
    height: min(480px, calc(100dvh - 110px));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--wchat-line);
    border-radius: .95rem;
    background: white;
    box-shadow: 0 18px 55px #132d4352;
    color: var(--wchat-ink);
}

.wchat-header,
.wchat-conversation-header {
    display: flex;
    min-height: 54px;
    align-items: center;
    justify-content: space-between;
    gap: .55rem;
    padding: .55rem .9rem;
}

.wchat-header {
    background: #173f50;
    color: white;
}

.wchat-widget .wchat-header h2,
.wchat-inbox h2 {
    margin: 0;
    font: inherit;
    font-size: 1rem;
    font-weight: 750;
    letter-spacing: normal;
    line-height: 1.3;
}

.wchat-widget .wchat-header h2 { color: white; }

.wchat-widget .wchat-close {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    padding: 0;
    border: 1px solid #fff4;
    border-radius: .5rem;
    background: #fff1;
    color: white;
    font-size: 1.4rem;
    line-height: 1;
}

.wchat-thread {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: .55rem;
    overflow: auto;
    padding: .85rem;
    background: var(--wchat-surface);
    overscroll-behavior: contain;
}

.wchat-message {
    width: fit-content;
    max-width: 88%;
    flex-shrink: 0;
    padding: .55rem .72rem;
    border: 1px solid var(--wchat-line);
    border-radius: .65rem .65rem .65rem .25rem;
    background: white;
    color: var(--wchat-ink);
}

.wchat-message-own {
    align-self: flex-end;
    border-color: #b5dce2;
    border-radius: .65rem .65rem .25rem .65rem;
    background: #dcf2f5;
}

.wchat-message-meta {
    display: block;
    margin-bottom: .16rem;
    color: var(--wchat-muted);
    font-size: .72rem;
}

.wchat-thread .wchat-message p {
    margin: 0;
    font-size: .9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.wchat-status {
    margin: 0;
    padding: .25rem .85rem 0;
    background: white;
    color: var(--wchat-muted);
    font-size: .8rem;
}

.wchat-status:empty { display: none; }

.wchat-widget .wchat-fallback {
    margin: 0;
    padding: .6rem .85rem;
    color: var(--wchat-muted);
    font-size: .82rem;
}

.wchat-fallback a { text-decoration: underline; }

.wchat-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: .5rem;
    margin: 0;
    padding: .65rem .8rem;
    background: white;
}

.wchat-widget .wchat-compose textarea,
.wchat-inbox .wchat-compose textarea {
    width: 100%;
    min-height: 48px;
    max-height: 108px;
    margin: 0;
    padding: .5rem .6rem;
    resize: vertical;
    border: 1px solid #afc6d0;
    border-radius: .5rem;
    background: white;
    color: var(--wchat-ink);
    font: inherit;
    font-size: .95rem;
    line-height: 1.35;
    text-transform: none;
    letter-spacing: normal;
}

.wchat-compose button {
    min-height: 44px;
    padding: .5rem .72rem;
}

.wchat-compose button:disabled { opacity: .55; cursor: default; }
.wchat-note { padding: 0 .85rem .65rem; color: var(--wchat-muted); font-size: .75rem; }

.wchat-inbox-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .7rem;
    margin-bottom: 1rem;
}

.wchat-inbox-header h1 { margin: 0 0 .2rem; font-size: 1.3rem; }
.wchat-inbox-header p { margin: 0; color: #506778; }

.wchat-inbox {
    display: grid;
    grid-template-columns: minmax(235px, .62fr) minmax(0, 1fr);
    align-items: start;
    gap: .85rem;
    color: var(--wchat-ink);
}

.wchat-inbox-list,
.wchat-inbox-conversation {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--wchat-line);
    border-radius: .75rem;
    background: white;
}

.wchat-inbox-list h2 { padding: .85rem .85rem 0; }

.wchat-inbox-tabs,
.wchat-inbox-filter,
.wchat-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .4rem;
    padding: .6rem .85rem;
    font-size: .8rem;
}

.wchat-inbox-tabs { justify-content: flex-start; border-bottom: 1px solid var(--wchat-line); }
.wchat-inbox-tabs a { padding: .35rem .55rem; border-radius: .4rem; }
.wchat-inbox-tabs a[aria-current] { background: #e2f1f6; color: #154e64; font-weight: 750; }
.wchat-inbox-list [data-chat-list] { max-height: 455px; overflow-y: auto; }
.wchat-empty { margin: 0; padding: .85rem; color: var(--wchat-muted); font-size: .85rem; }

.wchat-inbox-item {
    display: grid;
    width: 100%;
    gap: .22rem;
    padding: .65rem .85rem;
    border: 0;
    border-bottom: 1px solid #eaf0f3;
    background: white;
    color: var(--wchat-ink);
    font: inherit;
    font-size: .88rem;
    text-align: left;
    overflow-wrap: anywhere;
}

.wchat-inbox-item span { color: var(--wchat-muted); font-size: .77rem; }
.wchat-inbox-item:hover,
.wchat-inbox-item[aria-current] { background: #e7f5f9; }
.wchat-inbox-item[aria-current] { box-shadow: inset 3px 0 var(--wchat-blue); }
.wchat-inbox-item:focus-visible { outline-offset: -2px; }

.wchat-pagination button {
    padding: .3rem .55rem;
    border: 1px solid var(--wchat-line);
    border-radius: .4rem;
    background: white;
    color: var(--wchat-ink);
}

.wchat-pagination button:disabled { opacity: .5; }
.wchat-inbox-conversation { display: flex; min-height: 460px; height: min(640px, 75vh); flex-direction: column; }
.wchat-conversation-header { display: grid; align-content: center; justify-content: stretch; gap: .2rem; overflow-wrap: anywhere; }
.wchat-conversation-header p { margin: 0; color: var(--wchat-muted); font-size: .8rem; }
.wchat-conversation-header p:empty { display: none; }

@media (max-width: 740px) {
    .wchat-inbox { grid-template-columns: minmax(0, 1fr); }
    .wchat-inbox-list [data-chat-list] { max-height: 190px; }
    .wchat-inbox-conversation { min-height: 390px; }
}

@media (max-width: 500px) {
    .wchat-widget .wchat-compose textarea { font-size: 16px; }
}
