.tchat-page {
    background: #fffaf7;
}

.tchat-wrap {
    max-width: 900px;
    padding-top: 10px;
}

.tchat-titlebar {
    margin-bottom: 20px;
}

.tchat-titlebar h1 {
    margin: 0;
    color: #27211f;
    font-size: clamp(27px, 4vw, 38px);
    letter-spacing: -0.035em;
}

.tchat-titlebar p,
.tchat-safety-note {
    color: #756d68;
    font-size: 13px;
    line-height: 1.55;
}

.tchat-titlebar p {
    margin: 7px 0 0;
}

.tchat-entry {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: max-content;
    margin-bottom: 15px;
    border: 1px solid #f6d9d2;
    border-radius: 999px;
    background: #fff;
    color: #d83f31;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 15px;
    text-decoration: none;
}

.tchat-entry:hover {
    background: #fff3ef;
    color: #c73529;
    text-decoration: none;
}

.tchat-list,
.tchat-room {
    overflow: hidden;
    border: 1px solid #eee4df;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(65, 43, 33, 0.07);
}

.tchat-list__item {
    display: flex;
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid #f2ece8;
    color: #302a27;
    padding: 15px 18px;
    text-decoration: none;
}

.tchat-list__item:last-child {
    border-bottom: 0;
}

.tchat-list__item:hover {
    background: #fff8f5;
    color: #302a27;
    text-decoration: none;
}

.tchat-list__text {
    display: grid;
    min-width: 0;
    gap: 3px;
    flex: 1;
}

.tchat-list__text strong,
.tchat-list__text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tchat-list__text strong {
    font-size: 14px;
}

.tchat-list__text small {
    color: #827973;
    font-size: 12px;
}

.tchat-unread {
    display: grid;
    min-width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 50%;
    background: #ff4b39;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    padding: 0 5px;
}

.tchat-empty {
    padding: 42px 20px;
    text-align: center;
}

.tchat-empty h2 {
    margin: 0;
    font-size: 19px;
}

.tchat-empty p {
    margin: 8px 0 16px;
    color: #776e68;
    font-size: 13px;
}

.tchat-room__head {
    display: flex;
    gap: 11px;
    align-items: center;
    border-bottom: 1px solid #eee6e1;
    padding: 14px 18px;
}

.tchat-room__head h1 {
    margin: 0;
    color: #28221f;
    font-size: 15px;
    font-weight: 800;
}

.tchat-room__head p {
    margin: 2px 0 0;
    color: #897f79;
    font-size: 11px;
}

.tchat-room__menu {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.tchat-room__menu form {
    margin: 0;
}

.tchat-text-button,
.tchat-report-trigger {
    border: 0;
    background: transparent;
    color: #8a7770;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    padding: 3px;
}

.tchat-text-button:hover,
.tchat-report-trigger:hover {
    color: #ff4b39;
}

.tchat-alert {
    border-bottom: 1px solid #f3dfd8;
    background: #fff3ef;
    color: #704b42;
    font-size: 12px;
    line-height: 1.5;
    padding: 10px 18px;
}

.tchat-history {
    display: flex;
    height: min(56vh, 570px);
    min-height: 320px;
    flex-direction: column;
    gap: 13px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px 20px;
}

.tchat-history__empty {
    align-self: center;
    margin: auto;
    color: #8c817b;
    font-size: 13px;
    text-align: center;
}

.tchat-message {
    width: fit-content;
    max-width: min(78%, 540px);
    min-width: 0;
    flex: 0 0 auto;
    align-self: flex-start;
}

.tchat-message.is-mine {
    align-self: flex-end;
}

.tchat-message__bubble {
    border: 1px solid #ede6e1;
    border-radius: 15px 15px 15px 4px;
    background: #f8f6f4;
    color: #403833;
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
    padding: 9px 12px;
    white-space: normal;
}

.tchat-message__bubble > span { white-space: pre-wrap; }

.tchat-message.is-mine .tchat-message__bubble {
    border-color: #ff4b39;
    border-radius: 15px 15px 4px 15px;
    background: #ff4b39;
    color: #fff;
}

.tchat-message__bubble .tchat-message__image { display: block; max-width: 280px; margin-bottom: 5px; }
.tchat-message__bubble .tchat-message__image:last-child { margin-bottom: 0; }
.tchat-message__image img { display: block; width: 100%; max-height: 290px; object-fit: contain; border-radius: 8px; }
.tchat-message__receipt { display: inline-flex; align-items: center; color: #9e9690; }
.tchat-message__receipt.is-read { color: #ff4b39; }
.tchat-message__receipt svg { display: block; width: 17px; height: 17px; }

.tchat-message__meta {
    display: flex;
    gap: 9px;
    align-items: center;
    margin-top: 3px;
    color: #948a84;
    font-size: 10px;
}

.tchat-message.is-mine .tchat-message__meta {
    justify-content: flex-end;
}

.tchat-compose {
    border-top: 1px solid #eee6e1;
    padding: 12px 16px 13px;
}

.tchat-compose textarea {
    width: 100%;
    min-height: 48px;
    max-height: 110px;
    border: 1px solid #e9dfda;
    border-radius: 10px;
    color: #302a27;
    font-size: 14px;
    line-height: 1.45;
    outline: none;
    overflow-y: auto;
    padding: 11px 12px;
    resize: none;
}

.tchat-compose textarea:focus {
    border-color: #ff4b39;
    box-shadow: 0 0 0 3px rgba(255, 75, 57, 0.12);
}

.tchat-compose__actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 8px;
}

.tchat-attach { position: relative; display: grid; width: 39px; height: 39px; place-items: center; margin: 0 auto 0 0; border: 1px solid #e8dcd5; border-radius: 50%; color: #736c67; cursor: pointer; }
.tchat-attach:hover { border-color: #ff4b39; color: #ff4b39; }
.tchat-attach .tc-icon { width: 19px; height: 19px; }
.tchat-attach input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tchat-attach:focus-within { outline: 2px solid #ff4b39; outline-offset: 2px; }
.tchat-compose__file { display: flex; align-items: center; gap: 8px; margin-top: 7px; color: #655b54; font-size: 12px; }
.tchat-compose__file[hidden] { display: none; }
.tchat-compose__file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tchat-compose__file button { display: grid; flex: none; place-items: center; width: 24px; height: 24px; border: 0; background: transparent; color: #ae3e31; cursor: pointer; }
.tchat-compose__file .tc-icon { width: 15px; height: 15px; }

.tchat-voice-button {
    display: grid;
    width: 39px;
    height: 39px;
    place-items: center;
    border: 1px solid #e8dcd5;
    border-radius: 50%;
    background: #fff;
    color: #736c67;
    cursor: pointer;
}

.tchat-voice-button svg {
    width: 18px;
    height: 18px;
}

.tchat-voice-button.is-armed,
.tchat-voice-button:hover {
    border-color: #ff4b39;
    color: #ff4b39;
}

.tchat-voice-button.is-recording {
    border-color: #ff4b39;
    background: #ff4b39;
    color: #fff;
}

.tchat-voice-button[disabled] {
    opacity: 0.55;
}

.tchat-compose .tc-voice-status {
    min-height: 16px;
    margin-top: 4px;
    text-align: right;
}

.tchat-compose__error {
    margin-top: 5px;
    color: #bd382b;
    font-size: 12px;
}

.tchat-safety-note {
    margin: 13px 4px 0;
    text-align: center;
}

.tchat-modal[hidden] {
    display: none;
}

.tchat-modal {
    position: fixed;
    z-index: 10030;
    inset: 0;
}

.tchat-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(34, 27, 23, 0.55);
}

.tchat-modal__dialog {
    position: relative;
    width: calc(100% - 32px);
    max-width: 450px;
    margin: 10vh auto;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(29, 20, 17, 0.3);
    padding: 23px;
}

.tchat-modal__dialog h2 {
    margin: 0;
    font-size: 21px;
}

.tchat-modal__dialog p {
    color: #736a65;
    font-size: 12px;
    line-height: 1.5;
}

.tchat-modal__close {
    position: absolute;
    top: 7px;
    right: 13px;
    border: 0;
    background: transparent;
    color: #7a706b;
    cursor: pointer;
    font-size: 26px;
}

@media (max-width: 767px) {
    .tchat-room__head { flex-wrap: wrap; }
    .tchat-room__menu { width: 100%; justify-content: flex-end; margin-left: 0; }
    .tchat-wrap {
        padding-right: 12px;
        padding-left: 12px;
    }

    .tchat-room {
        border-radius: 12px;
    }

    .tchat-history {
        height: min(58vh, 540px);
        min-height: 280px;
        padding: 15px 12px;
    }

    .tchat-message {
        max-width: 84%;
    }

    .tchat-compose {
        padding: 10px;
    }

    .tchat-safety-note {
        font-size: 11px;
    }
}
