.chat-page-shell {
    display: flex;
    flex-direction: column;
}

.chat-page-host {
    min-height: calc(100vh - 9.5rem);
}

.chat-app {
    --chat-bg: #efeae2;
    --chat-panel: #f8faf7;
    --chat-sidebar: #eff4f0;
    --chat-primary: #128c7e;
    --chat-primary-soft: #e0f3ef;
    --chat-text: #1f2937;
    --chat-muted: #60717f;
    --chat-own: #dcf8c6;
    --chat-other: #ffffff;
    border: 1px solid #d3ddd4;
    border-radius: 14px;
    overflow: hidden;
    background: var(--chat-panel);
    height: calc(100vh - 10.5rem);
    min-height: 560px;
    display: grid;
    grid-template-columns: 340px 1fr;
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #d8e3db;
    background: linear-gradient(180deg, #f4f8f4 0%, var(--chat-sidebar) 100%);
}

.chat-brand {
    padding: 0.8rem;
    border-bottom: 1px solid #d8e3db;
}

.chat-auth-actions {
    display: flex;
    justify-content: flex-end;
}

.chat-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    background: #ffffff;
    color: #355046;
}

.chat-btn-primary {
    background: var(--chat-primary);
    color: #ffffff;
}

.chat-btn-outline {
    border-color: #c6d7cb;
    background: #f9fcf9;
    color: #29483e;
}

.chat-search-wrap {
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid #d8e3db;
}

.chat-search {
    width: 100%;
    border: 1px solid #cad8cf;
    border-radius: 9px;
    padding: 0.56rem 0.7rem;
    outline: none;
    background: #ffffff;
}

.chat-user-search-head {
    display: block;
}

.chat-user-results {
    margin-top: 0.5rem;
    max-height: 360px;
    overflow: auto;
}

.chat-user-result {
    width: 100%;
    border: 1px solid #d4e0d7;
    border-radius: 10px;
    padding: 0.5rem 0.55rem;
    margin-bottom: 0.4rem;
    background: #ffffff;
    cursor: pointer;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem;
    align-items: center;
    text-align: left;
}

.chat-user-result:hover {
    background: #ebf5ef;
}

.chat-user-avatar {
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 999px;
    background: #d9efe3;
    color: #1f5c46;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.83rem;
    font-weight: 700;
}

.chat-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-user-name {
    font-size: 0.86rem;
    color: #173d32;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user-id {
    font-size: 0.72rem;
    color: #60717f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user-action {
    font-size: 0.73rem;
    color: #1f5c46;
    font-weight: 700;
}

.chat-user-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(8, 20, 14, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.chat-user-modal-card {
    width: min(680px, 100%);
    max-height: min(84vh, 760px);
    overflow: auto;
    background: #f8fcf9;
    border: 1px solid #d5e2d9;
    border-radius: 14px;
    box-shadow: 0 18px 38px rgba(17, 45, 35, 0.28);
    padding: 0.9rem;
}

.chat-user-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    margin-bottom: 0.65rem;
}

.chat-user-modal-title {
    margin: 0;
    font-size: 1rem;
    color: #173d32;
}

.chat-rooms {
    overflow: auto;
    padding: 0.2rem 0;
}

.chat-room {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.45rem;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(192, 208, 197, 0.65);
}

.chat-room:hover {
    background: #eaf4ef;
}

.chat-room.active {
    background: #dcefe7;
}

.chat-room-main {
    min-width: 0;
}

.chat-room-name {
    margin: 0;
    font-size: 0.92rem;
    color: var(--chat-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-room-last {
    margin: 0.22rem 0 0;
    font-size: 0.76rem;
    color: var(--chat-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-room-meta {
    display: flex;
    flex-direction: column;
    align-items: end;
    gap: 0.25rem;
}

.chat-room-time {
    font-size: 0.7rem;
    color: #6c7f74;
}

.chat-room-unread {
    min-width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    background: var(--chat-primary);
    color: #ffffff;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0 0.35rem;
}

.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
}

.chat-main-header {
    min-height: 64px;
    border-bottom: 1px solid #d9e4dc;
    background: #f4f8f3;
    padding: 0.65rem 0.9rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
}

.chat-main-title {
    margin: 0;
    font-size: 1rem;
    color: #163b31;
}

.chat-back {
    display: none;
}

.chat-timeline {
    flex: 1;
    overflow: auto;
    padding: 0.95rem;
    background-image: radial-gradient(circle at 1px 1px, rgba(100, 115, 103, 0.09) 1px, transparent 0);
    background-size: 16px 16px;
}

.chat-load-more-wrap {
    text-align: center;
    margin-bottom: 0.75rem;
}

.chat-day-sep {
    text-align: center;
    margin: 0.7rem 0;
}

.chat-day-sep span {
    display: inline-block;
    background: #dae9df;
    color: #3f5749;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.72rem;
}

.chat-message {
    display: flex;
    margin-bottom: 0.6rem;
}

.chat-message.other {
    justify-content: flex-start;
}

.chat-message.own {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: min(720px, 78%);
    border-radius: 10px;
    padding: 0.5rem 0.62rem 0.35rem;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.chat-message.own .chat-bubble {
    background: var(--chat-own);
}

.chat-message.other .chat-bubble {
    background: var(--chat-other);
}

.chat-sender {
    margin: 0 0 0.15rem;
    color: #39584c;
    font-size: 0.72rem;
    font-weight: 700;
}

.chat-body {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: #10261f;
    font-size: 0.9rem;
}

.chat-meta {
    display: flex;
    justify-content: flex-end;
    gap: 0.36rem;
    margin-top: 0.2rem;
    color: #60717f;
    font-size: 0.68rem;
}

.chat-receipts {
    color: #2c7ecf;
    font-weight: 700;
}

.chat-empty {
    margin: 2.5rem auto;
    max-width: 430px;
    text-align: center;
    color: #5a6f62;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid #d6e3da;
    border-radius: 12px;
    padding: 1.25rem;
}

.chat-typing {
    min-height: 1.2rem;
    padding: 0 1rem 0.35rem;
    font-size: 0.77rem;
    color: #4f6558;
}

.chat-input-wrap {
    border-top: 1px solid #d9e4dc;
    background: #f8fbf8;
    padding: 0.65rem 0.8rem;
}

.chat-input-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: end;
}

.chat-input {
    resize: none;
    border: 1px solid #c6d7cb;
    border-radius: 10px;
    min-height: 46px;
    max-height: 180px;
    padding: 0.55rem 0.65rem;
    outline: none;
    font-size: 0.92rem;
    background: #ffffff;
}

.chat-input-hint {
    margin: 0.35rem 0 0;
    color: #60717f;
    font-size: 0.72rem;
}

@media (max-width: 992px) {
    .chat-app {
        grid-template-columns: 1fr;
        height: calc(100vh - 8.8rem);
        min-height: 520px;
    }

    .chat-back {
        display: inline-flex;
        align-items: center;
        gap: 0.28rem;
    }

    .chat-app.chat-mobile-room-open .chat-sidebar {
        display: none;
    }

    .chat-app:not(.chat-mobile-room-open) .chat-main {
        display: none;
    }

    .chat-bubble {
        max-width: 90%;
    }
}
