.rt_chat-container,
.rt_chat-container * {
    box-sizing: border-box;
}

.rt_chat-container {
    --rt-chat-bg: var(--cs-bg, #090b0c);
    --rt-chat-surface: var(--cs-surface, #151719);
    --rt-chat-surface-2: var(--cs-surface-2, #1d2022);
    --rt-chat-surface-3: var(--cs-surface-3, #262a2d);
    --rt-chat-border: var(--cs-border, #34383b);
    --rt-chat-border-soft: var(--cs-border-soft, rgba(180, 188, 196, 0.16));
    --rt-chat-text: var(--cs-text, #f2eee6);
    --rt-chat-muted: var(--cs-muted, #aaa39a);
    --rt-chat-blue: var(--cs-blue, #4da3ff);
    --rt-chat-blue-deep: var(--cs-blue-deep, #1d4f86);
    --rt-chat-amber: var(--cs-amber, #d9a441);
    --rt-chat-orange: var(--cs-orange, #c97832);
    --rt-chat-brown: var(--cs-brown, #6f4d2f);
    --rt-chat-red: var(--cs-red, #d65a3a);
    --rt-chat-radius: var(--cs-radius, 8px);
    --rt-chat-shadow: var(--cs-shadow, 0 18px 55px rgba(0, 0, 0, 0.48));
    --rt-chat-font: var(--cs-font, "Inter", Arial, Helvetica, sans-serif);
    --rt-chat-display: var(--cs-display, "Rajdhani", "Inter", Arial, Helvetica, sans-serif);
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 320px;
    color: var(--rt-chat-text);
    font-family: var(--rt-chat-font);
    container-type: inline-size;
    background:
        linear-gradient(135deg, rgba(77, 163, 255, 0.08), transparent 34%),
        linear-gradient(315deg, rgba(201, 120, 50, 0.12), transparent 36%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 16px),
        linear-gradient(180deg, rgba(29, 32, 34, 0.98), rgba(9, 11, 12, 0.98));
    border: 1px solid var(--rt-chat-border);
    border-radius: var(--rt-chat-radius);
    box-shadow: var(--rt-chat-shadow);
    overflow: hidden;
}

.rt_chat-container::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    z-index: -1;
    height: 4px;
    background: linear-gradient(90deg, var(--rt-chat-blue-deep), var(--rt-chat-blue), var(--rt-chat-amber), var(--rt-chat-orange));
}

.rt_chat-container::after {
    content: "";
    position: absolute;
    inset: 4px 0 auto;
    z-index: -1;
    height: 112px;
    background:
        linear-gradient(90deg, rgba(77, 163, 255, 0.13), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent);
    pointer-events: none;
}

.rt_chat-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 68px;
    padding: 14px;
    background: linear-gradient(90deg, rgba(29, 79, 134, 0.46), rgba(201, 120, 50, 0.18));
    border-bottom: 1px solid var(--rt-chat-border);
}

.rt_chat-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.rt_chat-title-icon {
    display: inline-grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    place-items: center;
    color: #080a0b;
    background: linear-gradient(135deg, var(--rt-chat-blue), var(--rt-chat-amber));
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(77, 163, 255, 0.18);
}

.rt_chat-title-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.rt_chat-title-copy strong {
    color: var(--rt-chat-text);
    font-family: var(--rt-chat-display);
    font-size: 22px;
    line-height: 1;
    font-weight: 800;
}

.rt_chat-title-copy small {
    color: var(--rt-chat-amber);
    font-size: 12px;
    font-weight: 800;
}

.rt_chat-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 0;
}

.rt_chat-popout,
.rt_chat-statistics {
    min-width: 0;
}

.rt_chat-statistics span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt_chat-popout,
.rt_chat-statistics {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 11px !important;
    color: var(--rt-chat-text) !important;
    background: rgba(8, 10, 11, 0.62) !important;
    border: 1px solid rgba(77, 163, 255, 0.28) !important;
    border-radius: 8px !important;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none !important;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.rt_chat-popout {
    width: 38px;
    padding: 0 !important;
}

.rt_chat-popout:hover,
.rt_chat-statistics:hover {
    color: #080a0b !important;
    background: linear-gradient(135deg, var(--rt-chat-amber), var(--rt-chat-orange)) !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
    box-shadow: 0 12px 24px rgba(217, 164, 65, 0.18);
    transform: translateY(-1px);
}

.rt_chat-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    color: var(--rt-chat-muted);
    background: rgba(8, 10, 11, 0.54);
    border-bottom: 1px solid var(--rt-chat-border-soft);
    font-size: 12px;
    font-weight: 800;
}

.rt_chat-statusbar span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.rt_chat-statusbar .bi-circle-fill {
    color: var(--rt-chat-blue);
    font-size: 8px;
    filter: drop-shadow(0 0 7px rgba(77, 163, 255, 0.75));
}

.rt_chat-messages {
    position: relative;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    scrollbar-color: var(--rt-chat-blue) rgba(255, 255, 255, 0.06);
    scrollbar-width: thin;
}

.rt_chat-messages::-webkit-scrollbar {
    width: 9px;
}

.rt_chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}

.rt_chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--rt-chat-blue), var(--rt-chat-orange));
    border: 2px solid rgba(8, 10, 11, 0.86);
    border-radius: 8px;
}

.rt_chat-message {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: linear-gradient(180deg, rgba(29, 32, 34, 0.64), rgba(13, 16, 18, 0.7));
    border: 1px solid rgba(180, 188, 196, 0.1);
    border-left: 2px solid rgba(77, 163, 255, 0.52);
    border-radius: 8px;
    animation: rtChatMessageIn 220ms ease both;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.rt_chat-message:hover {
    background: linear-gradient(180deg, rgba(32, 36, 39, 0.82), rgba(15, 17, 18, 0.86));
    border-color: rgba(77, 163, 255, 0.28);
    transform: translateY(-1px);
}

@keyframes rtChatMessageIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rt_chat-message-avatar {
    flex: 0 0 34px;
}

.rt_chat-message-avatar span {
    display: block;
    width: 34px;
    height: 34px;
    padding: 2px;
    background: linear-gradient(135deg, var(--rt-chat-blue), var(--rt-chat-brown), var(--rt-chat-orange));
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.rt_chat-message-avatar img {
    display: block;
    width: 30px;
    height: 30px;
    object-fit: cover;
    background: var(--rt-chat-surface-3);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
}

.rt_chat-message-content {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    position: relative;
    padding-right: 92px;
}

.rt_chat-message:hover .rt_chat-message-content {
    border-color: transparent;
    background: transparent;
}

.rt_chat-message-line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
}

.rt_chat-message-author {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    max-width: 38%;
    min-width: 0;
    color: var(--rt-chat-blue);
    font-family: var(--rt-chat-display);
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt_chat-message-arrow {
    flex: 0 0 auto;
    color: var(--rt-chat-amber);
    font-size: 12px;
    font-weight: 900;
}

.rt_chat-whisper-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 3px 6px;
    color: #080a0b;
    background: linear-gradient(135deg, var(--rt-chat-amber), var(--rt-chat-orange));
    border-radius: 6px;
    font-family: var(--rt-chat-font);
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.rt_chat-message-timestamp {
    flex: 0 0 auto;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--rt-chat-muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.rt_chat-message-text {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    color: var(--rt-chat-text);
    background: transparent;
    border: 0;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.rt_chat-message-text a {
    color: var(--rt-chat-blue) !important;
    font-weight: 800;
}

.rt_chat-message-text a:hover {
    color: var(--rt-chat-amber) !important;
}

.rt_chat-message-action {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    min-height: 0;
    position: absolute;
    right: 0;
    bottom: -2px;
    opacity: 0;
    transform: translateY(3px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.rt_chat-message:hover .rt_chat-message-action {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.rt_chat-action-link {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 22px;
    padding: 0 6px !important;
    color: var(--rt-chat-muted) !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid var(--rt-chat-border-soft) !important;
    border-radius: 7px !important;
    font-size: 10px !important;
    font-weight: 800;
    line-height: 1;
    text-decoration: none !important;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.rt_chat-action-link:hover {
    color: var(--rt-chat-text) !important;
    background: rgba(77, 163, 255, 0.13) !important;
    border-color: rgba(77, 163, 255, 0.32) !important;
    transform: translateY(-1px);
}

.rt_chat-delete:hover {
    color: #080a0b !important;
    background: linear-gradient(135deg, var(--rt-chat-red), var(--rt-chat-orange)) !important;
}

.rt_chat-input {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: linear-gradient(180deg, rgba(14, 16, 17, 0.98), rgba(8, 10, 11, 0.98));
    border-top: 1px solid var(--rt-chat-border);
}

.rt_chat-input-shell {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    height: 44px;
    padding: 0 12px;
    color: var(--rt-chat-blue);
    background: rgba(6, 8, 9, 0.82);
    border: 1px solid var(--rt-chat-border);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.rt_chat-input-shell:focus-within {
    border-color: rgba(77, 163, 255, 0.62);
    box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.13);
}

.rt_chat-input input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 42px;
    margin: 0;
    padding: 0;
    color: var(--rt-chat-text);
    background: transparent;
    border: 0;
    border-radius: 0;
    outline: 0;
    font: 14px var(--rt-chat-font);
}

.rt_chat-input input[type="text"]::placeholder {
    color: var(--rt-chat-muted);
}

.rt_chat-send {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    min-width: 112px;
    height: 44px;
    padding: 0 16px !important;
    color: #080a0b !important;
    background: linear-gradient(135deg, var(--rt-chat-blue), #7dbbff) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 12px 26px rgba(77, 163, 255, 0.15);
    transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.rt_chat-send:hover {
    background: linear-gradient(135deg, var(--rt-chat-amber), var(--rt-chat-orange)) !important;
    box-shadow: 0 16px 34px rgba(217, 164, 65, 0.18);
    transform: translateY(-1px);
}

.rt_chat-input button:disabled,
.rt_chat-input input:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.rt_chat-input button:disabled {
    background: linear-gradient(135deg, #50575c, #32373a) !important;
    box-shadow: none;
}

.rt_chat-statistics-modal {
    width: 100%;
    max-width: min(560px, calc(100vw - 24px));
    color: var(--cs-text, #f2eee6);
    background:
        linear-gradient(135deg, rgba(77, 163, 255, 0.08), transparent 42%),
        linear-gradient(180deg, rgba(29, 32, 34, 0.98), rgba(9, 11, 12, 0.98)) !important;
    border: 1px solid var(--cs-border, #34383b) !important;
    border-radius: 8px !important;
    box-shadow: var(--cs-shadow, 0 18px 55px rgba(0, 0, 0, 0.48)) !important;
    overflow: hidden;
}

.rt_chat-statistics-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 0 16px;
    color: var(--cs-text, #f2eee6);
    background: linear-gradient(90deg, var(--cs-blue-deep, #1d4f86), rgba(77, 163, 255, 0.68), rgba(201, 120, 50, 0.82));
    font-family: var(--cs-display, "Rajdhani", Arial, sans-serif);
    font-size: 20px;
    font-weight: 800;
}

.rt_chat-statistics-scroll {
    max-height: 420px;
    overflow-y: auto;
}

.rt_chat-statistics-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--cs-muted, #aaa39a);
    font-family: var(--cs-font, "Inter", Arial, Helvetica, sans-serif);
}

.rt_chat-statistics-table th,
.rt_chat-statistics-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--cs-border-soft, rgba(180, 188, 196, 0.16));
}

.rt_chat-statistics-table th {
    color: var(--cs-text, #f2eee6);
    background: rgba(8, 10, 11, 0.72);
    font-size: 12px;
    font-weight: 900;
    text-align: left;
}

.rt_chat-statistics-table th:last-child {
    text-align: center;
}

.rt_chat-statistics-table tr:hover td {
    color: var(--cs-text, #f2eee6);
    background: rgba(77, 163, 255, 0.08);
}

.rt_chat-stat-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.rt_chat-stat-user .bi {
    color: var(--cs-blue, #4da3ff);
}

.rt_chat-stat-count {
    display: inline-flex;
    min-width: 42px;
    justify-content: center;
    padding: 5px 8px;
    color: #080a0b;
    background: linear-gradient(135deg, var(--cs-amber, #d9a441), var(--cs-orange, #c97832));
    border-radius: 7px;
    font-weight: 900;
}

@media (max-width: 640px) {
    .rt_chat-container {
        min-height: 360px;
    }

    .rt_chat-container .rt_chat-header {
        align-items: stretch !important;
        flex-direction: column !important;
        padding: 12px;
    }

    .rt_chat-container .rt_chat-header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .rt_chat-container .rt_chat-statistics {
        flex: 1 1 auto;
    }

    .rt_chat-statusbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .rt_chat-messages {
        padding: 10px;
    }

    .rt_chat-message {
        gap: 8px;
    }

    .rt_chat-message-avatar,
    .rt_chat-message-avatar span {
        flex-basis: 32px;
        width: 32px;
        height: 32px;
    }

    .rt_chat-message-avatar img {
        width: 28px;
        height: 28px;
    }

    .rt_chat-message-content {
        align-items: center;
        flex-direction: row;
        gap: 8px;
        padding-right: 72px;
    }

    .rt_chat-message-line {
        width: 100%;
    }

    .rt_chat-message-author {
        max-width: 44%;
    }

    .rt_chat-message-timestamp {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        font-size: 10px;
    }

    .rt_chat-message-action {
        position: absolute;
        right: 0;
        bottom: -2px;
        justify-content: flex-end;
        opacity: 0;
        transform: translateY(3px);
        pointer-events: none;
    }

    .rt_chat-input {
        flex-wrap: wrap;
    }

    .rt_chat-input-shell,
    .rt_chat-send {
        width: 100%;
    }
}

@container (max-width: 520px) {
    .rt_chat-container .rt_chat-header {
        align-items: stretch !important;
        flex-direction: column !important;
        padding: 12px;
    }

    .rt_chat-container .rt_chat-header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .rt_chat-container .rt_chat-statistics {
        flex: 1 1 auto;
    }
}
