.team-chat-workspace {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 0;
    height: clamp(560px, 70vh, 720px);
    min-height: 0;
    max-height: 720px;
    margin: 22px 0;
    overflow: hidden;
}

.team-chat-page {
    gap: 18px;
}

.team-chat-dedicated {
    margin: 0;
}

.teams-chat-shell {
    position: relative;
    height: calc(100vh - 214px);
    min-height: 620px;
    max-height: none;
}

.chat-profile-trigger {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}

.chat-profile-trigger:disabled,
.chat-details-button:disabled {
    cursor: default;
}

.chat-profile-trigger:not(:disabled) {
    cursor: pointer;
}

.chat-details-button,
.chat-details-header button {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
    color: #d8fbfb;
}

.chat-details-panel {
    position: absolute;
    z-index: 12;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(390px, 92vw);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-left: 1px solid rgba(255, 255, 255, .1);
    border-radius: 0 18px 18px 0;
    background: rgba(7, 19, 29, .98);
    box-shadow: -22px 0 48px rgba(0, 0, 0, .34);
    transform: translateX(105%);
    transition: transform .22s ease;
}

.chat-details-panel.open {
    transform: translateX(0);
}

.chat-details-scrim {
    position: absolute;
    z-index: 11;
    inset: 0;
    border: 0;
    background: rgba(1, 8, 14, .5);
}

.chat-details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    color: #f5fbfc;
}

.chat-details-body {
    overflow-y: auto;
}

.chat-details-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 28px 20px;
    text-align: center;
    background: linear-gradient(180deg, rgba(79, 209, 208, .12), transparent);
}

.chat-details-avatar {
    width: 112px;
    height: 112px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #377688, #7faf9a);
    color: #fff;
    font-size: 36px;
    font-weight: 800;
    object-fit: cover;
}

.chat-details-avatar.channel {
    background: linear-gradient(135deg, #229893, #3b82f6);
}

.chat-details-hero h3 {
    margin: 8px 0 0;
    color: #fff;
    font-size: 20px;
}

.chat-details-hero > span,
.chat-details-section small {
    color: #9fb5bf;
}

.chat-details-section {
    margin-top: 9px;
    padding: 18px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    background: rgba(255, 255, 255, .025);
}

.chat-details-section h4 {
    margin: 0 0 13px;
    color: #64edf0;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.chat-details-section p {
    color: #dce9ed;
    white-space: pre-wrap;
}

.chat-details-list {
    display: grid;
    gap: 0;
    margin: 0;
}

.chat-details-list > div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.chat-details-list dt {
    color: #9fb5bf;
    font-weight: 500;
}

.chat-details-list dd {
    margin: 0;
    color: #f5fbfc;
    text-align: right;
    overflow-wrap: anywhere;
}

.chat-details-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-details-tags > span {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(79, 209, 208, .13);
    color: #d8fbfb;
    font-size: 12px;
}

.chat-details-members {
    display: grid;
    gap: 8px;
}

.chat-details-member {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.chat-details-member strong,
.chat-details-member small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.team-chat-rail,
.team-chat-main {
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(7, 19, 29, .72);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .22);
}

.team-chat-rail {
    padding: 12px;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
    overflow: hidden;
    border-radius: 18px 0 0 18px;
    border-right: 0;
    background:
        linear-gradient(180deg, rgba(79, 209, 208, .10), rgba(7, 19, 29, .78)),
        rgba(7, 19, 29, .72);
}

.team-chat-main {
    border-radius: 0 18px 18px 0;
}

.team-chat-rail-header,
.team-chat-main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.team-chat-rail-header {
    padding: 4px 4px 14px;
    color: #e9f6f8;
    font-weight: 800;
}

.team-chat-rail-header small {
    min-width: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(79, 209, 208, .16);
    color: #64edf0;
    text-align: center;
}

.team-chat-rail-label {
    margin: 16px 4px 8px;
    color: #9fb5bf;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.team-chat-switcher {
    width: 100%;
}

.team-chat-switcher button {
    flex: 1 1 0;
    min-width: 0;
}

.team-chat-search {
    position: relative;
}

.team-chat-search i {
    position: absolute;
    top: 50%;
    left: 13px;
    transform: translateY(-50%);
    color: #9fb5bf;
    pointer-events: none;
}

.team-chat-search .form-control {
    min-height: 42px;
    padding-left: 38px;
}

.team-chat-member-list {
    display: grid;
    gap: 8px;
    min-height: 0;
    max-height: 460px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 3px;
    scrollbar-gutter: stable;
}

.teams-chat-thread-list {
    max-height: 100%;
    align-content: start;
}

.team-chat-thread {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 22px;
    align-items: center;
    gap: 11px;
    min-height: 68px;
    padding: 10px 11px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: #e9f6f8;
    text-align: left;
    transition: .2s ease;
}

.team-chat-thread:hover,
.team-chat-thread.active {
    border-color: rgba(79, 209, 208, .34);
    background:
        linear-gradient(90deg, rgba(79, 209, 208, .18), rgba(55, 118, 136, .08)),
        rgba(255, 255, 255, .04);
}

.team-chat-thread.active {
    box-shadow: inset 3px 0 0 var(--primary-light);
}

.team-chat-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #377688, #7faf9a);
    color: #fff;
    font-weight: 800;
    object-fit: cover;
}

.team-chat-avatar.channel {
    background: linear-gradient(135deg, #229893, #3b82f6);
}

.team-chat-avatar.large {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
}

.team-chat-thread-copy {
    min-width: 0;
}

.team-chat-thread-copy strong,
.team-chat-thread-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.team-chat-thread-copy small {
    margin-top: 3px;
    color: #9fb5bf;
    font-size: 12px;
}

.team-chat-main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    overflow: hidden;
}

.teams-style-chat-page .workspace-page-header {
    margin-bottom: 0;
}

.teams-style-message-panel {
    min-height: 460px;
}

.team-chat-main-header {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background:
        linear-gradient(90deg, rgba(55, 118, 136, .30), rgba(7, 19, 29, .92)),
        rgba(7, 19, 29, .94);
    backdrop-filter: blur(16px);
}

.team-chat-main-header h6 {
    margin: 0;
    color: #fff;
    font-size: 17px;
    font-weight: 800;
}

.team-chat-main-header small {
    color: #9fb5bf;
}

.team-chat-panel {
    min-height: 0;
    max-height: none;
    overflow: auto;
    padding: 22px 18px;
    border: 0;
    border-radius: 0;
    background:
        radial-gradient(circle at 14px 14px, rgba(79, 209, 208, .10) 0 1px, transparent 1px 100%),
        linear-gradient(135deg, rgba(55, 118, 136, .18), rgba(7, 19, 29, .18)),
        rgba(5, 16, 25, .36);
    background-size: 28px 28px, auto, auto;
    position: relative;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.project-chat-workspace {
    height: clamp(520px, 68vh, 680px);
    max-height: 680px;
    margin: 0;
    grid-template-columns: minmax(0, 1fr);
}

.project-chat-workspace .team-chat-main {
    border-radius: 18px;
}

.project-chat-workspace .team-chat-panel {
    padding: 22px 18px;
}

.chat-new-message-btn {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 auto;
    padding: 8px 12px;
    border: 1px solid rgba(79, 209, 208, .32);
    border-radius: 999px;
    background: rgba(7, 19, 29, .92);
    color: #d8fbfb;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
}

.team-chat-empty {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 9px;
    color: #9fb5bf;
    text-align: center;
}

.team-chat-empty i {
    color: #64edf0;
    font-size: 30px;
}

.team-chat-empty strong {
    color: #e9f6f8;
}

.chat-message {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.chat-message.mine {
    justify-content: flex-end;
}

.chat-message .chat-bubble {
    position: relative;
    max-width: min(680px, 74%);
    padding: 9px 12px 8px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 4px 16px 16px 16px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .045)),
        rgba(13, 32, 45, .86);
    color: #f5fbfc;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .14);
    overflow-wrap: anywhere;
}

.chat-message.mine .chat-bubble {
    border-color: rgba(79, 209, 208, .24);
    border-radius: 16px 4px 16px 16px;
    background:
        linear-gradient(135deg, rgba(55, 118, 136, .98), rgba(79, 209, 208, .88)),
        var(--primary);
}

.chat-message .chat-bubble::before {
    content: "";
    position: absolute;
    left: -7px;
    top: -1px;
    width: 10px;
    height: 12px;
    background: rgba(13, 32, 45, .86);
    clip-path: polygon(100% 0, 100% 100%, 0 0);
}

.chat-message.mine .chat-bubble::before {
    left: auto;
    right: -7px;
    background: rgba(79, 209, 208, .88);
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.chat-message-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
}

.chat-message-actions {
    display: flex;
    gap: 4px;
    opacity: .82;
}

.chat-message-actions button,
.chat-icon-btn,
.chat-attachment-chip button,
.chat-edit-banner button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: inherit;
}

.chat-message-actions button {
    width: 26px;
    height: 26px;
    border-radius: 8px;
}

.chat-message-actions button:hover {
    background: rgba(255, 255, 255, .16);
}

.chat-sender {
    color: #d8fbfb;
    font-size: 12px;
    font-weight: 800;
}

.chat-message-text {
    white-space: pre-wrap;
    line-height: 1.45;
}

.chat-mention-token {
    color: #9bf6ff;
    font-weight: 800;
}

.chat-deleted {
    color: rgba(255, 255, 255, .72);
    font-style: italic;
}

.chat-attachment {
    margin-top: 8px;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}

.chat-attachment.image img {
    display: block;
    max-width: min(360px, 100%);
    max-height: 260px;
    border-radius: 12px;
    object-fit: cover;
}

.chat-attachment.media,
.chat-attachment.audio {
    width: min(420px, 100%);
}

.chat-attachment.file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 12px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    text-decoration: none;
}

.chat-attachment.file:hover {
    border-color: rgba(79, 209, 208, .45);
    background: rgba(79, 209, 208, .14);
}

.chat-attachment.file span {
    min-width: 0;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-preview-modal .modal-body {
    min-height: min(70vh, 680px);
    max-height: min(78vh, 760px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(0, 0, 0, .18);
}

.media-preview-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(70vh, 680px);
    border-radius: 12px;
    object-fit: contain;
}

.media-preview-player,
.media-preview-frame {
    width: 100%;
    height: min(70vh, 680px);
    max-height: min(70vh, 680px);
    object-fit: contain;
    border: 0;
    border-radius: 12px;
    background: #020617;
}

.media-preview-audio {
    width: min(680px, 100%);
}

.media-preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    color: #9fb5bf;
}

.media-preview-empty i {
    color: #64edf0;
    font-size: 44px;
}

.media-preview-empty strong {
    color: #f7fbff;
    font-size: 18px;
}

.document-preview-fallback .btn {
    margin-top: 8px;
    width: auto;
}

.chat-bubble small {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 5px;
    color: rgba(255, 255, 255, .72);
    font-size: 10.5px;
}

.team-chat-composer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding: 10px 14px 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    background:
        linear-gradient(180deg, rgba(7, 19, 29, .80), rgba(7, 19, 29, .96)),
        rgba(7, 19, 29, .96);
    backdrop-filter: blur(16px);
}

.chat-mention-list {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: calc(100% - 8px);
    z-index: 10;
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 14px;
    background: rgba(7, 19, 29, .98);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .32);
}

.chat-mention-list button {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #f7fbff;
    text-align: left;
}

.chat-mention-list button:hover {
    background: rgba(79, 209, 208, .13);
}

.chat-mention-list strong,
.chat-mention-list small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-mention-list small {
    color: #9fb5bf;
}

.team-chat-composer-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 46px;
    align-items: end;
    gap: 8px;
}

.team-chat-composer textarea.form-control {
    min-height: 44px;
    max-height: 120px;
    resize: none;
    border-radius: 22px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, .09);
}

.chat-icon-btn {
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
    color: #d8fbfb;
}

.chat-icon-btn:hover {
    background: rgba(79, 209, 208, .14);
}

.chat-icon-btn:disabled {
    opacity: .45;
}

.chat-icon-btn.primary {
    border-color: rgba(79, 209, 208, .36);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 10px 22px rgba(55, 118, 136, .28);
}

.chat-attachment-chip,
.chat-edit-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(79, 209, 208, .12);
    color: #e9f6f8;
}

.chat-attachment-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-edit-banner button {
    color: #64edf0;
    font-weight: 800;
}

@media (max-width: 991.98px) {
    .team-chat-workspace {
        grid-template-columns: 1fr;
        gap: 12px;
        height: auto;
        min-height: 0;
        max-height: none;
        overflow: visible;
    }

    .teams-chat-shell {
        height: auto;
        min-height: 0;
    }

    .team-chat-rail,
    .team-chat-main {
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, .08);
    }

    .team-chat-rail {
        grid-template-rows: auto auto auto auto;
    }

    .teams-chat-thread-list {
        max-height: 280px;
    }

    .team-chat-panel {
        min-height: 420px;
        max-height: 62vh;
        padding: 16px 12px;
    }

    .chat-message .chat-bubble {
        max-width: 86%;
    }
}

@media (max-width: 575.98px) {
    .team-chat-workspace {
        margin: 14px 0;
    }

    .project-chat-workspace {
        margin: 0;
    }

    .team-chat-rail {
        padding: 10px;
    }

    .team-chat-thread {
        min-height: 62px;
        grid-template-columns: 42px minmax(0, 1fr) 18px;
        padding: 9px;
    }

    .team-chat-avatar {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .team-chat-main-header {
        padding: 10px 12px;
    }

    .team-chat-main-header h6 {
        font-size: 15px;
    }

    .team-chat-panel {
        min-height: 360px;
        max-height: 58vh;
    }

    .chat-message .chat-bubble {
        max-width: 92%;
        padding: 8px 10px 7px;
    }

    .team-chat-composer {
        padding: 9px 10px 10px;
    }

    .team-chat-composer-row {
        grid-template-columns: 40px minmax(0, 1fr) 42px;
        gap: 7px;
    }

    .chat-icon-btn {
        width: 40px;
        height: 40px;
    }

    .team-chat-composer textarea.form-control {
        min-height: 40px;
        padding: 10px 14px;
    }
}

