/* Customer ↔ operator chat, rendered inside the shared TurnX shell. */
.planet-chat-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.planet-chat-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    flex: 0 0 auto;
    padding: 8px 8px 0;
    background: rgb(var(--color-card));
    border-bottom: 1px solid rgb(var(--color-text-sub) / .12);
}
.planet-chat-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 7px 8px;
    border: 0;
    border-radius: 10px 10px 0 0;
    background: transparent;
    color: rgb(var(--color-text-sub));
    font: inherit;
    font-size: 11.5px;
    font-weight: 650;
    line-height: 1.5;
    cursor: pointer;
    white-space: nowrap;
}
.planet-chat-tab svg { width: 16px; height: 16px; flex: 0 0 16px; }
.planet-chat-tab[aria-selected="true"] {
    color: rgb(var(--color-prim));
    background: rgb(var(--color-prim) / .08);
    box-shadow: inset 0 -2px 0 rgb(var(--color-prim));
}
.planet-chat-tab:focus-visible { outline: 2px solid rgb(var(--color-prim)); outline-offset: -2px; }
.planet-chat-tab[disabled] { opacity: .45; cursor: not-allowed; }
.planet-chat-unread {
    position: absolute;
    top: 6px;
    inset-inline-start: 8px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #ef4444;
    box-shadow: 0 0 0 2px rgb(var(--color-card));
}
.planet-chat-unread[hidden] { display: none; }
.planet-chat-launcher-badge {
    position: absolute;
    top: 7px;
    inset-inline-start: 7px;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #ef4444;
    box-shadow: 0 0 0 2px rgb(var(--color-card));
    pointer-events: none;
}
.planet-chat-launcher-badge[hidden] { display: none !important; }

.planet-chat-panel {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
}
.planet-chat-panel[hidden] { display: none !important; }
.planet-chat-panel--experts { background: rgb(var(--color-back)); }
.planet-chat-avatar--experts { background: rgb(var(--color-prim) / .12); color: rgb(var(--color-prim)); }
.planet-chat-avatar--experts svg { width: 22px; height: 22px; }
.turnx-chat-subtitle[data-tone="online"]::before { background: #10b981; }
.turnx-chat-subtitle[data-tone="warn"]::before { background: #f59e0b; }
.turnx-chat-subtitle[data-tone="error"]::before { background: #ef4444; }

.planet-chat-experts-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 14px;
    min-height: 0;
    overscroll-behavior: contain;
}
.planet-chat-state {
    margin: auto;
    max-width: 280px;
    padding: 18px;
    text-align: center;
    color: rgb(var(--color-text-sub));
    font-size: 12px;
    line-height: 2;
}
.planet-chat-state strong { display: block; margin-bottom: 4px; color: rgb(var(--color-title)); font-size: 13px; }
.planet-chat-state--error { color: #be123c; }
.planet-chat-state button { margin-top: 10px; }

.planet-chat-load-more {
    align-self: center;
    min-height: 40px;
    padding: 6px 14px;
    border: 1px solid rgb(var(--color-text-sub) / .18);
    border-radius: 999px;
    background: rgb(var(--color-card));
    color: rgb(var(--color-text-sub));
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}
.planet-chat-load-more[disabled] { opacity: .55; cursor: wait; }

.planet-chat-msg {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-width: 88%;
    padding: 10px 12px;
    border-radius: var(--chat-radius, 10px);
    font-size: 12.5px;
    line-height: 1.9;
    word-break: break-word;
    white-space: pre-wrap;
    flex-shrink: 0;
}
.planet-chat-msg--customer {
    align-self: flex-start;
    background: rgb(var(--color-card));
    color: rgb(var(--color-title));
    border-end-start-radius: 4px;
}
.planet-chat-msg--operator {
    align-self: flex-end;
    background: rgb(var(--color-prim));
    color: #fff;
    border-end-end-radius: 4px;
}
.planet-chat-msg--pending { opacity: .72; }
.planet-chat-msg--failed { box-shadow: inset 0 0 0 1px #fca5a5; }
.planet-chat-msg__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 9.5px;
    opacity: .72;
}
.planet-chat-msg--operator .planet-chat-msg__meta { color: #fff; }
.planet-chat-msg__author { font-weight: 650; }

.planet-chat-attachment { display: grid; gap: 6px; min-width: 160px; }
.planet-chat-attachment img,
.planet-chat-attachment video {
    display: block;
    width: min(100%, 260px);
    max-height: 260px;
    border-radius: 10px;
    object-fit: cover;
    background: rgb(var(--color-back) / .7);
}
.planet-chat-attachment audio { width: min(100%, 260px); height: 36px; }
.planet-chat-attachment__file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgb(var(--color-back) / .55);
    color: inherit;
    text-decoration: none !important;
}
.planet-chat-msg--operator .planet-chat-attachment__file { background: rgb(255 255 255 / .16); color: #fff; }
.planet-chat-attachment__file svg { width: 18px; height: 18px; flex: 0 0 18px; }
.planet-chat-attachment__copy { display: grid; min-width: 0; gap: 2px; }
.planet-chat-attachment__copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.planet-chat-attachment__copy small { font-size: 9.5px; opacity: .75; }
.planet-chat-attachment__missing { padding: 7px 9px; border-radius: 8px; background: rgb(225 29 72 / .1); color: #be123c; font-size: 10px; }

.planet-chat-file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid rgb(var(--color-prim) / .2);
    border-radius: 10px;
    background: rgb(var(--color-prim) / .06);
    color: rgb(var(--color-title));
    font-size: 10.5px;
}
.planet-chat-file-preview[hidden] { display: none !important; }
.planet-chat-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.planet-chat-file-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgb(var(--color-text-sub) / .12);
    color: rgb(var(--color-text-sub));
    cursor: pointer;
}
.planet-chat-attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    margin-bottom: 2px;
    padding: 9px;
    border: 0;
    border-radius: var(--chat-radius, 10px);
    background: rgb(var(--color-prim) / .1);
    color: rgb(var(--color-prim));
    cursor: pointer;
}
.planet-chat-attach svg { width: 18px; height: 18px; }
.planet-chat-attach:disabled { opacity: .45; cursor: not-allowed; }
.planet-chat-form.is-busy { opacity: .7; }

@media (max-width: 768px) {
    .planet-chat-tab { font-size: 10px; gap: 4px; padding: 7px 3px; }
    .planet-chat-tab svg { width: 13px; height: 13px; flex-basis: 13px; }
    .planet-chat-msg { max-width: 92%; }
    .planet-chat-attachment img,
    .planet-chat-attachment video { max-height: 220px; }
}
@media (prefers-reduced-motion: reduce) {
    .planet-chat-tab { transition: none; }
}
