.support-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 160;
    font-size: 14px;
}
.support-chat-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: #2f6f9f;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(36, 89, 132, .22);
    cursor: pointer;
    text-decoration: none;
    touch-action: none;
    user-select: none;
}
.support-chat-toggle:hover {
    background: #285f89;
}
.support-chat-widget.is-dragging .support-chat-toggle {
    cursor: grabbing;
}
.support-chat-toggle-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.25;
}
.support-chat-toggle-text {
    white-space: nowrap;
}
.support-chat-toggle-time {
    font-size: 12px;
    font-weight: 600;
    opacity: .9;
    white-space: nowrap;
}
.support-chat-badge,
.support-thread-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #d64545;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}
.support-chat-panel {
    position: absolute;
    right: 0;
    bottom: 56px;
    width: min(360px, calc(100vw - 32px));
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 54px rgba(24, 31, 42, .18);
    overflow: hidden;
}
.support-chat-panel[hidden] {
    display: none;
}
.support-chat-head {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    background: #f8fafc;
}
.support-chat-title-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.support-chat-head strong {
    color: var(--text);
}
.support-chat-online-time {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
}
.support-chat-head > span {
    display: block;
    margin-top: 2px;
    color: var(--text-soft);
    font-size: 12px;
}
.support-chat-messages,
.support-admin-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    background: #f7f7f5;
}
.support-chat-messages {
    height: 300px;
    padding: 12px;
}
.support-chat-message {
    max-width: 84%;
    padding: 8px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff;
}
.support-chat-message-user {
    align-self: flex-end;
    background: #e9f3fb;
    border-color: #c9e0f1;
}
.support-chat-message-staff {
    align-self: flex-start;
}
.support-chat-message-meta {
    margin-bottom: 4px;
    color: var(--text-mute);
    font-size: 11px;
}
.support-chat-message-body {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
}
.support-chat-form {
    display: grid;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--border-soft);
}
.support-chat-form textarea,
.support-admin-compose textarea {
    width: 100%;
    min-height: 70px;
    resize: vertical;
}
.support-chat-form button,
.support-admin-compose button {
    justify-self: end;
}
.support-chat-error,
.support-admin-error {
    color: #b42318;
    font-size: 13px;
}
.support-chat-error[hidden],
.support-admin-error:empty {
    display: none;
}
.support-chat-empty,
.support-admin-empty {
    padding: 18px;
    color: var(--text-soft);
    text-align: center;
}
.support-admin-shell {
    display: grid;
    gap: 18px;
}
.support-admin-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.support-admin-head h1 {
    margin: 0 0 6px;
}
.support-admin-head p {
    margin: 0;
    color: var(--text-soft);
}
.support-admin-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    height: min(720px, calc(100vh - 210px));
    min-height: 480px;
    max-height: 720px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
.support-thread-list {
    border-right: 1px solid var(--border);
    background: #fbfbf9;
    overflow-y: auto;
    min-height: 0;
}
.support-thread-item {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text);
    text-decoration: none;
}
.support-thread-item:hover,
.support-thread-item.is-active {
    background: #eef5fb;
}
.support-thread-name {
    font-weight: 800;
}
.support-thread-role {
    display: inline-flex;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #eef1f4;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 800;
    vertical-align: middle;
}
.support-thread-status {
    font-size: 12px;
    color: var(--text-soft);
}
.support-thread-status-open {
    color: #13795b;
}
.support-thread-preview {
    grid-column: 1 / -1;
    color: var(--text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.support-thread-unread {
    position: absolute;
    right: 12px;
    bottom: 10px;
}
.support-admin-chat {
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    min-width: 0;
    min-height: 0;
}
.support-admin-back {
    display: none;
}
.support-admin-chat-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: #fff;
}
.support-admin-chat-head span {
    margin-left: 8px;
    color: var(--text-soft);
    font-size: 13px;
}
.support-admin-actions {
    display: flex;
    gap: 8px;
}
.support-admin-messages {
    padding: 16px;
    min-height: 0;
}
.support-admin-compose {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--border);
}
.support-admin-error {
    padding: 0 12px 12px;
}
@media (max-width: 720px) {
    .support-admin-page .site-header {
        margin-bottom: 10px;
    }
    .support-admin-page main.container {
        padding: 0 10px 10px;
    }
    .support-chat-widget {
        right: 14px;
        bottom: 14px;
    }
    .support-chat-toggle {
        min-width: 46px;
        padding: 0 12px;
    }
    .support-chat-toggle-text {
        font-size: 13px;
    }
    .support-chat-toggle-time {
        font-size: 11px;
    }
    .support-chat-panel {
        right: 0;
        bottom: 54px;
        width: calc(100vw - 28px);
    }
    .support-chat-messages {
        height: 52vh;
    }
    .support-admin-shell {
        gap: 10px;
    }
    .support-admin-head {
        align-items: center;
        gap: 10px;
    }
    .support-admin-head h1 {
        margin: 0;
        font-size: 28px;
        line-height: 1.2;
    }
    .support-admin-head p {
        display: none;
    }
    .support-admin-head .btn {
        flex: 0 0 auto;
        min-width: 58px;
        padding: 8px 12px;
        white-space: nowrap;
    }
    .support-admin-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - 126px);
        height: calc(100dvh - 126px);
        min-height: 0;
        max-height: none;
    }
    .support-thread-list {
        display: grid;
        align-content: start;
        gap: 10px;
        max-height: none;
        padding: 10px;
        border-right: 0;
        border-bottom: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .support-thread-item {
        grid-template-columns: minmax(0, 1fr) auto;
        align-content: start;
        min-height: 82px;
        padding: 12px;
        border: 1px solid var(--border-soft);
        border-radius: 8px;
        background: #fff;
        box-shadow: var(--shadow);
    }
    .support-thread-item.is-active {
        border-color: #c9e0f1;
    }
    .support-thread-name,
    .support-thread-status,
    .support-thread-preview {
        min-width: 0;
    }
    .support-thread-preview {
        font-size: 14px;
        line-height: 1.35;
    }
    .support-thread-unread {
        right: 8px;
        bottom: 8px;
    }
    .support-admin-shell[data-active-thread-id=""] .support-admin-chat {
        display: none;
    }
    .support-admin-shell:not([data-active-thread-id=""]) {
        gap: 0;
    }
    .support-admin-shell:not([data-active-thread-id=""]) .support-admin-head,
    .support-admin-shell:not([data-active-thread-id=""]) .support-thread-list {
        display: none;
    }
    .support-admin-shell:not([data-active-thread-id=""]) .support-admin-layout {
        height: calc(100vh - 90px);
        height: calc(100dvh - 90px);
        grid-template-rows: minmax(0, 1fr);
    }
    .support-admin-chat {
        min-height: 0;
    }
    .support-admin-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        min-height: 34px;
        padding: 0 10px;
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text);
        text-decoration: none;
        background: #fff;
        white-space: nowrap;
    }
    .support-admin-chat-head {
        align-items: center;
        justify-content: flex-start;
        padding: 8px 10px;
    }
    .support-admin-chat-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }
    .support-admin-chat-head strong {
        display: inline-block;
        max-width: 28vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: middle;
    }
    .support-admin-chat-head span {
        margin-left: 4px;
    }
    .support-admin-actions {
        gap: 6px;
    }
    .support-admin-actions .btn {
        padding: 6px 10px;
        white-space: nowrap;
    }
    .support-admin-messages {
        padding: 10px;
    }
    .support-admin-page .support-chat-message {
        max-width: 94%;
    }
    .support-admin-page .support-chat-message-meta {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .support-admin-compose {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
        gap: 8px;
        padding: 8px;
    }
    .support-admin-compose textarea {
        min-height: 52px;
        max-height: 110px;
        resize: none;
    }
    .support-admin-compose button {
        min-height: 42px;
        padding: 0 14px;
    }
}
