html,
body.chat-page {
    height: 100%;
    min-height: 100%;
}

/* Premium dark chat redesign */
body.chat-page {
    --chat-bg: #071019;
    --chat-surface: rgba(8, 16, 25, 0.76);
    --chat-surface-strong: rgba(10, 19, 30, 0.92);
    --chat-border: rgba(133, 161, 185, 0.13);
    --chat-border-strong: rgba(133, 161, 185, 0.2);
    --chat-text: #eff6fd;
    --chat-muted: #8ea4ba;
    --chat-muted-strong: #bfd0e0;
    --chat-accent: #82b6ff;
    --chat-accent-soft: rgba(130, 182, 255, 0.14);
    --chat-success: #58d0b3;
    /* Option-surface design foundation: one shared system for every menu,
       sheet, action row and selection bar. */
    --chat-radius-sheet: 20px;
    --chat-radius-menu: 16px;
    --chat-radius-row: 12px;
    --chat-radius-pill: 999px;
    --chat-hairline: var(--chat-border);
    --chat-menu-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.72);
    --chat-row-min: 44px;
    --chat-row-hover: var(--chat-control-bg-hover);
    --chat-row-gap: 0.16rem;
    --chat-shell-gradient:
        radial-gradient(circle at 18% 12%, rgba(93, 159, 255, 0.16), transparent 28%),
        radial-gradient(circle at 82% 0%, rgba(70, 206, 192, 0.12), transparent 20%),
        radial-gradient(circle at 50% 110%, rgba(33, 54, 91, 0.42), transparent 42%),
        linear-gradient(180deg, #091420 0%, #060d15 48%, #050a11 100%);
    --chat-header-bg: linear-gradient(180deg, rgba(13, 23, 35, 0.94), rgba(9, 17, 27, 0.9));
    --chat-pane-bg: linear-gradient(180deg, rgba(12, 21, 32, 0.94), rgba(8, 15, 24, 0.92));
    --chat-pane-bg-strong: linear-gradient(180deg, rgba(13, 22, 34, 0.98), rgba(8, 15, 24, 0.96));
    --chat-control-bg: rgba(16, 28, 42, 0.86);
    --chat-control-bg-hover: rgba(22, 37, 54, 0.96);
    --chat-list-active-bg: linear-gradient(180deg, rgba(130, 182, 255, 0.14), rgba(82, 221, 204, 0.08));
    --chat-stream-bg: rgba(8, 14, 22, 0.96);
    --chat-stream-pattern: rgba(137, 160, 185, 0.08);
    --chat-bubble: linear-gradient(180deg, rgba(15, 24, 36, 0.98), rgba(11, 19, 29, 0.98));
    --chat-bubble-me: linear-gradient(180deg, rgba(22, 53, 66, 0.98), rgba(16, 38, 51, 0.98));
    --chat-composer-bg: rgba(8, 16, 25, 0.92);
    --chat-input-bg: rgba(14, 25, 37, 0.96);
    --chat-chip-bg: rgba(18, 30, 45, 0.92);
    --chat-overlay-bg: rgba(3, 8, 14, 0.62);
    --chat-sheet-bg: rgba(9, 17, 27, 0.98);
    --chat-modal-bg: rgba(8, 16, 25, 0.98);
    --chat-toast-bg: rgba(8, 15, 23, 0.96);
    --chat-top-chrome-color: rgba(9, 17, 27, 0.98);
    --chat-statusbar-color: #08111b;
    background-color: var(--chat-statusbar-color);
    color: var(--chat-text);
}

html[data-theme="dark"] body.chat-page {
    --chat-top-chrome-color: rgba(9, 17, 27, 0.98);
    --chat-statusbar-color: #08111b;
}

body.chat-page .background-overlay {
    background: var(--chat-shell-gradient);
}

.chat-app {
    position: relative;
    width: min(1540px, calc(100% - 2rem));
    max-width: 1540px;
    padding: calc(1rem + env(safe-area-inset-top, 0px)) 0.9rem calc(1rem + var(--chat-shell-offset));
    gap: 0.9rem;
    contain: layout paint style;
}

.chat-app::before {
    content: "";
    position: absolute;
    top: 3.5rem;
    left: 50%;
    width: min(760px, 76vw);
    height: 280px;
    transform: translateX(-50%);
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 40%, rgba(113, 164, 255, 0.18), transparent 54%),
        radial-gradient(circle at 62% 52%, rgba(77, 214, 188, 0.1), transparent 48%);
    filter: blur(42px);
    opacity: 0.8;
    pointer-events: none;
    z-index: 0;
}

.chat-app > * {
    position: relative;
    z-index: 1;
}

.chat-app__header,
.chat-login-panel,
.chat-stage {
    border-radius: 30px;
    border: 1px solid var(--chat-border);
    background: var(--chat-pane-bg);
    box-shadow:
        0 30px 80px -48px rgba(0, 0, 0, 0.82),
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        inset 0 -1px 0 rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(24px);
}

.chat-app__header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: var(--chat-header-bg);
}

.chat-app__identity h1 {
    margin: 0;
    font-family: var(--font-accent);
    font-size: clamp(1.1rem, 1.4vw, 1.45rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.chat-app__identity p {
    margin: 0.24rem 0 0;
    color: var(--chat-muted);
    font-size: 0.8rem;
    line-height: 1.8;
    max-width: 42rem;
}

.chat-app__actions {
    gap: 0.52rem;
}

.chat-back,
.chat-top-btn,
.chat-sheet-close,
.conversation-pane__icon-btn,
.conversation-pane__close,
.thread-head__mobile-btn {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    border: 1px solid var(--chat-border);
    background: rgba(18, 31, 46, 0.8);
    color: var(--chat-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chat-back:hover,
.chat-back:focus-visible,
.chat-top-btn:hover,
.chat-top-btn:focus-visible,
.chat-sheet-close:hover,
.chat-sheet-close:focus-visible,
.conversation-pane__icon-btn:hover,
.conversation-pane__icon-btn:focus-visible,
.conversation-pane__close:hover,
.conversation-pane__close:focus-visible,
.thread-head__mobile-btn:hover,
.thread-head__mobile-btn:focus-visible {
    border-color: var(--chat-border-strong);
    background: rgba(23, 39, 58, 0.96);
    box-shadow:
        0 14px 28px -20px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.chat-top-btn-text {
    width: auto;
    min-width: 78px;
    padding-inline: 0.95rem;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 820;
}

#account-btn {
    width: 44px;
    min-width: 44px;
    border-radius: 16px;
}

.chat-connection {
    min-height: 40px;
    padding: 0.46rem 0.88rem;
    border-radius: 999px;
    border-color: var(--chat-border);
    background: rgba(14, 25, 37, 0.86);
    color: var(--chat-muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chat-stage {
    gap: 0.9rem;
    padding: 0.95rem;
    grid-template-columns: minmax(310px, 360px) minmax(0, 1fr);
    background: linear-gradient(180deg, rgba(11, 19, 29, 0.92), rgba(7, 13, 21, 0.96));
}

.conversation-pane,
.thread-pane {
    border-radius: 26px;
    border: 1px solid var(--chat-border);
    background: var(--chat-pane-bg-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.conversation-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-login-panel {
    width: min(520px, 100%);
    padding: 1.35rem;
    background: linear-gradient(180deg, rgba(12, 21, 33, 0.96), rgba(8, 15, 24, 0.96));
}

.chat-login-kicker {
    min-height: 30px;
    padding: 0.32rem 0.78rem;
    background: rgba(130, 182, 255, 0.12);
    color: var(--chat-accent);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.chat-login-title {
    font-family: var(--font-accent);
    font-size: 1.42rem;
    line-height: 1.5;
}

.chat-login-text,
.login-feedback,
.composer-storage-note {
    color: var(--chat-muted);
}

.chat-login-btn {
    min-height: 50px;
    border-radius: 18px;
    background: linear-gradient(135deg, #7cb0ff 0%, #4fd6ca 100%);
    color: #08111a;
    font-weight: 880;
    box-shadow: 0 20px 36px -24px rgba(79, 214, 202, 0.42);
}

.chat-secondary-link {
    min-height: 46px;
    border-radius: 16px;
    border-color: var(--chat-border);
    background: rgba(18, 31, 46, 0.8);
}

.conversation-pane__header,
.thread-head {
    padding: 1rem 1rem 0.88rem;
    border-bottom: 1px solid var(--chat-border);
    background: linear-gradient(180deg, rgba(13, 23, 35, 0.96), rgba(9, 17, 27, 0.9));
    backdrop-filter: blur(24px);
}

.conversation-pane__header h2,
.thread-head__copy strong,
.conversation-item__title {
    font-family: var(--font-accent);
    letter-spacing: -0.02em;
    text-align: center;
}

.conversation-pane__header h2 {
    font-size: 1rem;
    font-weight: 760;
}

.conversation-pane__header p,
.thread-head__copy span {
    color: var(--chat-muted);
}

.conversation-pane__header-actions {
    gap: 0.34rem;
    padding: 0.28rem;
    border-radius: 18px;
    border: 1px solid rgba(133, 161, 185, 0.1);
    background: rgba(11, 21, 33, 0.72);
}

.conversation-search-wrap {
    padding: 0.88rem 1rem 0.6rem;
}

.conversation-search-wrap input,
.chat-modal__fields input,
.chat-modal__fields textarea,
#edit-text {
    min-height: 48px;
    border-radius: 18px;
    border: 1px solid var(--chat-border);
    background: rgba(11, 21, 32, 0.9);
    color: var(--chat-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.conversation-search-wrap input::placeholder,
.composer-entry textarea::placeholder,
.chat-modal__fields input::placeholder,
.chat-modal__fields textarea::placeholder,
#edit-text::placeholder {
    color: color-mix(in srgb, var(--chat-muted) 88%, transparent);
}

.conversation-filter-tabs {
    gap: 0.42rem;
    padding: 0 1rem 0.75rem;
}

.conversation-filter-tab {
    min-height: 36px;
    padding-inline: 0.95rem;
    border-radius: 999px;
    border-color: rgba(133, 161, 185, 0.16);
    background: rgba(15, 26, 39, 0.76);
    color: var(--chat-muted);
    font-size: 0.7rem;
}

.conversation-filter-tab.is-active {
    border-color: rgba(130, 182, 255, 0.3);
    background: linear-gradient(180deg, rgba(130, 182, 255, 0.2), rgba(79, 214, 202, 0.08));
    color: var(--chat-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.conversation-manage-bar,
.conversation-empty,
.conversation-archive-toggle,
.chat-pinned-strip,
.chat-mute-strip {
    border-radius: 18px;
}

.conversation-manage-bar,
.conversation-empty {
    margin-inline: 1rem;
}

.conversation-empty {
    padding: 0.8rem 0.95rem;
    border: 1px dashed rgba(133, 161, 185, 0.18);
    background: rgba(12, 22, 34, 0.46);
    font-size: 0.76rem;
}

.conversation-list {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 0.72rem 0.8rem;
    gap: 0.34rem;
}

.conversation-item__main {
    min-height: 80px;
    padding: 0.8rem 0.82rem;
    border-radius: 22px;
    background: rgba(12, 22, 34, 0.42);
    border: 1px solid transparent;
}

.conversation-item__main::before {
    inset-inline-start: 0.36rem;
    inset-block: 12px;
    width: 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, #82b6ff 0%, #4fd6ca 100%);
}

.conversation-item__main:hover,
.conversation-item__main:focus-visible {
    background: rgba(15, 28, 42, 0.88);
    border-color: rgba(133, 161, 185, 0.16);
}

.conversation-item.is-active .conversation-item__main {
    background: var(--chat-list-active-bg);
    border-color: rgba(130, 182, 255, 0.26);
    box-shadow: 0 20px 40px -30px rgba(0, 0, 0, 0.62);
}

.conversation-item__avatar,
.thread-head__avatar {
    border-radius: 18px;
    box-shadow:
        0 16px 28px -20px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.conversation-item__avatar {
    width: 48px;
    height: 48px;
    font-size: 0.84rem;
}

.conversation-item__kind {
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 12px;
    background: rgba(130, 182, 255, 0.14);
    border-color: rgba(130, 182, 255, 0.18);
}

.conversation-item__title {
    font-size: 0.84rem;
    font-weight: 840;
}

.conversation-item__subtitle,
.conversation-item__preview,
.conversation-item__time {
    color: var(--chat-muted);
}

.conversation-item__preview {
    font-size: 0.71rem;
    line-height: 1.55;
}

.conversation-badge,
.conversation-item__unread {
    min-height: 21px;
    padding-inline: 0.42rem;
    border-radius: 999px;
}

.conversation-badge {
    background: rgba(82, 221, 204, 0.12);
    color: var(--chat-success);
}

.thread-pane {
    display: grid;
    background: var(--chat-pane-bg-strong);
}

.thread-placeholder {
    padding: clamp(1.2rem, 3vw, 2rem);
    background:
        radial-gradient(circle at 50% 18%, rgba(130, 182, 255, 0.09), transparent 30%),
        radial-gradient(circle at 18% 80%, rgba(79, 214, 202, 0.08), transparent 22%),
        linear-gradient(180deg, rgba(11, 19, 29, 0.96), rgba(8, 15, 24, 0.98));
}

.thread-placeholder__shell {
    width: min(760px, 100%);
    margin: auto;
    display: grid;
    gap: 0.95rem;
    padding: clamp(1.35rem, 3vw, 2.2rem);
    border-radius: 28px;
    border: 1px solid rgba(133, 161, 185, 0.14);
    background: rgba(11, 20, 30, 0.84);
    box-shadow:
        0 34px 70px -42px rgba(0, 0, 0, 0.78),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.thread-placeholder__eyebrow {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 30px;
    padding: 0.32rem 0.8rem;
    border-radius: 999px;
    background: rgba(130, 182, 255, 0.1);
    color: var(--chat-accent);
    font-size: 0.72rem;
    font-weight: 820;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.thread-placeholder strong {
    font-family: var(--font-accent);
    font-size: clamp(1.55rem, 2.4vw, 2.3rem);
    font-weight: 800;
    line-height: 1.16;
    letter-spacing: -0.04em;
}

.thread-placeholder__lead,
.thread-placeholder > span {
    font-size: 0.92rem;
    line-height: 1.95;
    color: var(--chat-muted);
}

.thread-placeholder__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.72rem;
}

.thread-placeholder__stat {
    display: grid;
    gap: 0.24rem;
    padding: 0.9rem 0.95rem;
    border-radius: 20px;
    border: 1px solid rgba(133, 161, 185, 0.12);
    background: rgba(15, 26, 38, 0.88);
}

.thread-placeholder__stat b {
    font-size: 1.06rem;
    font-weight: 840;
    color: var(--chat-text);
}

.thread-placeholder__stat span {
    color: var(--chat-muted);
    font-size: 0.74rem;
    line-height: 1.7;
}

.thread-placeholder__actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.78rem;
}

.thread-placeholder__action {
    display: grid;
    gap: 0.28rem;
    min-height: 168px;
    padding: 1rem;
    border-radius: 22px;
    border: 1px solid rgba(133, 161, 185, 0.12);
    background:
        linear-gradient(180deg, rgba(17, 29, 43, 0.96), rgba(12, 22, 34, 0.94)),
        radial-gradient(circle at top left, rgba(130, 182, 255, 0.1), transparent 36%);
    color: var(--chat-text);
    text-align: start;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.thread-placeholder__action:hover,
.thread-placeholder__action:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(130, 182, 255, 0.24);
    box-shadow: 0 22px 44px -34px rgba(0, 0, 0, 0.76);
}

.thread-placeholder__action:disabled {
    opacity: 0.56;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.thread-placeholder__action-kicker {
    color: var(--chat-accent);
    font-size: 0.68rem;
    font-weight: 820;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.thread-placeholder__action strong {
    font-size: 1rem;
    line-height: 1.4;
}

.thread-placeholder__action span:last-child {
    color: var(--chat-muted);
    font-size: 0.76rem;
    line-height: 1.85;
}

.thread-head {
    padding: 0.95rem 1.08rem 0.88rem;
}

.thread-head__identity {
    gap: 0.72rem;
}

.thread-head__avatar {
    width: 52px;
    height: 52px;
    font-size: 0.9rem;
}

.thread-head__copy strong {
    font-size: 1rem;
    font-weight: 820;
}

.thread-head__copy span {
    font-size: 0.76rem;
    line-height: 1.7;
}

.thread-head__actions {
    gap: 0.34rem;
}

.thread-banner-stack {
    padding: 0.8rem 1rem 0;
    gap: 0.5rem;
}

.chat-mute-strip {
    padding: 0.72rem 0.86rem;
    background: rgba(239, 124, 136, 0.08);
    border: 1px solid rgba(239, 124, 136, 0.14);
}

.chat-pinned-strip {
    padding: 0.75rem 0.86rem;
    background: rgba(15, 26, 39, 0.9);
    border-color: rgba(130, 182, 255, 0.14);
}

.chat-pinned-strip__copy strong {
    font-size: 0.74rem;
}

.thread-stream,
.messages,
.stream-state {
    background:
        radial-gradient(circle at 18% 12%, rgba(130, 182, 255, 0.08), transparent 28%),
        radial-gradient(circle at 82% 0%, rgba(79, 214, 202, 0.07), transparent 24%),
        linear-gradient(var(--chat-stream-bg), var(--chat-stream-bg)),
        radial-gradient(circle at 1px 1px, var(--chat-stream-pattern) 1px, transparent 0);
    background-size: auto, auto, auto, 28px 28px;
}

.stream-state {
    gap: 0.45rem;
    padding: 2.4rem 1rem;
}

.stream-state strong {
    font-family: var(--font-accent);
    font-size: 1.18rem;
    font-weight: 760;
}

.stream-state span {
    max-width: 28rem;
    margin: 0 auto;
    line-height: 1.85;
}

.messages {
    padding: 1rem 1.08rem 0.85rem;
    /* Ensure the messages area is an independent scroll container
       so scrolling works on mobile (touch) and desktop (wheel). */
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 981px) {
    .messages {
        padding-inline: clamp(1.4rem, 5vw, 5.4rem);
    }
}

.msg-item.day-start {
    margin-top: 1rem;
    padding-top: 1.2rem;
}

.msg-item.day-start::before {
    min-height: 28px;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    border-color: rgba(133, 161, 185, 0.14);
    background: rgba(15, 27, 40, 0.88);
    color: var(--chat-muted);
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 16px;
    box-shadow: 0 18px 28px -22px rgba(0, 0, 0, 0.76);
}

.msg-bubble {
    max-width: min(71%, 720px);
    padding: 0.62rem 0.82rem 0.5rem;
    border-radius: 24px;
    border-color: rgba(133, 161, 185, 0.12);
    background: var(--chat-bubble);
    box-shadow: 0 24px 48px -40px rgba(0, 0, 0, 0.78);
}

.msg-item.me .msg-bubble {
    border-color: rgba(79, 214, 202, 0.16);
    background: var(--chat-bubble-me);
}

.msg-text {
    font-size: 0.9rem;
    line-height: 1.92;
    color: var(--chat-text);
}

.msg-name {
    color: #9cc7ff;
    font-size: 0.72rem;
}

.msg-foot,
.msg-delivery,
.msg-time,
.msg-reaction__count {
    color: var(--chat-muted);
}

.msg-reaction {
    min-height: 26px;
    padding: 0.14rem 0.48rem;
    border-radius: 999px;
    border-color: rgba(133, 161, 185, 0.14);
    background: rgba(15, 27, 40, 0.86);
}

.msg-reaction.is-own {
    background: rgba(130, 182, 255, 0.12);
    border-color: rgba(130, 182, 255, 0.18);
    color: var(--chat-accent);
}

.msg-attachment {
    padding: 0.56rem 0.62rem;
    border-radius: 16px;
    border-color: rgba(133, 161, 185, 0.12);
    background: rgba(15, 28, 41, 0.88);
}

.reply-preview,
.reply-bar {
    border-radius: 16px;
}

.composer {
    padding: 0.9rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--chat-border);
    background: linear-gradient(180deg, rgba(8, 16, 25, 0.72), rgba(8, 16, 25, 0.96));
    backdrop-filter: blur(22px);
}

.reply-bar {
    margin-bottom: 0.6rem;
    padding: 0.55rem 0.72rem;
    background: rgba(130, 182, 255, 0.08);
    border: 1px solid rgba(130, 182, 255, 0.12);
}

.composer-box {
    gap: 0.5rem;
    padding: 0.42rem;
    border-radius: 26px;
    border-color: rgba(133, 161, 185, 0.14);
    background: linear-gradient(180deg, rgba(14, 25, 37, 0.96), rgba(10, 19, 29, 0.98));
    box-shadow:
        0 28px 52px -40px rgba(0, 0, 0, 0.82),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.composer-box:focus-within {
    border-color: rgba(130, 182, 255, 0.22);
    box-shadow:
        0 32px 56px -42px rgba(0, 0, 0, 0.88),
        0 0 0 4px rgba(130, 182, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    background: linear-gradient(180deg, rgba(16, 28, 42, 0.98), rgba(11, 21, 33, 0.98));
}

.composer-tools {
    gap: 0.34rem;
}

.composer-tool,
.composer-send {
    width: 44px;
    height: 44px;
    border-radius: 18px;
}

.composer-tool {
    border-color: rgba(133, 161, 185, 0.12);
    background: rgba(18, 31, 46, 0.82);
    color: var(--chat-muted-strong);
}

.composer-tool:hover,
.composer-tool:focus-visible,
.composer-tool.is-open,
.composer-tool.is-recording {
    background: rgba(22, 39, 58, 0.98);
    color: var(--chat-text);
}

.composer-entry textarea {
    min-height: 52px;
    max-height: 184px;
    padding: 0.7rem 0.18rem;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.94rem;
    line-height: 1.8;
}

.composer-send {
    border: 0;
    background: linear-gradient(135deg, #7cb0ff 0%, #4fd6ca 100%);
    color: #08111a;
    box-shadow: 0 20px 36px -24px rgba(79, 214, 202, 0.46);
}

.composer-send:hover:not(:disabled),
.composer-send:focus-visible {
    filter: brightness(1.03);
    box-shadow: 0 24px 42px -24px rgba(79, 214, 202, 0.5);
}

.composer-send:disabled {
    opacity: 0.48;
    box-shadow: none;
}

.composer-upload-sheet,
.composer-uploads {
    margin-bottom: 0.6rem;
}

.composer-upload-option,
.composer-upload-item {
    border-radius: 16px;
    border-color: rgba(133, 161, 185, 0.12);
    background: rgba(16, 29, 43, 0.88);
}

.composer-voice {
    margin-bottom: 0.6rem;
    padding: 0.8rem 0.9rem;
    border-radius: 18px;
    background: rgba(16, 28, 42, 0.88);
    border: 1px solid rgba(133, 161, 185, 0.12);
}

.composer-status {
    margin-top: 0.42rem;
    min-height: 1rem;
    font-size: 0.74rem;
}

.composer-storage-note {
    margin-top: 0.34rem;
    font-size: 0.72rem;
    line-height: 1.75;
}

.chat-info-sheet,
.chat-modal {
    border-radius: 28px;
    border: 1px solid var(--chat-border);
    background: linear-gradient(180deg, rgba(11, 20, 31, 0.98), rgba(8, 16, 25, 0.98));
    box-shadow: 0 36px 80px -44px rgba(0, 0, 0, 0.84);
}

.chat-mobile-nav {
    border: 1px solid var(--chat-border);
    background: rgba(10, 18, 28, 0.9);
    box-shadow:
        0 28px 56px -34px rgba(0, 0, 0, 0.84),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(24px);
}

.chat-mobile-nav__item {
    color: var(--chat-muted);
}

.chat-mobile-nav__item.is-active {
    color: var(--chat-text);
}

.chat-mobile-nav__item.is-active::before {
    background: linear-gradient(90deg, #7cb0ff, #4fd6ca);
}

.chat-fab {
    border-radius: 22px;
    border: 1px solid rgba(130, 182, 255, 0.18);
    background: linear-gradient(135deg, rgba(124, 176, 255, 0.98), rgba(79, 214, 202, 0.96));
    color: #08111a;
    box-shadow: 0 26px 48px -26px rgba(79, 214, 202, 0.4);
}

@media (max-width: 1240px) {
    .chat-stage {
        grid-template-columns: minmax(290px, 330px) minmax(0, 1fr);
    }

    .msg-bubble {
        max-width: min(78%, 680px);
    }
}

@media (max-width: 980px) {
    .chat-app {
        width: 100%;
        padding: 0 0 calc(0.8rem + var(--chat-shell-offset));
        gap: 0.55rem;
    }

    .chat-app::before {
        top: 0;
        width: 100%;
        height: 220px;
        filter: blur(54px);
    }

    .chat-app__header {
        margin: 0.55rem 0.55rem 0;
        padding: calc(0.82rem + env(safe-area-inset-top, 0px)) 0.82rem 0.82rem;
        border-radius: 24px;
        gap: 0.72rem;
    }

    .chat-back,
    .chat-top-btn,
    .conversation-pane__icon-btn,
    .thread-head__mobile-btn {
        width: 40px;
        height: 40px;
        border-radius: 15px;
    }

    .chat-connection {
        min-height: 34px;
        padding: 0.34rem 0.7rem;
    }

    .chat-stage {
        padding: 0.55rem;
        gap: 0.55rem;
        background: transparent;
        box-shadow: none;
        border: 0;
    }

    .conversation-pane,
    .thread-pane {
        border-radius: 24px;
    }

    .conversation-pane__header,
    .thread-head {
        padding: 0.82rem 0.82rem 0.72rem;
    }

    .conversation-search-wrap,
    .conversation-filter-tabs,
    .conversation-list {
        padding-inline: 0.82rem;
    }

    .conversation-search-wrap {
        padding-top: 0.72rem;
        padding-bottom: 0.52rem;
    }

    .conversation-filter-tabs {
        padding-bottom: 0.62rem;
    }

    .conversation-item__main {
        min-height: 72px;
        padding: 0.74rem 0.14rem;
        border-radius: 18px;
    }

    .thread-placeholder {
        padding: 0.82rem;
    }

    .thread-placeholder__shell {
        gap: 0.82rem;
        padding: 1.05rem;
        border-radius: 22px;
    }

    .thread-placeholder strong {
        font-size: 1.36rem;
    }

    .thread-placeholder__stats,
    .thread-placeholder__actions {
        grid-template-columns: 1fr;
    }

    .thread-placeholder__action {
        min-height: 0;
        padding: 0.92rem;
    }

    .thread-banner-stack {
        padding: 0.68rem 0.82rem 0;
    }

    .messages {
        padding: 0.82rem 0.82rem 0.74rem;
    }

    .msg-bubble {
        max-width: 90%;
        padding: 0.56rem 0.74rem 0.48rem;
        border-radius: 22px;
    }

    .composer {
        padding: 0.72rem 0.82rem calc(0.82rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
    }

    .composer-box {
        border-radius: 24px;
    }

    .composer-tool,
    .composer-send {
        width: 42px;
        height: 42px;
        border-radius: 16px;
    }

    .composer-entry textarea {
        min-height: 48px;
        font-size: 0.9rem;
    }

    .chat-mobile-nav {
        left: 0.55rem;
        right: 0.55rem;
        bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
        border-radius: 24px;
    }

    .chat-fab {
        right: 0.82rem;
        bottom: calc(5.9rem + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 680px) {
    .chat-app__identity p {
        font-size: 0.76rem;
    }

    .chat-app__header {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .chat-app__actions {
        grid-column: 1 / -1;
        justify-content: space-between;
    }

    .conversation-pane__header-actions {
        padding: 0.24rem;
    }

    .conversation-item__avatar,
    .thread-head__avatar {
        width: 46px;
        height: 46px;
    }

    .thread-head__identity {
        gap: 0.58rem;
    }

    .thread-head__copy strong {
        font-size: 0.92rem;
    }

    .messages {
        padding-inline: 0.72rem;
    }

    .msg-bubble {
        max-width: 94%;
    }

    .composer {
        padding-inline: 0.72rem;
    }

    .composer-box {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .composer-send {
        grid-column: 1 / -1;
        width: 100%;
        height: 46px;
        border-radius: 18px;
    }
}

body.chat-page {
    --chat-bg: #d8e4ef;
    --chat-surface: rgba(255, 255, 255, 0.84);
    --chat-surface-strong: rgba(255, 255, 255, 0.96);
    --chat-border: rgba(107, 129, 154, 0.16);
    --chat-text: #17263a;
    --chat-muted: #66778a;
    --chat-accent: #3390ec;
    --chat-accent-soft: rgba(51, 144, 236, 0.12);
    --chat-bubble: rgba(255, 255, 255, 0.98);
    --chat-bubble-me: linear-gradient(180deg, #dcf2ff 0%, #d3edff 100%);
    --chat-danger: #c7535e;
    --chat-warning: #c2811d;
    --chat-success: #158f63;
    --chat-shell-gradient:
        radial-gradient(circle at 11% 5%, rgba(51, 144, 236, 0.12), transparent 26%),
        radial-gradient(circle at 91% 1%, rgba(90, 180, 255, 0.11), transparent 24%),
        linear-gradient(180deg, #edf4fb 0%, #d8e4ef 100%);
    --chat-header-bg: rgba(255, 255, 255, 0.82);
    --chat-pane-bg: rgba(255, 255, 255, 0.78);
    --chat-pane-bg-strong: rgba(255, 255, 255, 0.93);
    --chat-control-bg: rgba(255, 255, 255, 0.88);
    --chat-control-bg-hover: rgba(255, 255, 255, 0.98);
    --chat-list-active-bg: rgba(51, 144, 236, 0.12);
    --chat-stream-bg: rgba(241, 247, 253, 0.9);
    --chat-stream-pattern: rgba(124, 145, 168, 0.08);
    --chat-composer-bg: rgba(248, 252, 255, 0.98);
    --chat-input-bg: rgba(255, 255, 255, 0.92);
    --chat-overlay-bg: rgba(8, 17, 28, 0.28);
    --chat-sheet-bg: rgba(255, 255, 255, 0.96);
    --chat-modal-bg: rgba(255, 255, 255, 0.98);
    --chat-chip-bg: rgba(255, 255, 255, 0.84);
    --chat-toast-bg: rgba(23, 37, 55, 0.94);
    --chat-shell-offset: 0px;
    --chat-local-nav-height: 0px;
    min-height: var(--chat-vh, 100dvh);
    color: var(--chat-text);
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.chat-page.has-app-shell:not(.app-shell-hidden) {
    --chat-shell-offset: calc(78px + env(safe-area-inset-bottom, 0px));
}

body.chat-page.app-shell-hidden {
    --chat-shell-offset: 0px;
}

body.chat-page.chat-modal-open {
    overflow: hidden;
}

html[data-theme="dark"] body.chat-page {
    --chat-bg: #0c141f;
    --chat-surface: rgba(12, 20, 31, 0.86);
    --chat-surface-strong: rgba(16, 25, 40, 0.96);
    --chat-border: rgba(124, 145, 168, 0.2);
    --chat-text: #eef3ff;
    --chat-muted: #9aabc2;
    --chat-accent: #66b7ff;
    --chat-accent-soft: rgba(102, 183, 255, 0.16);
    --chat-bubble: rgba(16, 25, 40, 0.98);
    --chat-bubble-me: linear-gradient(180deg, #1d4f7f 0%, #183f67 100%);
    --chat-danger: #ef7c88;
    --chat-warning: #e5a44b;
    --chat-success: #43c28f;
    --chat-shell-gradient:
        radial-gradient(circle at 12% 8%, rgba(102, 183, 255, 0.14), transparent 28%),
        radial-gradient(circle at 90% 0%, rgba(67, 194, 255, 0.15), transparent 24%),
        linear-gradient(180deg, #182436 0%, #0c141f 100%);
    --chat-header-bg: rgba(16, 25, 40, 0.88);
    --chat-pane-bg: rgba(14, 22, 34, 0.88);
    --chat-pane-bg-strong: rgba(16, 25, 40, 0.94);
    --chat-control-bg: rgba(16, 25, 40, 0.88);
    --chat-control-bg-hover: rgba(22, 34, 52, 0.96);
    --chat-list-active-bg: rgba(102, 183, 255, 0.2);
    --chat-stream-bg: rgba(12, 20, 31, 0.86);
    --chat-stream-pattern: rgba(124, 145, 168, 0.1);
    --chat-composer-bg: rgba(16, 25, 40, 0.9);
    --chat-input-bg: rgba(16, 25, 40, 0.92);
    --chat-overlay-bg: rgba(5, 9, 16, 0.45);
    --chat-sheet-bg: rgba(15, 23, 36, 0.96);
    --chat-modal-bg: rgba(15, 23, 36, 0.98);
    --chat-chip-bg: rgba(16, 25, 40, 0.86);
    --chat-toast-bg: rgba(10, 18, 29, 0.95);
}

body.chat-page .background-overlay {
    background: var(--chat-shell-gradient);
}

body.chat-page input,
body.chat-page textarea,
body.chat-page button {
    font: inherit;
}

body.chat-page button {
    touch-action: manipulation;
}

body.chat-page,
body.chat-page * {
    -webkit-tap-highlight-color: transparent;
}

.chat-app {
    width: min(1440px, 100%);
    flex: 1 1 auto;
    height: 100%;
    min-height: 100%;
    max-height: var(--chat-vh, 100dvh);
    margin: 0 auto;
    padding: calc(0.42rem + env(safe-area-inset-top, 0px)) 0.42rem calc(0.42rem + var(--chat-shell-offset));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.42rem;
}

.chat-app__header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.62rem;
    border-radius: 20px;
    border: 1px solid var(--chat-border);
    background: var(--chat-header-bg);
    box-shadow: 0 18px 42px -32px rgba(22, 42, 70, 0.18);
    backdrop-filter: blur(16px);
}

.chat-app__identity {
    min-width: 0;
}

.chat-app__identity h1 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 900;
    line-height: 1.4;
}

.chat-app__identity p {
    margin: 0.08rem 0 0;
    color: var(--chat-muted);
    font-size: 0.74rem;
    line-height: 1.55;
}

.chat-app__actions {
    display: flex;
    align-items: center;
    gap: 0.38rem;
}

.chat-back,
.chat-top-btn,
.chat-sheet-close,
.conversation-pane__close,
.thread-head__mobile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    background: var(--chat-control-bg);
    color: var(--chat-text);
    overflow: hidden;
    transition: transform var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease, box-shadow var(--motion-fast, 0.18s) ease;
}

.chat-back:hover,
.chat-back:focus-visible,
.chat-top-btn:hover,
.chat-top-btn:focus-visible,
.chat-sheet-close:hover,
.chat-sheet-close:focus-visible,
.conversation-pane__close:hover,
.conversation-pane__close:focus-visible,
.thread-head__mobile-btn:hover,
.thread-head__mobile-btn:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(43, 109, 243, 0.3);
    background: var(--chat-control-bg-hover);
    box-shadow: 0 12px 24px -20px rgba(22, 42, 70, 0.18);
}

.chat-back svg,
.chat-top-btn svg,
.chat-sheet-close svg,
.conversation-pane__close svg,
.thread-head__mobile-btn svg {
    width: 18px;
    height: 18px;
}

.chat-top-btn-text {
    width: auto;
    min-width: 64px;
    padding-inline: 0.8rem;
    font-size: 0.78rem;
    font-weight: 820;
}

#account-btn {
    font-size: 0.74rem;
    font-weight: 900;
}

#account-btn-avatar-image {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

#account-btn-avatar-fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: inherit;
    background: linear-gradient(160deg, #2f72f2, #6a9dff);
    color: #fff;
}

#account-btn[data-has-avatar="1"] #account-btn-avatar-fallback {
    display: none;
}

#account-btn-avatar-image[hidden] {
    display: none !important;
}

.chat-connection {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    min-height: 34px;
    padding: 0.35rem 0.72rem;
    border-radius: 999px;
    background: var(--chat-control-bg);
    border: 1px solid var(--chat-border);
    color: var(--chat-muted);
    font-size: 0.74rem;
    font-weight: 820;
}

.chat-connection::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

.chat-connection[data-state="live"] {
    color: var(--chat-success);
    background: rgba(21, 143, 99, 0.08);
    border-color: rgba(21, 143, 99, 0.16);
}

.chat-connection[data-state="sync"] {
    color: var(--chat-accent);
    background: rgba(43, 109, 243, 0.08);
    border-color: rgba(43, 109, 243, 0.16);
}

.chat-connection[data-state="issue"] {
    color: var(--chat-warning);
    background: rgba(194, 129, 29, 0.08);
    border-color: rgba(194, 129, 29, 0.16);
}

.chat-app__main {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
    contain: layout paint;
}

.chat-login-panel,
.chat-stage {
    min-height: 0;
    border-radius: 24px;
    border: 1px solid var(--chat-border);
    background: var(--chat-surface);
    box-shadow: 0 24px 52px -36px rgba(22, 42, 70, 0.22);
    backdrop-filter: blur(18px);
    contain: layout paint;
}

.chat-login-panel {
    width: min(470px, 100%);
    margin: auto;
    padding: 1.1rem;
}

.chat-login-head {
    display: grid;
    gap: 0.24rem;
    margin-bottom: 0.95rem;
}

.chat-login-kicker {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 28px;
    padding: 0.3rem 0.74rem;
    border-radius: 999px;
    background: var(--chat-accent-soft);
    color: var(--chat-accent);
    font-size: 0.74rem;
    font-weight: 840;
}

.chat-login-title {
    margin: 0.08rem 0 0;
    font-size: 1.26rem;
    line-height: 1.42;
    font-weight: 930;
    letter-spacing: -0.03em;
}

.chat-login-text {
    margin: 0;
    color: var(--chat-muted);
    font-size: 0.84rem;
    line-height: 1.85;
}

.chat-guard-actions {
    display: grid;
    gap: 0.7rem;
}

.chat-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 16px;
    background: var(--btn-gradient);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 860;
    box-shadow: var(--btn-shadow);
    transition: transform var(--motion-fast, 0.18s) ease, box-shadow var(--motion-fast, 0.18s) ease, filter var(--motion-fast, 0.18s) ease;
}

.chat-login-btn:hover:not(:disabled),
.chat-login-btn:focus-visible {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

.chat-login-btn:disabled {
    opacity: 0.65;
    cursor: default;
    box-shadow: none;
}

.chat-secondary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 14px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-text);
    font-size: 0.82rem;
    font-weight: 820;
}

.chat-secondary-link:hover,
.chat-secondary-link:focus-visible {
    border-color: rgba(43, 109, 243, 0.3);
    background: var(--chat-control-bg-hover);
}

.login-feedback {
    min-height: 1.35rem;
    margin-top: 0.75rem;
    text-align: center;
    font-size: 0.81rem;
}

.login-feedback.error {
    color: var(--chat-danger);
}

.chat-stage {
    display: grid;
    height: 100%;
    grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
    gap: 0.46rem;
    padding: 0.44rem;
    overflow: hidden;
}

.conversation-pane,
.thread-pane {
    height: 100%;
    min-height: 0;
    border-radius: 20px;
    border: 1px solid var(--chat-border);
    background: var(--chat-pane-bg);
    overflow: hidden;
    contain: layout paint;
}

.conversation-pane {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
}

.conversation-pane__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    padding: 0.56rem 0.62rem 0.42rem;
}

.conversation-pane__header h2 {
    margin: 0;
    font-size: 0.86rem;
    font-weight: 900;
}

.conversation-pane__header p {
    margin: 0.08rem 0 0;
    color: var(--chat-muted);
    font-size: 0.69rem;
}

.conversation-pane__close,
.thread-head__mobile-btn {
    display: none;
}

.conversation-pane__title-block {
    min-width: 0;
}

.conversation-pane__header-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.conversation-pane__icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    border: 1px solid var(--chat-border);
    color: var(--chat-text);
    background: var(--chat-control-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease;
}

.conversation-pane__icon-btn svg {
    width: 17px;
    height: 17px;
}

.conversation-pane__icon-btn:hover,
.conversation-pane__icon-btn:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(51, 144, 236, 0.32);
    background: var(--chat-control-bg-hover);
}

.conversation-search-wrap {
    display: block;
    padding: 0 0.62rem 0.5rem;
}

.conversation-search-wrap input {
    width: 100%;
    min-height: 38px;
    padding: 0.48rem 0.72rem;
    border-radius: 11px;
    border: 1px solid var(--chat-border);
    background: var(--chat-input-bg);
    color: var(--chat-text);
    font-size: 0.78rem;
}

.conversation-search-wrap input:focus {
    border-color: rgba(43, 109, 243, 0.32);
    box-shadow: 0 0 0 3px rgba(43, 109, 243, 0.08);
    outline: 0;
}

.conversation-empty {
    margin: 0 0.62rem 0.62rem;
    padding: 0.5rem 0.62rem;
    border-radius: 10px;
    border: 1px dashed rgba(124, 145, 168, 0.2);
    color: var(--chat-muted);
    font-size: 0.74rem;
}

.conversation-list {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0 0.4rem 0.5rem;
    display: grid;
    gap: 0.14rem;
}

.conversation-manage-bar {
    margin: 0 0.5rem 0.3rem;
    padding: 0.32rem 0.4rem;
    border-radius: 10px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    display: grid;
    gap: 0.22rem;
    position: relative;
}

.conversation-manage-bar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    min-width: 0;
}

.conversation-manage-bar__head-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    margin-inline-start: auto;
    min-width: 0;
}

.conversation-manage-bar__head strong {
    font-size: 0.66rem;
    font-weight: 760;
    color: var(--chat-muted);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-manage-bar__head button {
    min-height: 24px;
    padding-inline: 0.5rem;
    border-radius: 999px;
    border: none;
    background: none;
    color: var(--chat-accent);
    transition: background var(--motion-fast) var(--motion-ease-standard);
}

body.chat-page .conversation-manage-bar__head button {
    font-size: 0.66rem;
    font-weight: 800;
}

.conversation-manage-bar__head button:hover {
    background: var(--chat-control-bg-hover);
}

.conversation-manage-bar__actions {
    display: flex;
    align-items: center;
    gap: 0.28rem;
    min-height: 28px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -0.4rem;
    padding: 0 0.4rem;
}

.conversation-manage-bar__actions::-webkit-scrollbar {
    display: none;
}

.conversation-manage-bar__actions button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.34rem;
    min-height: 34px;
    padding: 0 0.72rem;
    border-radius: 12px;
    border: 1px solid var(--chat-border);
    background: var(--chat-surface);
    color: var(--chat-text);
    white-space: nowrap;
    transition:
        border-color var(--motion-fast) var(--motion-ease-standard),
        background var(--motion-fast) var(--motion-ease-standard),
        transform var(--motion-fast) var(--motion-ease-standard);
}

.conversation-manage-bar__actions .manage-action__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    color: var(--chat-muted);
}

.conversation-manage-bar__actions .manage-action__icon svg {
    width: 17px;
    height: 17px;
}

.conversation-manage-bar__actions .manage-action__label {
    line-height: 1;
}

body.chat-page .conversation-manage-bar__actions button {
    font-size: 0.7rem;
    font-weight: 760;
    line-height: 1;
}

.conversation-manage-bar__actions button:not(:disabled):hover,
.conversation-manage-bar__actions button:not(:disabled):focus-visible {
    border-color: rgba(43, 109, 243, 0.24);
    background: var(--chat-control-bg-hover);
    transform: translateY(-1px);
}

.conversation-manage-bar__actions button.is-danger {
    color: var(--chat-danger);
    border-color: rgba(199, 83, 94, 0.26);
    background: rgba(199, 83, 94, 0.08);
}

.conversation-manage-bar__actions button.is-danger .manage-action__icon {
    color: var(--chat-danger);
}

.conversation-manage-bar__actions button.is-danger:not(:disabled):hover,
.conversation-manage-bar__actions button.is-danger:not(:disabled):focus-visible {
    border-color: rgba(199, 83, 94, 0.4);
    background: rgba(199, 83, 94, 0.14);
}

.conversation-manage-bar__actions button:disabled,
.conversation-manage-bar__head button:disabled {
    opacity: 0.46;
    cursor: default;
}

.conversation-list::-webkit-scrollbar {
    width: 8px;
}

.conversation-list::-webkit-scrollbar-thumb {
    background: rgba(124, 145, 168, 0.24);
    border-radius: 999px;
}

.conversation-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.24rem;
    align-items: center;
    width: 100%;
}

.conversation-item__main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.42rem;
    align-items: center;
    width: 100%;
    padding: 0.42rem 0.5rem;
    border: 1px solid transparent;
    border-radius: 13px;
    background: transparent;
    color: var(--chat-text);
    text-align: start;
    position: relative;
    overflow: hidden;
    transition: transform var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease, box-shadow var(--motion-fast, 0.18s) ease;
}

.conversation-item__main:hover,
.conversation-item__main:focus-visible {
    border-color: rgba(51, 144, 236, 0.3);
    background: var(--chat-control-bg-hover);
}

.conversation-item__main::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block: 8px;
    width: 3px;
    border-radius: 999px;
    background: var(--chat-accent);
    opacity: 0;
    transition: opacity var(--motion-fast, 0.18s) ease;
}

.conversation-item.is-active .conversation-item__main {
    border-color: rgba(51, 144, 236, 0.4);
    background: var(--chat-list-active-bg);
}

.conversation-item.is-active .conversation-item__main::before {
    opacity: 1;
}

.conversation-item.is-selected .conversation-item__main {
    border-color: rgba(51, 144, 236, 0.36);
    background: rgba(51, 144, 236, 0.18);
}

.conversation-item.is-archived {
    opacity: 0.84;
}

.conversation-item.is-unread .conversation-item__title {
    font-weight: 920;
}

.conversation-item__tools {
    display: grid;
    justify-items: center;
    gap: 0.18rem;
}

.conversation-item__more,
.conversation-item__select {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--chat-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease, color var(--motion-fast, 0.18s) ease;
}

.conversation-item__more {
    font-size: 1rem;
    line-height: 1;
}

.conversation-item__more:hover,
.conversation-item__more:focus-visible,
.conversation-item__select:hover,
.conversation-item__select:focus-within {
    border-color: rgba(51, 144, 236, 0.26);
    background: var(--chat-control-bg-hover);
    color: var(--chat-text);
}

.conversation-item__select {
    opacity: 0;
    pointer-events: none;
    border-radius: 50% !important;
    border-color: transparent !important;
    background: transparent !important;
}

.conversation-item__select input {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    margin: 0;
    border-radius: 50%;
    border: 2px solid var(--chat-muted);
    background: transparent;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
    position: relative;
}

.conversation-item__select input:checked {
    background: var(--chat-accent);
    border-color: var(--chat-accent);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 10.5l3.5 3.5 6.5-7' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 100%;
}

body.chat-page.chat-selection-mode .conversation-item__select {
    opacity: 1;
    pointer-events: auto;
}

.conversation-archive-toggle {
    width: 100%;
    margin-top: 0.28rem;
    border: 1px dashed rgba(124, 145, 168, 0.28);
    border-radius: 12px;
    padding: 0.36rem 0.56rem;
    background: transparent;
    color: var(--chat-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.67rem;
    font-weight: 760;
    transition: border-color var(--motion-fast, 0.18s) ease, color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease;
}

.conversation-archive-toggle:hover,
.conversation-archive-toggle:focus-visible,
.conversation-archive-toggle.is-open {
    border-color: rgba(51, 144, 236, 0.28);
    color: var(--chat-text);
    background: var(--chat-control-bg-hover);
}

.conversation-item__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #2f72f2, #6a9dff);
    color: #fff;
    font-size: 0.76rem;
    font-weight: 900;
    flex-shrink: 0;
}

.conversation-item__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.conversation-item__avatar[data-has-avatar="1"] span {
    display: none;
}

.conversation-item__avatar img[hidden] {
    display: none !important;
}

.conversation-item__copy {
    min-width: 0;
    display: grid;
    gap: 0.02rem;
}

.conversation-item__head {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.conversation-item__kind {
    width: 1.28rem;
    height: 1.28rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-accent);
    background: rgba(43, 109, 243, 0.1);
    border: 1px solid rgba(43, 109, 243, 0.18);
    flex-shrink: 0;
}

.conversation-item__kind svg {
    width: 0.86rem;
    height: 0.86rem;
    display: block;
}

.conversation-item__preview-row {
    display: flex;
    align-items: baseline;
    min-width: 0;
    gap: 0.3rem;
    overflow: hidden;
}

.conversation-item__title,
.conversation-item__subtitle,
.conversation-item__preview {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item__title {
    font-size: 0.75rem;
    font-weight: 880;
}

.conversation-item__subtitle {
    font-size: 0.63rem;
    color: var(--chat-muted);
    flex: 0 0 auto;
}

.conversation-item__preview {
    color: var(--chat-muted);
    font-size: 0.67rem;
    display: block;
    flex: 1 1 auto;
}

.conversation-badge {
    display: inline-flex;
    align-items: center;
    min-height: 17px;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgba(43, 109, 243, 0.12);
    color: var(--chat-accent);
    font-size: 0.58rem;
    font-weight: 820;
}

.conversation-item__meta {
    display: grid;
    justify-items: end;
    gap: 0.12rem;
}

.conversation-item__flags {
    display: inline-flex;
    align-items: center;
    gap: 0.16rem;
}

.conversation-flag {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    opacity: 0.9;
}

.conversation-flag--muted {
    background: var(--chat-muted);
}

.conversation-flag--pinned {
    background: var(--chat-accent);
}

.conversation-flag--archived {
    background: rgba(124, 145, 168, 0.7);
}

.conversation-item__time {
    font-size: 0.6rem;
    color: var(--chat-muted);
}

.conversation-item__unread {
    min-width: 19px;
    height: 19px;
    padding-inline: 0.24rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--chat-accent);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 900;
}

.thread-pane {
    position: relative;
    min-width: 0;
    display: grid;
}

.thread-placeholder,
.thread-shell {
    min-height: 0;
}

.thread-placeholder {
    display: grid;
    place-content: center;
    gap: 0.22rem;
    padding: 0.9rem;
    text-align: center;
    color: var(--chat-muted);
}

.thread-placeholder strong {
    color: var(--chat-text);
    font-size: 1rem;
}

.thread-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.thread-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.38rem;
    padding: 0.42rem 0.52rem;
    border-bottom: 1px solid var(--chat-border);
    background: var(--chat-header-bg);
}

.thread-head__identity {
    min-width: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: start;
    display: flex;
    align-items: center;
    gap: 0.44rem;
}

.thread-head__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #2f72f2, #6a9dff);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 900;
    flex-shrink: 0;
}

.thread-head__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thread-head__avatar[data-has-avatar="1"] span {
    display: none;
}

.thread-head__avatar img[hidden] {
    display: none !important;
}

.thread-head__copy {
    min-width: 0;
    display: grid;
    gap: 0.08rem;
}

.thread-head__copy strong,
.thread-head__copy span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-head__copy strong {
    font-size: 0.9rem;
    font-weight: 900;
}

.thread-head__copy span {
    color: var(--chat-muted);
    font-size: 0.72rem;
}

.thread-head__actions {
    display: flex;
    align-items: center;
    gap: 0.24rem;
}

.thread-banner-stack {
    padding: 0.28rem 0.42rem 0;
    display: grid;
    gap: 0.22rem;
}

.chat-mute-strip {
    margin: 0;
    padding: 0.42rem 0.68rem;
    border-radius: 10px;
    background: rgba(199, 83, 94, 0.08);
    border: 1px solid rgba(199, 83, 94, 0.16);
    color: var(--chat-danger);
    font-size: 0.76rem;
}

.chat-pinned-strip {
    margin: 0;
    padding: 0.48rem 0.62rem;
    display: grid;
    grid-template-columns: 3px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    border: 1px solid rgba(43, 109, 243, 0.2);
    border-radius: 10px;
    background: var(--chat-chip-bg);
    color: var(--chat-text);
    text-align: start;
}

.chat-pinned-strip:hover,
.chat-pinned-strip:focus-visible {
    border-color: rgba(43, 109, 243, 0.34);
    background: var(--chat-control-bg-hover);
}

.chat-pinned-strip__line {
    width: 3px;
    align-self: stretch;
    border-radius: 999px;
    background: linear-gradient(180deg, #2b6df3 0%, #5ea0ff 100%);
}

.chat-pinned-strip__copy {
    min-width: 0;
    display: grid;
    gap: 0.08rem;
}

.chat-pinned-strip__copy strong {
    font-size: 0.7rem;
    color: var(--chat-accent);
}

.chat-pinned-strip__copy span {
    color: var(--chat-muted);
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-pinned-strip__action {
    color: var(--chat-accent);
    font-size: 0.66rem;
    font-weight: 820;
}

.thread-stream {
    position: relative;
    flex: 1 1 auto;
    display: grid;
    min-height: 0;
    overflow: hidden;
}

.stream-state {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-content: center;
    gap: 0.26rem;
    text-align: center;
    padding: 2rem 1rem;
    color: var(--chat-muted);
    background:
        linear-gradient(var(--chat-stream-bg), var(--chat-stream-bg)),
        radial-gradient(circle at 1px 1px, var(--chat-stream-pattern) 1px, transparent 0);
    background-size: auto, 28px 28px;
}

.stream-state strong {
    font-size: 1rem;
    font-weight: 920;
    color: var(--chat-text);
}

.stream-state span {
    font-size: 0.82rem;
}

.messages {
    direction: ltr;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: flex-end;
    height: auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0.48rem 0.52rem 0.38rem;
    background:
        linear-gradient(var(--chat-stream-bg), var(--chat-stream-bg)),
        radial-gradient(circle at 1px 1px, var(--chat-stream-pattern) 1px, transparent 0);
    background-size: auto, 28px 28px;
    scroll-behavior: smooth;
}

.messages > .msg-item {
    width: 100%;
}

.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-thumb {
    background: rgba(124, 145, 168, 0.22);
    border-radius: 999px;
}

.msg-item {
    direction: rtl;
    margin-bottom: 0.06rem;
}

.msg-item.is-new {
    animation: chat-message-in var(--motion-base) var(--motion-ease-standard);
    transform-origin: bottom center;
}

.msg-item.me.is-new {
    transform-origin: bottom left;
}

.msg-item.other.is-new {
    transform-origin: bottom right;
}

.msg-row {
    display: flex;
    direction: ltr;
    align-items: flex-end;
    gap: 0.28rem;
}

.msg-item.me .msg-row {
    justify-content: flex-end;
}

.msg-item.other .msg-row {
    justify-content: flex-start;
}

.msg-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(160deg, #97a9bc, #75889d);
    overflow: hidden;
    position: relative;
    transition:
        opacity var(--motion-fast) var(--motion-ease-standard),
        transform var(--motion-fast) var(--motion-ease-standard);
}

.msg-avatar__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.msg-avatar__fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: inherit;
    background: inherit;
    color: #fff;
    font-size: 0.74rem;
    font-weight: 900;
}

.msg-avatar[data-has-avatar="1"] .msg-avatar__fallback {
    display: none;
}

.msg-avatar__img[hidden] {
    display: none !important;
}

.msg-item.me .msg-avatar .msg-avatar__fallback {
    background: linear-gradient(160deg, #2f72f2, #5b99ff);
}

.msg-item.grouped-with-prev .msg-avatar {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.msg-bubble {
    position: relative;
    max-width: min(74%, 700px);
    padding: 0.36rem 0.58rem 0.28rem;
    border-radius: 14px;
    border: 1px solid var(--chat-border);
    background: var(--chat-bubble);
    box-shadow: 0 10px 24px -22px rgba(22, 42, 70, 0.12);
    transition: transform var(--motion-fast, 0.18s) ease, box-shadow var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease;
}

.msg-item.me .msg-bubble {
    background: var(--chat-bubble-me);
    border-color: rgba(51, 144, 236, 0.24);
}

.msg-item.delivery-failed .msg-bubble {
    border-color: rgba(199, 83, 94, 0.28);
    background: rgba(199, 83, 94, 0.08);
}

.msg-item.delivery-sending .msg-bubble {
    opacity: 0.82;
}

.msg-item.other.group-single .msg-bubble,
.msg-item.other.group-end .msg-bubble {
    border-bottom-right-radius: 8px;
}

.msg-item.other.group-start .msg-bubble,
.msg-item.other.group-middle .msg-bubble {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 12px;
}

.msg-item.me.group-single .msg-bubble,
.msg-item.me.group-end .msg-bubble {
    border-bottom-left-radius: 8px;
}

.msg-item.me.group-start .msg-bubble,
.msg-item.me.group-middle .msg-bubble {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 12px;
}

.msg-item:hover .msg-bubble,
.msg-item.is-menu-open .msg-bubble {
    box-shadow: 0 16px 30px -24px rgba(22, 42, 70, 0.16);
}

.msg-head {
    display: flex;
    align-items: center;
    gap: 0.34rem;
    margin-bottom: 0.16rem;
}

.msg-item.me .msg-head,
.msg-item.grouped-with-prev .msg-head {
    display: none;
}

.msg-name {
    font-size: 0.71rem;
    font-weight: 900;
    color: var(--chat-accent);
}

.msg-badge,
.msg-flag {
    display: inline-flex;
    align-items: center;
    min-height: 16px;
    padding: 0 0.34rem;
    border-radius: 999px;
    background: rgba(43, 109, 243, 0.08);
    color: var(--chat-accent);
    font-size: 0.58rem;
    font-weight: 780;
}

.msg-text {
    color: var(--chat-text);
    font-size: 0.81rem;
    line-height: 1.66;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-text:empty {
    display: none;
}

.msg-text--caption {
    margin-top: 0.16rem;
}

.msg-attachments {
    margin-top: 0.32rem;
    display: grid;
    gap: 0.36rem;
}

.msg-media-album {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.24rem;
}

.msg-media-album[data-count="3"] .msg-media-album__tile:first-child {
    grid-column: 1 / -1;
    min-height: 178px;
}

.msg-media-album__tile {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(5, 10, 18, 0.9);
    cursor: zoom-in;
}

.msg-media-album__tile img,
.msg-media-album__tile video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.msg-attachment {
    display: grid;
    gap: 0.3rem;
    padding: 0.42rem 0.5rem;
    border-radius: 11px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
}

.msg-attachment__media {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--chat-border);
    background: rgba(5, 10, 18, 0.88);
    cursor: zoom-in;
}

.msg-attachment__media img {
    display: block;
    width: 100%;
    max-height: min(460px, 62vh);
    object-fit: contain;
    background: rgba(5, 10, 18, 0.88);
}

.msg-attachment__media video {
    display: block;
    width: 100%;
    max-height: min(460px, 62vh);
    object-fit: contain;
    background: #000;
}

.msg-media-preview__play,
.msg-media-preview__badge {
    position: absolute;
    z-index: 1;
    pointer-events: none;
}

.msg-media-preview__play {
    inset: 50% auto auto 50%;
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
    border-radius: 50%;
    background: rgba(5, 10, 18, 0.44);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px);
}

.msg-media-preview__play::before {
    content: "";
    position: absolute;
    inset: 50% auto auto 50%;
    margin: -7px 0 0 -4px;
    border-style: solid;
    border-width: 7px 0 7px 11px;
    border-color: transparent transparent transparent rgba(255, 255, 255, 0.92);
}

.msg-media-preview__badge {
    inset-inline-end: 0.42rem;
    bottom: 0.42rem;
    min-height: 24px;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: rgba(5, 10, 18, 0.58);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 780;
    display: inline-flex;
    align-items: center;
    backdrop-filter: blur(6px);
}

.msg-attachment__audio {
    width: 100%;
    min-height: 34px;
}

.msg-attachment__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
}

.msg-attachment__name {
    min-width: 0;
    font-size: 0.76rem;
    font-weight: 780;
    color: var(--chat-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-attachment__meta {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--chat-muted);
    font-size: 0.64rem;
    white-space: nowrap;
}

.msg-attachment__actions {
    display: flex;
    align-items: center;
    gap: 0.34rem;
}

.msg-attachment__link {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 0.52rem;
    border-radius: 999px;
    border: 1px solid rgba(43, 109, 243, 0.24);
    background: rgba(43, 109, 243, 0.1);
    color: var(--chat-accent);
    font-size: 0.65rem;
    font-weight: 780;
    text-decoration: none;
    cursor: pointer;
}

.msg-attachment__link[aria-disabled="true"] {
    border-color: var(--chat-border);
    background: rgba(127, 145, 165, 0.12);
    color: var(--chat-muted);
    pointer-events: none;
    cursor: default;
}

.msg-attachment__state {
    color: var(--chat-muted);
    font-size: 0.65rem;
}

.msg-attachment__state.is-expired {
    color: var(--chat-danger);
}

.reply-preview {
    margin: 0 0 0.32rem;
    padding: 0.36rem 0.52rem;
    border-radius: 9px;
    border: 0;
    border-inline-end: 3px solid rgba(43, 109, 243, 0.34);
    background: rgba(43, 109, 243, 0.07);
    color: var(--chat-muted);
    font-size: 0.67rem;
    line-height: 1.7;
    text-align: start;
    width: 100%;
    cursor: pointer;
}

.reply-preview:hover,
.reply-preview:focus-visible {
    background: rgba(43, 109, 243, 0.12);
    outline: 0;
}

.reply-preview b {
    color: var(--chat-text);
}

.msg-forwarded {
    width: 100%;
    margin: 0 0 0.28rem;
    padding: 0.38rem 0.54rem;
    border: 0;
    border-radius: 10px;
    border-inline-end: 3px solid color-mix(in srgb, var(--chat-bale-green) 44%, var(--chat-accent));
    background: color-mix(in srgb, var(--chat-bale-green-soft) 72%, transparent);
    color: var(--chat-text);
    display: grid;
    gap: 0.08rem;
    text-align: start;
    cursor: pointer;
}

.msg-forwarded:disabled {
    cursor: default;
    opacity: 0.82;
}

.msg-forwarded__kicker {
    color: var(--chat-bale-green);
    font-size: 0.64rem;
    font-weight: 860;
}

.msg-forwarded__preview {
    font-size: 0.73rem;
    line-height: 1.62;
    color: var(--chat-text);
}

.msg-forwarded__meta {
    color: var(--chat-muted);
    font-size: 0.62rem;
}

.msg-foot {
    margin-top: 0.14rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.26rem;
    color: var(--chat-muted);
    font-size: 0.62rem;
}

.msg-flags {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    flex-wrap: wrap;
}

.msg-time {
    white-space: nowrap;
}

.msg-reactions {
    margin-top: 0.28rem;
    display: flex;
    align-items: center;
    gap: 0.32rem;
    flex-wrap: wrap;
}

.msg-reaction {
    display: inline-flex;
    align-items: center;
    gap: 0.24rem;
    min-height: 24px;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
    color: var(--chat-text);
    font-size: 0.68rem;
    font-weight: 760;
    cursor: pointer;
    transition: border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease;
}

.msg-reaction:hover,
.msg-reaction:focus-visible {
    border-color: rgba(43, 109, 243, 0.3);
    background: rgba(43, 109, 243, 0.08);
}

.msg-reaction.is-own {
    background: rgba(43, 109, 243, 0.1);
    border-color: rgba(43, 109, 243, 0.24);
    color: var(--chat-accent);
}

.msg-reaction__count {
    font-size: 0.62rem;
    color: var(--chat-muted);
}

.msg-delivery {
    color: var(--chat-muted);
    font-size: 0.62rem;
    font-weight: 760;
    white-space: nowrap;
}

.msg-delivery.is-seen {
    color: var(--chat-accent);
}

.composer {
    flex: 0 0 auto;
    padding: 0.44rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--chat-border);
    background: var(--chat-composer-bg);
    backdrop-filter: blur(16px);
}

.reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 0.34rem;
    padding: 0.4rem 0.52rem;
    border-radius: 11px;
    background: rgba(43, 109, 243, 0.08);
    border: 1px solid rgba(43, 109, 243, 0.12);
    color: var(--chat-muted);
    font-size: 0.7rem;
}

.reply-bar__copy {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.32rem;
    flex-wrap: wrap;
}

.reply-bar__label,
.reply-bar b {
    color: var(--chat-text);
    font-weight: 840;
}

.reply-cancel {
    border: 0;
    background: transparent;
    color: var(--chat-accent);
    font-weight: 840;
}

.composer-box {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.42rem;
    padding: 0.26rem;
    border-radius: 20px;
    border: 1px solid var(--chat-border);
    background: var(--chat-input-bg);
    transition: border-color var(--motion-fast, 0.18s) ease, box-shadow var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease;
}

.composer-box:focus-within {
    border-color: rgba(43, 109, 243, 0.26);
    box-shadow: 0 0 0 3px rgba(43, 109, 243, 0.06);
    background: var(--chat-control-bg-hover);
}

.composer-tools {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
}

.composer-tool {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
    color: var(--chat-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--motion-fast, 0.18s) ease, color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease;
}

.composer-tool svg {
    width: 17px;
    height: 17px;
}

.composer-tool:hover,
.composer-tool:focus-visible,
.composer-tool.is-open,
.composer-tool.is-recording {
    border-color: rgba(43, 109, 243, 0.32);
    color: var(--chat-accent);
    background: rgba(43, 109, 243, 0.1);
}

.composer-upload-sheet {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.2rem, 1fr));
    gap: 0.32rem;
    margin-bottom: 0.38rem;
}

.composer-upload-sheet::-webkit-scrollbar {
    height: 0;
}

.composer-upload-option {
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
    color: var(--chat-text);
    min-height: 34px;
    border-radius: 12px;
    padding: 0.34rem 0.52rem;
    font-size: 0.7rem;
    font-weight: 790;
    white-space: nowrap;
    text-align: center;
    transition: transform var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease, color var(--motion-fast, 0.18s) ease;
}

.composer-upload-option:hover,
.composer-upload-option:focus-visible {
    border-color: rgba(43, 109, 243, 0.32);
    background: rgba(43, 109, 243, 0.1);
    color: var(--chat-accent);
    transform: translateY(-1px);
}

.composer-uploads {
    margin-bottom: 0.38rem;
    display: grid;
    gap: 0.3rem;
}

.composer-upload-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.48rem;
    border-radius: 12px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
}

.composer-upload-item__preview {
    position: relative;
    width: 58px;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(5, 10, 18, 0.88);
    cursor: zoom-in;
}

.composer-upload-item__preview img,
.composer-upload-item__preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.composer-upload-item__preview--file {
    background: var(--chat-control-bg);
    color: var(--chat-muted);
    cursor: default;
}

.composer-upload-item__preview-icon {
    font-size: 0.58rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.composer-upload-item__order {
    position: absolute;
    top: 0.28rem;
    inset-inline-start: 0.28rem;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.28rem;
    border-radius: 999px;
    background: rgba(5, 10, 18, 0.68);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 820;
    backdrop-filter: blur(8px);
}

.composer-upload-item__copy {
    min-width: 0;
    flex: 1;
}

.composer-upload-item__name {
    color: var(--chat-text);
    font-size: 0.72rem;
    font-weight: 780;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer-upload-item__meta {
    color: var(--chat-muted);
    font-size: 0.64rem;
}

.composer-upload-item__progress {
    margin-top: 0.2rem;
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: rgba(127, 145, 165, 0.24);
    overflow: hidden;
}

.composer-upload-item__progress > span {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--accent-color);
}

.composer-upload-item__actions {
    display: grid;
    gap: 0.3rem;
}

.composer-upload-item__edit,
.composer-upload-item__move,
.composer-upload-item__remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.82rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.composer-upload-item__edit,
.composer-upload-item__move {
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-text);
}

.composer-upload-item__edit svg {
    width: 15px;
    height: 15px;
}

.composer-upload-item__move:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.composer-upload-item__remove {
    border: 1px solid rgba(199, 83, 94, 0.18);
    background: rgba(199, 83, 94, 0.12);
    color: var(--chat-danger);
    font-size: 0.9rem;
}

.composer-voice {
    margin-bottom: 0.38rem;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 0.54rem;
    padding: 0.46rem 0.56rem;
    border-radius: 14px;
    border: 1px solid rgba(43, 109, 243, 0.2);
    background:
        linear-gradient(180deg, rgba(43, 109, 243, 0.13), rgba(43, 109, 243, 0.08)),
        var(--chat-chip-bg);
}

.composer-voice__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--chat-danger);
    box-shadow: 0 0 0 0 rgba(199, 83, 94, 0.44);
    animation: composer-voice-pulse 1.45s var(--motion-ease-soft) infinite;
}

.composer-voice__timer {
    min-width: 48px;
    font-size: 0.78rem;
    font-weight: 850;
    color: var(--chat-text);
}

.composer-voice__actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.composer-voice__actions .shell-action-btn {
    min-height: 32px;
    padding-inline: 0.64rem;
    font-size: 0.68rem;
    border-radius: 10px;
}

@keyframes composer-voice-pulse {
    0% {
        transform: scale(0.92);
        box-shadow: 0 0 0 0 rgba(199, 83, 94, 0.34);
    }
    48% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(199, 83, 94, 0);
    }
    100% {
        transform: scale(0.92);
        box-shadow: 0 0 0 0 rgba(199, 83, 94, 0);
    }
}

.composer-entry textarea {
    width: 100%;
    min-height: 38px;
    max-height: 184px;
    padding: 0.45rem 0.62rem;
    border-radius: 14px;
    border: 0;
    resize: none;
    background: transparent;
    color: var(--chat-text);
    line-height: 1.72;
    font-size: 0.8rem;
    box-shadow: none !important;
}

.composer-entry {
    min-width: 0;
}

.composer-send {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: var(--btn-gradient);
    color: #fff;
    box-shadow: var(--btn-shadow);
    transition: transform var(--motion-fast, 0.18s) ease, box-shadow var(--motion-fast, 0.18s) ease, filter var(--motion-fast, 0.18s) ease, opacity var(--motion-fast, 0.18s) ease;
}

.composer-send svg {
    width: 16px;
    height: 16px;
}

.composer-send:hover:not(:disabled),
.composer-send:focus-visible {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

.composer-send:disabled {
    opacity: 0.58;
    cursor: default;
    box-shadow: none;
}

.composer-status {
    min-height: 0.84rem;
    margin-top: 0.24rem;
    color: var(--chat-muted);
    font-size: 0.64rem;
}

.composer-status.error {
    color: var(--chat-danger);
}

.composer-storage-note {
    margin-top: 0.14rem;
    color: var(--chat-muted);
    font-size: 0.62rem;
    line-height: 1.7;
}

.chat-context-backdrop,
.chat-list-context-backdrop,
.chat-sheet-backdrop,
.chat-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 260;
    background: var(--chat-overlay-bg);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.chat-context-backdrop.is-open,
.chat-list-context-backdrop.is-open,
.chat-sheet-backdrop.is-open,
.chat-modal-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.chat-context-menu {
    position: fixed;
    z-index: 270;
    display: flex;
    flex-direction: column;
    min-width: 224px;
    max-width: min(290px, calc(100vw - 1rem));
    max-height: min(72vh, 560px);
    padding: 0.34rem;
    border-radius: var(--chat-radius-menu);
    border: 1px solid var(--chat-hairline);
    background: var(--chat-sheet-bg);
    box-shadow: var(--chat-menu-shadow);
    backdrop-filter: blur(18px);
    transform: translateY(6px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    overflow: hidden;
}

.chat-list-context-menu {
    position: fixed;
    z-index: 270;
    min-width: 240px;
    max-width: min(300px, calc(100vw - 1rem));
    padding: 0.5rem;
    border-radius: 18px;
    border: 1px solid var(--chat-border);
    background: var(--chat-sheet-bg);
    box-shadow: 0 28px 60px -34px rgba(18, 30, 48, 0.28);
    backdrop-filter: blur(18px);
    transform: translateY(6px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.chat-context-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-list-context-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-list-context-menu__head {
    display: grid;
    gap: 0.08rem;
    margin-bottom: 0.42rem;
    padding: 0.2rem 0.24rem 0.12rem;
}

.chat-list-context-menu__head strong {
    font-size: 0.76rem;
    font-weight: 860;
    color: var(--chat-text);
}

.chat-list-context-menu__head span {
    font-size: 0.66rem;
    color: var(--chat-muted);
}

.chat-reaction-bar {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    flex: 0 0 auto;
    margin-bottom: 0.34rem;
    padding: 0.16rem;
    border-radius: var(--chat-radius-pill);
    background: var(--chat-control-bg);
    border: 1px solid var(--chat-hairline);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    pointer-events: none;
}

.chat-reaction-bar::-webkit-scrollbar {
    display: none;
}

.chat-reaction-bar:empty {
    display: none;
}

.chat-list-context-action,
.chat-sheet-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 40px;
    border-radius: 14px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-text);
    font-size: 0.8rem;
    font-weight: 780;
    pointer-events: auto;
    transition: transform var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease;
}

.chat-list-context-action:hover,
.chat-list-context-action:focus-visible,
.chat-sheet-btn:hover,
.chat-sheet-btn:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(43, 109, 243, 0.22);
    background: var(--chat-control-bg-hover);
}

/* Message reaction pill: light, circular, borderless emoji buttons */
.chat-reaction-btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--chat-text);
    font-size: 20px;
    line-height: 1;
    pointer-events: auto;
    transition: transform var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease;
}

.chat-reaction-btn:hover,
.chat-reaction-btn:focus-visible {
    transform: scale(1.16);
    background: var(--chat-row-hover);
}

.chat-reaction-btn.is-active {
    background: var(--chat-accent-soft);
}

.chat-reaction-btn-more {
    font-size: 18px;
    color: var(--chat-muted);
    background: var(--chat-control-bg-hover);
}

.chat-context-actions {
    display: grid;
    gap: var(--chat-row-gap);
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.chat-list-context-actions {
    display: grid;
    gap: 0.26rem;
}

.chat-context-action {
    justify-content: initial;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 0.66rem;
    min-height: var(--chat-row-min);
    padding: 0 0.7rem;
    border: 0;
    border-radius: var(--chat-radius-row);
    background: transparent;
    color: var(--chat-text);
    font-size: 0.82rem;
    font-weight: 600;
    pointer-events: auto;
    direction: rtl;
    unicode-bidi: isolate;
    text-align: start;
    transition: background var(--motion-fast, 0.18s) ease, color var(--motion-fast, 0.18s) ease;
}

.chat-context-action:hover,
.chat-context-action:focus-visible {
    background: var(--chat-row-hover);
}

.chat-context-action__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--chat-muted);
}

.chat-context-action__icon svg {
    width: 19px;
    height: 19px;
}

.chat-context-action__hint {
    display: none;
}

.chat-list-context-action {
    justify-content: initial;
    display: flex;
    align-items: center;
    gap: 0.62rem;
    padding: 0.54rem 0.74rem;
    direction: rtl;
    unicode-bidi: isolate;
    text-align: start;
}

.chat-list-context-action__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    opacity: 0.68;
}

.chat-list-context-action__hint {
    display: none;
}

.chat-context-action__label,
.chat-context-action__hint,
.chat-list-context-action__label,
.chat-list-context-action__hint {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: rtl;
    unicode-bidi: isolate;
}

.chat-context-action__hint {
    font-size: 0.72rem;
    color: var(--chat-muted);
    font-weight: 820;
}

.chat-list-context-action__hint {
    font-size: 0.69rem;
    color: var(--chat-muted);
    font-weight: 800;
}

.chat-context-action.is-danger,
.chat-list-context-action.is-danger,
.chat-sheet-btn-danger {
    color: var(--chat-danger);
    background: rgba(199, 83, 94, 0.08);
    border-color: rgba(199, 83, 94, 0.16);
}

/* Borderless message-menu delete row: red text/icon, tint only on hover */
.chat-context-action.is-danger {
    background: transparent;
}

.chat-context-action.is-danger .chat-context-action__icon {
    color: var(--chat-danger);
}

.chat-context-action.is-danger:hover,
.chat-context-action.is-danger:focus-visible {
    background: rgba(199, 83, 94, 0.12);
}

.chat-info-sheet {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: 275;
    width: min(400px, 100vw);
    padding: calc(0.95rem + env(safe-area-inset-top, 0px)) 0.9rem calc(0.95rem + env(safe-area-inset-bottom, 0px) + var(--chat-shell-offset));
    border-inline-start: 1px solid var(--chat-border);
    background: var(--chat-sheet-bg);
    box-shadow: -28px 0 60px -42px rgba(18, 30, 48, 0.28);
    backdrop-filter: blur(18px);
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    transition:
        transform var(--motion-slow) var(--motion-ease-soft),
        opacity var(--motion-base) var(--motion-ease-soft);
    overflow: auto;
    overscroll-behavior: contain;
}

.chat-info-sheet.is-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.chat-peer-sheet {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: 280;
    width: min(400px, 100vw);
    padding: calc(0.95rem + env(safe-area-inset-top, 0px)) 0.9rem calc(0.95rem + env(safe-area-inset-bottom, 0px) + var(--chat-shell-offset));
    border-inline-start: 1px solid var(--chat-border);
    background: var(--chat-sheet-bg);
    box-shadow: -28px 0 60px -42px rgba(18, 30, 48, 0.28);
    backdrop-filter: blur(18px);
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    transition:
        transform var(--motion-slow) var(--motion-ease-soft),
        opacity var(--motion-base) var(--motion-ease-soft);
    overflow: auto;
    overscroll-behavior: contain;
}

.chat-peer-sheet.is-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.chat-info-sheet__topbar {
    display: flex;
    justify-content: flex-end;
}

.chat-info-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 0.3rem;
    padding: 0.1rem 0.6rem 1.05rem;
    border: 0;
    background: none;
    text-align: center;
    cursor: default;
    font: inherit;
    color: inherit;
}

.chat-info-profile.is-clickable {
    cursor: pointer;
    border-radius: 16px;
    transition: background var(--motion-fast) var(--motion-ease-standard);
}

.chat-info-profile.is-clickable:hover,
.chat-info-profile.is-clickable:focus-visible {
    background: var(--chat-control-bg);
}

.chat-info-profile__avatar {
    position: relative;
    width: 96px;
    height: 96px;
    margin-bottom: 0.3rem;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #2f72f2, #6a9dff);
    color: #fff;
    font-size: 2rem;
    font-weight: 900;
}

.chat-info-profile__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-info-profile__avatar[data-has-avatar="1"] span {
    display: none;
}

.chat-info-profile__avatar img[hidden] {
    display: none !important;
}

.chat-info-profile__name {
    margin: 0;
    font-size: 1.16rem;
    font-weight: 900;
    color: var(--chat-text);
}

.chat-info-profile__status {
    margin: 0;
    color: var(--chat-muted);
    font-size: 0.82rem;
}

.chat-info-profile__about {
    margin: 0.35rem 0 0;
    max-width: 100%;
    color: var(--chat-text);
    font-size: 0.82rem;
    line-height: 1.8;
}

.chat-info-quick-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--chat-border);
}

.chat-info-quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.32rem;
    min-width: 64px;
    padding: 0.5rem 0.4rem;
    border: 0;
    border-radius: 14px;
    background: none;
    color: var(--chat-text);
    font-size: 0.7rem;
    font-weight: 760;
    transition:
        background var(--motion-fast) var(--motion-ease-standard),
        color var(--motion-fast) var(--motion-ease-standard);
}

.chat-info-quick-action:hover,
.chat-info-quick-action:focus-visible {
    background: var(--chat-control-bg);
}

.chat-info-quick-action__icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--chat-chip-bg);
    color: var(--chat-accent);
}

.chat-info-quick-action__icon svg {
    width: 20px;
    height: 20px;
}

.chat-info-quick-action.is-active .chat-info-quick-action__icon {
    color: #c94155;
}

.chat-info-block {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--chat-border);
}

.chat-info-block__label {
    display: block;
    margin-bottom: 0.55rem;
    color: var(--chat-muted);
    font-size: 0.74rem;
    font-weight: 820;
}

.chat-info-members {
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
    overflow: hidden;
}

.chat-info-rows {
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
    overflow: hidden;
}

.chat-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.64rem 0.76rem;
    border-bottom: 1px solid var(--chat-border);
}

.chat-info-row:last-child {
    border-bottom: none;
}

.chat-info-row--empty {
    justify-content: center;
    color: var(--chat-muted);
    font-size: 0.74rem;
}

.chat-info-row__label {
    color: var(--chat-muted);
    font-size: 0.73rem;
    font-weight: 760;
}

.chat-info-row__value {
    color: var(--chat-text);
    font-size: 0.74rem;
    font-weight: 820;
}

.chat-info-row__value--good {
    color: #0b8a5f;
}

.chat-info-row__value--danger {
    color: #c94155;
}

.chat-info-row__value--muted {
    color: var(--chat-muted);
}

.chat-member {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.62rem;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--chat-border);
}

.chat-member:last-child {
    border-bottom: none;
}

.chat-member--empty {
    grid-template-columns: 1fr;
}

.chat-member--clickable {
    cursor: pointer;
    transition: background var(--motion-fast) var(--motion-ease-standard);
}

.chat-member--clickable:hover,
.chat-member--clickable:focus-visible {
    background: var(--chat-control-bg);
}

.chat-member__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #2f72f2, #6a9dff);
    color: #fff;
    font-size: 0.76rem;
    font-weight: 900;
    flex-shrink: 0;
}

.chat-member__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.chat-member__avatar[data-has-avatar="1"] span {
    display: none;
}

.chat-member__avatar img[hidden] {
    display: none !important;
}

.chat-member__copy {
    min-width: 0;
    display: grid;
    gap: 0.04rem;
}

.chat-member__copy strong,
.chat-member__copy span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-member strong {
    font-size: 0.82rem;
}

.chat-member__menu-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--chat-muted);
    flex-shrink: 0;
    transition:
        background var(--motion-fast) var(--motion-ease-standard),
        color var(--motion-fast) var(--motion-ease-standard);
}

.chat-member__menu-btn:hover,
.chat-member__menu-btn:focus-visible {
    background: var(--chat-control-bg);
    color: var(--chat-text);
}

.chat-member__menu-btn svg {
    width: 18px;
    height: 18px;
}

.chat-member span {
    color: var(--chat-muted);
    font-size: 0.74rem;
}

.chat-info-actions-list {
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
    overflow: hidden;
}

.chat-info-action-row,
.chat-info-link-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.66rem 0.8rem;
    border: 0;
    border-bottom: 1px solid var(--chat-border);
    background: none;
    color: var(--chat-text);
    font: inherit;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--motion-fast) var(--motion-ease-standard);
}

.chat-info-action-row:last-child,
.chat-info-link-row:last-child {
    border-bottom: none;
}

.chat-info-action-row:hover,
.chat-info-action-row:focus-visible,
.chat-info-link-row:hover,
.chat-info-link-row:focus-visible {
    background: var(--chat-control-bg-hover);
}

.chat-info-action-row__icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--chat-control-bg);
    color: var(--chat-accent);
    flex-shrink: 0;
}

.chat-info-action-row__icon svg {
    width: 18px;
    height: 18px;
}

.chat-info-action-row__label {
    font-size: 0.84rem;
    font-weight: 760;
}

.chat-info-action-row--danger {
    color: #c94155;
}

.chat-info-action-row--danger .chat-info-action-row__icon {
    color: #c94155;
}

.chat-modal {
    position: fixed;
    inset-inline: 50%;
    inset-block-start: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    z-index: 280;
    width: min(460px, calc(100vw - 1rem));
    max-height: calc(var(--chat-vh, 100dvh) - 1.2rem);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    background: var(--chat-modal-bg);
    box-shadow: 0 28px 60px -34px rgba(18, 30, 48, 0.28);
    backdrop-filter: blur(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.chat-modal--group {
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-modal--forward {
    width: min(520px, calc(100vw - 1rem));
}

.chat-modal--reaction {
    width: min(540px, calc(100vw - 1rem));
    grid-template-rows: auto auto minmax(0, 1fr);
}

.chat-modal--edit {
    width: min(560px, calc(100vw - 1rem));
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-modal--poll {
    width: min(560px, calc(100vw - 1rem));
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.poll-options-list {
    display: grid;
    gap: 0.34rem;
}

.poll-option-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.4rem;
}

.poll-option-row input {
    width: 100%;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    padding: 0.48rem 0.62rem;
    background: var(--chat-input-bg);
    color: var(--chat-text);
    font-size: 0.8rem;
}

.poll-option-row input:focus {
    border-color: rgba(43, 109, 243, 0.32);
    box-shadow: 0 0 0 3px rgba(43, 109, 243, 0.08);
    outline: 0;
}

.poll-option-remove {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-muted-strong);
    display: grid;
    place-items: center;
    flex: none;
}

.poll-option-remove:hover,
.poll-option-remove:focus-visible {
    color: var(--chat-danger);
    border-color: rgba(229, 84, 84, 0.32);
}

.poll-option-remove svg {
    width: 16px;
    height: 16px;
}

.poll-add-option-btn {
    justify-self: start;
    min-height: 38px;
    padding: 0 0.9rem;
    border-radius: 10px;
    border: 1px dashed var(--chat-border);
    background: transparent;
    color: var(--chat-accent);
    font-size: 0.76rem;
    font-weight: 830;
}

.chat-modal--confirm {
    width: min(430px, calc(100vw - 1rem));
    grid-template-rows: auto auto auto;
}

.chat-modal--group .group-flow-step {
    grid-row: 2;
    min-height: 0;
}

.chat-modal--group .group-flow-step.is-active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
}

.chat-modal--group .chat-modal__footer {
    grid-row: 3;
    position: sticky;
    inset-block-end: 0;
    z-index: 2;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-modal-bg);
}

.chat-modal.is-open {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.chat-modal.is-busy .chat-modal__body,
.chat-modal.is-busy .chat-modal__footer {
    pointer-events: none;
    opacity: 0.66;
}

.chat-modal.is-busy .chat-sheet-close {
    pointer-events: none;
    opacity: 0.46;
}

.chat-modal__header {
    padding: 0.58rem 0.64rem 0.48rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.48rem;
    border-bottom: 1px solid var(--chat-border);
}

.chat-modal__header h2 {
    margin: 0;
    font-size: 0.86rem;
    font-weight: 900;
}

.chat-modal__body--confirm {
    padding: 0.9rem 0.82rem 0.42rem;
}

.chat-modal__body--confirm p {
    margin: 0;
    color: var(--chat-text);
    font-size: 0.82rem;
    line-height: 1.9;
}

.reaction-picker-native-wrap {
    padding: 0 0.68rem 0.42rem;
    border-bottom: 1px solid var(--chat-border);
}

.reaction-picker-native-wrap button {
    width: 100%;
    min-height: 32px;
    border-radius: 10px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-text);
    font-size: 0.68rem;
    font-weight: 820;
}

.reaction-picker-native-wrap button:hover,
.reaction-picker-native-wrap button:focus-visible {
    border-color: rgba(43, 109, 243, 0.3);
    background: var(--chat-control-bg-hover);
}

.reaction-picker-tabs {
    display: flex;
    align-items: center;
    gap: 0.26rem;
    overflow-x: auto;
    padding: 0 0.68rem 0.44rem;
    border-bottom: 1px solid var(--chat-border);
}

.reaction-picker-tabs::-webkit-scrollbar {
    height: 0;
}

.reaction-picker-tab {
    min-height: 28px;
    padding: 0.2rem 0.58rem;
    border-radius: 999px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-muted);
    font-size: 0.62rem;
    font-weight: 820;
    white-space: nowrap;
}

.reaction-picker-tab.is-active {
    border-color: rgba(51, 144, 236, 0.34);
    background: rgba(43, 109, 243, 0.14);
    color: var(--chat-accent);
}

.reaction-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 0.38rem;
    padding: 0.74rem;
}

.reaction-picker-btn {
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
    font-size: 1.24rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.reaction-picker-btn:hover,
.reaction-picker-btn:focus-visible {
    border-color: rgba(51, 144, 236, 0.32);
    background: rgba(43, 109, 243, 0.08);
    transform: translateY(-1px);
}

.reaction-picker-btn.is-active {
    border-color: rgba(51, 144, 236, 0.4);
    background: rgba(43, 109, 243, 0.15);
}

#edit-text {
    width: 100%;
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    padding: 0.62rem 0.68rem;
    background: var(--chat-input-bg);
    color: var(--chat-text);
    line-height: 1.8;
    resize: vertical;
}

#edit-text:focus {
    border-color: rgba(51, 144, 236, 0.32);
    box-shadow: 0 0 0 3px rgba(43, 109, 243, 0.08);
    outline: 0;
}

.chat-login-btn.chat-login-btn-danger {
    background: linear-gradient(135deg, #cf3f57, #e7657a);
    box-shadow: 0 12px 24px -18px rgba(207, 63, 87, 0.55);
}

.chat-modal__title-wrap {
    min-width: 0;
    display: grid;
    gap: 0.12rem;
}

.chat-modal__title-wrap p {
    margin: 0;
    color: var(--chat-muted);
    font-size: 0.68rem;
}

.chat-modal .conversation-search-wrap {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.chat-modal__fields {
    display: grid;
    gap: 0.36rem;
    padding: 0.52rem 0.68rem 0.34rem;
}

.chat-modal__fields label {
    font-size: 0.72rem;
    font-weight: 840;
}

.chat-modal__fields--compact {
    padding-bottom: 0.22rem;
}

.chat-modal-meta {
    margin: 0;
    color: var(--chat-muted);
    font-size: 0.68rem;
}

.chat-modal__fields input,
.chat-modal__fields textarea {
    width: 100%;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    padding: 0.48rem 0.62rem;
    background: var(--chat-input-bg);
    color: var(--chat-text);
    font-size: 0.8rem;
}

.chat-modal__fields textarea {
    resize: vertical;
    min-height: 96px;
}

.chat-modal__fields input:focus,
.chat-modal__fields textarea:focus {
    border-color: rgba(43, 109, 243, 0.32);
    box-shadow: 0 0 0 3px rgba(43, 109, 243, 0.08);
    outline: 0;
}

.chat-modal__body {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0.14rem 0.6rem 0.56rem;
    display: grid;
    gap: 0.18rem;
}

.chat-modal__members {
    max-height: 280px;
}

.chat-modal__body--dense {
    padding-top: 0.08rem;
}

.chat-modal__footer {
    padding: 0.12rem 0.64rem 0.64rem;
}

.chat-modal__footer--split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 0.42rem;
    align-items: center;
}

.chat-modal-secondary-btn {
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-text);
    font-size: 0.76rem;
    font-weight: 830;
}

.chat-modal-secondary-btn-primary {
    border-color: rgba(51, 144, 236, 0.26);
    background: rgba(51, 144, 236, 0.1);
    color: var(--chat-accent);
}

.group-flow-step {
    min-height: 0;
    display: none;
}

.group-flow-step.is-active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.group-selected {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.group-selected[hidden] {
    display: none !important;
}

.group-selected-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 26px;
    padding: 0 0.5rem;
    border-radius: 999px;
    border: 1px solid rgba(51, 144, 236, 0.24);
    background: rgba(51, 144, 236, 0.1);
    color: var(--chat-accent);
    font-size: 0.68rem;
}

.group-selected-chip strong {
    font-size: 0.8rem;
    line-height: 1;
}

.chat-picker-item {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--chat-text);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.46rem;
    text-align: start;
    padding: 0.42rem 0.44rem;
}

.chat-picker-item:hover,
.chat-picker-item:focus-visible {
    border-color: rgba(51, 144, 236, 0.3);
    background: var(--chat-control-bg-hover);
}

.chat-picker-item.is-selected {
    border-color: rgba(51, 144, 236, 0.38);
    background: rgba(51, 144, 236, 0.1);
}

.chat-picker-item--saved {
    border-color: color-mix(in srgb, var(--chat-bale-green) 28%, var(--chat-border));
    background: color-mix(in srgb, var(--chat-bale-green-soft) 58%, transparent);
}

.chat-picker-item--saved .chat-picker-item__avatar {
    background: linear-gradient(160deg, #2b8a6d, #55b992);
}

.chat-picker-item__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #2f72f2, #6a9dff);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 900;
}

.chat-picker-item__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-picker-item__avatar[data-has-avatar="1"] span {
    display: none;
}

.chat-picker-item__avatar img[hidden] {
    display: none !important;
}

.chat-picker-item__copy {
    min-width: 0;
    display: grid;
    gap: 0.06rem;
}

.chat-picker-item__copy strong,
.chat-picker-item__copy span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-picker-item__copy strong {
    font-size: 0.75rem;
}

.chat-picker-item__copy span {
    font-size: 0.66rem;
    color: var(--chat-muted);
}

.chat-picker-check {
    width: 16px;
    height: 16px;
}

.chat-picker-empty {
    padding: 0.64rem;
    border-radius: 10px;
    border: 1px dashed rgba(124, 145, 168, 0.2);
    color: var(--chat-muted);
    font-size: 0.74rem;
    text-align: center;
}

.forward-source-preview {
    display: grid;
    gap: 0.38rem;
    margin-bottom: 0.12rem;
}

.forward-source-card {
    display: grid;
    gap: 0.1rem;
    padding: 0.54rem 0.6rem;
    border-radius: 12px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
}

.forward-source-card__kicker {
    color: var(--chat-accent);
    font-size: 0.64rem;
    font-weight: 860;
}

.forward-source-card__preview {
    color: var(--chat-text);
    font-size: 0.75rem;
    line-height: 1.6;
}

.forward-source-card__meta {
    color: var(--chat-muted);
    font-size: 0.62rem;
}

.forward-option-row {
    margin-bottom: 0.08rem;
}

.chat-mobile-nav {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 286;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.24rem;
    padding: 0.3rem 0.44rem calc(0.34rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--chat-border);
    background: var(--chat-pane-bg-strong);
    backdrop-filter: blur(18px);
}

.chat-mobile-nav[hidden] {
    display: none !important;
}

.chat-mobile-nav__item {
    min-height: 46px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--chat-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
    gap: 0.04rem;
    font-size: 0.58rem;
    font-weight: 810;
    text-decoration: none;
    transition: transform var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease, color var(--motion-fast, 0.18s) ease;
}

.chat-mobile-nav__badge {
    position: absolute;
    top: 0.36rem;
    inset-inline-start: 50%;
    transform: translateX(-0.2rem);
    min-width: 18px;
    height: 18px;
    padding: 0 0.28rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    color: var(--accent-contrast);
    font-size: 0.58rem;
    font-weight: 860;
    line-height: 1;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    pointer-events: none;
}

.chat-mobile-nav__item svg {
    width: 18px;
    height: 18px;
}

.chat-mobile-nav__item:hover,
.chat-mobile-nav__item:focus-visible {
    border-color: rgba(51, 144, 236, 0.24);
    background: var(--chat-control-bg-hover);
    color: var(--chat-text);
}

.chat-mobile-nav__item.is-active {
    border-color: rgba(51, 144, 236, 0.32);
    background: rgba(51, 144, 236, 0.12);
    color: var(--chat-accent);
}

.chat-fab {
    position: fixed;
    inset-inline-end: 1rem;
    bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px) + var(--chat-shell-offset));
    z-index: 285;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(180deg, #53b6ff 0%, #3390ec 100%);
    color: #fff;
    box-shadow: 0 24px 36px -26px rgba(8, 48, 86, 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--motion-fast, 0.18s) ease, box-shadow var(--motion-fast, 0.18s) ease, opacity var(--motion-fast, 0.18s) ease;
}

.chat-fab svg {
    width: 22px;
    height: 22px;
}

.chat-fab[hidden] {
    display: none !important;
}

.chat-fab:hover,
.chat-fab:focus-visible {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 28px 42px -26px rgba(8, 48, 86, 0.78);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + var(--chat-shell-offset));
    transform: translate(-50%, 16px);
    opacity: 0;
    pointer-events: none;
    padding: 0.68rem 0.94rem;
    border-radius: 999px;
    background: var(--chat-toast-bg);
    color: #fff;
    font-size: 0.78rem;
    box-shadow: 0 22px 42px -30px rgba(22, 42, 70, 0.3);
    transition: opacity var(--motion-fast, 0.18s) ease, transform var(--motion-fast, 0.18s) ease;
    z-index: 290;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@keyframes chat-message-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.96);
    }

    60% {
        opacity: 1;
        transform: translateY(-1px) scale(1.01);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (min-width: 980px) {
    .messages {
        padding-inline: clamp(1rem, 8vw, 7rem);
    }

    .chat-fab {
        display: none !important;
    }

    .chat-mobile-nav {
        display: none !important;
    }
}

@media (max-width: 1100px) {
    .msg-bubble {
        max-width: 76%;
    }
}

@media (max-width: 980px) {
    .thread-placeholder {
        place-content: start center;
        align-content: start;
        justify-items: center;
        gap: 0.2rem;
        padding: calc(1.4rem + env(safe-area-inset-top, 0px)) 0.8rem 0.8rem;
    }

    .thread-placeholder strong {
        font-size: 0.9rem;
    }

    .thread-placeholder span {
        font-size: 0.74rem;
        line-height: 1.55;
        max-width: 28ch;
    }
    body.chat-page {
        --chat-local-nav-height: 0px;
        font-size: clamp(15px, 3.9vw, 16.2px);
        line-height: 1.66;
    }

    body.chat-page.chat-mobile-nav-visible {
        --chat-local-nav-height: calc(62px + env(safe-area-inset-bottom, 0px));
    }

    .chat-app {
        width: 100%;
        max-width: none;
        padding: 0 0 calc(var(--chat-shell-offset) + var(--chat-local-nav-height));
        gap: 0;
        grid-template-rows: minmax(0, 1fr);
    }

    .chat-app__header {
        display: none;
    }

    .chat-app__main {
        min-height: var(--chat-vh, 100dvh);
    }

    .chat-stage {
        position: relative;
        height: 100%;
        min-height: 0;
        grid-template-columns: 1fr;
        padding: 0;
        gap: 0;
        border-radius: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .conversation-pane,
    .thread-pane {
        position: absolute;
        inset: 0;
        border-radius: 0;
        border: 0;
        background: var(--chat-pane-bg-strong);
        transition: transform 0.24s ease, opacity 0.24s ease;
    }

    .conversation-pane {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .thread-pane {
        transform: translateX(100%);
        opacity: 0;
        pointer-events: none;
    }

    .conversation-pane__close,
    .thread-head__mobile-btn {
        display: inline-flex;
    }

    .chat-app[data-mobile-view="list"] .conversation-pane {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .chat-app[data-mobile-view="list"] .thread-pane {
        transform: translateX(100%);
        opacity: 0;
        pointer-events: none;
    }

    .chat-app[data-mobile-view="thread"] .conversation-pane {
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
    }

    .chat-app[data-mobile-view="thread"] .thread-pane {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .chat-app[data-mobile-view="dm"] .conversation-pane,
    .chat-app[data-mobile-view="group"] .conversation-pane,
    .chat-app[data-mobile-view="dm"] .thread-pane,
    .chat-app[data-mobile-view="group"] .thread-pane {
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
    }

    .conversation-search-wrap input,
    .chat-modal__fields input,
    .chat-modal__fields textarea,
    #dm-search,
    #group-search,
    .composer-entry textarea {
        font-size: 16px;
    }

    .chat-modal {
        inset-inline: 0;
        inset-block-start: 0;
        transform: translateX(104%);
        width: 100vw;
        max-height: var(--chat-vh, 100dvh);
        min-height: var(--chat-vh, 100dvh);
        height: var(--chat-vh, 100dvh);
        border-radius: 0;
        border: 0;
        box-shadow: none;
        backdrop-filter: none;
        transition: transform 0.24s ease;
    }

    .chat-modal.is-open {
        transform: translateX(0);
    }

    .chat-context-menu,
    .chat-list-context-menu {
        max-height: min(46vh, 430px);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .chat-modal-backdrop {
        background: rgba(10, 22, 38, 0.14);
        backdrop-filter: none;
    }

    .chat-modal__header {
        padding: calc(0.52rem + env(safe-area-inset-top, 0px)) 0.7rem 0.5rem;
    }

    .chat-modal__body {
        padding: 0.14rem 0.56rem 0.56rem;
    }

    .chat-modal__members {
        max-height: none;
        min-height: 0;
    }

    .chat-modal__footer {
        padding: 0.3rem 0.56rem calc(0.72rem + env(safe-area-inset-bottom, 0px));
    }

    .chat-modal--group .chat-modal__footer {
        box-shadow: 0 -8px 24px -18px rgba(18, 30, 48, 0.36);
    }

    .chat-modal__footer--split {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #group-create-btn {
        grid-column: 1 / -1;
    }

    .chat-fab {
        inset-inline-end: 0.82rem;
        bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px) + var(--chat-shell-offset));
    }

    .conversation-list {
        padding-bottom: calc(0.56rem + var(--chat-local-nav-height));
    }

    .conversation-manage-bar {
        margin-inline: 0.48rem;
    }

    .composer {
        padding-bottom: calc(0.62rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
    }

    .thread-pane,
    .conversation-pane {
        padding-bottom: 0;
    }

    .chat-app__identity h1 {
        font-size: 1.18rem;
        line-height: 1.42;
    }

    .chat-app__identity p {
        font-size: 0.92rem;
        line-height: 1.62;
    }

    .chat-back,
    .chat-top-btn,
    .chat-sheet-close,
    .conversation-pane__close,
    .thread-head__mobile-btn,
    .conversation-pane__icon-btn {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .chat-back svg,
    .chat-top-btn svg,
    .chat-sheet-close svg,
    .conversation-pane__close svg,
    .thread-head__mobile-btn svg,
    .conversation-pane__icon-btn svg {
        width: 18px;
        height: 18px;
    }

    .chat-top-btn-text {
        min-height: 40px;
        min-width: 70px;
        padding-inline: 0.8rem;
        font-size: 0.78rem;
    }

    .chat-connection {
        min-height: 36px;
        padding: 0.4rem 0.72rem;
        font-size: 0.76rem;
    }

    .chat-mobile-nav {
        gap: 0.22rem;
        padding: 0.34rem 0.48rem calc(0.38rem + env(safe-area-inset-bottom, 0px));
    }

    .chat-mobile-nav__item {
        min-height: 48px;
        gap: 0.08rem;
        font-size: 0.64rem;
    }

    .chat-mobile-nav__item svg {
        width: 18px;
        height: 18px;
    }

    .conversation-pane__header {
        gap: 0.42rem;
        padding: calc(0.4rem + env(safe-area-inset-top, 0px)) 0.64rem 0.34rem;
    }

    .conversation-pane__header h2 {
        font-size: 0.86rem;
        line-height: 1.4;
    }

    .conversation-pane__header p {
        margin-top: 0.08rem;
        font-size: 0.68rem;
        line-height: 1.6;
    }

    .conversation-search-wrap {
        padding: 0 0.64rem 0.44rem;
    }

    .conversation-search-wrap input {
        min-height: 40px;
        border-radius: 12px;
        padding: 0.48rem 0.72rem;
    }

    .conversation-manage-bar {
        margin: 0 0.5rem 0.36rem;
    }

    .conversation-manage-bar__head button {
        min-height: 28px;
    }

    .conversation-manage-bar__actions button {
        min-height: 30px;
    }

    .conversation-list {
        gap: 0.12rem;
        padding-inline: 0.26rem;
    }

    .conversation-item {
        gap: 0.34rem;
    }

    .conversation-item__main {
        min-height: 58px;
        gap: 0.42rem;
        padding: 0.32rem 0.46rem;
        border-radius: 12px;
    }

    .conversation-item__avatar {
        width: 40px;
        height: 40px;
        font-size: 0.74rem;
    }

    .conversation-item__kind {
        width: 1.3rem;
        height: 1.3rem;
        border-radius: 10px;
    }

    .conversation-item__kind svg {
        width: 0.84rem;
        height: 0.84rem;
    }

    .conversation-item__copy {
        gap: 0.08rem;
    }

    .conversation-item__head {
        gap: 0.38rem;
    }

    .conversation-item__title {
        font-size: 0.8rem;
        line-height: 1.38;
    }

    .conversation-item__subtitle {
        font-size: 0.65rem;
        line-height: 1.42;
    }

    .conversation-item__preview {
        font-size: 0.7rem;
        line-height: 1.45;
    }

    .conversation-item__time {
        font-size: 0.62rem;
    }

    .conversation-item__unread {
        min-width: 20px;
        height: 20px;
        padding-inline: 0.24rem;
        font-size: 0.62rem;
    }

    .conversation-item__more,
    .conversation-item__select {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .conversation-item__select input {
        width: 18px;
        height: 18px;
    }

    .conversation-archive-toggle {
        min-height: 42px;
        padding: 0.44rem 0.62rem;
        font-size: 0.76rem;
    }

    .thread-head {
        gap: 0.34rem;
        padding: calc(0.34rem + env(safe-area-inset-top, 0px)) 0.5rem 0.42rem;
    }

    .thread-head__avatar {
        width: 48px;
        height: 48px;
        font-size: 0.82rem;
    }

    .thread-head__copy strong {
        font-size: 0.94rem;
        line-height: 1.46;
    }

    .thread-head__copy span {
        font-size: 0.75rem;
        line-height: 1.48;
    }

    .messages {
        padding: 0.46rem 0.5rem 0.42rem;
    }

    .msg-row {
        gap: 0.4rem;
    }

    .msg-avatar {
        width: 36px;
        height: 36px;
    }

    .msg-bubble {
        max-width: 90%;
        padding: 0.44rem 0.58rem 0.36rem;
        border-radius: 14px;
    }

    .msg-head {
        margin-bottom: 0.24rem;
    }

    .msg-name {
        font-size: 0.78rem;
    }

    .msg-text {
        font-size: 0.82rem;
        line-height: 1.52;
    }

    .msg-attachment__name {
        font-size: 0.82rem;
    }

    .msg-attachment__meta,
    .msg-attachment__link,
    .msg-attachment__state {
        font-size: 0.72rem;
    }

    .reply-preview {
        margin-bottom: 0.32rem;
        padding: 0.44rem 0.58rem;
        font-size: 0.76rem;
    }

    .msg-foot,
    .msg-delivery,
    .msg-reaction__count {
        font-size: 0.72rem;
    }

    .msg-reactions {
        margin-top: 0.3rem;
        gap: 0.32rem;
    }

    .msg-reaction {
        min-height: 32px;
        padding: 0.18rem 0.46rem;
        font-size: 0.78rem;
    }

    .composer {
        padding: 0.42rem 0.42rem calc(0.46rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
    }

    .composer-box {
        gap: 0.32rem;
        padding: 0.24rem;
        border-radius: 16px;
    }

    .composer-tool {
        width: 38px;
        height: 38px;
    }

    .composer-tool svg {
        width: 18px;
        height: 18px;
    }

    .composer-upload-sheet {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .composer-upload-option {
        min-height: 40px;
        border-radius: 13px;
        font-size: 0.76rem;
    }

    .composer-voice {
        gap: 0.42rem;
        padding: 0.48rem 0.52rem;
        border-radius: 13px;
    }

    .composer-voice__actions .shell-action-btn {
        min-height: 34px;
        padding-inline: 0.7rem;
        font-size: 0.72rem;
    }

    .composer-entry textarea {
        min-height: 40px;
        max-height: 176px;
        padding: 0.44rem 0.54rem;
        line-height: 1.52;
    }

    .composer-send {
        width: 40px;
        height: 40px;
        border-radius: 13px;
    }

    .composer-send svg {
        width: 18px;
        height: 18px;
    }

    .composer-status {
        margin-top: 0.24rem;
        min-height: 0.94rem;
        font-size: 0.74rem;
    }

    .composer-storage-note {
        font-size: 0.72rem;
        line-height: 1.62;
    }
}

@media (max-width: 680px) {
    .chat-stage,
    .chat-login-panel {
        border-radius: 0;
    }

    .chat-stage {
        padding: 0;
    }

    .thread-head {
        padding: calc(0.28rem + env(safe-area-inset-top, 0px)) 0.42rem 0.36rem;
    }

    .messages {
        padding: 0.4rem 0.42rem 0.34rem;
    }

    .msg-bubble {
        max-width: 92%;
        padding: 0.42rem 0.56rem 0.34rem;
    }

    .msg-attachment {
        padding: 0.44rem 0.48rem;
    }

    .msg-avatar {
        width: 34px;
        height: 34px;
    }

    .msg-attachment__media img,
    .msg-attachment__media video {
        max-height: min(56vh, 420px);
    }

    .composer {
        padding: 0.34rem 0.34rem calc(0.44rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
    }

    .chat-context-menu {
        min-width: min(260px, calc(100vw - 1rem));
    }

    .chat-info-sheet {
        width: 100vw;
    }

    .chat-modal {
        width: 100vw;
    }

    .conversation-pane__header {
        padding-inline: 0.58rem;
    }

    .conversation-search-wrap {
        padding-inline: 0.58rem;
    }

    .conversation-list {
        padding-inline: 0.24rem;
    }

    .conversation-manage-bar {
        margin-inline: 0.5rem;
        margin-bottom: 0.3rem;
    }

    .conversation-item__more,
    .conversation-item__select {
        width: 34px;
        height: 34px;
    }
}

/* Telegram-inspired refinement layer */
body.chat-page {
    --chat-bg: var(--bg-body);
    --chat-surface: var(--surface);
    --chat-surface-strong: var(--surface-solid);
    --chat-border: var(--border-color);
    --chat-text: var(--text-primary);
    --chat-muted: var(--text-secondary);
    --chat-accent: var(--accent-color);
    --chat-accent-soft: var(--accent-soft);
    --chat-bubble: var(--surface-solid);
    --chat-bubble-me: linear-gradient(180deg, rgba(43, 109, 243, 0.13) 0%, rgba(43, 109, 243, 0.07) 100%);
    --chat-shell-gradient: linear-gradient(180deg, var(--bg-body-strong) 0%, var(--bg-body) 100%);
    --chat-header-bg: var(--surface);
    --chat-pane-bg: var(--surface);
    --chat-pane-bg-strong: var(--surface-solid);
    --chat-control-bg: var(--surface);
    --chat-control-bg-hover: var(--surface-solid);
    --chat-stream-bg: var(--surface-muted);
    --chat-stream-pattern: rgba(127, 145, 165, 0.08);
    --chat-composer-bg: var(--surface);
    --chat-input-bg: var(--surface-solid);
    --chat-overlay-bg: var(--overlay-backdrop);
    --chat-sheet-bg: var(--surface-solid);
    --chat-modal-bg: var(--surface-solid);
    --chat-chip-bg: var(--surface-contrast);
    --chat-toast-bg: rgba(17, 30, 54, 0.92);
}

html[data-theme="dark"] body.chat-page {
    --chat-bubble-me: linear-gradient(180deg, rgba(114, 169, 255, 0.26) 0%, rgba(114, 169, 255, 0.16) 100%);
    --chat-shell-gradient: linear-gradient(180deg, var(--bg-body-strong) 0%, var(--bg-body) 100%);
    --chat-stream-pattern: rgba(124, 145, 168, 0.16);
}

.chat-app {
    width: min(1540px, 100%);
    padding: calc(0.2rem + env(safe-area-inset-top, 0px)) 0.2rem calc(0.2rem + var(--chat-shell-offset));
    gap: 0.2rem;
}

.chat-app__header,
.chat-login-panel,
.chat-stage,
.conversation-pane,
.thread-pane,
.chat-info-sheet,
.chat-modal,
.chat-context-menu,
.chat-list-context-menu {
    border-radius: 14px;
}

.chat-app__header {
    position: sticky;
    top: 0;
    z-index: 18;
    padding: 0.34rem 0.46rem;
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(10px);
}

.chat-app__identity h1 {
    font-size: 0.92rem;
    line-height: 1.28;
}

.chat-app__identity p {
    font-size: 0.69rem;
    line-height: 1.42;
}

.chat-login-panel,
.chat-stage,
.conversation-pane,
.thread-pane {
    box-shadow: none;
    backdrop-filter: none;
}

.chat-stage {
    padding: 0.22rem;
    gap: 0.22rem;
    grid-template-columns: minmax(302px, 356px) minmax(0, 1fr);
    background: var(--chat-surface);
}

.conversation-pane {
    background: var(--chat-pane-bg);
}

.thread-pane {
    background: var(--chat-pane-bg-strong);
}

.conversation-pane__header {
    padding: 0.42rem 0.5rem 0.28rem;
}

.conversation-search-wrap {
    padding: 0 0.5rem 0.34rem;
}

.conversation-search-wrap input,
.chat-modal__fields input,
.chat-modal__fields textarea,
#edit-text,
.composer-entry textarea {
    border-radius: 11px;
}

.conversation-list {
    padding: 0 0.2rem 0.3rem;
    gap: 0.06rem;
    scrollbar-gutter: stable both-edges;
}

.conversation-item__main {
    min-height: 54px;
    padding: 0.28rem 0.42rem;
    border-radius: 12px;
}

.conversation-item__avatar {
    width: 40px;
    height: 40px;
}

.thread-head {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 0.32rem 0.48rem;
    background: var(--chat-header-bg);
    border-bottom: 1px solid var(--chat-border);
    backdrop-filter: blur(8px);
}

.thread-head__copy strong {
    font-size: 0.86rem;
}

.thread-head__copy span {
    font-size: 0.68rem;
}

.thread-banner-stack {
    padding: 0.2rem 0.3rem 0;
}

.thread-stream {
    background:
        linear-gradient(var(--chat-stream-bg), var(--chat-stream-bg)),
        radial-gradient(circle at 1px 1px, var(--chat-stream-pattern) 1px, transparent 0);
    background-size: auto, 28px 28px;
}

.stream-state {
    background:
        linear-gradient(var(--chat-stream-bg), var(--chat-stream-bg)),
        radial-gradient(circle at 1px 1px, var(--chat-stream-pattern) 1px, transparent 0);
    background-size: auto, 28px 28px;
}

.stream-state::before {
    content: "";
    width: 34px;
    height: 34px;
    border-radius: 50%;
    margin: 0 auto 0.2rem;
    border: 2px solid rgba(127, 145, 165, 0.3);
    border-top-color: var(--chat-accent);
    animation: chat-stream-spin 1s linear infinite;
}

.stream-state[data-kind="empty"]::before {
    border-style: dashed;
    border-top-color: rgba(127, 145, 165, 0.3);
    animation: none;
}

.stream-state[data-kind="error"]::before {
    border-color: rgba(199, 83, 94, 0.26);
    border-top-color: var(--chat-danger);
}

.stream-state[data-kind="reconnect"]::before {
    border-color: rgba(194, 129, 29, 0.24);
    border-top-color: var(--chat-warning);
}

.stream-state[data-kind="error"] strong {
    color: var(--chat-danger);
}

.stream-state[data-kind="reconnect"] strong {
    color: var(--chat-warning);
}

.messages {
    padding: 0.46rem 0.52rem 0.36rem;
    background:
        linear-gradient(var(--chat-stream-bg), var(--chat-stream-bg)),
        radial-gradient(circle at 1px 1px, var(--chat-stream-pattern) 1px, transparent 0);
    background-size: auto, 28px 28px;
    scroll-behavior: auto;
    scrollbar-gutter: stable both-edges;
}

@media (min-width: 981px) {
    .messages {
        padding-inline: clamp(1.1rem, 5.6vw, 4.9rem);
    }
}

.msg-item {
    margin-bottom: 0.1rem;
}

.msg-item.day-start {
    position: relative;
    margin-top: 0.72rem;
    padding-top: 0.94rem;
}

.msg-item.day-start::before {
    content: attr(data-day-label);
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    min-height: 22px;
    padding: 0.1rem 0.54rem;
    border-radius: 999px;
    border: 1px solid var(--chat-border);
    background: var(--chat-chip-bg);
    color: var(--chat-muted);
    font-size: 0.66rem;
    font-weight: 760;
    white-space: nowrap;
}

.msg-row {
    gap: 0.26rem;
}

.msg-avatar {
    width: 32px;
    height: 32px;
}

.msg-item.me .msg-avatar {
    display: none;
}

.msg-item.grouped-with-prev .msg-avatar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: none;
}

.msg-bubble {
    max-width: min(72%, 640px);
    padding: 0.34rem 0.54rem 0.28rem;
    border-radius: 16px;
    box-shadow: none;
}

.msg-item.other.group-single .msg-bubble,
.msg-item.other.group-end .msg-bubble {
    border-bottom-left-radius: 8px;
}

.msg-item.other.group-start .msg-bubble,
.msg-item.other.group-middle .msg-bubble {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 12px;
}

.msg-item.me.group-single .msg-bubble,
.msg-item.me.group-end .msg-bubble {
    border-bottom-right-radius: 8px;
}

.msg-item.me.group-start .msg-bubble,
.msg-item.me.group-middle .msg-bubble {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 12px;
}

.msg-item:hover .msg-bubble,
.msg-item.is-menu-open .msg-bubble {
    box-shadow: 0 10px 26px -24px rgba(17, 30, 54, 0.26);
}

.msg-head {
    margin-bottom: 0.12rem;
}

.msg-name {
    font-size: 0.69rem;
}

.msg-text {
    font-size: 0.81rem;
    line-height: 1.66;
}

.msg-foot {
    margin-top: 0.14rem;
}

.msg-reactions {
    margin-top: 0.2rem;
    gap: 0.22rem;
}

.msg-reaction {
    min-height: 22px;
    padding: 0.08rem 0.34rem;
    border-radius: 999px;
}

.composer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 0.32rem 0.38rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
    background: var(--chat-composer-bg);
    border-top: 1px solid var(--chat-border);
    backdrop-filter: blur(8px);
}

.composer-box {
    border-radius: 18px;
    padding: 0.18rem;
    gap: 0.28rem;
}

.composer-entry textarea {
    min-height: 40px;
    max-height: 168px;
    padding: 0.38rem 0.52rem;
    line-height: 1.66;
    font-size: 0.81rem;
}

.composer-tool,
.composer-send {
    width: 36px;
    height: 36px;
    border-radius: 11px;
}

.composer-status {
    min-height: 0.9rem;
}

.chat-mobile-nav {
    background: var(--chat-pane-bg-strong);
}

.chat-info-sheet {
    width: min(368px, 100vw);
}

.chat-modal {
    width: min(500px, calc(100vw - 1rem));
}

@keyframes chat-stream-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1240px) {
    .chat-stage {
        grid-template-columns: minmax(286px, 326px) minmax(0, 1fr);
    }

    .msg-bubble {
        max-width: min(76%, 640px);
    }
}

@media (max-width: 980px) {
    .chat-stage {
        grid-template-columns: 1fr;
        padding: 0;
        border-radius: 0;
        background: transparent;
    }

    .conversation-pane,
    .thread-pane {
        border-radius: 0;
        box-shadow: none;
    }

    .conversation-pane {
        background: var(--chat-pane-bg-strong);
    }

    .thread-head {
        padding-inline: 0.46rem;
    }

    .messages {
        padding: 0.46rem 0.48rem 0.34rem;
    }

    .msg-item.day-start {
        margin-top: 0.58rem;
        padding-top: 0.84rem;
    }

    .msg-item.day-start::before {
        font-size: 0.64rem;
    }

    .msg-bubble {
        max-width: 88%;
        padding: 0.4rem 0.54rem 0.34rem;
    }

    .composer {
        padding: 0.38rem 0.38rem calc(0.44rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
    }

    .composer-box {
        border-radius: 15px;
    }
}

@media (max-width: 680px) {
    .messages {
        padding: 0.42rem 0.4rem 0.3rem;
    }

    .msg-bubble {
        max-width: 91%;
    }
}

/* Telegram mobile fidelity layer */
body.chat-page {
    --chat-top-chrome-color: var(--surface-solid);
    --chat-statusbar-color: var(--surface-solid);
    background-color: var(--chat-statusbar-color);
}

html[data-theme="dark"] body.chat-page {
    --chat-top-chrome-color: #131b25;
    --chat-statusbar-color: #131b25;
}

.conversation-filter-tabs {
    display: flex;
    align-items: center;
    gap: 0.24rem;
    overflow-x: auto;
    padding: 0 0.5rem 0.36rem;
    scrollbar-width: none;
}

.conversation-filter-tabs::-webkit-scrollbar {
    height: 0;
}

.conversation-filter-tab {
    min-height: 30px;
    padding: 0.2rem 0.74rem;
    border-radius: 999px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-muted);
    font-size: 0.68rem;
    font-weight: 830;
    white-space: nowrap;
    transition: color var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease, background var(--motion-fast, 0.18s) ease, transform var(--motion-fast, 0.18s) ease;
}

.conversation-filter-tab:hover,
.conversation-filter-tab:focus-visible {
    border-color: color-mix(in srgb, var(--chat-accent) 34%, var(--chat-border));
    color: var(--chat-text);
    background: var(--chat-control-bg-hover);
}

.conversation-filter-tab.is-active {
    border-color: color-mix(in srgb, var(--chat-accent) 42%, var(--chat-border));
    color: var(--chat-accent);
    background: color-mix(in srgb, var(--chat-accent) 14%, transparent);
}

@media (max-width: 980px) {
    body.chat-page.chat-mobile-nav-visible {
        --chat-local-nav-height: calc(84px + env(safe-area-inset-bottom, 0px));
    }

    .conversation-pane,
    .thread-pane {
        background: var(--chat-pane-bg-strong);
    }

    .conversation-pane__header,
    .thread-head {
        background: var(--chat-top-chrome-color);
    }

    .conversation-pane__header {
        position: sticky;
        top: 0;
        z-index: 12;
        padding: calc(0.42rem + env(safe-area-inset-top, 0px)) 0.64rem 0.34rem;
        border-bottom: 1px solid var(--chat-border);
    }

    .conversation-pane__header h2 {
        font-size: 1.18rem;
        line-height: 1.26;
        letter-spacing: -0.02em;
    }

    .conversation-pane__header p {
        font-size: 0.72rem;
        line-height: 1.52;
    }

    .conversation-pane__header-actions {
        gap: 0.22rem;
        padding: 0.16rem;
        border-radius: 999px;
        border: 1px solid var(--chat-border);
        background: color-mix(in srgb, var(--chat-control-bg) 90%, transparent);
    }

    .conversation-pane__icon-btn {
        width: 34px;
        height: 34px;
        border-radius: 999px;
        border-color: transparent;
    }

    .conversation-search-wrap {
        padding: 0.34rem 0.64rem 0.3rem;
        background: var(--chat-top-chrome-color);
    }

    .conversation-search-wrap input {
        min-height: 42px;
        padding-inline: 0.92rem;
        border-radius: 14px;
        border-color: color-mix(in srgb, var(--chat-border) 85%, transparent);
        background: color-mix(in srgb, var(--chat-input-bg) 94%, transparent);
        font-size: 0.84rem;
    }

    .conversation-filter-tabs {
        padding: 0 0.64rem 0.36rem;
        background: var(--chat-top-chrome-color);
        border-bottom: 1px solid var(--chat-border);
    }

    .conversation-filter-tab {
        min-height: 34px;
        padding-inline: 0.88rem;
        font-size: 0.73rem;
    }

    .conversation-list {
        padding: 0 0.56rem calc(0.7rem + var(--chat-local-nav-height));
        gap: 0;
    }

    .conversation-item {
        gap: 0;
    }

    .conversation-item__main {
        min-height: 62px;
        border-radius: 0;
        border: 0;
        border-bottom: 1px solid color-mix(in srgb, var(--chat-border) 75%, transparent);
        padding: 0.36rem 0.12rem;
    }

    .conversation-item__main::before {
        display: none;
    }

    .conversation-item.is-active .conversation-item__main {
        background: color-mix(in srgb, var(--chat-accent) 10%, transparent);
        border-color: color-mix(in srgb, var(--chat-accent) 24%, var(--chat-border));
    }

    .conversation-item__avatar {
        width: 52px;
        height: 52px;
        font-size: 0.9rem;
    }

    .conversation-item__title {
        font-size: 0.96rem;
        line-height: 1.28;
        font-weight: 880;
    }

    .conversation-item__subtitle {
        margin-top: 0.02rem;
        font-size: 0.7rem;
    }

    .conversation-item__preview {
        margin-top: 0.03rem;
        font-size: 0.78rem;
        line-height: 1.38;
    }

    .conversation-item__meta {
        align-self: stretch;
        display: grid;
        justify-items: end;
        align-content: space-between;
    }

    .conversation-item__time {
        font-size: 0.76rem;
    }

    .conversation-item__unread {
        min-width: 22px;
        height: 22px;
        border-radius: 999px;
        font-size: 0.68rem;
        font-weight: 860;
    }

    .conversation-item__tools {
        align-self: center;
        gap: 0.08rem;
    }

    .thread-head {
        position: sticky;
        top: 0;
        z-index: 14;
        padding: calc(0.34rem + env(safe-area-inset-top, 0px)) 0.52rem 0.36rem;
        border-bottom: 1px solid var(--chat-border);
    }

    .thread-head__identity {
        padding: 0.2rem 0.46rem 0.2rem 0.24rem;
        border-radius: 999px;
        border: 1px solid color-mix(in srgb, var(--chat-border) 85%, transparent);
        background: color-mix(in srgb, var(--chat-control-bg) 82%, transparent);
        min-height: 48px;
    }

    .thread-head__avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
    }

    .thread-head__copy strong {
        font-size: 0.97rem;
        line-height: 1.2;
    }

    .thread-head__copy span {
        margin-top: 0.05rem;
        font-size: 0.74rem;
        line-height: 1.38;
    }

    .thread-head__actions .chat-top-btn,
    .thread-head__mobile-btn {
        width: 38px;
        height: 38px;
        border-radius: 999px;
        background: color-mix(in srgb, var(--chat-control-bg) 88%, transparent);
    }

    .thread-banner-stack {
        padding: 0.28rem 0.42rem 0;
    }

    .chat-pinned-strip {
        min-height: 44px;
        border-radius: 16px;
        background: color-mix(in srgb, var(--chat-control-bg) 90%, transparent);
        border-color: color-mix(in srgb, var(--chat-border) 90%, transparent);
    }

    .chat-pinned-strip__copy strong {
        font-size: 0.74rem;
        line-height: 1.24;
    }

    .chat-pinned-strip__copy span {
        font-size: 0.72rem;
        line-height: 1.3;
    }

    .messages {
        padding: 0.46rem 0.5rem 0.34rem;
        background:
            linear-gradient(var(--chat-stream-bg), var(--chat-stream-bg)),
            radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--chat-stream-pattern) 88%, transparent) 1px, transparent 0);
        background-size: auto, 24px 24px;
    }

    .msg-item {
        margin-bottom: 0.16rem;
    }

    .msg-item.day-start {
        margin-top: 0.66rem;
        padding-top: 0.86rem;
    }

    .msg-item.day-start::before {
        min-height: 24px;
        padding: 0.14rem 0.64rem;
        border-radius: 999px;
        font-size: 0.68rem;
        background: color-mix(in srgb, var(--chat-chip-bg) 94%, transparent);
    }

    .msg-row {
        gap: 0.34rem;
    }

    .msg-avatar {
        width: 34px;
        height: 34px;
    }

    .msg-bubble {
        max-width: min(86%, 700px);
        border-radius: 18px;
        padding: 0.46rem 0.62rem 0.38rem;
    }

    .msg-text {
        font-size: 0.92rem;
        line-height: 1.62;
    }

    .msg-foot {
        margin-top: 0.18rem;
    }

    .composer {
        position: sticky;
        bottom: 0;
        z-index: 15;
        padding: 0.38rem 0.42rem calc(0.5rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
        background: color-mix(in srgb, var(--chat-composer-bg) 92%, transparent);
        border-top: 1px solid color-mix(in srgb, var(--chat-border) 88%, transparent);
        backdrop-filter: blur(16px);
    }

    .composer-box {
        border-radius: 20px;
        border-color: color-mix(in srgb, var(--chat-border) 86%, transparent);
        background: color-mix(in srgb, var(--chat-control-bg) 94%, transparent);
        padding: 0.2rem;
        gap: 0.24rem;
    }

    .composer-entry textarea {
        min-height: 42px;
        max-height: 184px;
        padding: 0.46rem 0.58rem;
        font-size: 0.9rem;
        line-height: 1.58;
        border-radius: 14px;
    }

    .composer-tool,
    .composer-send {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .composer-upload-sheet {
        position: fixed;
        inset-inline: 0.64rem;
        inset-block-end: calc(0.56rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
        z-index: 300;
        border-radius: 22px;
        border: 1px solid color-mix(in srgb, var(--chat-border) 90%, transparent);
        background: color-mix(in srgb, var(--chat-sheet-bg) 92%, transparent);
        backdrop-filter: blur(18px);
        box-shadow: 0 24px 48px -32px rgba(14, 24, 38, 0.5);
        padding: 0.44rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.32rem;
    }

    .composer-upload-option {
        min-height: 46px;
        border-radius: 14px;
        font-size: 0.74rem;
        font-weight: 830;
    }

    body.chat-page #conversation-manage-bar {
        position: fixed !important;
        inset-inline: 0.56rem !important;
        top: auto !important;
        bottom: calc(0.54rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height)) !important;
        z-index: 200 !important;
        margin: 0 !important;
        border-radius: 20px !important;
        border: 1px solid var(--chat-border) !important;
        background: color-mix(in srgb, var(--chat-sheet-bg) 94%, transparent) !important;
        backdrop-filter: blur(20px) !important;
        padding: 0.44rem 0.64rem !important;
        box-shadow: 0 12px 36px -16px rgba(14, 24, 38, 0.3) !important;
    }

    body.chat-page .conversation-manage-bar__head {
        gap: 0.6rem !important;
    }

    body.chat-page .conversation-manage-bar__head strong {
        flex: 1 !important;
        font-size: 0.82rem !important;
        font-weight: 800 !important;
        color: var(--chat-text) !important;
    }

    body.chat-page .conversation-manage-bar__actions {
        gap: 0.34rem !important;
    }

    body.chat-page .conversation-manage-bar__actions button {
        min-height: 38px !important;
        padding-inline: 0.78rem !important;
        border-radius: 13px !important;
        font-size: 0.74rem !important;
    }

    .chat-context-menu,
    .chat-list-context-menu {
        inset-inline: 0.56rem !important;
        inset-block-start: auto !important;
        inset-block-end: calc(0.54rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
        max-width: none;
        width: auto;
        border-radius: 24px;
        padding: 0.58rem;
        transform: translateY(18px) scale(0.98);
    }

    .chat-context-menu.is-open,
    .chat-list-context-menu.is-open {
        transform: translateY(0) scale(1);
    }

    .chat-mobile-nav {
        inset-inline: 0.72rem;
        inset-block-end: calc(0.34rem + env(safe-area-inset-bottom, 0px));
        border-radius: 999px;
        border: 1px solid color-mix(in srgb, var(--chat-border) 90%, transparent);
        background: color-mix(in srgb, var(--chat-pane-bg-strong) 84%, transparent);
        backdrop-filter: blur(24px);
        box-shadow: 0 18px 40px -30px rgba(16, 26, 41, 0.62);
        padding: 0.34rem;
        display: flex;
        align-items: stretch;
        gap: 0.24rem;
    }

    .chat-mobile-nav__item {
        flex: 1 1 0;
        min-height: 54px;
        border-radius: 999px;
        font-size: 0.72rem;
        gap: 0.09rem;
    }

    .chat-mobile-nav__item svg {
        width: 20px;
        height: 20px;
    }

    .chat-mobile-nav__item.is-active {
        background: color-mix(in srgb, var(--chat-accent) 16%, transparent);
        border-color: color-mix(in srgb, var(--chat-accent) 34%, var(--chat-border));
    }

    .toast {
        bottom: calc(1.12rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
    }
}

@media (max-width: 680px) {
    .conversation-pane__header {
        padding-inline: 0.56rem;
    }

    .conversation-search-wrap,
    .conversation-filter-tabs {
        padding-inline: 0.56rem;
    }

    .conversation-list {
        padding-inline: 0.46rem;
    }

    .thread-head {
        padding-inline: 0.42rem;
    }

    .messages {
        padding-inline: 0.38rem;
    }

    .msg-bubble {
        max-width: 89.5%;
    }

    .chat-mobile-nav {
        inset-inline: 0.54rem;
    }
}

/* Mobile stability + readability hardening */
body.chat-page {
    font-size: clamp(16px, 0.28vw + 15px, 18px);
}

html,
body.chat-page {
    background-color: var(--chat-statusbar-color, var(--bg-body-strong));
}

body.chat-page::before {
    content: "";
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    height: calc(env(safe-area-inset-top, 0px) + 2px);
    background: var(--chat-statusbar-color);
    pointer-events: none;
    z-index: 40;
}

body.chat-page .conversation-item,
body.chat-page .conversation-item *,
body.chat-page .msg-item,
body.chat-page .msg-item *,
body.chat-page .thread-head,
body.chat-page .thread-head *,
body.chat-page .chat-mobile-nav,
body.chat-page .chat-mobile-nav * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

body.chat-page textarea,
body.chat-page input,
body.chat-page [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

.conversation-list,
.messages {
    overscroll-behavior: contain;
}

.conversation-item__main,
.msg-item,
.msg-bubble {
    touch-action: manipulation;
}

@media (min-width: 981px) {
    .conversation-item__title {
        font-size: 0.94rem;
    }

    .conversation-item__preview {
        font-size: 0.84rem;
    }

    .msg-text {
        font-size: 0.9rem;
    }
}

@media (max-width: 980px) {
    body.chat-page,
    .chat-app,
    .chat-app__main,
    .chat-stage {
        height: var(--chat-vh, 100dvh);
        min-height: var(--chat-vh, 100dvh);
    }

    .chat-app[data-mobile-view="list"] .conversation-pane,
    .chat-app[data-mobile-view="thread"] .thread-pane {
        transform: none;
    }

    body.chat-page input,
    body.chat-page textarea,
    body.chat-page select,
    .conversation-search-wrap input,
    .composer-entry textarea {
        font-size: 16px !important;
    }

    body.chat-page.chat-keyboard-open .conversation-pane,
    body.chat-page.chat-keyboard-open .thread-pane {
        transition: none;
    }

    .conversation-item__title {
        font-size: 1.04rem;
    }

    .conversation-item__preview {
        font-size: 0.86rem;
    }

    .msg-text {
        font-size: 1rem;
    }

    .thread-head__copy strong {
        font-size: 1.06rem;
    }

    .composer-entry textarea {
        min-height: 44px;
    }
}

/* Conversation list refinement */
@media (min-width: 981px) {
    .chat-stage {
        grid-template-columns: minmax(410px, 470px) minmax(0, 1fr);
        gap: 0.38rem;
    }

    .conversation-pane {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .conversation-pane__header,
    .conversation-search-wrap,
    .conversation-filter-tabs,
    .conversation-manage-bar,
    .conversation-empty {
        flex: 0 0 auto;
    }

    .conversation-list {
        flex: 1 1 auto;
        min-height: 0;
        padding: 0 0.4rem 0.46rem;
        gap: 0.18rem;
    }

    .conversation-item {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: stretch;
        gap: 0.34rem;
    }

    .conversation-item__main {
        min-height: 88px;
        padding: 0.78rem 0.92rem;
        gap: 0.82rem;
        border-radius: 20px;
        border-color: color-mix(in srgb, var(--chat-border) 84%, transparent);
        background: color-mix(in srgb, var(--chat-control-bg) 78%, transparent);
        box-shadow: 0 16px 32px -28px rgba(17, 31, 50, 0.24);
    }

    .conversation-item__main::before,
    .conversation-item__kind,
    .conversation-badge {
        display: none;
    }

    .conversation-item__main:hover,
    .conversation-item__main:focus-visible {
        transform: translateY(-1px);
        border-color: color-mix(in srgb, var(--chat-accent) 34%, var(--chat-border));
        background: color-mix(in srgb, var(--chat-control-bg-hover) 94%, transparent);
    }

    .conversation-item.is-active .conversation-item__main {
        border-color: color-mix(in srgb, var(--chat-accent) 38%, var(--chat-border));
        background: color-mix(in srgb, var(--chat-accent) 11%, var(--chat-control-bg-hover));
        box-shadow: 0 20px 38px -30px color-mix(in srgb, var(--chat-accent) 32%, transparent);
    }

    .conversation-item__avatar {
        width: 58px;
        height: 58px;
        font-size: 1rem;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    }

    .conversation-item__copy {
        gap: 0.24rem;
        align-content: center;
    }

    .conversation-item__head {
        gap: 0.5rem;
        align-items: start;
    }

    .conversation-item__title {
        display: -webkit-box;
        overflow: hidden;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        font-size: 1rem;
        line-height: 1.32;
        font-weight: 900;
    }

    .conversation-item__preview-row {
        min-width: 0;
        display: grid;
        grid-template-columns: max-content minmax(0, 1fr);
        align-items: start;
        gap: 0.42rem;
    }

    .conversation-item__subtitle {
        display: inline-flex;
        align-items: center;
        min-height: 22px;
        padding-inline: 0.48rem;
        border-radius: 999px;
        background: color-mix(in srgb, var(--chat-accent) 14%, transparent);
        color: var(--chat-accent);
        font-size: 0.66rem;
        font-weight: 810;
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .conversation-item__preview {
        display: -webkit-box;
        overflow: hidden;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        font-size: 0.85rem;
        line-height: 1.52;
    }

    .conversation-item__meta {
        min-width: 3.9rem;
        align-self: stretch;
        justify-items: end;
        align-content: space-between;
        gap: 0.28rem;
        padding-block: 0.06rem;
    }

    .conversation-item__time {
        font-size: 0.75rem;
        font-weight: 780;
        white-space: nowrap;
    }

    .conversation-item__flags {
        gap: 0.24rem;
    }

    .conversation-item__unread {
        min-width: 24px;
        height: 24px;
        padding-inline: 0.38rem;
        font-size: 0.68rem;
        font-weight: 880;
        box-shadow: 0 10px 18px -16px color-mix(in srgb, var(--chat-accent) 72%, transparent);
    }

    .conversation-item__tools {
        position: static;
        align-self: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0.26rem;
        opacity: 0;
        pointer-events: none;
        transform: none;
        transition: opacity var(--motion-fast, 0.18s) ease;
    }

    .conversation-item:hover .conversation-item__tools,
    .conversation-item:focus-within .conversation-item__tools,
    body.chat-page.chat-selection-mode .conversation-item__tools {
        opacity: 1;
        pointer-events: auto;
    }

    .conversation-item__more,
    .conversation-item__select {
        width: 32px;
        height: 32px;
        border-radius: 12px;
        border-color: color-mix(in srgb, var(--chat-border) 88%, transparent);
        background: color-mix(in srgb, var(--chat-control-bg) 96%, transparent);
        box-shadow: 0 14px 26px -22px rgba(18, 30, 48, 0.34);
    }

    body.chat-page:not(.chat-selection-mode) .conversation-item__select {
        display: none;
    }
}

@media (max-width: 980px) {
    .chat-stage {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .conversation-list {
        padding: 0 0.48rem calc(0.84rem + var(--chat-local-nav-height));
        gap: 0;
    }

    .conversation-item__main {
        min-height: 76px;
        padding-block: 0.54rem;
        padding-inline: 0.08rem;
        border-radius: 0;
        border: 0;
        border-bottom: 1px solid color-mix(in srgb, var(--chat-border) 76%, transparent);
        background: transparent;
    }

    .conversation-item__avatar {
        width: 52px;
        height: 52px;
        font-size: 0.9rem;
    }

    .conversation-item__title {
        font-size: 1rem;
    }

    .conversation-item__subtitle {
        min-height: 19px;
        padding-inline: 0.4rem;
        font-size: 0.61rem;
    }

    .conversation-item__preview {
        font-size: 0.84rem;
    }

    .conversation-item__time {
        font-size: 0.74rem;
    }

    .conversation-item__tools {
        display: none;
    }
}

/* Premium chat final overrides */
.conversation-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.conversation-pane__header,
.conversation-search-wrap,
.conversation-filter-tabs,
.conversation-manage-bar,
.conversation-empty {
    flex: 0 0 auto;
}

.conversation-filter-tabs {
    align-content: flex-start;
    height: auto;
    margin: 0;
}

.conversation-list {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

@media (max-width: 980px) {
    .conversation-pane {
        display: flex;
    }

    .conversation-filter-tabs {
        padding-top: 0.12rem;
        padding-bottom: 0.62rem;
    }

    .conversation-list {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
    }
}

/* Stage 1: full-screen telegram-like frame */
body.chat-page {
    --chat-shell-offset: 0px;
    --chat-frame-bg: #e8edf3;
    --chat-header-solid: #f7f9fc;
    --chat-panel-solid: #ffffff;
    --chat-stream-solid: #e9dcc6;
    --chat-border-soft: color-mix(in srgb, var(--chat-border, #c7d2df) 76%, transparent);
    background: var(--chat-frame-bg);
}

body.chat-page .background-overlay {
    background:
        radial-gradient(circle at 56% 18%, rgba(138, 183, 230, 0.2), transparent 42%),
        linear-gradient(180deg, #ecf1f7 0%, #e6ecf3 100%);
    opacity: 1;
}

body.chat-page .chat-app {
    width: 100% !important;
    max-width: none !important;
    min-height: var(--chat-vh, 100dvh) !important;
    height: var(--chat-vh, 100dvh) !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    border-radius: 0 !important;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

body.chat-page .chat-app::before {
    display: none !important;
}

body.chat-page .chat-app__header,
body.chat-page .chat-login-panel,
body.chat-page .chat-stage,
body.chat-page .conversation-pane,
body.chat-page .thread-pane {
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body.chat-page .chat-app__header {
    position: sticky;
    top: 0;
    z-index: 120;
    border: 0 !important;
    border-bottom: 1px solid var(--chat-border-soft) !important;
    background: var(--chat-header-solid) !important;
    padding: calc(0.48rem + env(safe-area-inset-top, 0px)) 0.84rem 0.56rem !important;
}

body.chat-page .chat-app__identity h1,
body.chat-page .chat-app__identity p {
    color: var(--text-primary);
}

body.chat-page .chat-app__identity p {
    color: var(--text-secondary);
}

body.chat-page .chat-back,
body.chat-page .chat-top-btn,
body.chat-page .conversation-pane__icon-btn,
body.chat-page .conversation-pane__close,
body.chat-page .thread-head__mobile-btn {
    background: #f1f5fa;
    border-color: var(--chat-border-soft);
    color: var(--text-primary);
}

body.chat-page .chat-app__main {
    min-height: 0;
    height: 100%;
    padding: 0;
}

body.chat-page .chat-stage {
    border: 0 !important;
    background: var(--chat-panel-solid) !important;
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    gap: 0;
    min-height: 0;
    height: 100%;
    padding: 0 !important;
}

body.chat-page .chat-login-panel {
    border: 1px solid var(--chat-border-soft) !important;
    border-radius: 20px !important;
    background: var(--chat-panel-solid) !important;
    margin: auto;
    width: min(560px, calc(100% - 1.2rem));
    box-shadow: 0 24px 40px -30px rgba(17, 34, 57, 0.28) !important;
}

body.chat-page .conversation-pane {
    border: 0 !important;
    border-inline-end: 1px solid var(--chat-border-soft) !important;
    background: #f8fbff !important;
}

body.chat-page .thread-pane {
    border: 0 !important;
    background: var(--chat-panel-solid) !important;
}

body.chat-page .conversation-pane__header,
body.chat-page .thread-head {
    border-bottom: 1px solid var(--chat-border-soft) !important;
    background: #f8fbff !important;
    padding: 0.62rem 0.8rem 0.58rem !important;
}

body.chat-page .thread-shell {
    position: relative;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
}

body.chat-page .thread-shell > .thread-stream {
    grid-row: 5;
}

body.chat-page .thread-shell > .composer {
    grid-row: 6;
}

body.chat-page .chat-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.55);
    pointer-events: none;
}

body.chat-page .chat-drop-overlay__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.4rem 1.8rem;
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.35);
    color: #fff;
    text-align: center;
}

body.chat-page .chat-drop-overlay__card svg {
    width: 36px;
    height: 36px;
}

body.chat-page .chat-drop-overlay__card strong {
    font-size: 0.98rem;
}

body.chat-page .chat-drop-overlay__card span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.75);
}

body.chat-page .thread-stream {
    min-height: 0 !important;
    background: var(--chat-stream-solid) !important;
}

body.chat-page .messages {
    padding: 0.78rem 0.68rem 0.94rem !important;
    /* Ensure the messages pane remains scrollable when running as the chat app shell */
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

body.chat-page .composer {
    border-top: 1px solid var(--chat-border-soft) !important;
    background: var(--chat-panel-solid) !important;
    padding: 0.44rem 0.58rem calc(0.56rem + env(safe-area-inset-bottom, 0px)) !important;
}

body.chat-page .composer-box {
    border-radius: 20px !important;
    border-color: var(--chat-border-soft) !important;
    background: #f2f6fb !important;
}

body.chat-page .composer-entry textarea {
    max-height: 142px;
    min-height: 42px;
}

body.chat-page .chat-mobile-nav {
    border-color: var(--chat-border-soft);
    background: rgba(247, 250, 252, 0.95);
}

@media (max-width: 980px) {
    body.chat-page.chat-mobile-nav-visible {
        --chat-local-nav-height: calc(66px + env(safe-area-inset-bottom, 0px));
    }

    body.chat-page .chat-app {
        min-height: var(--chat-vh, 100dvh) !important;
        height: var(--chat-vh, 100dvh) !important;
    }

    body.chat-page .chat-app__header {
        padding-inline: 0.7rem !important;
    }

    body.chat-page .chat-stage {
        grid-template-columns: 1fr !important;
    }

    body.chat-page .conversation-pane,
    body.chat-page .thread-pane {
        border-inline-end: 0 !important;
        background: var(--chat-panel-solid) !important;
    }

    body.chat-page .thread-head {
        position: sticky;
        top: 0;
        z-index: 8;
    }

    body.chat-page .composer {
        position: sticky;
        bottom: 0;
        z-index: 9;
        padding-bottom: calc(0.52rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height)) !important;
    }

    body.chat-page.chat-keyboard-open {
        --chat-local-nav-height: 0px;
    }

    body.chat-page.chat-keyboard-open .chat-mobile-nav {
        visibility: hidden;
        pointer-events: none;
    }
}

/* Reference-inspired polish layer (original implementation, not a clone) */
body.chat-page {
    --chat-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --chat-ref-bg:
        radial-gradient(circle at 8% 0%, color-mix(in srgb, var(--accent-color) 12%, transparent), transparent 24%),
        radial-gradient(circle at 90% 12%, color-mix(in srgb, var(--accent-color) 8%, transparent), transparent 28%),
        linear-gradient(180deg, color-mix(in srgb, var(--bg-body) 92%, #fff), var(--bg-body-strong));
    --chat-row-height: 74px;
    --chat-soft-line: color-mix(in srgb, var(--border-color) 82%, transparent);
    --chat-soft-surface: color-mix(in srgb, var(--surface-solid) 97%, transparent);
    --chat-soft-muted: color-mix(in srgb, var(--surface-muted) 92%, #fff);
    --chat-thread-bg: color-mix(in srgb, var(--surface-strong) 58%, #fff);
    --chat-bubble-me: color-mix(in srgb, var(--accent-color) 13%, #f7fbff);
    --chat-bubble-peer: color-mix(in srgb, var(--surface-solid) 92%, #fff);
    --chat-nav-glass: color-mix(in srgb, var(--surface-solid) 86%, transparent);
    --chat-shadow-soft: 0 16px 44px -36px rgba(19, 35, 62, 0.22);
    background: var(--chat-ref-bg);
    color: var(--text-primary);
}

body.chat-page .background-overlay {
    background: transparent;
}

body.chat-page .chat-app {
    width: min(1520px, calc(100% - 1.1rem));
    max-width: 1520px;
    min-height: var(--chat-vh, 100dvh);
    height: var(--chat-vh, 100dvh);
    margin: 0 auto;
    padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 0.54rem calc(0.54rem + env(safe-area-inset-bottom, 0px));
    gap: 0.52rem;
}

body.chat-page .chat-app__header {
    position: sticky;
    top: 0;
    z-index: 120;
    border: 1px solid var(--chat-soft-line) !important;
    border-radius: 24px !important;
    background: color-mix(in srgb, var(--surface-solid) 86%, transparent) !important;
    backdrop-filter: blur(18px) saturate(1.05) !important;
    box-shadow: var(--chat-shadow-soft) !important;
    padding: 0.58rem 0.72rem !important;
}

body.chat-page .chat-app__identity h1 {
    font-family: var(--font-accent);
    font-weight: 820;
    letter-spacing: -0.012em;
}

body.chat-page .chat-app__identity p {
    color: var(--text-secondary);
    line-height: 1.6;
}

body.chat-page .chat-back,
body.chat-page .chat-top-btn,
body.chat-page .conversation-pane__icon-btn,
body.chat-page .thread-head__mobile-btn,
body.chat-page .conversation-pane__close {
    background: var(--chat-soft-muted) !important;
    border: 1px solid var(--chat-soft-line) !important;
    box-shadow: none !important;
    transition: transform 0.18s var(--chat-ease), background-color 0.18s ease, border-color 0.18s ease;
}

body.chat-page .chat-back:hover,
body.chat-page .chat-top-btn:hover,
body.chat-page .conversation-pane__icon-btn:hover,
body.chat-page .thread-head__mobile-btn:hover,
body.chat-page .conversation-pane__close:hover,
body.chat-page .chat-back:focus-visible,
body.chat-page .chat-top-btn:focus-visible,
body.chat-page .conversation-pane__icon-btn:focus-visible,
body.chat-page .thread-head__mobile-btn:focus-visible,
body.chat-page .conversation-pane__close:focus-visible {
    transform: translateY(-1px);
    border-color: var(--border-color-strong) !important;
}

body.chat-page .chat-stage {
    border-radius: 26px !important;
    border: 1px solid var(--chat-soft-line) !important;
    background: color-mix(in srgb, var(--surface-solid) 96%, transparent) !important;
    box-shadow: var(--chat-shadow-soft) !important;
    grid-template-columns: minmax(340px, 410px) minmax(0, 1fr);
    gap: 0 !important;
}

body.chat-page .conversation-pane {
    background: linear-gradient(180deg, #fcfdff 0%, #f8fbff 100%) !important;
    border-inline-end: 1px solid var(--chat-soft-line) !important;
}

body.chat-page .thread-pane {
    background: var(--chat-soft-surface) !important;
}

body.chat-page .conversation-pane__header,
body.chat-page .thread-head {
    border-bottom: 1px solid var(--chat-soft-line) !important;
    background: color-mix(in srgb, var(--surface-solid) 91%, #fff) !important;
    backdrop-filter: blur(16px);
}

body.chat-page .conversation-search-wrap input,
body.chat-page .chat-modal__fields input,
body.chat-page .chat-modal__fields textarea,
body.chat-page #edit-text {
    background: color-mix(in srgb, var(--surface-muted) 90%, #fff) !important;
    border-color: var(--chat-soft-line) !important;
    color: var(--text-primary) !important;
    transition: border-color var(--motion-fast, 0.18s) ease, box-shadow var(--motion-fast, 0.18s) ease, background-color var(--motion-fast, 0.18s) ease;
}

body.chat-page .conversation-search-wrap input:focus,
body.chat-page .chat-modal__fields input:focus,
body.chat-page .chat-modal__fields textarea:focus,
body.chat-page #edit-text:focus {
    border-color: color-mix(in srgb, var(--accent-color) 40%, var(--chat-soft-line)) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 14%, transparent) !important;
    background: #fff !important;
}

body.chat-page .conversation-filter-tabs {
    gap: 0.34rem;
    padding-bottom: 0.66rem;
}

body.chat-page .conversation-filter-tab {
    min-height: 34px;
    border-radius: 999px;
    border: 1px solid var(--chat-soft-line);
    background: color-mix(in srgb, var(--surface-muted) 90%, #fff);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    transition: background-color var(--motion-fast, 0.18s) ease, color var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease;
}

body.chat-page .conversation-filter-tab.is-active {
    color: var(--accent-color);
    border-color: color-mix(in srgb, var(--accent-color) 26%, var(--chat-soft-line));
    background: color-mix(in srgb, var(--accent-color) 10%, #fff);
    box-shadow: none;
}

body.chat-page .conversation-list {
    padding: 0 0.56rem 0.74rem;
    gap: 0.08rem;
}

body.chat-page .conversation-item__main {
    min-height: var(--chat-row-height);
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--chat-soft-line) 88%, transparent);
    background: transparent;
    padding: 0.58rem 0.3rem;
    transition: background-color var(--motion-fast, 0.18s) ease, border-color var(--motion-fast, 0.18s) ease;
}

body.chat-page .conversation-item__main::before {
    inset-inline-start: 0;
    inset-block: 10px;
    width: 3px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-color) 70%, #6ea2ff);
    opacity: 0;
    transition: opacity 0.18s ease;
}

body.chat-page .conversation-item__main:hover,
body.chat-page .conversation-item__main:focus-visible {
    background: color-mix(in srgb, var(--accent-color) 4%, transparent);
    border-color: color-mix(in srgb, var(--accent-color) 22%, var(--chat-soft-line));
}

body.chat-page .conversation-item.is-active .conversation-item__main {
    background: color-mix(in srgb, var(--accent-color) 8%, #f8fbff);
    border-color: color-mix(in srgb, var(--accent-color) 26%, var(--chat-soft-line));
    box-shadow: none;
}

body.chat-page .conversation-item.is-active .conversation-item__main::before {
    opacity: 1;
}

body.chat-page .conversation-item__avatar,
body.chat-page .thread-head__avatar {
    border-radius: 50%;
    box-shadow: none;
}

body.chat-page .conversation-item__title {
    color: var(--text-primary);
    font-weight: 780;
}

body.chat-page .conversation-item__preview,
body.chat-page .conversation-item__time,
body.chat-page .conversation-item__subtitle,
body.chat-page .thread-head__copy span {
    color: var(--text-secondary);
}

body.chat-page .thread-stream,
body.chat-page .messages,
body.chat-page .stream-state {
    background:
        radial-gradient(circle at 50% 0, color-mix(in srgb, var(--accent-color) 7%, transparent), transparent 34%),
        linear-gradient(180deg, color-mix(in srgb, var(--chat-thread-bg) 72%, #fff), var(--chat-thread-bg));
}

body.chat-page .messages {
    padding: 0.8rem 0.84rem 1rem !important;
}

body.chat-page .msg-bubble {
    border-color: color-mix(in srgb, var(--border-color) 84%, transparent);
    background: var(--chat-bubble-peer);
    border-radius: 18px;
    box-shadow: 0 8px 18px -16px rgba(17, 36, 63, 0.24);
}

body.chat-page .msg-item.me .msg-bubble {
    background: var(--chat-bubble-me);
    border-color: color-mix(in srgb, var(--accent-color) 20%, var(--border-color));
}

body.chat-page .msg-text {
    direction: rtl;
    unicode-bidi: isolate;
    color: var(--text-primary);
    line-height: 1.78;
}

body.chat-page .msg-foot,
body.chat-page .msg-delivery,
body.chat-page .msg-time,
body.chat-page .msg-name {
    color: var(--text-tertiary);
}

body.chat-page .composer {
    border-top: 1px solid var(--chat-soft-line) !important;
    background: color-mix(in srgb, var(--surface-solid) 88%, transparent) !important;
    backdrop-filter: blur(16px) saturate(1.05);
    padding: 0.46rem 0.62rem calc(0.54rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height, 0px)) !important;
}

body.chat-page .composer-box {
    border-radius: 999px !important;
    background: color-mix(in srgb, var(--surface-muted) 94%, #fff) !important;
    border: 1px solid var(--chat-soft-line) !important;
    box-shadow: none !important;
    padding: 0.24rem;
}

body.chat-page .composer-box:focus-within {
    border-color: color-mix(in srgb, var(--accent-color) 35%, var(--chat-soft-line)) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 10%, transparent) !important;
}

body.chat-page .composer-entry textarea {
    direction: rtl;
    unicode-bidi: isolate;
    min-height: 42px;
    max-height: 172px;
    border: 0;
    border-radius: 999px;
    background: transparent !important;
    color: var(--text-primary);
    padding-inline: 0.72rem;
    line-height: 1.6;
    resize: none;
}

body.chat-page .composer-tool,
body.chat-page .composer-send {
    border-radius: 999px;
    width: 40px;
    height: 40px;
}

body.chat-page .composer-tool {
    background: color-mix(in srgb, var(--surface-muted) 92%, #fff);
    border-color: var(--chat-soft-line);
    color: var(--text-secondary);
}

body.chat-page .composer-send {
    color: var(--text-on-accent);
    background: var(--btn-gradient);
    border-color: transparent;
}

body.chat-page .chat-modal-backdrop,
body.chat-page .chat-sheet-backdrop {
    background: color-mix(in srgb, var(--overlay-backdrop) 86%, transparent);
    backdrop-filter: blur(3px);
}

body.chat-page .chat-modal,
body.chat-page .chat-info-sheet {
    border-radius: 24px !important;
    border: 1px solid var(--chat-soft-line) !important;
    background: color-mix(in srgb, var(--surface-solid) 96%, transparent) !important;
    box-shadow: 0 22px 54px -34px rgba(16, 29, 48, 0.28);
}

body.chat-page .chat-mobile-nav {
    border: 1px solid var(--chat-soft-line);
    background: var(--chat-nav-glass);
    backdrop-filter: blur(20px);
}

body.chat-page .chat-mobile-nav__item {
    min-height: 52px;
    font-weight: 700;
}

body.chat-page .chat-mobile-nav__item.is-active {
    background: color-mix(in srgb, var(--accent-color) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent-color) 24%, var(--chat-soft-line));
    color: var(--accent-strong);
}

@media (max-width: 980px) {
    body.chat-page,
    body.chat-page input,
    body.chat-page select,
    body.chat-page textarea {
        font-size: 16px !important;
    }

    body.chat-page .chat-app {
        width: 100%;
        padding: 0;
        gap: 0;
    }

    body.chat-page .chat-app__header,
    body.chat-page .chat-stage,
    body.chat-page .conversation-pane,
    body.chat-page .thread-pane {
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    body.chat-page .chat-app__header {
        border-inline: 0 !important;
        border-top: 0 !important;
        padding: calc(0.34rem + env(safe-area-inset-top, 0px)) 0.58rem 0.42rem !important;
        background: color-mix(in srgb, var(--surface-solid) 94%, transparent) !important;
    }

    body.chat-page .conversation-list {
        padding: 0 0.44rem calc(0.68rem + var(--chat-local-nav-height));
    }

    body.chat-page .conversation-item__main {
        min-height: 72px;
        padding-inline: 0.12rem;
    }

    body.chat-page .thread-head {
        position: sticky;
        top: 0;
        z-index: 12;
    }

    body.chat-page .messages {
        padding: 0.7rem 0.46rem 0.86rem !important;
    }

    body.chat-page .msg-bubble {
        max-width: 88%;
        border-radius: 16px;
    }

    body.chat-page .composer {
        position: sticky;
        bottom: 0;
        z-index: 14;
    }

    body.chat-page .composer-box {
        border-radius: 20px !important;
    }

    body.chat-page .composer-entry textarea {
        border-radius: 14px;
    }

    body.chat-page.chat-keyboard-open .composer,
    body.chat-page.chat-keyboard-open .conversation-pane,
    body.chat-page.chat-keyboard-open .thread-pane {
        transition: none !important;
    }

    body.chat-page .chat-modal {
        inset-inline: 0.54rem;
        inset-block-end: calc(0.52rem + env(safe-area-inset-bottom, 0px));
        max-height: min(82vh, 680px);
        border-radius: 22px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.chat-page *,
    body.chat-page *::before,
    body.chat-page *::after {
        transition: none !important;
        animation: none !important;
    }
}

html[data-performance-mode="lite"] body.chat-page .messages {
    scroll-behavior: auto;
}

html[data-performance-mode="lite"] body.chat-page .msg-item.is-new {
    animation: none;
}

html[data-performance-mode="lite"] body.chat-page .chat-modal,
html[data-performance-mode="lite"] body.chat-page .chat-modal-backdrop,
html[data-performance-mode="lite"] body.chat-page .chat-sheet-backdrop,
html[data-performance-mode="lite"] body.chat-page .chat-context-backdrop,
html[data-performance-mode="lite"] body.chat-page .chat-list-context-backdrop,
html[data-performance-mode="lite"] body.chat-page .chat-context-menu,
html[data-performance-mode="lite"] body.chat-page .chat-list-context-menu,
html[data-performance-mode="lite"] body.chat-page .chat-info-sheet,
html[data-performance-mode="lite"] body.chat-page .composer-upload-sheet,
html[data-performance-mode="lite"] body.chat-page .chat-mobile-nav {
    backdrop-filter: none !important;
}

/* Bale-style flat chat shell. Keep this final so earlier redesign layers cannot collapse mobile. */
body.chat-page {
    --chat-bale-line: color-mix(in srgb, var(--border-color) 78%, transparent);
    --chat-bale-ink: var(--text-primary);
    --chat-bale-muted: var(--text-secondary);
    --chat-bale-soft: var(--surface-muted);
    --chat-bale-green: var(--success-color);
    --chat-local-nav-height: 78px;
    background: var(--bg-body) !important;
    color: var(--chat-bale-ink) !important;
}

body.chat-page .background-overlay,
body.chat-page .chat-app::before {
    display: none !important;
}

body.chat-page .chat-app {
    width: min(1366px, 100%) !important;
    max-width: 1366px !important;
    min-height: var(--chat-vh, 100dvh) !important;
    height: var(--chat-vh, 100dvh) !important;
    padding: 0 !important;
    gap: 0 !important;
    background: var(--surface-solid) !important;
}

body.chat-page .chat-app__header {
    min-height: 60px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--chat-bale-line) !important;
    border-radius: 0 !important;
    background: var(--surface-solid) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body.chat-page .conversation-pane__header-actions {
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

body.chat-page .chat-stage {
    height: calc(var(--chat-vh, 100dvh) - 61px) !important;
    min-height: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--surface-solid) !important;
    box-shadow: none !important;
    overflow: hidden !important;
    grid-template-columns: minmax(340px, 400px) minmax(0, 1fr) !important;
}

body.chat-page .conversation-pane,
body.chat-page .thread-pane {
    min-height: 0 !important;
    height: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--surface-solid) !important;
    box-shadow: none !important;
}

body.chat-page .conversation-pane {
    border-inline-start: 1px solid var(--chat-bale-line) !important;
}

body.chat-page .conversation-pane__header,
body.chat-page .thread-head {
    min-height: 68px !important;
    padding: 0.74rem 1rem !important;
    border-bottom: 1px solid var(--chat-bale-line) !important;
    background: var(--surface-solid) !important;
    backdrop-filter: none !important;
}

body.chat-page .conversation-pane__title-block h2,
body.chat-page .thread-head__copy strong {
    color: var(--chat-bale-ink) !important;
    font-size: 1rem !important;
    font-weight: 800 !important;
    letter-spacing: 0 !important;
}

body.chat-page .conversation-pane__title-block p,
body.chat-page .thread-head__copy span {
    color: var(--chat-bale-muted) !important;
    font-size: 0.78rem !important;
}

body.chat-page .chat-back,
body.chat-page .chat-top-btn,
body.chat-page .conversation-pane__icon-btn,
body.chat-page .conversation-pane__close,
body.chat-page .thread-head__mobile-btn,
body.chat-page .chat-sheet-close {
    width: 40px !important;
    height: 40px !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: var(--chat-bale-muted) !important;
    box-shadow: none !important;
}

body.chat-page .conversation-search-wrap {
    padding: 0.6rem 0.72rem 0.35rem !important;
}

body.chat-page .conversation-search-wrap input {
    min-height: 48px !important;
    border: 1px solid var(--chat-bale-line) !important;
    border-radius: 16px !important;
    background: var(--chat-bale-soft) !important;
    color: var(--chat-bale-ink) !important;
    box-shadow: none !important;
}

body.chat-page .conversation-filter-tabs {
    display: flex !important;
    gap: 0 !important;
    min-height: 50px !important;
    padding: 0 0.44rem !important;
    border-bottom: 1px solid var(--chat-bale-line) !important;
    overflow-x: auto !important;
}

body.chat-page .conversation-filter-tab {
    position: relative !important;
    min-width: max-content !important;
    min-height: 50px !important;
    padding: 0 0.78rem !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--chat-bale-muted) !important;
    box-shadow: none !important;
    font-size: 0.82rem !important;
    font-weight: 760 !important;
}

body.chat-page .conversation-filter-tab.is-active {
    color: var(--chat-bale-green) !important;
}

body.chat-page .conversation-filter-tab.is-active::after {
    content: "";
    position: absolute;
    inset-inline: 0.62rem;
    bottom: 0;
    height: 3px;
    border-radius: 999px 999px 0 0;
    background: var(--chat-bale-green);
}

body.chat-page .conversation-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    overflow: auto !important;
}

body.chat-page .conversation-item {
    padding: 0 !important;
}

body.chat-page .conversation-item__main {
    min-height: 76px !important;
    grid-template-columns: 56px minmax(0, 1fr) auto !important;
    gap: 0.72rem !important;
    padding: 0.62rem 0.88rem !important;
    border: 0 !important;
    border-bottom: 1px solid var(--chat-bale-line) !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

body.chat-page .conversation-item.is-active .conversation-item__main,
body.chat-page .conversation-item__main:hover,
body.chat-page .conversation-item__main:focus-visible {
    background: color-mix(in srgb, var(--accent-color) 9%, var(--surface-solid)) !important;
}

body.chat-page .conversation-item__main::before,
body.chat-page .conversation-item__kind {
    display: none !important;
}

body.chat-page .conversation-item__avatar,
body.chat-page .thread-head__avatar {
    width: 56px !important;
    height: 56px !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: color-mix(in srgb, var(--accent-color) 70%, #ffffff) !important;
    color: var(--text-on-accent) !important;
    box-shadow: none !important;
}

body.chat-page .conversation-item__title {
    color: var(--chat-bale-ink) !important;
    font-size: 0.96rem !important;
    font-weight: 800 !important;
    line-height: 1.45 !important;
}

body.chat-page .conversation-item__preview,
body.chat-page .conversation-item__subtitle,
body.chat-page .conversation-item__time {
    color: var(--chat-bale-muted) !important;
    font-size: 0.78rem !important;
    line-height: 1.5 !important;
}

body.chat-page .conversation-item__unread {
    min-width: 22px !important;
    height: 22px !important;
    border-radius: 999px !important;
    background: var(--chat-bale-green) !important;
    color: var(--text-on-accent) !important;
    box-shadow: none !important;
}

body.chat-page .thread-stream,
body.chat-page .messages,
body.chat-page .stream-state {
    background: var(--bg-body) !important;
}

body.chat-page .msg-bubble {
    border: 1px solid var(--chat-bale-line) !important;
    border-radius: 18px !important;
    background: var(--surface-solid) !important;
    box-shadow: none !important;
}

body.chat-page .msg-item.me .msg-bubble {
    background: color-mix(in srgb, var(--accent-color) 12%, var(--surface-solid)) !important;
    border-color: color-mix(in srgb, var(--accent-color) 26%, var(--chat-bale-line)) !important;
}

body.chat-page .composer {
    border-top: 1px solid var(--chat-bale-line) !important;
    background: var(--surface-solid) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body.chat-page .composer-box {
    min-height: 54px !important;
    border: 1px solid var(--chat-bale-line) !important;
    border-radius: 28px !important;
    background: var(--chat-bale-soft) !important;
    box-shadow: none !important;
}

body.chat-page .composer-entry textarea {
    color: var(--chat-bale-ink) !important;
}

body.chat-page .chat-mobile-nav {
    border: 1px solid var(--chat-bale-line) !important;
    border-radius: 26px !important;
    background: color-mix(in srgb, var(--surface-solid) 94%, transparent) !important;
    box-shadow: 0 12px 30px -24px rgba(19, 35, 62, 0.28) !important;
    backdrop-filter: blur(18px) !important;
}

body.chat-page .chat-mobile-nav__item {
    color: var(--chat-bale-muted) !important;
}

body.chat-page .chat-mobile-nav__item.is-active {
    border-color: color-mix(in srgb, var(--accent-color) 30%, var(--chat-bale-line)) !important;
    background: color-mix(in srgb, var(--accent-color) 12%, var(--surface-solid)) !important;
    color: var(--accent-strong) !important;
}

@media (max-width: 980px) {
    body.chat-page .chat-app {
        width: 100% !important;
        max-width: none !important;
        overflow: hidden !important;
    }

    body.chat-page .chat-app__header {
        display: none !important;
    }

    body.chat-page .chat-app__main,
    body.chat-page .chat-stage {
        display: block !important;
        width: 100% !important;
        height: calc(var(--chat-vh, 100dvh) - var(--chat-local-nav-height)) !important;
        min-height: calc(var(--chat-vh, 100dvh) - var(--chat-local-nav-height)) !important;
        overflow: hidden !important;
    }

    body.chat-page .conversation-pane,
    body.chat-page .thread-pane {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: calc(var(--chat-vh, 100dvh) - var(--chat-local-nav-height)) !important;
        min-height: calc(var(--chat-vh, 100dvh) - var(--chat-local-nav-height)) !important;
        transition: transform 0.2s ease, opacity 0.2s ease !important;
    }

    body.chat-page .chat-app[data-mobile-view="list"] .conversation-pane {
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: translateX(0) !important;
    }

    body.chat-page .chat-app[data-mobile-view="list"] .thread-pane {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateX(-100%) !important;
    }

    body.chat-page .chat-app[data-mobile-view="thread"] .conversation-pane {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateX(100%) !important;
    }

    body.chat-page .chat-app[data-mobile-view="thread"] .thread-pane {
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: translateX(0) !important;
    }

    body.chat-page .conversation-pane__header,
    body.chat-page .thread-head {
        min-height: 86px !important;
        padding: calc(1rem + env(safe-area-inset-top, 0px)) 1rem 0.74rem !important;
    }

    body.chat-page .conversation-pane__title-block h2 {
        font-size: 1.15rem !important;
    }

    body.chat-page .conversation-pane__title-block p {
        display: none !important;
    }

    body.chat-page .conversation-pane__header-actions {
        gap: 0.22rem !important;
    }

    body.chat-page #mobile-home-link,
    body.chat-page #conversation-manage-btn,
    body.chat-page #mobile-close-list,
    body.chat-page #thread-home-link,
    body.chat-page #refresh-btn {
        display: none !important;
    }

    body.chat-page .conversation-search-wrap {
        padding-inline: 1rem !important;
    }

    body.chat-page .conversation-filter-tabs {
        padding-inline: 0.82rem !important;
    }

    body.chat-page .conversation-list {
        padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.chat-page .conversation-item__main {
        grid-template-columns: 58px minmax(0, 1fr) auto !important;
        min-height: 78px !important;
        padding-inline: 1rem !important;
    }

    body.chat-page .conversation-item__avatar {
        width: 58px !important;
        height: 58px !important;
    }

    body.chat-page .thread-stream {
        min-height: 0 !important;
    }

    body.chat-page .messages {
        padding: 0.72rem 0.62rem 0.9rem !important;
    }

    body.chat-page .composer {
        position: sticky !important;
        bottom: 0 !important;
        padding: 0.5rem 0.58rem calc(0.56rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.chat-page .composer-box {
        border-radius: 24px !important;
    }

    body.chat-page .chat-mobile-nav {
        left: 8px !important;
        right: 8px !important;
        bottom: calc(5px + env(safe-area-inset-bottom, 0px)) !important;
        min-height: 64px !important;
        padding: 0.26rem !important;
    }
}

/* Final messenger chrome alignment: flat bars, compact chat bottom, site tokens. */
body.chat-page {
    --chat-bale-line: color-mix(in srgb, var(--border-color) 70%, transparent);
    --chat-bale-soft: color-mix(in srgb, var(--surface-muted) 96%, var(--surface-solid));
    --chat-bale-thread: color-mix(in srgb, var(--bg-body) 82%, var(--surface-solid));
    --chat-local-nav-height: 74px;
}

body.chat-page .thread-head__identity {
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

body.chat-page .thread-head__copy {
    gap: 0 !important;
}

body.chat-page .thread-head__copy strong {
    line-height: 1.28 !important;
}

body.chat-page .thread-head__copy span {
    line-height: 1.35 !important;
}

body.chat-page .thread-stream,
body.chat-page .messages,
body.chat-page .stream-state {
    background: var(--chat-bale-thread) !important;
}

body.chat-page .messages {
    scrollbar-gutter: stable;
}

body.chat-page .msg-bubble {
    border-color: color-mix(in srgb, var(--border-color) 64%, transparent) !important;
    box-shadow: 0 6px 14px -14px rgba(17, 35, 60, 0.22) !important;
}

body.chat-page .msg-item.me .msg-bubble {
    background: color-mix(in srgb, var(--accent-color) 14%, var(--surface-solid)) !important;
}

body.chat-page .composer {
    border-top: 1px solid var(--chat-bale-line) !important;
    background: color-mix(in srgb, var(--surface-solid) 97%, transparent) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body.chat-page .composer-box {
    border-color: var(--chat-bale-line) !important;
    background: var(--chat-bale-soft) !important;
    box-shadow: none !important;
}

body.chat-page .composer-box:focus-within {
    border-color: color-mix(in srgb, var(--accent-color) 34%, var(--chat-bale-line)) !important;
    box-shadow: 0 0 0 3px var(--focus-ring-soft) !important;
}

body.chat-page .composer-entry textarea {
    font-size: 16px !important;
}

body.chat-page:not(.chat-composer-has-draft) .composer-send {
    display: none !important;
}

body.chat-page .composer-storage-note {
    display: none !important;
}

@media (min-width: 981px) {
    body.chat-page .chat-app {
        max-width: none !important;
    }

    body.chat-page .chat-stage {
        grid-template-columns: minmax(330px, 390px) minmax(0, 1fr) !important;
    }

    body.chat-page .conversation-pane {
        border-inline-start: 1px solid var(--chat-bale-line) !important;
    }

    body.chat-page .thread-head {
        min-height: 64px !important;
        padding: 0.54rem 0.8rem !important;
    }

    body.chat-page .thread-head__avatar {
        width: 48px !important;
        height: 48px !important;
    }

    body.chat-page .composer {
        padding: 0.42rem 0.56rem 0.5rem !important;
    }

    body.chat-page .composer-box {
        min-height: 50px !important;
        border-radius: 999px !important;
    }
}

@media (max-width: 980px) {
    body.chat-page {
        --chat-local-nav-height: 72px;
    }

    body.chat-page .conversation-pane__header,
    body.chat-page .thread-head {
        min-height: calc(74px + env(safe-area-inset-top, 0px)) !important;
        padding: calc(0.76rem + env(safe-area-inset-top, 0px)) 0.86rem 0.56rem !important;
        border-bottom: 1px solid var(--chat-bale-line) !important;
        background: var(--surface-solid) !important;
    }

    body.chat-page .conversation-pane__header {
        grid-template-columns: minmax(0, 1fr) auto !important;
    }

    body.chat-page .conversation-pane__title-block h2 {
        font-size: 1.12rem !important;
        line-height: 1.22 !important;
    }

    body.chat-page .conversation-pane__header-actions {
        gap: 0.42rem !important;
    }

    body.chat-page .chat-back,
    body.chat-page .chat-top-btn,
    body.chat-page .conversation-pane__icon-btn,
    body.chat-page .conversation-pane__close,
    body.chat-page .thread-head__mobile-btn,
    body.chat-page .chat-sheet-close {
        width: 38px !important;
        height: 38px !important;
    }

    body.chat-page .chat-app[data-mobile-view="thread"] .chat-app__main,
    body.chat-page .chat-app[data-mobile-view="thread"] .chat-stage,
    body.chat-page .chat-app[data-mobile-view="thread"] .conversation-pane,
    body.chat-page .chat-app[data-mobile-view="thread"] .thread-pane {
        height: calc(var(--chat-vh, 100dvh) - var(--chat-local-nav-height)) !important;
        min-height: calc(var(--chat-vh, 100dvh) - var(--chat-local-nav-height)) !important;
    }

    body.chat-page .conversation-search-wrap {
        padding: 0.62rem 1rem 0.34rem !important;
    }

    body.chat-page .conversation-search-wrap input {
        min-height: 46px !important;
        border-radius: 18px !important;
        font-size: 16px !important;
    }

    body.chat-page .conversation-filter-tabs {
        min-height: 48px !important;
        padding-inline: 0.9rem !important;
    }

    body.chat-page .conversation-filter-tab {
        min-height: 48px !important;
        font-size: 0.86rem !important;
    }

    body.chat-page .conversation-item.is-active .conversation-item__main {
        background: transparent !important;
    }

    body.chat-page .conversation-item__main {
        min-height: 76px !important;
        padding-inline: 0.9rem !important;
    }

    body.chat-page .thread-head {
        grid-template-columns: 40px minmax(0, 1fr) auto !important;
        gap: 0.56rem !important;
    }

    body.chat-page .thread-head__avatar {
        width: 48px !important;
        height: 48px !important;
    }

    body.chat-page .thread-head__copy strong {
        font-size: 1rem !important;
    }

    body.chat-page .thread-head__copy span {
        font-size: 0.78rem !important;
    }

    body.chat-page #thread-home-link {
        display: none !important;
    }

    body.chat-page #refresh-btn {
        display: inline-flex !important;
    }

    body.chat-page .thread-stream {
        background: var(--chat-bale-thread) !important;
    }

    body.chat-page .messages {
        padding: 0.74rem 0.64rem 0.78rem !important;
    }

    body.chat-page .msg-bubble {
        max-width: 86% !important;
        border-radius: 18px !important;
    }

    body.chat-page .composer {
        position: sticky !important;
        bottom: 0 !important;
        z-index: 18 !important;
        padding: 0 0 env(safe-area-inset-bottom, 0px) !important;
    }

    body.chat-page .composer-box {
        width: 100% !important;
        min-height: 58px !important;
        padding: 0.36rem 0.62rem !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: var(--surface-solid) !important;
        grid-template-columns: auto minmax(0, 1fr) auto !important;
        align-items: center !important;
        gap: 0.24rem !important;
    }

    body.chat-page .composer-tool,
    body.chat-page .composer-send {
        width: 42px !important;
        height: 42px !important;
        border-radius: 999px !important;
    }

    body.chat-page .composer-tool {
        border-color: transparent !important;
        background: transparent !important;
    }

    body.chat-page .composer-send {
        grid-column: auto !important;
        grid-row: auto !important;
        align-self: center !important;
        justify-self: center !important;
        box-shadow: none !important;
    }

    body.chat-page .composer-entry textarea {
        min-height: 42px !important;
        padding: 0.46rem 0.58rem !important;
        border-radius: 999px !important;
        line-height: 1.55 !important;
        background: var(--surface-muted) !important;
    }

    body.chat-page .chat-mobile-nav {
        left: 8px !important;
        right: 8px !important;
        bottom: calc(4px + env(safe-area-inset-bottom, 0px)) !important;
        min-height: 62px !important;
        border-radius: 28px !important;
    }
}

/* Bale-like messenger pass: clean chrome, inline media, receipts, and profile content. */
body.chat-page {
    --chat-bale-green: #0aa37f;
    --chat-bale-green-soft: color-mix(in srgb, var(--chat-bale-green) 15%, transparent);
    --chat-bale-blue: #4f7df3;
    --chat-bale-bg: #f4f7fb;
    --chat-bale-surface: #ffffff;
    --chat-bale-surface-soft: #f8fafc;
    --chat-bale-surface-strong: #edf1f7;
    --chat-bale-text: #172033;
    --chat-bale-muted: #738097;
    --chat-bale-line-strong: color-mix(in srgb, var(--border-color) 82%, transparent);
    --chat-bale-shadow: 0 10px 28px -24px rgba(17, 35, 60, 0.22);
    background: var(--chat-bale-bg);
    color: var(--chat-bale-text);
}

html[data-theme="dark"] body.chat-page {
    --chat-bale-bg: #101720;
    --chat-bale-surface: #18222e;
    --chat-bale-surface-soft: #121b25;
    --chat-bale-surface-strong: #1f2d3d;
    --chat-bale-text: #eef4fb;
    --chat-bale-muted: #a0afbf;
    --chat-bale-line-strong: rgba(139, 159, 182, 0.2);
    --chat-bale-shadow: 0 16px 34px -28px rgba(0, 0, 0, 0.78);
}

body.chat-page * {
    letter-spacing: 0 !important;
}

body.chat-page .background-overlay {
    background: var(--chat-bale-bg) !important;
}

body.chat-page .chat-app::before {
    display: none !important;
}

body.chat-page .chat-app__header,
body.chat-page .chat-login-panel,
body.chat-page .chat-stage,
body.chat-page .conversation-pane,
body.chat-page .thread-pane,
body.chat-page .thread-head,
body.chat-page .conversation-pane__header {
    background: var(--chat-bale-surface) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body.chat-page .chat-login-title,
body.chat-page .chat-login-head {
    color: var(--chat-bale-text) !important;
}

body.chat-page .chat-login-text,
body.chat-page #msg {
    color: var(--chat-bale-muted) !important;
}

body.chat-page .chat-login-panel {
    border-color: var(--chat-bale-line-strong) !important;
}

body.chat-page .conversation-filter-tab.is-active {
    color: var(--chat-bale-green) !important;
}

body.chat-page .conversation-filter-tab.is-active::after {
    background: var(--chat-bale-green) !important;
}

body.chat-page .conversation-item__main {
    border-radius: 0 !important;
    box-shadow: none !important;
}

body.chat-page .conversation-item.is-active .conversation-item__main {
    background: color-mix(in srgb, var(--chat-bale-blue) 12%, var(--chat-bale-surface)) !important;
}

body.chat-page .thread-stream,
body.chat-page .messages,
body.chat-page .stream-state {
    background: color-mix(in srgb, var(--chat-bale-bg) 82%, var(--chat-bale-surface)) !important;
}

body.chat-page .msg-bubble {
    border: 1px solid var(--chat-bale-line-strong) !important;
    background: var(--chat-bale-surface) !important;
    box-shadow: var(--chat-bale-shadow) !important;
}

body.chat-page .msg-item.me .msg-bubble {
    background: color-mix(in srgb, var(--chat-bale-blue) 14%, var(--chat-bale-surface)) !important;
    border-color: color-mix(in srgb, var(--chat-bale-blue) 38%, var(--chat-bale-line-strong)) !important;
}

body.chat-page .msg-delivery-btn {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    padding: 0;
}

body.chat-page .msg-delivery-btn:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: 999px;
}

body.chat-page .msg-link-previews {
    display: grid;
    gap: 0.42rem;
    margin-top: 0.48rem;
}

body.chat-page .msg-item.is-important-mention .msg-bubble {
    border-color: color-mix(in srgb, var(--chat-warning) 42%, var(--chat-border-strong));
    box-shadow: 0 16px 28px rgba(0, 0, 0, 0.18), 0 0 0 1px color-mix(in srgb, var(--chat-warning) 22%, transparent);
}

body.chat-page .msg-important-mention {
    display: inline-flex;
    align-items: center;
    margin: 0 0 0.42rem;
    padding: 0.22rem 0.62rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-warning) 16%, transparent);
    color: var(--chat-warning);
    font-size: 0.62rem;
    font-weight: 860;
}

body.chat-page .msg-card {
    width: 100%;
    display: grid;
    gap: 0.32rem;
    margin: 0 0 0.42rem;
    padding: 0.78rem 0.84rem;
    border: 1px solid var(--chat-border-strong);
    border-radius: 18px;
    background: color-mix(in srgb, var(--chat-surface) 88%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body.chat-page .msg-card--route {
    border-inline-end: 3px solid color-mix(in srgb, var(--chat-accent) 58%, var(--chat-border-strong));
}

body.chat-page .msg-card--task {
    border-inline-end: 3px solid color-mix(in srgb, var(--chat-warning) 58%, var(--chat-border-strong));
}

body.chat-page .msg-card--task.is-tone-important {
    border-inline-end-color: color-mix(in srgb, var(--chat-warning) 78%, var(--chat-border-strong));
}

body.chat-page .msg-card--task.is-tone-urgent {
    border-inline-end-color: color-mix(in srgb, var(--chat-danger) 78%, var(--chat-border-strong));
}

body.chat-page .msg-card.is-preview {
    background: color-mix(in srgb, var(--chat-surface) 76%, transparent);
    border-style: dashed;
}

body.chat-page .msg-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    flex-wrap: wrap;
}

body.chat-page .msg-card__badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.52rem;
    padding: 0.12rem 0.62rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-accent) 18%, transparent);
    color: var(--chat-accent);
    font-size: 0.64rem;
    font-weight: 860;
}

body.chat-page .msg-card--task .msg-card__badge {
    background: color-mix(in srgb, var(--chat-warning) 18%, transparent);
    color: var(--chat-warning);
}

body.chat-page .msg-card--task.is-tone-urgent .msg-card__badge {
    background: color-mix(in srgb, var(--chat-danger) 18%, transparent);
    color: var(--chat-danger);
}

body.chat-page .msg-card__meta {
    color: var(--chat-muted);
    font-size: 0.64rem;
    line-height: 1.6;
}

body.chat-page .msg-card__title {
    color: var(--chat-text);
    font-size: 0.82rem;
    line-height: 1.55;
}

body.chat-page .msg-card__text {
    margin: 0;
    color: var(--chat-muted-strong);
    font-size: 0.74rem;
    line-height: 1.75;
}

body.chat-page .msg-card__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 2rem;
    padding: 0.18rem 0.84rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-accent) 16%, transparent);
    color: var(--chat-accent);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 820;
}

body.chat-page .msg-card__cta:hover,
body.chat-page .msg-card__cta:focus-visible {
    background: color-mix(in srgb, var(--chat-accent) 24%, transparent);
    outline: 0;
}

body.chat-page .msg-link-preview {
    display: grid;
    grid-template-columns: 4px minmax(0, 1fr);
    gap: 0.55rem;
    padding: 0.58rem 0.64rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 8px;
    background: color-mix(in srgb, var(--chat-bale-surface-soft) 92%, transparent);
    color: inherit;
    text-decoration: none;
}

body.chat-page .msg-link-preview__rail {
    border-radius: 999px;
    background: var(--chat-bale-green);
}

body.chat-page .msg-link-preview__copy {
    min-width: 0;
    display: grid;
    gap: 0.16rem;
}

body.chat-page .msg-link-preview strong,
body.chat-page .msg-link-preview small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.chat-page .msg-link-preview small {
    color: var(--chat-bale-muted);
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
}

body.chat-page .msg-attachment__media-btn {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
    text-align: inherit;
}

body.chat-page .msg-attachment__media {
    border: 1px solid var(--chat-border);
    background: rgba(5, 10, 18, 0.88);
}

body.chat-page .msg-media-album__tile {
    background: rgba(5, 10, 18, 0.92);
}

body.chat-page .chat-media-viewer {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    grid-template-rows: 1fr auto;
    place-items: center;
    padding: calc(1rem + env(safe-area-inset-top, 0px)) 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, 0.84);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
}

body.chat-page .chat-media-viewer.is-open {
    opacity: 1;
    pointer-events: auto;
}

body.chat-page .chat-media-viewer[hidden] {
    display: none !important;
}

body.chat-page .chat-media-viewer__stage {
    width: min(100%, 980px);
    height: min(78dvh, 820px);
    display: grid;
    place-items: center;
    transition:
        transform var(--motion-fast) var(--motion-ease-standard),
        opacity var(--motion-fast) var(--motion-ease-standard);
    will-change: transform, opacity;
    touch-action: pan-y;
}

body.chat-page .chat-media-viewer__stage.is-dragging {
    transition: none;
}

body.chat-page .chat-media-viewer__stage.is-settling {
    pointer-events: none;
}

body.chat-page .chat-media-viewer__stage img,
body.chat-page .chat-media-viewer__stage video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    background: #000;
}

body.chat-page .chat-media-viewer__close {
    position: fixed;
    top: calc(0.8rem + env(safe-area-inset-top, 0px));
    inset-inline-start: 0.8rem;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.44);
    color: #fff;
}

body.chat-page .chat-media-viewer__meta {
    position: fixed;
    z-index: 1110;
    top: calc(0.8rem + env(safe-area-inset-top, 0px));
    inset-inline-start: calc(0.8rem + 44px + 0.6rem);
    inset-inline-end: calc(0.8rem + (44px + 0.5rem) * 4);
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.1rem;
    overflow: hidden;
    color: #fff;
    pointer-events: none;
}

body.chat-page .chat-media-viewer__meta-name {
    font-size: 0.86rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.chat-page .chat-media-viewer__meta-time {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.7);
}

body.chat-page .chat-media-viewer__actions {
    position: fixed;
    z-index: 1110;
    top: calc(0.8rem + env(safe-area-inset-top, 0px));
    inset-inline-end: 0.8rem;
    display: flex;
    gap: 0.5rem;
}

body.chat-page .chat-media-viewer__action {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.44);
    color: #fff;
}

body.chat-page .chat-media-viewer__action svg {
    width: 22px;
    height: 22px;
}

body.chat-page .chat-media-viewer__action--danger {
    color: #ff7a7a;
}

body.chat-page .chat-media-viewer__caption {
    max-width: min(100%, 980px);
    color: #fff;
    text-align: center;
    line-height: 1.75;
}

body.chat-page .chat-image-editor {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: rgba(0, 0, 0, 0.92);
    padding: calc(0.8rem + env(safe-area-inset-top, 0px)) 0.8rem calc(0.8rem + env(safe-area-inset-bottom, 0px));
}

body.chat-page .chat-image-editor__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

body.chat-page .chat-image-editor__icon-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

body.chat-page .chat-image-editor__icon-btn svg {
    width: 22px;
    height: 22px;
}

body.chat-page .chat-image-editor__icon-btn--primary {
    background: var(--chat-accent);
    border-color: transparent;
    color: #0b1320;
}

body.chat-page .chat-image-editor__tools {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    flex: 1;
    gap: 0.4rem;
}

body.chat-page .chat-image-editor__tool {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    height: 40px;
    padding: 0 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

body.chat-page .chat-image-editor__tool svg {
    width: 19px;
    height: 19px;
}

body.chat-page .chat-image-editor__tool.is-active {
    background: var(--chat-accent);
    border-color: transparent;
    color: #0b1320;
}

body.chat-page .chat-image-editor__filter-label {
    font-size: 0.78rem;
    white-space: nowrap;
}

body.chat-page .chat-image-editor__stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
}

body.chat-page .chat-image-editor__stage canvas {
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
    border-radius: 0.4rem;
}

body.chat-page .chat-image-editor__crop-box {
    position: absolute;
    border: 2px dashed #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

body.chat-page .chat-image-editor__crop-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--chat-accent);
    transform: translate(-50%, -50%);
    touch-action: none;
}

body.chat-page .chat-image-editor__crop-handle[data-handle="nw"] {
    top: 0;
    left: 0;
}

body.chat-page .chat-image-editor__crop-handle[data-handle="ne"] {
    top: 0;
    left: 100%;
}

body.chat-page .chat-image-editor__crop-handle[data-handle="sw"] {
    top: 100%;
    left: 0;
}

body.chat-page .chat-image-editor__crop-handle[data-handle="se"] {
    top: 100%;
    left: 100%;
}

body.chat-page .chat-image-editor__draw-options {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

body.chat-page .chat-image-editor__color {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

body.chat-page .chat-image-editor__color.is-selected {
    border-color: #fff;
}

@media (max-width: 980px) {
    body.chat-page .chat-image-editor__icon-btn {
        width: 38px;
        height: 38px;
    }

    body.chat-page .chat-image-editor__icon-btn svg {
        width: 19px;
        height: 19px;
    }

    body.chat-page .chat-image-editor__tool {
        height: 36px;
        padding: 0 0.55rem;
    }

    body.chat-page .chat-image-editor__filter-label {
        display: none;
    }
}

body.chat-page .group-kind-control label {
    min-height: 38px;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 8px;
    background: var(--chat-bale-surface-soft);
    color: var(--chat-bale-text);
    font-weight: 800;
}

body.chat-page .chat-info-content-tabs {
    display: flex;
    gap: 0.1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--chat-border);
}

body.chat-page .chat-info-content-tabs button {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    min-height: 32px;
    padding: 0.2rem 0.2rem;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--chat-muted);
}

body.chat-page .chat-info-content-tabs button {
    font-size: 0.72rem;
    font-weight: 760;
}

body.chat-page .chat-info-content-tabs button span {
    font-size: 0.64rem;
    color: inherit;
    opacity: 0.6;
}

body.chat-page .chat-info-content-tabs button.is-active {
    border-bottom-color: var(--chat-accent);
    color: var(--chat-accent);
}

body.chat-page .chat-info-content-tabs button.is-active span {
    opacity: 0.85;
}

body.chat-page .chat-info-content-table,
body.chat-page .receipt-section {
    display: grid;
    gap: 0.42rem;
}

body.chat-page .chat-info-content-row,
body.chat-page .receipt-row {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    min-height: 48px;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 8px;
    background: var(--chat-bale-surface-soft);
    color: inherit;
    text-align: start;
    text-decoration: none;
}

body.chat-page .chat-info-content-row span {
    min-width: 0;
}

body.chat-page .chat-info-content-row strong,
body.chat-page .chat-info-content-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.chat-page .chat-info-content-row small,
body.chat-page .chat-info-content-row em,
body.chat-page .receipt-row small {
    color: var(--chat-bale-muted);
    font-style: normal;
    font-size: 0.76rem;
}

body.chat-page .chat-info-empty {
    grid-column: 1 / -1;
    color: var(--chat-bale-muted);
    padding: 0.72rem 0.2rem;
    text-align: center;
}

body.chat-page .chat-info-content-table--grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.16rem;
}

body.chat-page .chat-info-content-table--grid .msg-attachment__media-btn {
    width: 100%;
}

body.chat-page .chat-info-content-table--grid .msg-attachment__media {
    border-radius: 6px;
    aspect-ratio: 1 / 1;
}

body.chat-page .chat-info-content-table--grid .msg-attachment__media img,
body.chat-page .chat-info-content-table--grid .msg-attachment__media video {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
}

body.chat-page .chat-info-media-cell--placeholder {
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    padding: 0.4rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 6px;
    background: var(--chat-bale-surface-soft);
    color: var(--chat-bale-muted);
    font-size: 0.7rem;
    text-align: center;
}

body.chat-page .chat-info-media-cell--placeholder span {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

body.chat-page .chat-member-tag {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0.1rem 0.44rem;
    border-radius: 999px;
    background: var(--chat-bale-green-soft);
    color: var(--chat-bale-green);
    font-size: 0.72rem;
    font-weight: 850;
}

body.chat-page .group-kind-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    border: 0;
}

body.chat-page .group-kind-control legend {
    grid-column: 1 / -1;
    color: var(--chat-bale-muted);
    font-size: 0.8rem;
    font-weight: 800;
}

body.chat-page .group-kind-control label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding-inline: 0.7rem;
}

body.chat-page .group-kind-control input {
    accent-color: var(--chat-bale-green);
}

body.chat-page .receipt-section > strong {
    color: var(--chat-bale-muted);
    font-size: 0.82rem;
}

body.chat-page .receipt-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
}

body.chat-page .receipt-row__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--chat-bale-blue) 18%, var(--chat-bale-surface));
    color: var(--chat-bale-blue);
    font-weight: 850;
}

body.chat-page .receipt-row__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body.chat-page .receipt-row__copy {
    min-width: 0;
    display: grid;
}

body.chat-page .receipt-row__copy strong,
body.chat-page .receipt-row__copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.chat-page .receipt-row__state {
    color: var(--chat-bale-muted);
    font-size: 0.76rem;
    font-weight: 850;
}

body.chat-page .receipt-row__state.is-seen {
    color: var(--chat-bale-green);
}

body.chat-page .reaction-detail-row__emoji {
    font-size: 1.05rem;
    line-height: 1;
}

body.chat-page .chat-options-stack {
    display: grid;
    gap: 0.5rem;
}

body.chat-page .chat-option-row {
    width: 100%;
    min-height: 64px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.28rem 0.7rem;
    padding: 0.72rem 0.78rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 8px;
    background: var(--chat-bale-surface-soft);
    color: inherit;
    text-align: start;
}

body.chat-page button.chat-option-row {
    grid-template-columns: minmax(0, 1fr);
    cursor: pointer;
}

body.chat-page .chat-option-row input {
    accent-color: var(--chat-bale-green);
}

body.chat-page .chat-option-row strong,
body.chat-page .chat-option-row span {
    min-width: 0;
}

body.chat-page .chat-option-row strong {
    font-size: 0.84rem;
}

body.chat-page .chat-option-row span {
    grid-column: 2;
    color: var(--chat-bale-muted);
    font-size: 0.76rem;
    line-height: 1.75;
}

body.chat-page button.chat-option-row span {
    grid-column: auto;
}

body.chat-page .chat-option-row.is-selected {
    border-color: color-mix(in srgb, var(--chat-bale-green) 46%, var(--chat-bale-line-strong));
    background: var(--chat-bale-green-soft);
}

body.chat-page .chat-options-form {
    padding: 0;
}

body.chat-page .chat-options-footer {
    margin-top: 0.8rem;
    padding: 0;
}

body.chat-page .chat-options-link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.7rem;
    padding: 0.6rem 0.68rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 8px;
    background: var(--chat-bale-surface-soft);
}

body.chat-page .chat-options-link span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
    color: var(--chat-bale-muted);
    font-size: 0.76rem;
}

body.chat-page .chat-options-link button {
    min-height: 34px;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 8px;
    background: var(--chat-bale-surface);
    color: var(--chat-bale-green);
    font-weight: 850;
}

body.chat-page .chat-options-search {
    padding: 0 0 0.6rem;
}

body.chat-page .chat-options-member-list {
    max-height: min(52vh, 460px);
    overflow: auto;
    padding: 0;
}

@media (min-width: 981px) {
    body.chat-page .chat-mobile-nav,
    body.chat-page .chat-fab {
        display: none !important;
    }
}

@media (max-width: 980px) {
    html,
    body.chat-page {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        touch-action: manipulation;
    }

    body.chat-page input,
    body.chat-page select,
    body.chat-page textarea,
    body.chat-page [contenteditable="true"],
    body.chat-page .composer-entry textarea,
    body.chat-page .conversation-search-wrap input,
    body.chat-page .chat-modal__fields input,
    body.chat-page .chat-modal__fields textarea {
        font-size: 16px !important;
        transform: none !important;
    }

    body.chat-page .chat-mobile-nav {
        position: fixed !important;
        bottom: env(safe-area-inset-bottom, 0px) !important;
    }
}

@media (min-width: 981px) {
    body.chat-page .chat-app {
        width: 100% !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    body.chat-page .chat-app__header {
        display: none !important;
    }

    body.chat-page .chat-app__identity p {
        display: none !important;
    }

    body.chat-page .chat-stage {
        min-height: 100dvh !important;
        height: 100dvh !important;
        border: 0 !important;
        border-radius: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        grid-template-columns: minmax(340px, 390px) minmax(0, 1fr) !important;
    }

    body.chat-page .conversation-pane,
    body.chat-page .thread-pane {
        border: 0 !important;
        border-radius: 0 !important;
    }

    body.chat-page .conversation-pane {
        border-inline-start: 1px solid var(--chat-bale-line-strong) !important;
    }

    body.chat-page .thread-head {
        border-bottom: 1px solid var(--chat-bale-line-strong) !important;
    }
}

@media (max-width: 980px) {
    body.chat-page .chat-app__header {
        display: none !important;
    }

    body.chat-page .chat-stage {
        top: 0 !important;
        min-height: var(--chat-vh, 100dvh) !important;
    }
}

/* Final chat parity pass: login guard, 3-item nav, compact sheets, cleaner composer. */
body.chat-page [hidden] {
    display: none !important;
}

body.chat-page #refresh-btn {
    display: none !important;
}

body.chat-page .compose-menu-wrap {
    position: relative;
}

body.chat-page .conversation-pane__icon-btn {
    border-color: transparent !important;
    background: transparent !important;
    border-radius: 50% !important;
}

body.chat-page .conversation-pane__icon-btn:hover,
body.chat-page .conversation-pane__icon-btn:focus-visible {
    transform: none !important;
    border-color: transparent !important;
    background: color-mix(in srgb, var(--chat-bale-text) 9%, transparent) !important;
}

body.chat-page .compose-menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: 0;
    z-index: 30;
    min-width: 168px;
    border-radius: 10px;
    border: 1px solid var(--chat-bale-line-strong);
    background: var(--chat-bale-surface-strong);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

body.chat-page .compose-menu:not([hidden]) {
    animation: bale-menu-in 0.14s ease;
}

@keyframes bale-menu-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

body.chat-page #conversation-search-wrap:not([hidden]) {
    animation: bale-search-in 0.18s ease;
}

@keyframes bale-search-in {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

body.chat-page .compose-menu__item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.58rem;
    padding: 0.6rem 0.82rem;
    font-size: 0.84rem;
    font-weight: 650;
    color: var(--chat-bale-text);
    text-align: start;
    transition: background 80ms ease;
}

body.chat-page .compose-menu__item:hover {
    background: color-mix(in srgb, var(--chat-bale-text) 7%, transparent);
}

body.chat-page .compose-menu__item + .compose-menu__item {
    border-top: 1px solid var(--chat-bale-line-strong);
}

body.chat-page .compose-menu__icon,
body.chat-page .compose-menu__icon svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    opacity: 0.7;
}

body.chat-page .chat-context-receipt {
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 0.3rem 0.58rem;
    border-radius: 8px;
    background: color-mix(in srgb, var(--chat-bale-green) 10%, var(--chat-bale-surface-soft));
    color: var(--chat-bale-green);
    font-size: 0.78rem;
    font-weight: 850;
}

body.chat-page .composer {
    padding-block: 0.34rem !important;
}

body.chat-page .composer-box {
    min-height: 50px !important;
    padding: 0.28rem 0.42rem !important;
    align-items: center !important;
}

body.chat-page .composer-entry {
    display: flex !important;
    align-items: center !important;
}

body.chat-page .composer-entry textarea {
    min-height: 38px !important;
    height: 38px !important;
    padding: 0.42rem 0.74rem !important;
    line-height: 22px !important;
    overflow-y: hidden !important;
}

body.chat-page .composer-status:empty,
body.chat-page .composer-storage-note {
    display: none !important;
}

body.chat-page .composer-tool,
body.chat-page .composer-send {
    width: 40px !important;
    height: 40px !important;
}

body.chat-page .chat-mobile-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

@media (max-width: 980px) {
    body.chat-page .chat-mobile-nav {
        left: 0.65rem !important;
        right: 0.65rem !important;
        bottom: calc(0.42rem + env(safe-area-inset-bottom, 0px)) !important;
        min-height: 64px !important;
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        border-radius: 22px !important;
        padding: 0.24rem !important;
        background: var(--shell-nav-inner-bg) !important;
        border-color: var(--shell-nav-inner-border) !important;
        box-shadow: 0 24px 54px -38px rgba(17, 30, 54, 0.22) !important;
    }

    body.chat-page .chat-mobile-nav[hidden] {
        display: none !important;
    }

    body.chat-page .chat-mobile-nav__item {
        min-height: 52px !important;
        border-radius: 18px !important;
        color: var(--text-tertiary) !important;
        font-size: 0.68rem !important;
        font-weight: 820 !important;
    }

    body.chat-page .chat-mobile-nav__item.is-active {
        background: var(--shell-nav-active-bg) !important;
        border-color: transparent !important;
        color: var(--accent-strong) !important;
    }


    body.chat-page .thread-head {
        grid-template-columns: 40px minmax(0, 1fr) 40px !important;
    }

    body.chat-page .composer {
        padding: 0 !important;
    }

    body.chat-page .composer-box {
        min-height: 52px !important;
        padding: 0.3rem 0.58rem !important;
    }

    body.chat-page .composer-entry textarea {
        min-height: 38px !important;
        height: 38px !important;
        padding-block: 0.42rem !important;
    }

    body.chat-page .chat-context-menu,
    body.chat-page .chat-list-context-menu {
        inset: auto !important;
        width: min(320px, calc(100vw - 24px)) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: min(44vh, 340px) !important;
        border-radius: 16px !important;
        padding: 0.5rem !important;
        transform: scale(0.98) !important;
    }

    body.chat-page .chat-reaction-bar {
        display: flex !important;
        gap: 0.28rem !important;
        overflow-x: auto !important;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        margin-bottom: 0.38rem !important;
        padding-bottom: 0.02rem;
    }

    body.chat-page .chat-reaction-bar::-webkit-scrollbar {
        display: none;
    }

    body.chat-page .chat-reaction-btn {
        min-width: 42px !important;
        width: 42px !important;
        min-height: 42px !important;
        height: 42px !important;
        border-radius: 50% !important;
        flex: 0 0 auto;
    }

    body.chat-page .chat-context-actions {
        gap: var(--chat-row-gap) !important;
    }

    body.chat-page .chat-context-action {
        min-height: 44px !important;
        grid-template-columns: auto minmax(0, 1fr) !important;
        column-gap: 0.66rem !important;
        padding: 0 0.7rem !important;
    }

    body.chat-page .chat-list-context-action {
        min-height: 42px !important;
        grid-template-columns: minmax(0, 1fr) !important;
        padding: 0.52rem 0.68rem !important;
    }

    body.chat-page .chat-list-context-actions {
        gap: 0.24rem !important;
    }

    body.chat-page .chat-context-action__hint {
        display: none !important;
    }

    body.chat-page .chat-list-context-action__hint {
        display: none !important;
    }

    body.chat-page .chat-context-action__label,
    body.chat-page .chat-list-context-action__label {
        font-size: 0.86rem !important;
        line-height: 1.25 !important;
    }

    body.chat-page .chat-context-menu.is-open,
    body.chat-page .chat-list-context-menu.is-open {
        transform: scale(1) !important;
    }
}

body.chat-page .chat-modal--options {
    inset: auto !important;
    inset-inline-start: auto !important;
    inset-inline-end: auto !important;
    inset-block-start: auto !important;
    inset-block-end: auto !important;
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    width: min(520px, calc(100vw - 24px)) !important;
    max-height: min(86vh, calc(var(--chat-vh, 100dvh) - 24px)) !important;
    min-height: 0 !important;
    height: auto !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    overflow: hidden !important;
    transform: translate(-50%, -50%) scale(0.96) !important;
}

body.chat-page .chat-modal--options.is-open {
    transform: translate(-50%, -50%) scale(1) !important;
}

body.chat-page .chat-modal--options .chat-modal__body--options {
    min-height: 0;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 980px) {
    body.chat-page .chat-modal--options {
        inset: auto !important;
        left: 0.54rem !important;
        right: 0.54rem !important;
        top: auto !important;
        bottom: calc(0.52rem + env(safe-area-inset-bottom, 0px)) !important;
        width: auto !important;
        max-width: calc(100vw - 1.08rem) !important;
        max-height: min(86vh, calc(var(--chat-vh, 100dvh) - 1.4rem - env(safe-area-inset-bottom, 0px))) !important;
        transform: translateY(110%) !important;
        transition: transform 0.24s ease, opacity 0.18s ease !important;
    }

    body.chat-page .chat-modal--options.is-open {
        transform: translateY(0) !important;
    }
}

body.chat-page .chat-modal--confirm {
    inset: auto !important;
    inset-inline-start: auto !important;
    inset-inline-end: auto !important;
    inset-block-start: auto !important;
    inset-block-end: auto !important;
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    width: min(420px, calc(100vw - 32px)) !important;
    max-height: min(86vh, calc(var(--chat-vh, 100dvh) - 24px)) !important;
    min-height: 0 !important;
    height: auto !important;
    border-radius: 18px !important;
    transform: translate(-50%, -50%) scale(0.96) !important;
    transition: opacity 0.18s ease, transform 0.18s ease !important;
}

body.chat-page .chat-modal--confirm.is-open {
    transform: translate(-50%, -50%) scale(1) !important;
}

@media (max-width: 980px) {
    body.chat-page .chat-modal--confirm {
        width: min(340px, calc(100vw - 32px)) !important;
    }
}

body.chat-page.chat-auth-guard .chat-app {
    grid-template-rows: auto minmax(0, 1fr) !important;
}

body.chat-page.chat-auth-guard .chat-app__header {
    display: grid !important;
}

body.chat-page.chat-auth-guard .chat-app__identity p {
    display: block !important;
}

@media (max-width: 980px) {
    body.chat-page.chat-auth-guard .chat-app__header {
        display: grid !important;
    }
}

/* Attachment picker refresh */
body.chat-page .composer-upload-sheet {
    position: relative;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.48rem;
    margin-bottom: 0.5rem;
    padding: 0.62rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 18px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--chat-bale-surface) 96%, transparent), color-mix(in srgb, var(--chat-bale-surface-soft) 96%, transparent));
    box-shadow: 0 18px 40px -32px rgba(17, 30, 54, 0.34);
    backdrop-filter: blur(18px);
}

body.chat-page .composer-upload-sheet[hidden] {
    display: none !important;
}

body.chat-page .composer-upload-sheet__head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
    padding: 0 0.08rem 0.1rem;
}

body.chat-page .composer-upload-sheet__title {
    color: var(--chat-bale-text);
    font-size: 0.82rem;
    font-weight: 900;
}

body.chat-page .composer-upload-sheet__hint {
    color: var(--chat-bale-muted);
    direction: ltr;
    unicode-bidi: isolate;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

body.chat-page .composer-upload-option {
    min-width: 0;
    min-height: 74px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.36rem;
    padding: 0.64rem 0.42rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 14px;
    background: var(--chat-bale-surface-soft);
    color: var(--chat-bale-text);
    font-size: 0.75rem;
    font-weight: 880;
    line-height: 1.3;
    white-space: normal;
    text-align: center;
}

body.chat-page .composer-upload-option__icon {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 13px;
    background: color-mix(in srgb, var(--chat-bale-green) 12%, var(--chat-bale-surface));
    color: var(--chat-bale-green);
}

body.chat-page .composer-upload-option__icon svg {
    width: 21px;
    height: 21px;
}

body.chat-page .composer-upload-option:hover,
body.chat-page .composer-upload-option:focus-visible {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--chat-bale-green) 42%, var(--chat-bale-line-strong));
    background: var(--chat-bale-green-soft);
    color: var(--chat-bale-green);
}

@media (max-width: 980px) {
    body.chat-page .composer-upload-sheet {
        position: fixed;
        inset-inline: 0.62rem;
        inset-block-end: calc(0.54rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height));
        z-index: 300;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.42rem;
        padding: 0.66rem;
        border-radius: 22px;
        box-shadow: 0 24px 54px -34px rgba(17, 30, 54, 0.48);
    }

    body.chat-page .composer-upload-option {
        min-height: 72px;
        padding: 0.56rem 0.3rem;
        border-radius: 16px;
        font-size: 0.74rem;
    }

    body.chat-page .composer-upload-option__icon {
        width: 34px;
        height: 34px;
    }
}

html.chat-page-root,
html.chat-page-root body.chat-page {
    height: var(--chat-vh, 100dvh);
    min-height: var(--chat-vh, 100dvh);
    overflow: hidden;
    overscroll-behavior: none;
}

body.chat-page .conversation-list,
body.chat-page .messages {
    overscroll-behavior-y: contain !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y !important;
}

body.chat-page .msg-item,
body.chat-page .msg-bubble {
    touch-action: pan-y !important;
}

body.chat-page .conversation-pane__header {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    align-items: center !important;
}

body.chat-page .conversation-pane__title-block {
    grid-column: 2;
    justify-self: center;
    text-align: center;
}

body.chat-page .conversation-pane__title-block h2,
body.chat-page .conversation-pane__title-block p,
body.chat-page .thread-head__copy,
body.chat-page .thread-head__copy strong,
body.chat-page .thread-head__copy span {
    text-align: center !important;
}

body.chat-page .thread-head__identity {
    justify-content: center !important;
    text-align: center !important;
}

body.chat-page .messages {
    justify-content: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
}

body.chat-page .messages::before {
    content: "";
    flex: 0 0 auto;
    margin-top: auto;
}

body.chat-page .msg-item.day-start {
    position: relative;
    margin-top: 0.64rem !important;
    padding-top: 2.2rem !important;
}

body.chat-page .msg-item.day-start::before {
    z-index: 2;
    top: 0.24rem !important;
    min-height: 26px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    line-height: 1.35;
    box-shadow: 0 8px 20px -16px rgba(17, 34, 57, 0.34);
    pointer-events: none;
}

body.chat-page .conversation-list.is-swiping {
    transition: none !important;
    will-change: transform;
}

body.chat-page .conversation-list.is-swipe-settling {
    transition: transform 180ms cubic-bezier(0.22, 0.61, 0.36, 1) !important;
    will-change: transform;
}

/* Chat compact/performance pass */
@media (min-width: 981px) {
    body.chat-page .chat-stage {
        grid-template-columns: minmax(304px, 348px) minmax(0, 1fr) !important;
    }
}

body.chat-page .conversation-pane__header,
body.chat-page .thread-head {
    min-height: 56px !important;
    padding: 0.48rem 0.72rem !important;
}

body.chat-page .conversation-pane__header h2 {
    font-size: 0.9rem !important;
    line-height: 1.25 !important;
}

body.chat-page .conversation-pane__header p,
body.chat-page .thread-head__copy span {
    font-size: 0.68rem !important;
    line-height: 1.35 !important;
}

body.chat-page .conversation-search-wrap {
    padding: 0.46rem 0.7rem !important;
}

body.chat-page .conversation-search-wrap input {
    min-height: 38px !important;
    border-radius: 8px !important;
    font-size: 0.82rem !important;
}


body.chat-page .conversation-filter-tabs {
    min-height: 42px !important;
    scroll-behavior: smooth;
}

body.chat-page .conversation-filter-tab {
    min-height: 42px !important;
    padding: 0 0.62rem !important;
    font-size: 0.76rem !important;
}

body.chat-page .conversation-list {
    gap: 0 !important;
}

body.chat-page .conversation-item__main {
    min-height: 58px !important;
    padding: 0.48rem 0.62rem !important;
}

body.chat-page .conversation-item__avatar {
    width: 40px !important;
    height: 40px !important;
    border-radius: 12px !important;
    font-size: 0.76rem !important;
}

body.chat-page .conversation-item__kind {
    width: 1.22rem !important;
    height: 1.22rem !important;
    border-radius: 8px !important;
}

body.chat-page .conversation-item__kind svg {
    width: 13px !important;
    height: 13px !important;
}

body.chat-page .conversation-item__title {
    font-size: 0.78rem !important;
    line-height: 1.32 !important;
}

body.chat-page .conversation-item__subtitle,
body.chat-page .conversation-item__preview,
body.chat-page .conversation-item__time {
    font-size: 0.67rem !important;
    line-height: 1.35 !important;
}

body.chat-page .conversation-item__unread {
    min-height: 18px !important;
    min-width: 18px !important;
    padding-inline: 0.34rem !important;
    font-size: 0.66rem !important;
}

body.chat-page .thread-head__avatar {
    width: 40px !important;
    height: 40px !important;
    border-radius: 12px !important;
}

body.chat-page .thread-head__copy strong {
    font-size: 0.88rem !important;
    line-height: 1.24 !important;
}

body.chat-page .chat-top-btn,
body.chat-page .thread-head__mobile-btn,
body.chat-page .conversation-pane__icon-btn,
body.chat-page .conversation-pane__close,
body.chat-page .chat-sheet-close {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 10px !important;
}

body.chat-page .messages {
    padding: 0.58rem 0.72rem 0.52rem !important;
}

@media (min-width: 981px) {
    body.chat-page .messages {
        padding-inline: clamp(1.1rem, 4.2vw, 4.6rem) !important;
    }
}

body.chat-page .msg-avatar {
    width: 30px !important;
    height: 30px !important;
    border-radius: 10px !important;
    font-size: 0.68rem !important;
}

body.chat-page .msg-bubble {
    max-width: min(68%, 650px) !important;
    padding: 0.42rem 0.58rem 0.36rem !important;
    border-radius: 12px !important;
}

/* Telegram-style grouped bubble tails: keep the asymmetric corner on the
   side facing the avatar so consecutive messages read as one stack. */
body.chat-page .msg-item.other.group-single .msg-bubble,
body.chat-page .msg-item.other.group-end .msg-bubble {
    border-bottom-left-radius: 4px !important;
}

body.chat-page .msg-item.other.group-start .msg-bubble,
body.chat-page .msg-item.other.group-middle .msg-bubble {
    border-top-left-radius: 8px !important;
}

body.chat-page .msg-item.me.group-single .msg-bubble,
body.chat-page .msg-item.me.group-end .msg-bubble {
    border-bottom-right-radius: 4px !important;
}

body.chat-page .msg-item.me.group-start .msg-bubble,
body.chat-page .msg-item.me.group-middle .msg-bubble {
    border-top-right-radius: 8px !important;
}

/* دم حباب: small curved tail on the last bubble of each consecutive group */
body.chat-page .msg-item.other.group-single .msg-bubble::after,
body.chat-page .msg-item.other.group-end .msg-bubble::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: -7px;
    width: 11px;
    height: 13px;
    background: inherit;
    -webkit-mask-image: radial-gradient(circle at top right, transparent 11px, #000 11.5px);
    mask-image: radial-gradient(circle at top right, transparent 11px, #000 11.5px);
    pointer-events: none;
}

body.chat-page .msg-item.me.group-single .msg-bubble::after,
body.chat-page .msg-item.me.group-end .msg-bubble::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: -7px;
    width: 11px;
    height: 13px;
    background: inherit;
    -webkit-mask-image: radial-gradient(circle at top left, transparent 11px, #000 11.5px);
    mask-image: radial-gradient(circle at top left, transparent 11px, #000 11.5px);
    pointer-events: none;
}

body.chat-page .msg-text {
    font-size: 0.84rem !important;
    line-height: 1.72 !important;
}

body.chat-page .msg-name,
body.chat-page .msg-foot,
body.chat-page .msg-delivery,
body.chat-page .msg-time {
    font-size: 0.66rem !important;
}

body.chat-page .msg-attachment {
    padding: 0.42rem !important;
    border-radius: 10px !important;
}

body.chat-page .composer {
    padding-block: 0.24rem !important;
}

body.chat-page .composer-box {
    min-height: 46px !important;
    border-radius: 16px !important;
}

body.chat-page .composer-tool,
body.chat-page .composer-send {
    width: 36px !important;
    height: 36px !important;
    border-radius: 12px !important;
}

body.chat-page .composer-entry textarea {
    min-height: 34px !important;
    height: 34px !important;
    line-height: 20px !important;
}

body.chat-page .conversation-list.is-swiping {
    transition: transform 80ms linear !important;
}

body.chat-page .conversation-list.is-swipe-settling {
    transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

body.chat-page .chat-media-viewer {
    grid-template-rows: minmax(0, 1fr) auto !important;
    padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 0.6rem calc(0.72rem + env(safe-area-inset-bottom, 0px)) !important;
    background: rgba(0, 0, 0, 0.92) !important;
}

body.chat-page .chat-media-viewer__stage {
    width: min(100%, 1180px) !important;
    height: min(84dvh, 900px) !important;
    overflow: auto;
    overscroll-behavior: contain;
}

body.chat-page .chat-media-viewer__stage img,
body.chat-page .chat-media-viewer__stage video {
    transition: transform 180ms ease;
    transform-origin: center center;
}

body.chat-page .chat-media-viewer__stage img {
    cursor: zoom-in;
}

body.chat-page .chat-media-viewer.is-zoomed .chat-media-viewer__stage {
    touch-action: none;
}

body.chat-page .chat-media-viewer.is-zoomed .chat-media-viewer__stage img {
    cursor: grab;
}

body.chat-page .chat-media-viewer.is-zoomed .chat-media-viewer__stage img:active {
    cursor: grabbing;
}

body.chat-page .chat-media-viewer__nav,
body.chat-page .chat-media-viewer__counter {
    position: fixed;
    z-index: 1110;
    color: #fff;
}

body.chat-page .chat-media-viewer__nav {
    top: 50%;
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.42);
    transform: translateY(-50%);
}

body.chat-page .chat-media-viewer__nav svg {
    width: 23px;
    height: 23px;
}

body.chat-page .chat-media-viewer__nav--prev {
    inset-inline-start: 0.75rem;
}

body.chat-page .chat-media-viewer__nav--next {
    inset-inline-end: 0.75rem;
}

body.chat-page .chat-media-viewer__counter {
    top: calc(0.9rem + env(safe-area-inset-top, 0px));
    left: 50%;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 0.72rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.44);
    font-size: 0.78rem;
    font-weight: 850;
    transform: translateX(-50%);
}

@media (max-width: 980px) {
    body.chat-page .chat-stage {
        min-height: var(--chat-vh, 100dvh) !important;
    }

    body.chat-page .conversation-pane__header,
    body.chat-page .thread-head {
        min-height: 52px !important;
    }

    body.chat-page .conversation-item__main {
        min-height: 56px !important;
    }

    body.chat-page .msg-bubble {
        max-width: min(82%, 620px) !important;
    }

    body.chat-page .chat-media-viewer__nav {
        width: 40px;
        height: 40px;
    }

    body.chat-page .chat-media-viewer__nav--prev {
        inset-inline-start: 0.42rem;
    }

    body.chat-page .chat-media-viewer__nav--next {
        inset-inline-end: 0.42rem;
    }

    body.chat-page .chat-media-viewer__close,
    body.chat-page .chat-media-viewer__action {
        width: 38px;
        height: 38px;
    }

    body.chat-page .chat-media-viewer__close {
        inset-inline-start: 0.42rem;
    }

    body.chat-page .chat-media-viewer__actions {
        inset-inline-end: 0.42rem;
        gap: 0.32rem;
    }

    body.chat-page .chat-media-viewer__meta {
        inset-inline-start: calc(0.42rem + 38px + 0.4rem);
        inset-inline-end: calc(0.42rem + (38px + 0.32rem) * 4);
    }

    body.chat-page .chat-media-viewer__action svg {
        width: 19px;
        height: 19px;
    }
}

/* Keep chat list avatar/text spacing compact after avatar downscale. */
body.chat-page .conversation-item__main {
    grid-template-columns: 40px minmax(0, 1fr) auto !important;
    column-gap: 0.5rem !important;
}

@media (max-width: 980px) {
    body.chat-page .conversation-item__main {
        grid-template-columns: 40px minmax(0, 1fr) auto !important;
        column-gap: 0.48rem !important;
    }
}

/* Telegram-like message gestures: double-tap heart and swipe-to-reply. */
body.chat-page .msg-bubble {
    --msg-swipe-offset: 0px;
    --msg-swipe-progress: 0;
    position: relative;
    transform: translate3d(var(--msg-swipe-offset), 0, 0);
    transition:
        transform var(--motion-fast) var(--motion-ease-standard),
        border-color var(--motion-fast) var(--motion-ease-standard),
        background var(--motion-fast) var(--motion-ease-standard),
        box-shadow var(--motion-fast) var(--motion-ease-standard) !important;
}

body.chat-page .msg-bubble::before {
    content: "↩";
    position: absolute;
    top: 50%;
    right: -2.18rem;
    width: 1.9rem;
    height: 1.9rem;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
    background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
    color: color-mix(in srgb, var(--accent-color) 82%, var(--text-primary));
    box-shadow: 0 14px 24px -24px rgba(17, 35, 60, 0.34);
    opacity: 0;
    pointer-events: none;
    transform: translate3d(calc((1 - var(--msg-swipe-progress)) * -14px), -50%, 0) scale(calc(0.82 + (var(--msg-swipe-progress) * 0.22)));
    transition:
        opacity var(--motion-fast) var(--motion-ease-standard),
        transform var(--motion-fast) var(--motion-ease-standard),
        border-color var(--motion-fast) var(--motion-ease-standard),
        background var(--motion-fast) var(--motion-ease-standard),
        color var(--motion-fast) var(--motion-ease-standard);
}

body.chat-page .msg-select-badge {
    position: absolute;
    inset-inline-start: -0.82rem;
    top: 0.78rem;
    width: 1.4rem;
    height: 1.4rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--chat-bale-line-strong) 82%, transparent);
    background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
    color: transparent;
    box-shadow: 0 14px 24px -26px rgba(17, 35, 60, 0.34);
    opacity: 0;
    pointer-events: none;
    transform: scale(0.78);
    transition:
        opacity var(--motion-fast) var(--motion-ease-standard),
        transform var(--motion-fast) var(--motion-ease-standard),
        background var(--motion-fast) var(--motion-ease-standard),
        border-color var(--motion-fast) var(--motion-ease-standard),
        color var(--motion-fast) var(--motion-ease-standard);
}

body.chat-page .msg-item.is-selection-mode .msg-bubble {
    cursor: pointer;
}

body.chat-page .msg-item.is-selection-mode .msg-bubble::before {
    opacity: 0 !important;
}

body.chat-page .msg-item.is-selection-mode .msg-select-badge {
    opacity: 0.96;
}

body.chat-page .msg-item.is-selected .msg-bubble {
    border-color: color-mix(in srgb, var(--accent-color) 44%, transparent) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 20%, transparent), 0 18px 30px -28px rgba(43, 109, 243, 0.34) !important;
}

body.chat-page .msg-item.is-selected .msg-select-badge {
    background: var(--accent-color);
    border-color: color-mix(in srgb, var(--accent-color) 76%, transparent);
    color: #fff;
    transform: scale(1);
}

body.chat-page.chat-message-selection-mode .composer-box,
body.chat-page.chat-message-selection-mode .composer-uploads,
body.chat-page.chat-message-selection-mode .composer-mention-tray {
    opacity: 0.68;
}

body.chat-page .msg-bubble.is-swipe-tracking,
body.chat-page .msg-bubble.is-swipe-settling {
    z-index: 4;
    will-change: transform;
}

body.chat-page .msg-bubble.is-swipe-tracking {
    transition: none !important;
    box-shadow: 0 18px 30px -24px rgba(17, 35, 60, 0.22) !important;
}

body.chat-page .msg-bubble.is-swipe-tracking::before {
    transition: none !important;
}

body.chat-page .msg-bubble.is-swipe-tracking::before,
body.chat-page .msg-bubble.is-swipe-settling::before {
    opacity: calc(var(--msg-swipe-progress) * 1.12);
}

body.chat-page .msg-bubble.is-swipe-reply-ready {
    border-color: color-mix(in srgb, var(--accent-color) 42%, transparent) !important;
    box-shadow: 0 20px 34px -26px rgba(43, 109, 243, 0.34) !important;
}

body.chat-page .msg-bubble.is-swipe-reply-ready::before,
body.chat-page .msg-bubble.is-swipe-reply-fired::before {
    background: var(--accent-color);
    border-color: color-mix(in srgb, var(--accent-color) 72%, transparent);
    color: #fff;
}

body.chat-page .msg-bubble.is-swipe-reply-fired {
    box-shadow: 0 22px 36px -28px rgba(43, 109, 243, 0.36) !important;
}

body.chat-page .msg-bubble.is-gesture-reacting {
    box-shadow: 0 22px 36px -28px rgba(225, 78, 102, 0.34) !important;
}

body.chat-page .msg-heart-burst {
    position: absolute;
    inset-inline-end: 0.72rem;
    top: 50%;
    z-index: 5;
    display: inline-grid;
    place-items: center;
    min-width: 2rem;
    min-height: 2rem;
    font-size: 1.9rem;
    line-height: 1;
    pointer-events: none;
    filter: drop-shadow(0 8px 18px rgba(226, 72, 102, 0.26));
    transform: translate3d(0, -10%, 0) scale(0.32);
    opacity: 0;
    animation: chat-heart-burst 620ms var(--motion-ease-emphasized) forwards;
}

body.chat-page .msg-heart-burst::after {
    content: "";
    position: absolute;
    inset: -1.15rem;
    z-index: -1;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(226, 72, 102, 0.34) 0%, rgba(226, 72, 102, 0.14) 34%, rgba(226, 72, 102, 0) 72%);
    opacity: 0;
    animation: chat-heart-glow 620ms var(--motion-ease-soft) forwards;
}

@keyframes chat-heart-burst {
    0% {
        opacity: 0;
        transform: translate3d(0, 18%, 0) scale(0.32);
    }

    24% {
        opacity: 1;
        transform: translate3d(0, -14%, 0) scale(1.08);
    }

    58% {
        opacity: 1;
        transform: translate3d(8px, -74%, 0) scale(1.2);
    }

    100% {
        opacity: 0;
        transform: translate3d(12px, -132%, 0) scale(0.9);
    }
}

@keyframes chat-heart-glow {
    0% {
        opacity: 0;
        transform: scale(0.4);
    }

    30% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.85);
    }
}

html[data-performance-mode="lite"] body.chat-page .msg-heart-burst {
    display: none;
}

@media (max-width: 980px) {
    body.chat-page .msg-bubble::before {
        right: -2rem;
    }
}

body.chat-page .thread-head__copy span.is-live-presence,
body.chat-page .conversation-item__subtitle,
body.chat-page .chat-member__copy span {
    transition: color var(--motion-fast) var(--motion-ease-standard);
}

body.chat-page .thread-head__copy span.is-live-presence,
body.chat-page .chat-member__copy span.is-live-presence {
    color: var(--chat-accent);
}

body.chat-page .conversation-item__avatar,
body.chat-page .thread-head__avatar,
body.chat-page .chat-member__avatar {
    position: relative;
}

body.chat-page .conversation-item__avatar::after,
body.chat-page .thread-head__avatar::after,
body.chat-page .chat-member__avatar::after {
    content: "";
    position: absolute;
    inset-inline-end: 1px;
    inset-block-end: 1px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 2px solid var(--chat-panel-solid, #ffffff);
    background: #36c56f;
    box-shadow: 0 0 0 0 rgba(54, 197, 111, 0);
    opacity: 0;
    transform: scale(0.72);
    transition:
        opacity var(--motion-fast) var(--motion-ease-standard),
        transform var(--motion-fast) var(--motion-ease-standard),
        box-shadow var(--motion-fast) var(--motion-ease-standard),
        background var(--motion-fast) var(--motion-ease-standard);
}

body.chat-page .conversation-item__avatar[data-presence="online"]::after,
body.chat-page .thread-head__avatar[data-presence="online"]::after,
body.chat-page .chat-member__avatar[data-presence="online"]::after,
body.chat-page .conversation-item__avatar[data-presence="typing"]::after,
body.chat-page .thread-head__avatar[data-presence="typing"]::after,
body.chat-page .chat-member__avatar[data-presence="typing"]::after {
    opacity: 1;
    transform: scale(1);
}

body.chat-page .conversation-item__avatar[data-presence="online"]::after,
body.chat-page .thread-head__avatar[data-presence="online"]::after,
body.chat-page .chat-member__avatar[data-presence="online"]::after {
    background: #36c56f;
    box-shadow: 0 0 0 4px rgba(54, 197, 111, 0.14);
}

body.chat-page .conversation-item__avatar[data-presence="typing"]::after,
body.chat-page .thread-head__avatar[data-presence="typing"]::after,
body.chat-page .chat-member__avatar[data-presence="typing"]::after {
    background: var(--chat-accent);
    box-shadow: 0 0 0 4px rgba(43, 109, 243, 0.16);
}

html[data-performance-mode="lite"] body.chat-page .conversation-item__avatar::after,
html[data-performance-mode="lite"] body.chat-page .thread-head__avatar::after {
    box-shadow: none;
}

body.chat-page .chat-info-profile__avatar::after {
    content: "";
    position: absolute;
    inset-inline-end: 5px;
    inset-block-end: 5px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 3px solid var(--chat-panel-solid, #ffffff);
    background: #36c56f;
    box-shadow: 0 0 0 0 rgba(54, 197, 111, 0);
    opacity: 0;
    transform: scale(0.72);
    transition:
        opacity var(--motion-fast) var(--motion-ease-standard),
        transform var(--motion-fast) var(--motion-ease-standard),
        box-shadow var(--motion-fast) var(--motion-ease-standard),
        background var(--motion-fast) var(--motion-ease-standard);
}

body.chat-page .chat-info-profile__avatar[data-presence="online"]::after,
body.chat-page .chat-info-profile__avatar[data-presence="typing"]::after {
    opacity: 1;
    transform: scale(1);
}

body.chat-page .chat-info-profile__avatar[data-presence="online"]::after {
    background: #36c56f;
    box-shadow: 0 0 0 4px rgba(54, 197, 111, 0.14);
}

body.chat-page .chat-info-profile__avatar[data-presence="typing"]::after {
    background: var(--chat-accent);
    box-shadow: 0 0 0 4px rgba(43, 109, 243, 0.16);
}

html[data-performance-mode="lite"] body.chat-page .chat-info-profile__avatar::after {
    box-shadow: none;
}

body.chat-page .chat-top-btn.is-active {
    color: var(--chat-accent);
    border-color: color-mix(in srgb, var(--chat-accent) 34%, var(--chat-bale-line-strong));
    background: color-mix(in srgb, var(--chat-accent) 10%, var(--chat-bale-surface-soft));
}

body.chat-page .thread-search-panel {
    display: grid;
    gap: 0.52rem;
    padding: 0.72rem 0.96rem 0.86rem;
    border-bottom: 1px solid var(--chat-bale-line-strong);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--chat-bale-surface) 96%, transparent), color-mix(in srgb, var(--chat-bale-surface-soft) 96%, transparent));
}

body.chat-page .thread-search-panel__row {
    display: flex;
    align-items: center;
    gap: 0.46rem;
    flex-wrap: wrap;
    min-width: 0;
}

body.chat-page .thread-search-panel__field,
body.chat-page .thread-search-panel__select {
    flex: 1 1 220px;
    min-width: 0;
}

body.chat-page .thread-search-panel__field input,
body.chat-page .thread-search-panel__select select {
    width: 100%;
    min-height: 40px;
    padding: 0.52rem 0.74rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 12px;
    background: var(--chat-bale-surface-soft);
    color: var(--chat-bale-text);
}

body.chat-page .thread-search-panel__field input:focus,
body.chat-page .thread-search-panel__select select:focus {
    border-color: color-mix(in srgb, var(--chat-accent) 42%, var(--chat-bale-line-strong));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-accent) 12%, transparent);
    outline: 0;
}

body.chat-page .thread-search-panel__btn,
body.chat-page .thread-search-panel__close {
    min-height: 38px;
    padding: 0.48rem 0.76rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 12px;
    background: var(--chat-bale-surface-soft);
    color: var(--chat-bale-text);
    font-size: 0.74rem;
    font-weight: 860;
}

body.chat-page .thread-search-panel__btn--accent {
    border-color: color-mix(in srgb, var(--chat-accent) 34%, var(--chat-bale-line-strong));
    background: color-mix(in srgb, var(--chat-accent) 10%, var(--chat-bale-surface-soft));
    color: var(--chat-accent);
}

body.chat-page .thread-search-panel__btn:disabled,
body.chat-page .thread-search-panel__close:disabled {
    opacity: 0.56;
    cursor: default;
}

body.chat-page .thread-search-panel__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 0.7rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-bale-line-strong) 42%, transparent);
    color: var(--chat-bale-muted);
    font-size: 0.73rem;
    font-weight: 820;
    white-space: nowrap;
}

body.chat-page .thread-search-panel__preview {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 0.12rem;
    padding: 0.62rem 0.72rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 14px;
    background: var(--chat-bale-surface-soft);
    color: inherit;
    text-align: start;
}

body.chat-page .thread-search-panel__preview strong,
body.chat-page .thread-search-panel__preview span,
body.chat-page .thread-search-panel__preview small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.chat-page .thread-search-panel__preview span {
    color: var(--chat-bale-text);
    font-size: 0.76rem;
}

body.chat-page .thread-search-panel__preview small {
    color: var(--chat-bale-muted);
    font-size: 0.68rem;
}

body.chat-page .msg-unread-divider {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.26rem 0 0.08rem;
    pointer-events: none;
}

body.chat-page .msg-unread-divider::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 50%;
    height: 1px;
    background: color-mix(in srgb, var(--chat-accent) 14%, var(--chat-bale-line-strong));
}

body.chat-page .msg-unread-divider span {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 0.7rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--chat-accent) 16%, var(--chat-bale-line-strong));
    background: color-mix(in srgb, var(--chat-bale-surface) 88%, transparent);
    color: var(--chat-accent);
    font-size: 0.7rem;
    font-weight: 850;
    box-shadow: 0 12px 24px -22px rgba(17, 30, 54, 0.42);
}

body.chat-page .msg-voice-note {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.58rem;
    align-items: center;
    padding: 0.48rem 0.54rem;
    border: 1px solid color-mix(in srgb, var(--chat-accent) 16%, var(--chat-bale-line-strong));
    border-radius: 16px;
    background: color-mix(in srgb, var(--chat-bale-surface-soft) 92%, transparent);
}

body.chat-page .msg-item.me .msg-voice-note {
    background: color-mix(in srgb, var(--chat-accent) 8%, var(--chat-bale-surface-soft));
}

body.chat-page .msg-voice-note.is-unavailable {
    opacity: 0.8;
}

body.chat-page .msg-voice-note__play {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-accent) 14%, var(--chat-bale-surface));
    color: var(--chat-accent);
}

body.chat-page .msg-voice-note__play[disabled] {
    opacity: 0.56;
}

body.chat-page .msg-voice-note__play-icon {
    position: relative;
    width: 14px;
    height: 14px;
    display: inline-block;
}

body.chat-page .msg-voice-note__play-icon--play::before {
    content: "";
    position: absolute;
    inset: 1px 0 1px 2px;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    background: currentColor;
}

body.chat-page .msg-voice-note__play-icon--pause::before,
body.chat-page .msg-voice-note__play-icon--pause::after {
    content: "";
    position: absolute;
    top: 1px;
    bottom: 1px;
    width: 4px;
    border-radius: 999px;
    background: currentColor;
}

body.chat-page .msg-voice-note__play-icon--pause::before {
    inset-inline-start: 1px;
}

body.chat-page .msg-voice-note__play-icon--pause::after {
    inset-inline-end: 1px;
}

body.chat-page .msg-voice-note__body {
    min-width: 0;
    display: grid;
    gap: 0.34rem;
}

body.chat-page .msg-voice-note__wave,
body.chat-page .composer-voice__wave {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(3px, 1fr);
    align-items: center;
    gap: 2px;
    min-height: 28px;
}

body.chat-page .msg-voice-note__bar,
body.chat-page .composer-voice__bar {
    display: block;
    height: var(--voice-bar-height, 44%);
    min-height: 6px;
    max-height: 100%;
    align-self: center;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-bale-muted) 22%, var(--chat-bale-surface));
    transition:
        height var(--motion-fast) var(--motion-ease-standard),
        background var(--motion-fast) var(--motion-ease-standard),
        opacity var(--motion-fast) var(--motion-ease-standard);
}

body.chat-page .msg-voice-note__bar.is-played {
    background: color-mix(in srgb, var(--chat-accent) 74%, var(--chat-bale-surface));
}

body.chat-page .msg-voice-note.is-playing .msg-voice-note__bar:not(.is-played) {
    opacity: 0.78;
}

body.chat-page .msg-voice-note__meta {
    display: flex;
    align-items: center;
    gap: 0.42rem;
    flex-wrap: wrap;
    min-width: 0;
}

body.chat-page .msg-voice-note__time,
body.chat-page .msg-voice-note__state {
    color: var(--chat-bale-muted);
    font-size: 0.69rem;
    font-weight: 820;
}

body.chat-page .msg-voice-note__speed,
body.chat-page .msg-voice-note__download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 0.58rem;
    border: 1px solid var(--chat-bale-line-strong);
    border-radius: 999px;
    background: var(--chat-bale-surface);
    color: var(--chat-bale-text);
    font-size: 0.68rem;
    font-weight: 860;
    text-decoration: none;
}

body.chat-page .composer-voice {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.58rem 0.72rem;
    align-items: center;
    padding: 0.72rem 0.84rem;
    border-radius: 18px;
    border: 1px solid color-mix(in srgb, var(--chat-accent) 18%, var(--chat-bale-line-strong));
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--chat-accent) 8%, var(--chat-bale-surface)), color-mix(in srgb, var(--chat-bale-surface-soft) 94%, transparent));
    box-shadow: 0 22px 42px -34px rgba(17, 30, 54, 0.34);
}

body.chat-page .composer-voice__topline {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.44rem;
    flex-wrap: wrap;
}

body.chat-page .composer-voice__wave,
body.chat-page .composer-voice__hint,
body.chat-page .composer-voice__actions {
    grid-column: 1 / -1;
}

body.chat-page .composer-voice__lock-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 0.54rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-bale-green) 14%, var(--chat-bale-surface));
    color: var(--chat-bale-green);
    font-size: 0.68rem;
    font-weight: 860;
}

body.chat-page .composer-voice__hint {
    color: var(--chat-bale-muted);
    font-size: 0.72rem;
    line-height: 1.75;
}

body.chat-page .composer-voice__actions {
    justify-self: end;
}

body.chat-page .composer-voice.is-cancel-ready {
    border-color: color-mix(in srgb, var(--chat-danger) 34%, var(--chat-bale-line-strong));
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--chat-danger) 10%, var(--chat-bale-surface)), color-mix(in srgb, var(--chat-bale-surface-soft) 94%, transparent));
}

body.chat-page .composer-voice.is-cancel-ready .composer-voice__bar,
body.chat-page .composer-voice.is-cancel-ready .composer-voice__dot {
    background: var(--chat-danger);
}

body.chat-page .composer-voice.is-lock-ready,
body.chat-page .composer-voice.is-locked {
    border-color: color-mix(in srgb, var(--chat-bale-green) 32%, var(--chat-bale-line-strong));
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--chat-bale-green) 10%, var(--chat-bale-surface)), color-mix(in srgb, var(--chat-bale-surface-soft) 94%, transparent));
}

body.chat-page .composer-voice.is-lock-ready .composer-voice__bar,
body.chat-page .composer-voice.is-locked .composer-voice__bar {
    background: color-mix(in srgb, var(--chat-bale-green) 56%, var(--chat-bale-surface));
}

@media (max-width: 980px) {
    body.chat-page .thread-search-panel {
        padding: 0.64rem 0.72rem 0.8rem;
    }

    body.chat-page .thread-search-panel__row--tools {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.chat-page .thread-search-panel__count,
    body.chat-page .thread-search-panel__preview {
        grid-column: 1 / -1;
    }

    body.chat-page .msg-voice-note {
        gap: 0.5rem;
        padding: 0.46rem 0.48rem;
    }

    body.chat-page .msg-voice-note__meta {
        gap: 0.34rem;
    }

    body.chat-page .composer-voice {
        padding: 0.68rem 0.74rem;
        border-radius: 16px;
    }

    body.chat-page .composer-upload-item {
        grid-template-columns: 52px minmax(0, 1fr) auto;
        gap: 0.42rem;
    }

    body.chat-page .composer-upload-item__preview {
        width: 52px;
        border-radius: 12px;
    }

    body.chat-page .msg-media-album {
        gap: 0.18rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.chat-page .msg-voice-note__bar,
    body.chat-page .composer-voice__bar,
    body.chat-page .msg-unread-divider span,
    body.chat-page .thread-search-panel__preview,
    body.chat-page .msg-select-badge,
    body.chat-page .chat-media-viewer__stage {
        transition: none;
    }

    body.chat-page .composer-voice__dot {
        animation: none;
    }
}

html[data-performance-mode="lite"] body.chat-page .msg-voice-note__bar,
html[data-performance-mode="lite"] body.chat-page .composer-voice__bar,
html[data-performance-mode="lite"] body.chat-page .msg-select-badge,
html[data-performance-mode="lite"] body.chat-page .chat-media-viewer__stage {
    transition: none;
}

body.chat-page .conversation-item__mention {
    min-width: 2.25rem;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 133, 102, 0.18);
    color: #ffb6a3;
    font-size: 0.7rem;
    font-weight: 800;
    text-align: center;
}

body.chat-page .composer-mention-tray {
    display: grid;
    gap: 0.38rem;
    margin-top: 0.55rem;
    padding: 0.5rem;
    border: 1px solid var(--chat-border);
    border-radius: 18px;
    background: rgba(12, 22, 33, 0.92);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body.chat-page .composer-mention-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.7rem;
    align-items: center;
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid transparent;
    border-radius: 16px;
    background: rgba(18, 30, 45, 0.72);
    color: var(--chat-text);
    text-align: right;
    transition: background var(--motion-fast, 180ms ease), border-color var(--motion-fast, 180ms ease), transform var(--motion-fast, 180ms ease);
}

body.chat-page .composer-mention-item:hover,
body.chat-page .composer-mention-item:focus-visible,
body.chat-page .composer-mention-item.is-selected {
    background: rgba(130, 182, 255, 0.16);
    border-color: rgba(130, 182, 255, 0.26);
    transform: translateY(-1px);
}

body.chat-page .composer-mention-item__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 50%;
    background: rgba(130, 182, 255, 0.16);
    color: var(--chat-accent);
    font-weight: 800;
    font-size: 0.82rem;
}

body.chat-page .composer-mention-item__copy {
    display: grid;
    gap: 0.12rem;
    min-width: 0;
}

body.chat-page .composer-mention-item__copy strong,
body.chat-page .composer-mention-item__copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.chat-page .composer-mention-item__copy small {
    color: var(--chat-muted);
}

body.chat-page .composer-mention-item__badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.3rem;
    margin-inline-start: 0.42rem;
    padding: 0 0.42rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chat-warning) 16%, transparent);
    color: var(--chat-warning);
    font-size: 0.58rem;
    font-weight: 860;
    vertical-align: middle;
}

body.chat-page .composer-emoji-panel {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.55rem;
    padding: 0.6rem;
    border: 1px solid var(--chat-border);
    border-radius: 18px;
    background: var(--chat-control-bg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body.chat-page .composer-emoji-panel[hidden] {
    display: none !important;
}

body.chat-page .composer-emoji-panel__tabs {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    overflow-x: auto;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--chat-border);
}

body.chat-page .composer-emoji-tab {
    flex: 0 0 auto;
    width: 2.2rem;
    height: 2.2rem;
    display: inline-grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    font-size: 1.15rem;
    line-height: 1;
    transition: background var(--motion-fast, 180ms ease), border-color var(--motion-fast, 180ms ease);
}

body.chat-page .composer-emoji-tab:hover,
body.chat-page .composer-emoji-tab:focus-visible,
body.chat-page .composer-emoji-tab.is-active {
    background: rgba(130, 182, 255, 0.16);
    border-color: rgba(130, 182, 255, 0.26);
}

body.chat-page .composer-emoji-panel__grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.2rem;
    max-height: 13.5rem;
    overflow-y: auto;
}

body.chat-page .composer-emoji-item {
    display: inline-grid;
    place-items: center;
    aspect-ratio: 1;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    transition: background var(--motion-fast, 180ms ease), transform var(--motion-fast, 180ms ease);
}

body.chat-page .composer-emoji-item:hover,
body.chat-page .composer-emoji-item:focus-visible {
    background: rgba(130, 182, 255, 0.16);
    transform: translateY(-1px);
}

@media (max-width: 720px) {
    body.chat-page .composer-emoji-panel__grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        max-height: 11.5rem;
    }
}

body.chat-page .msg-mention {
    display: inline-flex;
    align-items: center;
    min-height: 1.7rem;
    margin-inline: 0.08rem;
    padding: 0.08rem 0.52rem;
    border-radius: 999px;
    background: rgba(130, 182, 255, 0.16);
    color: var(--chat-accent);
    font-weight: 780;
}

body.chat-page .msg-poll {
    display: grid;
    gap: 0.7rem;
    margin-top: 0.3rem;
    padding: 0.9rem;
    border: 1px solid rgba(130, 182, 255, 0.18);
    border-radius: 20px;
    background: rgba(9, 18, 29, 0.7);
}

body.chat-page .msg-poll__head,
body.chat-page .msg-poll__actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

body.chat-page .msg-poll__head {
    justify-content: space-between;
}

body.chat-page .msg-poll__question {
    font-size: 0.96rem;
    line-height: 1.9;
}

body.chat-page .msg-poll__status,
body.chat-page .msg-poll__summary {
    color: var(--chat-muted);
    font-size: 0.74rem;
}

body.chat-page .msg-poll__status {
    padding: 0.18rem 0.56rem;
    border-radius: 999px;
    background: rgba(130, 182, 255, 0.12);
    color: var(--chat-accent);
    font-weight: 760;
}

body.chat-page .msg-poll__meta {
    color: var(--chat-muted);
    font-size: 0.76rem;
    line-height: 1.8;
}

body.chat-page .msg-poll__options {
    display: grid;
    gap: 0.5rem;
}

body.chat-page .msg-poll__option {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.8rem;
    align-items: center;
    width: 100%;
    overflow: hidden;
    padding: 0.78rem 0.88rem;
    border: 1px solid rgba(130, 182, 255, 0.14);
    border-radius: 16px;
    background: rgba(18, 31, 46, 0.84);
    color: var(--chat-text);
    text-align: right;
    transition: border-color var(--motion-fast, 180ms ease), transform var(--motion-fast, 180ms ease), background var(--motion-fast, 180ms ease);
}

body.chat-page .msg-poll__option:hover,
body.chat-page .msg-poll__option:focus-visible,
body.chat-page .msg-poll__option.is-selected {
    border-color: rgba(130, 182, 255, 0.3);
    background: rgba(22, 38, 56, 0.96);
    transform: translateY(-1px);
}

body.chat-page .msg-poll__option.is-readonly {
    cursor: default;
}

body.chat-page .msg-poll__option-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: calc(var(--poll-fill, 0) * 1%);
    background: linear-gradient(90deg, rgba(130, 182, 255, 0.18), rgba(79, 214, 202, 0.16));
    pointer-events: none;
}

body.chat-page .msg-poll__option-copy {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

body.chat-page .msg-poll__option-copy strong,
body.chat-page .msg-poll__option-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.chat-page .msg-poll__option-copy small {
    color: var(--chat-muted);
}

body.chat-page .msg-poll__option-check {
    position: relative;
    z-index: 1;
    min-width: 1.35rem;
    color: var(--chat-accent);
    font-weight: 900;
    text-align: center;
}

body.chat-page .msg-poll__actions {
    justify-content: flex-start;
}

body.chat-page .msg-poll__action {
    min-height: 2.2rem;
    padding: 0.45rem 0.82rem;
    border: 1px solid rgba(130, 182, 255, 0.18);
    border-radius: 999px;
    background: rgba(18, 31, 46, 0.82);
    color: var(--chat-text);
    font-size: 0.76rem;
    font-weight: 760;
}

body.chat-page .msg-poll__action--primary {
    background: linear-gradient(135deg, rgba(124, 176, 255, 0.92), rgba(79, 214, 202, 0.92));
    color: #08111a;
    border-color: transparent;
}

body.chat-page .msg-poll__action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 720px) {
    body.chat-page .composer-mention-item {
        padding: 0.66rem 0.72rem;
    }

    body.chat-page .msg-poll {
        padding: 0.78rem;
    }

    body.chat-page .msg-poll__option {
        padding: 0.72rem 0.78rem;
    }
}

/* Chat bottom nav: a docked, full-width tab bar pinned to the bottom edge
   (Telegram / Digikala style) — only on the chat page. Stays fixed at bottom:0
   from the base rule; here we drop the floating pill and make it a solid bar with
   icon + label tabs. Must remain last so it wins the cascade. */
body.chat-page .chat-mobile-nav:not([hidden]) {
    display: flex !important;
    align-items: stretch !important;
    justify-content: center !important;
    grid-template-columns: none !important;
    position: fixed !important;
    inset-inline: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    padding: 0.24rem 0.4rem calc(0.24rem + env(safe-area-inset-bottom, 0px)) !important;
    background: var(--chat-bale-surface, var(--chat-pane-bg-strong)) !important;
    border: 0 !important;
    border-top: 1px solid var(--chat-border) !important;
    border-radius: 0 !important;
    box-shadow: 0 -10px 28px -22px rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: blur(18px) !important;
}

body.chat-page .chat-mobile-nav__inner {
    width: 100% !important;
    max-width: 560px !important;
    margin: 0 auto !important;
    padding: 0 !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: space-around !important;
    gap: 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body.chat-page .chat-mobile-nav__item {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: auto !important;
    min-height: 48px !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.16rem !important;
    padding: 0.26rem 0.2rem !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: transparent !important;
    color: var(--chat-muted) !important;
    white-space: nowrap !important;
}

body.chat-page .chat-mobile-nav__item svg {
    width: 23px !important;
    height: 23px !important;
}

body.chat-page .chat-mobile-nav__item > span:not(.chat-mobile-nav__badge) {
    display: block !important;
    font-size: 0.6rem !important;
    font-weight: 760 !important;
    line-height: 1 !important;
}

body.chat-page .chat-mobile-nav__item:not(.is-active):hover,
body.chat-page .chat-mobile-nav__item:not(.is-active):focus-visible {
    color: var(--chat-text) !important;
}

body.chat-page .chat-mobile-nav__item.is-active {
    background: transparent !important;
    color: var(--chat-accent) !important;
    box-shadow: none !important;
}

body.chat-page .chat-mobile-nav__item.is-active svg {
    color: var(--chat-accent) !important;
}

body.chat-page .chat-mobile-nav__item .chat-mobile-nav__badge {
    inset-block-start: 0.2rem !important;
    inset-inline-start: calc(50% + 4px) !important;
    inset-inline-end: auto !important;
    transform: none !important;
}

/* Multi-select fix: every selected conversation must show the selected tint.
   The bale theme gives .is-active an !important background that beat the plain
   .is-selected rule, so only the active row looked selected. This wins for all
   selected rows (and for an active row while it is also selected). */
body.chat-page .conversation-item.is-selected .conversation-item__main {
    background: color-mix(in srgb, var(--chat-bale-blue) 22%, var(--chat-bale-surface)) !important;
    border-color: color-mix(in srgb, var(--chat-bale-blue) 45%, transparent) !important;
}

/* ===== Telegram-style multi-select bars =====
   Top bar (both messages + conversations) replaces the header; a bottom action
   bar (forward/delete) replaces the composer during message selection. Bars flow
   in the existing flex columns, so no overlay/absolute positioning is needed. */
body.chat-page .chat-selection-topbar {
    flex: 0 0 auto;
}

body.chat-page .chat-selection-topbar:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.46rem 0.5rem;
    min-height: 52px;
    border: 0;
    border-bottom: 1px solid var(--chat-border);
    border-radius: 0;
    background: var(--chat-header-bg, var(--chat-sheet-bg));
}

body.chat-page #conversation-manage-bar {
    position: static !important;
    inset: auto !important;
    margin: 0 !important;
    padding: 0.46rem 0.5rem !important;
    border: 0 !important;
    border-bottom: 1px solid var(--chat-border) !important;
    border-radius: 0 !important;
    background: var(--chat-header-bg, var(--chat-sheet-bg)) !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    z-index: auto !important;
}

.chat-selection-topbar__close,
.chat-selection-topbar__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--chat-text);
    transition:
        background var(--motion-fast) var(--motion-ease-standard),
        color var(--motion-fast) var(--motion-ease-standard);
}

.chat-selection-topbar__close svg,
.chat-selection-topbar__icon svg {
    width: 21px;
    height: 21px;
}

.chat-selection-topbar__icon {
    color: var(--chat-muted-strong);
}

.chat-selection-topbar__close:hover,
.chat-selection-topbar__icon:not([disabled]):hover,
.chat-selection-topbar__icon:not([disabled]):focus-visible {
    background: var(--chat-control-bg-hover);
    color: var(--chat-text);
}

.chat-selection-topbar__icon.is-danger {
    color: var(--chat-danger);
}

.chat-selection-topbar__icon.is-danger:not([disabled]):hover {
    background: rgba(199, 83, 94, 0.12);
}

.chat-selection-topbar__icon[disabled],
.chat-selection-topbar__text[disabled] {
    opacity: 0.4;
    cursor: default;
}

body.chat-page .chat-selection-topbar__count {
    flex: 0 0 auto;
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--chat-text);
    white-space: nowrap;
}

.chat-selection-topbar__actions {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: 0.08rem;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.chat-selection-topbar__actions::-webkit-scrollbar {
    display: none;
}

body.chat-page .chat-selection-topbar__text {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 0.6rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--chat-accent);
    font-size: 0.74rem;
    font-weight: 800;
    white-space: nowrap;
}

.chat-selection-topbar__text:not([disabled]):hover {
    background: var(--chat-accent-soft);
}

body.chat-page .chat-selection-bottombar {
    display: none;
    flex: 0 0 auto;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--chat-border);
    background: var(--chat-composer-bg);
    backdrop-filter: blur(16px);
}

body.chat-page.chat-message-selection-mode .chat-selection-bottombar {
    display: flex;
}

.chat-selection-bottombar__btn {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.42rem;
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid var(--chat-border);
    background: var(--chat-control-bg);
    color: var(--chat-text);
    font-size: 0.86rem;
    font-weight: 820;
    transition:
        background var(--motion-fast) var(--motion-ease-standard),
        border-color var(--motion-fast) var(--motion-ease-standard),
        transform var(--motion-fast) var(--motion-ease-standard);
}

.chat-selection-bottombar__btn svg {
    width: 20px;
    height: 20px;
}

.chat-selection-bottombar__btn:not([disabled]):hover {
    background: var(--chat-control-bg-hover);
    border-color: rgba(43, 109, 243, 0.24);
    transform: translateY(-1px);
}

.chat-selection-bottombar__btn.is-danger {
    color: var(--chat-danger);
    border-color: rgba(199, 83, 94, 0.28);
    background: rgba(199, 83, 94, 0.08);
}

.chat-selection-bottombar__btn.is-danger:not([disabled]):hover {
    background: rgba(199, 83, 94, 0.14);
    border-color: rgba(199, 83, 94, 0.4);
}

.chat-selection-bottombar__btn[disabled] {
    opacity: 0.46;
    cursor: default;
}

body.chat-page.chat-message-selection-mode .thread-head,
body.chat-page.chat-message-selection-mode #mute-badge,
body.chat-page.chat-message-selection-mode #pinned-wrap,
body.chat-page.chat-message-selection-mode .thread-search-panel,
body.chat-page.chat-message-selection-mode .composer {
    display: none !important;
}

body.chat-page.chat-list-selection-mode .conversation-pane__header,
body.chat-page.chat-list-selection-mode #conversation-search-wrap,
body.chat-page.chat-list-selection-mode .conversation-filter-tabs {
    display: none !important;
}

/* Composer alignment with the current site language. Chat keeps its compact
   messenger behavior, while upload/voice states use the same restrained
   surfaces, dividers and control geometry as the rest of the interface. */
body.chat-page .composer {
    padding: 0.42rem 0.56rem calc(0.48rem + env(safe-area-inset-bottom, 0px)) !important;
    border-top: 1px solid var(--chat-border) !important;
    background: var(--chat-bale-surface, var(--chat-composer-bg)) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body.chat-page .composer-box {
    min-height: 50px !important;
    padding: 0.3rem 0.38rem !important;
    gap: 0.28rem !important;
    border: 1px solid var(--chat-border) !important;
    border-radius: 8px !important;
    background: var(--chat-bale-surface-soft, var(--chat-input-bg)) !important;
    box-shadow: none !important;
}

body.chat-page .composer-box:focus-within {
    border-color: color-mix(in srgb, var(--chat-accent) 46%, var(--chat-border)) !important;
    background: var(--chat-bale-surface, var(--chat-input-bg)) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--chat-accent) 10%, transparent) !important;
}

body.chat-page .composer-tools {
    gap: 0.06rem !important;
}

body.chat-page .composer-tool,
body.chat-page .composer-send {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 8px !important;
    box-shadow: none !important;
}

body.chat-page .composer-tool {
    border: 0 !important;
    background: transparent !important;
    color: var(--chat-bale-muted, var(--chat-muted)) !important;
}

body.chat-page .composer-tool:hover,
body.chat-page .composer-tool:focus-visible,
body.chat-page .composer-tool.is-open,
body.chat-page .composer-tool.is-recording {
    transform: none !important;
    color: var(--chat-accent) !important;
    background: color-mix(in srgb, var(--chat-accent) 10%, transparent) !important;
}

body.chat-page .composer-send {
    border: 0 !important;
    background: var(--chat-accent) !important;
    color: var(--text-on-accent, #fff) !important;
}

body.chat-page .composer-entry textarea {
    min-height: 38px !important;
    height: 38px !important;
    padding: 0.42rem 0.58rem !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--chat-bale-text, var(--chat-text)) !important;
    font-size: 16px !important;
    line-height: 22px !important;
}

body.chat-page .composer-upload-sheet {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 0 !important;
    margin: 0 0 0.42rem !important;
    padding: 0 !important;
    overflow: hidden;
    border: 1px solid var(--chat-border) !important;
    border-radius: 8px !important;
    background: var(--chat-bale-surface, var(--chat-sheet-bg)) !important;
    background-image: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body.chat-page .composer-upload-sheet__head {
    min-height: 38px;
    padding: 0.38rem 0.58rem !important;
    border-bottom: 1px solid var(--chat-border);
}

body.chat-page .composer-upload-option {
    min-height: 62px !important;
    gap: 0.28rem !important;
    padding: 0.46rem 0.28rem !important;
    border: 0 !important;
    border-inline-end: 1px solid var(--chat-border) !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--chat-bale-text, var(--chat-text)) !important;
    box-shadow: none !important;
}

body.chat-page .composer-upload-option:first-of-type {
    border-inline-end: 0 !important;
}

body.chat-page .composer-upload-option__icon {
    width: 28px !important;
    height: 28px !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--chat-accent) !important;
}

body.chat-page .composer-upload-option__icon svg {
    width: 19px !important;
    height: 19px !important;
}

body.chat-page .composer-upload-option:hover,
body.chat-page .composer-upload-option:focus-visible {
    transform: none !important;
    border-color: var(--chat-border) !important;
    background: color-mix(in srgb, var(--chat-accent) 8%, transparent) !important;
    color: var(--chat-accent) !important;
}

body.chat-page .composer-uploads {
    gap: 0 !important;
    margin: 0 0 0.42rem !important;
    border-block: 1px solid var(--chat-border);
}

body.chat-page .composer-upload-item {
    min-height: 58px;
    padding: 0.38rem 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--chat-border) !important;
    background: transparent !important;
}

body.chat-page .composer-upload-item:last-child {
    border-bottom: 0 !important;
}

body.chat-page .composer-upload-item__preview {
    width: 48px !important;
    border-radius: 6px !important;
    box-shadow: none !important;
}

body.chat-page .composer-upload-item__edit,
body.chat-page .composer-upload-item__move,
body.chat-page .composer-upload-item__remove {
    border-radius: 6px !important;
    box-shadow: none !important;
}

body.chat-page .composer-voice {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 0.42rem 0.7rem !important;
    margin: 0 0 0.42rem !important;
    padding: 0.48rem 0 !important;
    border: 0 !important;
    border-block: 1px solid var(--chat-border) !important;
    border-radius: 0 !important;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
}

body.chat-page .composer-voice__topline {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

body.chat-page .composer-voice__wave {
    min-width: 0;
    color: var(--chat-accent);
}

body.chat-page .composer-voice__hint {
    grid-column: 1 / -1;
    color: var(--chat-bale-muted, var(--chat-muted));
    font-size: 0.68rem;
    line-height: 1.6;
}

body.chat-page .composer-voice__actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
}

body.chat-page .composer-voice__actions .shell-action-btn {
    min-height: 36px !important;
    border-radius: 6px !important;
    box-shadow: none !important;
}

body.chat-page .composer-status:not(:empty) {
    margin-top: 0.32rem !important;
    padding-inline: 0.18rem;
    font-size: 0.7rem !important;
}

@media (max-width: 980px) {
    body.chat-page .composer {
        padding: 0 !important;
    }

    body.chat-page .composer-box {
        width: 100% !important;
        min-height: 54px !important;
        padding: 0.32rem 0.44rem !important;
        border-inline: 0 !important;
        border-bottom: 0 !important;
        border-radius: 0 !important;
    }

    body.chat-page .composer-upload-sheet {
        inset-inline: 0.5rem !important;
        inset-block-end: calc(0.42rem + env(safe-area-inset-bottom, 0px) + var(--chat-local-nav-height)) !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        max-height: min(19rem, calc(100dvh - var(--chat-local-nav-height) - 5rem));
        overflow-y: auto;
        border-radius: 8px !important;
    }

    body.chat-page .composer-upload-option {
        min-height: 58px !important;
        border-block-end: 1px solid var(--chat-border) !important;
    }

    body.chat-page .composer-voice,
    body.chat-page .composer-uploads {
        margin-inline: 0.52rem !important;
    }

    body.chat-page .composer-voice {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    body.chat-page .composer-voice__actions {
        grid-column: 1;
        grid-row: auto;
        width: 100%;
        justify-self: stretch;
    }

    body.chat-page .composer-voice__actions .shell-action-btn {
        flex: 1 1 0;
    }
}
