﻿.tg-message-date {
    display: inline-flex;
    align-self: center;
    margin: 2px auto 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    color: #d9e7f5;
    background: rgba(68, 90, 112, 0.68);
    backdrop-filter: blur(10px);
}

.tg-system-message {
    display: flex;
    justify-content: center;
    margin: 8px 0;
}

.tg-system-message__pill {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 14px;
    color: #dbe8f5;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    background: rgba(60, 79, 99, 0.58);
    backdrop-filter: blur(12px);
}

.tg-message {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.tg-message--search-hit .tg-message__bubble {
    animation: tg-search-hit-rainbow 2.8s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    will-change: box-shadow, transform;
}

.tg-message--self {
    justify-content: flex-end;
}

.tg-message__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 36px;
    background: rgba(255, 255, 255, 0.08);
}

.tg-message__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tg-message__card {
    max-width: min(78%, 320px);
}

.tg-message__card--image {
    max-width: min(90%, 360px);
}

.tg-message__bubble {
    position: relative;
    padding: 8px 10px 7px;
    border-radius: 18px 18px 18px 8px;
    background: var(--tg-peer-bubble);
    box-shadow: var(--tg-shadow);
}

.tg-message__reply {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding: 6px 8px;
    border-left: 3px solid rgba(124, 202, 255, 0.9);
    border-radius: 10px;
    background: rgba(12, 21, 31, 0.26);
}

.tg-message__reply--jumpable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.tg-message__reply--jumpable:active {
    transform: translateY(1px) scale(0.996);
}

.tg-message__reply--jumpable:focus-visible {
    outline: 2px solid rgba(126, 205, 255, 0.95);
    outline-offset: 1px;
}

.tg-message--self .tg-message__reply {
    border-left-color: rgba(174, 230, 255, 0.94);
    background: rgba(18, 33, 50, 0.34);
}

.tg-message__reply--jumpable:hover {
    background: rgba(19, 33, 48, 0.45);
}

.tg-message--self .tg-message__reply--jumpable:hover {
    background: rgba(30, 53, 78, 0.5);
}

.tg-message__reply-thumb {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

.tg-message__reply-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tg-message__reply-meta {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 1px;
}

.tg-message__reply-author {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #8dd7ff;
    font-size: 11px;
    font-weight: 700;
}

.tg-message__reply-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(229, 238, 247, 0.84);
    font-size: 12px;
}

.tg-message--self .tg-message__bubble {
    border-radius: 18px 18px 8px 18px;
    background: linear-gradient(180deg, rgba(48, 95, 138, 0.98), rgba(39, 82, 121, 1));
}

.tg-message__bubble--image {
    width: clamp(198px, 68vw, 306px);
    padding: 7px;
    overflow: hidden;
}

.tg-message__bubble--sticker {
    padding: 4px 6px 2px;
    background: transparent;
    box-shadow: none;
}

.tg-message__bubble--emoji {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    min-width: 98px;
    min-height: 42px;
    padding: 4px 7px 4px 8px;
    line-height: 1;
}

.tg-message__bubble--emoji .tg-message__author-block {
    margin-bottom: 2px;
}

.tg-message__author {
    font-size: 12px;
    font-weight: 700;
    color: #7fd0ff;
}

.tg-message__author-block {
    margin-bottom: 5px;
}

.tg-message__author-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.tg-message__author-tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tg-message__author-sub {
    margin-top: 2px;
    font-size: 11px;
    color: rgba(231, 239, 246, 0.56);
}

.tg-message__tag,
.tg-panel__tag {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #f6fbff;
    background: var(--tag-color);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.12),
        0 6px 12px rgba(0, 0, 0, 0.12);
}

.tg-message__text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.42;
}

.tg-message__text--empty {
    min-height: 1.42em;
}

.tg-message__text-meta {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.tg-message__text-meta .tg-message__text {
    flex: 1 1 auto;
    min-width: 0;
}

.tg-mention {
    padding: 1px 4px;
    border-radius: 6px;
    background: rgba(255, 218, 95, 0.22);
    box-shadow: inset 0 0 0 1px rgba(255, 229, 130, 0.08);
}

.tg-mention--me {
    background: rgba(255, 132, 95, 0.24);
    color: #ffe3d9;
}

.tg-message__media {
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tg-message__media:focus-visible {
    outline: 2px solid rgba(112, 195, 255, 0.9);
    outline-offset: 1px;
}

.tg-message__media:active {
    outline: none;
    background: rgba(255, 255, 255, 0.05);
}

@media (pointer: coarse) {
    .tg-message__media:focus,
    .tg-message__media:focus-visible {
        outline: none;
    }
}

.tg-message__media::before {
    content: '';
    display: block;
    padding-top: var(--media-ratio, 100%);
}

.tg-message__media.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.05) 18%, rgba(255, 255, 255, 0.12) 38%, rgba(255, 255, 255, 0.05) 58%);
    animation: tg-media-shimmer 1.1s linear infinite;
}

.tg-message__media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.tg-message__media.is-ready img {
    opacity: 1;
}

.tg-message__caption {
    padding: 9px 6px 2px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.45;
}

.tg-message__sticker {
    display: grid;
    place-items: center;
    min-width: 92px;
    min-height: 92px;
    padding: 6px 10px;
    font-size: 52px;
    line-height: 1;
    border-radius: 24px;
    background: transparent;
}

.tg-message__emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    padding: 0;
    font-size: 27.2px;
    line-height: 1;
    transform: translateY(-2px);
    vertical-align: bottom;
}

.tg-message__emoji-row {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    gap: 6px;
}

.tg-message__bubble--emoji .tg-message__meta {
    display: inline-flex;
    align-self: flex-end;
    margin-top: 0;
    padding-bottom: 0;
    white-space: nowrap;
}

.tg-message__sticker-label {
    margin-top: 3px;
    text-align: center;
    font-size: 11px;
    color: rgba(234, 242, 249, 0.68);
}

.tg-message__meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    font-size: 11px;
    color: rgba(235, 243, 250, 0.72);
}

.tg-message__meta--inline {
    display: block;
    min-width: 34px;
    margin-top: 0;
    padding-bottom: 1px;
    text-align: right;
    white-space: nowrap;
}

.tg-message__meta--overlay {
    position: absolute;
    right: 8px;
    bottom: 8px;
    margin-top: 0;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(4, 11, 18, 0.38);
    backdrop-filter: blur(8px);
}

.tg-message__error {
    margin-top: 4px;
    font-size: 11px;
    color: #ffb4b4;
}

.tg-unread-fab {
    position: absolute;
    right: 14px;
    bottom: 96px;
    z-index: 5;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 21px;
    color: #fff;
    background: linear-gradient(135deg, #4ea0eb, #2c7fd9);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.tg-unread-fab.is-mention {
    background: linear-gradient(135deg, #ff8f5a, #f35757);
}

.tg-panel__grid {
    display: grid;
    gap: 8px;
}

.tg-panel__header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.tg-panel__header-row .tg-panel__header {
    margin-bottom: 0;
}

.tg-expression-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.tg-expression-tabs__tab {
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--tg-muted);
    font-size: 12px;
    font-weight: 700;
    background: transparent;
    transition: background 0.16s ease, color 0.16s ease;
}

.tg-expression-tabs__tab.is-active {
    color: #f5fbff;
    background: rgba(83, 169, 235, 0.28);
}

.tg-panel__grid--emoji {
    grid-template-columns: repeat(8, minmax(0, 1fr));
}

.tg-panel__grid--sticker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tg-panel__grid button,
.tg-panel__list button {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--tg-text);
    transition: transform 0.14s ease, background 0.14s ease;
}

.tg-panel__grid button:active,
.tg-panel__list button:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.08);
}

.tg-panel__grid--emoji button {
    height: 42px;
    font-size: 22px;
}

.tg-sticker-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 84px;
    padding: 8px 6px;
}

.tg-sticker-tile__emoji {
    font-size: 32px;
    line-height: 1;
}

.tg-sticker-tile__label {
    font-size: 11px;
    color: var(--tg-muted);
}

.tg-panel__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tg-panel__list button {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
}

.tg-panel__list-text {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
}

.tg-panel__list-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.tg-panel__list-name {
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--tg-text);
}

.tg-panel__list-tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tg-panel__list-avatar {
    width: 30px;
    height: 30px;
    margin-top: 1px;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 30px;
    background: rgba(255, 255, 255, 0.08);
}

.tg-panel__list-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tg-panel__list-sub {
    display: block;
    margin-top: 2px;
    color: var(--tg-muted);
    font-size: 12px;
}

.tg-popup-announcement {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.tg-popup-announcement.is-open {
    opacity: 1;
    pointer-events: auto;
}

.tg-popup-announcement__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 18, 0.62);
    -webkit-backdrop-filter: blur(18px) saturate(145%);
    backdrop-filter: blur(18px) saturate(145%);
    will-change: backdrop-filter;
}

.tg-popup-announcement__dialog {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(112px, 150px) minmax(0, 1fr);
    width: min(100%, 520px);
    max-width: calc(100vw - 8px);
    max-height: min(82dvh, 680px);
    overflow: hidden;
    border: 1px solid rgba(137, 174, 210, 0.3);
    border-radius: 18px;
    background:
        radial-gradient(circle at 90% 0%, rgba(209, 124, 95, 0.2), transparent 34%),
        linear-gradient(180deg, rgba(18, 33, 50, 0.98), rgba(9, 20, 34, 0.98));
    color: #e8f3ff;
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.46),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateY(8px) scale(0.98);
    transition: transform 0.18s ease;
}

.tg-popup-announcement.is-open .tg-popup-announcement__dialog {
    transform: translateY(0) scale(1);
}

.tg-popup-announcement.is-single .tg-popup-announcement__dialog {
    grid-template-columns: minmax(0, 1fr);
}

.tg-popup-announcement__tabs {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    padding: 14px 10px;
    overflow-y: auto;
    background: rgba(12, 24, 38, 0.72);
    border-right: 1px solid rgba(122, 161, 199, 0.18);
}

.tg-popup-announcement__tabs.is-single {
    display: none;
}

.tg-popup-announcement__tab {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 10px;
    color: #9fb8d2;
    background: transparent;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    word-break: break-word;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.tg-popup-announcement__tab.is-active {
    color: #fff4ef;
    background: rgba(209, 124, 95, 0.18);
    box-shadow: 0 10px 22px rgba(209, 124, 95, 0.14);
}

.tg-popup-announcement__tab:active {
    transform: scale(0.98);
}

.tg-popup-announcement__content {
    position: relative;
    display: grid;
    gap: 12px;
    min-width: 0;
    max-height: min(82dvh, 680px);
    overflow-y: auto;
    padding: 20px;
}

.tg-popup-announcement__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #d7e6f5;
    background: rgba(118, 156, 193, 0.18);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    font-size: 22px;
    line-height: 1;
}

.tg-popup-announcement__media {
    width: 100%;
    aspect-ratio: 21 / 9;
    max-height: 142px;
    overflow: hidden;
    border-radius: 13px;
    background: linear-gradient(135deg, rgba(25, 43, 64, 0.9), rgba(14, 27, 43, 0.94));
}

.tg-popup-announcement__media.is-empty {
    display: none;
}

.tg-popup-announcement__media img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.tg-popup-announcement__body {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.tg-popup-announcement__body h2 {
    margin: 0;
    color: #f4fbff;
    font-size: 17px;
    font-weight: 780;
    line-height: 1.25;
    word-break: break-word;
}

.tg-popup-announcement__markdown {
    margin: 0;
    color: #b3c7dc;
    font-size: 12px;
    line-height: 1.55;
    word-break: break-word;
}

.tg-popup-announcement__markdown.is-empty {
    display: none;
}

.tg-popup-announcement__markdown > * {
    margin: 0;
}

.tg-popup-announcement__markdown > * + * {
    margin-top: 8px;
}

.tg-popup-announcement__markdown h3,
.tg-popup-announcement__markdown h4,
.tg-popup-announcement__markdown h5 {
    color: #edf7ff;
    font-size: 13px;
    font-weight: 780;
    line-height: 1.35;
}

.tg-popup-announcement__markdown ul,
.tg-popup-announcement__markdown ol {
    display: grid;
    gap: 3px;
    padding-left: 18px;
}

.tg-popup-announcement__markdown blockquote {
    padding: 5px 0 5px 10px;
    border-left: 3px solid rgba(223, 139, 105, 0.68);
    color: #c7d8e9;
    background: rgba(255, 255, 255, 0.04);
}

.tg-popup-announcement__markdown a {
    color: #8fd1ff;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.tg-popup-announcement__markdown strong {
    color: #f2fbff;
}

.tg-popup-announcement__markdown code {
    padding: 1px 5px;
    border-radius: 5px;
    color: #ffe4d6;
    background: rgba(209, 124, 95, 0.18);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.94em;
}

.tg-popup-announcement__confirm {
    justify-self: end;
    min-width: 104px;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(180deg, #df8b69, #c56b4d);
    font-size: 13px;
    font-weight: 780;
    box-shadow: 0 12px 26px rgba(197, 107, 77, 0.24);
}

@media (max-width: 640px) {
    .tg-popup-announcement {
        align-items: center;
        padding: 14px;
    }

    .tg-popup-announcement__dialog {
        grid-template-columns: minmax(96px, 112px) minmax(0, 1fr);
        width: min(94vw, 420px);
        max-height: 86dvh;
    }

    .tg-popup-announcement__tabs {
        flex-direction: column;
        gap: 7px;
        padding: 10px 8px;
        overflow-x: hidden;
        overflow-y: auto;
        border-right: 1px solid rgba(122, 161, 199, 0.18);
        border-bottom: none;
    }

    .tg-popup-announcement__tab {
        width: 100%;
        max-width: none;
        white-space: normal;
        overflow: hidden;
        text-align: left;
    }

    .tg-popup-announcement__content {
        max-height: 86dvh;
        padding: 16px;
    }

    .tg-popup-announcement__media {
        aspect-ratio: 21 / 9;
        max-height: 128px;
        border-radius: 12px;
    }

    .tg-popup-announcement__body h2 {
        padding-right: 30px;
        font-size: 16px;
    }

    .tg-popup-announcement__confirm {
        justify-self: stretch;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tg-popup-announcement,
    .tg-popup-announcement__dialog,
    .tg-popup-announcement__tab {
        transition: none;
    }
}

.tg-ranking-layer {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.tg-reducer-layer,
.tg-shenmi-layer {
    position: fixed;
    inset: 0;
    z-index: 52;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.tg-ranking-layer.is-open {
    opacity: 1;
    pointer-events: auto;
}

.tg-reducer-layer.is-open,
.tg-shenmi-layer.is-open {
    opacity: 1;
    pointer-events: auto;
}

.tg-ranking-layer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 18, 0.62);
    -webkit-backdrop-filter: blur(16px) saturate(145%);
    backdrop-filter: blur(16px) saturate(145%);
    will-change: backdrop-filter;
}

.tg-reducer-layer__backdrop,
.tg-shenmi-layer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 18, 0.66);
    -webkit-backdrop-filter: blur(16px) saturate(145%);
    backdrop-filter: blur(16px) saturate(145%);
    will-change: backdrop-filter;
}

.tg-popup-announcement,
.tg-ranking-layer,
.tg-reducer-layer,
.tg-shenmi-layer,
.tg-popup-announcement__backdrop,
.tg-ranking-layer__backdrop,
.tg-reducer-layer__backdrop,
.tg-shenmi-layer__backdrop {
    -webkit-tap-highlight-color: transparent;
}

.tg-popup-announcement__backdrop,
.tg-ranking-layer__backdrop,
.tg-reducer-layer__backdrop,
.tg-shenmi-layer__backdrop {
    appearance: none;
    -webkit-appearance: none;
    touch-action: manipulation;
    user-select: none;
}

.tg-popup-announcement__backdrop:active,
.tg-popup-announcement__backdrop:focus,
.tg-popup-announcement__backdrop:focus-visible,
.tg-ranking-layer__backdrop:active,
.tg-ranking-layer__backdrop:focus,
.tg-ranking-layer__backdrop:focus-visible,
.tg-reducer-layer__backdrop:active,
.tg-reducer-layer__backdrop:focus,
.tg-reducer-layer__backdrop:focus-visible,
.tg-shenmi-layer__backdrop:active,
.tg-shenmi-layer__backdrop:focus,
.tg-shenmi-layer__backdrop:focus-visible {
    outline: none;
    background: rgba(5, 10, 18, 0.62);
}

.tg-reducer-dialog,
.tg-shenmi-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 980px);
    height: min(88dvh, 820px);
    overflow: hidden;
    border-radius: 20px;
    border: 1px solid rgba(137, 174, 210, 0.28);
    background:
        linear-gradient(180deg, rgba(17, 26, 40, 0.98), rgba(8, 16, 28, 0.98)),
        radial-gradient(circle at 86% 0%, rgba(209, 124, 95, 0.24), transparent 34%);
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateY(10px) scale(0.98);
    transition: transform 0.2s ease;
}

.tg-reducer-layer.is-open .tg-reducer-dialog,
.tg-shenmi-layer.is-open .tg-shenmi-dialog {
    transform: translateY(0) scale(1);
}

.tg-reducer-dialog__close,
.tg-shenmi-dialog__close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #fff4ef;
    background: rgba(209, 124, 95, 0.9);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    font-size: 24px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.tg-reducer-dialog__close:active,
.tg-reducer-dialog__close:focus,
.tg-reducer-dialog__close:focus-visible,
.tg-shenmi-dialog__close:active,
.tg-shenmi-dialog__close:focus,
.tg-shenmi-dialog__close:focus-visible {
    outline: none;
    background: rgba(209, 124, 95, 0.96);
}

.tg-reducer-dialog__frame,
.tg-shenmi-dialog__frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #0f1320;
}

.tg-ranking-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 480px);
    max-height: min(82dvh, 680px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px;
    border: 1px solid rgba(137, 174, 210, 0.28);
    background:
        linear-gradient(180deg, rgba(18, 33, 50, 0.98), rgba(9, 20, 34, 0.98)),
        radial-gradient(circle at 85% 0%, rgba(209, 124, 95, 0.22), transparent 32%);
    color: #e8f3ff;
    box-shadow:
        0 28px 70px rgba(0, 0, 0, 0.46),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateY(10px) scale(0.98);
    transition: transform 0.2s ease;
}

.tg-ranking-layer.is-open .tg-ranking-dialog {
    transform: translateY(0) scale(1);
}

.tg-ranking-dialog__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 12px;
    border-bottom: 1px solid rgba(122, 161, 199, 0.18);
}

.tg-ranking-dialog__eyebrow {
    margin-bottom: 3px;
    color: #d17c5f;
    font-size: 12px;
    font-weight: 800;
}

.tg-ranking-dialog__head h2 {
    margin: 0;
    color: #f4fbff;
    font-size: 22px;
    line-height: 1.2;
}

.tg-ranking-dialog__head p {
    margin: 5px 0 0;
    color: #93aec8;
    font-size: 12px;
    line-height: 1.4;
}

.tg-ranking-dialog__close {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 50%;
    color: #d7e6f5;
    background: rgba(118, 156, 193, 0.18);
    font-size: 22px;
    line-height: 1;
}

.tg-ranking-dialog__summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 18px;
}

.tg-ranking-dialog__summary-item {
    min-width: 0;
    padding: 10px;
    border-radius: 13px;
    background: rgba(112, 153, 193, 0.12);
    border: 1px solid rgba(128, 170, 210, 0.17);
}

.tg-ranking-dialog__summary-item strong {
    display: block;
    color: #ffffff;
    font-size: 16px;
    line-height: 1.1;
}

.tg-ranking-dialog__summary-item span {
    display: block;
    margin-top: 4px;
    color: #8faccc;
    font-size: 11px;
}

.tg-ranking-dialog__list {
    min-height: 180px;
    overflow-y: auto;
    padding: 4px 12px 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--tg-scrollbar-thumb) var(--tg-scrollbar-track);
}

.tg-ranking-card {
    display: grid;
    grid-template-columns: 34px 42px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 78px;
    padding: 10px;
    border-radius: 16px;
    background: rgba(21, 39, 59, 0.84);
    border: 1px solid rgba(119, 160, 199, 0.18);
}

.tg-ranking-card + .tg-ranking-card {
    margin-top: 8px;
}

.tg-ranking-card--top {
    border-color: rgba(209, 124, 95, 0.5);
    background:
        linear-gradient(180deg, rgba(51, 49, 54, 0.92), rgba(26, 40, 56, 0.9)),
        radial-gradient(circle at 0 0, rgba(209, 124, 95, 0.32), transparent 42%);
}

.tg-ranking-card__rank {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #ffe8df;
    background: rgba(209, 124, 95, 0.18);
    font-size: 13px;
    font-weight: 840;
}

.tg-ranking-card__avatar {
    width: 42px;
    height: 42px;
    overflow: hidden;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(72, 145, 218, 0.8), rgba(209, 124, 95, 0.8));
}

.tg-ranking-card__avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.tg-ranking-card__avatar-fallback {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
}

.tg-ranking-card__body {
    min-width: 0;
}

.tg-ranking-card__name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.tg-ranking-card__name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #f3f9ff;
    font-size: 14px;
    font-weight: 820;
}

.tg-ranking-card__id {
    flex: 0 0 auto;
    padding: 2px 6px;
    border-radius: 999px;
    color: #ffd8ca;
    background: rgba(209, 124, 95, 0.16);
    font-size: 10px;
    font-weight: 800;
}

.tg-ranking-card__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tg-ranking-card__stat {
    padding: 4px 7px;
    border-radius: 999px;
    color: #bad2e9;
    background: rgba(111, 152, 192, 0.14);
    font-size: 11px;
    line-height: 1.1;
}

.tg-ranking-card__stat strong {
    color: #ffffff;
    font-weight: 820;
}

.tg-ranking-dialog__refresh {
    margin: 0 18px 18px;
    min-height: 40px;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(180deg, #df8b69, #c56b4d);
    font-size: 14px;
    font-weight: 820;
    box-shadow: 0 12px 26px rgba(197, 107, 77, 0.24);
}

.tg-ranking-dialog__refresh[disabled] {
    opacity: 0.58;
    pointer-events: none;
}

.tg-ranking-empty,
.tg-ranking-loading {
    min-height: 180px;
    display: grid;
    place-items: center;
    padding: 24px;
    color: #9eb7d0;
    text-align: center;
    font-size: 14px;
}

@media (max-width: 420px) {
    .tg-reducer-layer,
    .tg-shenmi-layer {
        padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    }

    .tg-reducer-dialog,
    .tg-shenmi-dialog {
        height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
        border-radius: 16px;
    }

    .tg-reducer-dialog__close,
    .tg-shenmi-dialog__close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 22px;
    }

    .tg-ranking-dialog__summary {
        grid-template-columns: 1fr;
    }

    .tg-ranking-card {
        grid-template-columns: 30px 38px minmax(0, 1fr);
        gap: 8px;
    }

    .tg-ranking-card__avatar {
        width: 38px;
        height: 38px;
    }
}

@keyframes tg-media-shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

@media (max-width: 640px), (pointer: coarse) {
    .tg-message-date {
        margin: 1px auto 5px;
        padding: 4px 10px;
        font-size: 10.5px;
    }

    .tg-system-message {
        margin: 6px 0;
    }

    .tg-system-message__pill {
        padding: 6px 10px;
        font-size: 10.5px;
        line-height: 1.42;
    }

    .tg-message {
        gap: 7px;
    }

    .tg-message__avatar {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
    }

    .tg-message__card {
        max-width: min(80%, 280px);
    }

    .tg-message__card--image {
        max-width: min(90%, 310px);
    }

    .tg-message__bubble {
        padding: 6px 8px 6px;
        border-radius: 15px 15px 15px 7px;
    }

    .tg-message--self .tg-message__bubble {
        border-radius: 15px 15px 7px 15px;
    }

    .tg-message__text {
        font-size: 12.5px;
        line-height: 1.38;
    }

    .tg-message__caption {
        padding: 7px 5px 2px;
        font-size: 11.5px;
    }

    .tg-message__author {
        font-size: 10.5px;
    }

    .tg-message__author-block {
        margin-bottom: 4px;
    }

    .tg-message__author-sub,
    .tg-message__reply-author,
    .tg-message__meta,
    .tg-message__error,
    .tg-message__sticker-label {
        font-size: 9.5px;
    }

    .tg-message__reply {
        gap: 6px;
        margin-bottom: 5px;
        padding: 5px 7px;
        border-radius: 8px;
    }

    .tg-message__reply-thumb {
        width: 24px;
        height: 24px;
        flex-basis: 24px;
        border-radius: 6px;
    }

    .tg-message__reply-text {
        font-size: 10px;
    }

    .tg-message__tag,
    .tg-panel__tag {
        min-height: 15px;
        padding: 0 5px;
        font-size: 8.5px;
    }

    .tg-message__bubble--image {
        width: clamp(168px, 64vw, 260px);
        padding: 5px;
    }

    .tg-message__bubble--emoji {
        min-width: 82px;
        min-height: 36px;
        padding: 3px 6px;
    }

    .tg-message__emoji {
        font-size: 22px;
        transform: translateY(-1px);
    }

    .tg-message__emoji-row {
        min-height: 28px;
        gap: 5px;
    }

    .tg-message__sticker {
        min-width: 74px;
        min-height: 74px;
        padding: 5px 8px;
        font-size: 42px;
        border-radius: 20px;
    }

    .tg-message__meta--inline {
        min-width: 28px;
    }

    .tg-message__meta--overlay {
        right: 6px;
        bottom: 6px;
        padding: 2px 5px;
    }

    .tg-unread-fab {
        right: 10px;
        bottom: 78px;
        min-height: 34px;
        padding: 0 12px;
        border-radius: 17px;
        font-size: 12px;
    }

    .tg-panel__grid {
        gap: 6px;
    }

    .tg-expression-tabs__tab {
        height: 24px;
        padding: 0 10px;
        font-size: 10.5px;
    }

    .tg-panel__grid--emoji button {
        height: 34px;
        font-size: 18px;
    }

    .tg-sticker-tile {
        min-height: 68px;
        gap: 5px;
        padding: 6px 5px;
    }

    .tg-sticker-tile__emoji {
        font-size: 26px;
    }

    .tg-sticker-tile__label {
        font-size: 9.5px;
    }
}

@media (max-width: 640px), (pointer: coarse) {
    .tg-message-date {
        padding: 4.2px 10.5px;
        font-size: 11px;
    }

    .tg-system-message__pill {
        padding: 6.5px 10.5px;
        font-size: 11px;
    }

    .tg-message {
        gap: 7.5px;
    }

    .tg-message__avatar {
        width: 31.5px;
        height: 31.5px;
        flex-basis: 31.5px;
    }

    .tg-message__card {
        max-width: min(81%, 294px);
    }

    .tg-message__card--image {
        max-width: min(91%, 326px);
    }

    .tg-message__bubble {
        padding: 6.5px 8.5px;
        border-radius: 16px 16px 16px 7.5px;
    }

    .tg-message--self .tg-message__bubble {
        border-radius: 16px 16px 7.5px 16px;
    }

    .tg-message__text {
        font-size: 13.1px;
        line-height: 1.4;
    }

    .tg-message__caption {
        padding: 7.5px 5.5px 2px;
        font-size: 12px;
    }

    .tg-message__author {
        font-size: 11px;
    }

    .tg-message__author-sub,
    .tg-message__reply-author,
    .tg-message__meta,
    .tg-message__error,
    .tg-message__sticker-label {
        font-size: 10px;
    }

    .tg-message__reply {
        gap: 6.5px;
        margin-bottom: 5.5px;
        padding: 5.5px 7.5px;
        border-radius: 8.5px;
    }

    .tg-message__reply-thumb {
        width: 25px;
        height: 25px;
        flex-basis: 25px;
    }

    .tg-message__reply-text {
        font-size: 10.5px;
    }

    .tg-message__tag,
    .tg-panel__tag {
        min-height: 16px;
        padding: 0 5.5px;
        font-size: 9px;
    }

    .tg-message__bubble--image {
        width: clamp(176px, 65vw, 273px);
        padding: 5.5px;
    }

    .tg-message__bubble--emoji {
        min-width: 86px;
        min-height: 38px;
        padding: 3.2px 6.5px;
    }

    .tg-message__emoji {
        font-size: 23px;
    }

    .tg-message__emoji-row {
        min-height: 29.5px;
        gap: 5.5px;
    }

    .tg-message__sticker {
        min-width: 78px;
        min-height: 78px;
        padding: 5.5px 8.5px;
        font-size: 44px;
        border-radius: 21px;
    }

    .tg-message__meta--inline {
        min-width: 29.5px;
    }

    .tg-message__meta--overlay {
        right: 6.5px;
        bottom: 6.5px;
    }

    .tg-unread-fab {
        right: 10.5px;
        bottom: 82px;
        min-height: 36px;
        padding: 0 12.5px;
        border-radius: 18px;
        font-size: 12.5px;
    }

    .tg-panel__grid {
        gap: 6.5px;
    }

    .tg-expression-tabs__tab {
        height: 25px;
        padding: 0 10.5px;
        font-size: 11px;
    }

    .tg-panel__grid--emoji button {
        height: 36px;
        font-size: 19px;
    }

    .tg-sticker-tile {
        min-height: 71px;
        gap: 5.5px;
        padding: 6.5px 5.5px;
    }

    .tg-sticker-tile__emoji {
        font-size: 27.5px;
    }

    .tg-sticker-tile__label {
        font-size: 10px;
    }
}

@keyframes tg-search-hit-rainbow {
    0% {
        box-shadow:
            0 0 0 0 rgba(255, 96, 180, 0.0),
            0 0 0 0 rgba(255, 96, 180, 0.0),
            var(--tg-shadow);
        transform: translateY(0) scale(1);
    }

    14% {
        box-shadow:
            0 0 0 2px rgba(255, 96, 180, 0.95),
            0 0 0 7px rgba(255, 96, 180, 0.18),
            0 0 22px rgba(255, 96, 180, 0.42),
            var(--tg-shadow);
    }

    30% {
        box-shadow:
            0 0 0 2px rgba(255, 171, 77, 0.95),
            0 0 0 7px rgba(255, 171, 77, 0.18),
            0 0 22px rgba(255, 171, 77, 0.42),
            var(--tg-shadow);
        transform: translateY(-0.4px) scale(1.005);
    }

    46% {
        box-shadow:
            0 0 0 2px rgba(255, 230, 109, 0.95),
            0 0 0 7px rgba(255, 230, 109, 0.18),
            0 0 22px rgba(255, 230, 109, 0.4),
            var(--tg-shadow);
    }

    62% {
        box-shadow:
            0 0 0 2px rgba(79, 231, 223, 0.95),
            0 0 0 7px rgba(79, 231, 223, 0.18),
            0 0 22px rgba(79, 231, 223, 0.42),
            var(--tg-shadow);
        transform: translateY(0) scale(1);
    }

    78% {
        box-shadow:
            0 0 0 2px rgba(98, 173, 255, 0.95),
            0 0 0 7px rgba(98, 173, 255, 0.18),
            0 0 22px rgba(98, 173, 255, 0.42),
            var(--tg-shadow);
    }

    84% {
        box-shadow:
            0 0 0 2px rgba(176, 126, 255, 0.9),
            0 0 0 7px rgba(176, 126, 255, 0.16),
            0 0 18px rgba(176, 126, 255, 0.34),
            var(--tg-shadow);
    }

    90% {
        box-shadow:
            0 0 0 2px rgba(176, 126, 255, 0.62),
            0 0 0 6px rgba(176, 126, 255, 0.12),
            0 0 15px rgba(176, 126, 255, 0.24),
            var(--tg-shadow);
    }

    95% {
        box-shadow:
            0 0 0 1px rgba(176, 126, 255, 0.35),
            0 0 0 4px rgba(176, 126, 255, 0.08),
            0 0 10px rgba(176, 126, 255, 0.16),
            var(--tg-shadow);
    }

    98% {
        box-shadow:
            0 0 0 1px rgba(176, 126, 255, 0.16),
            0 0 0 2px rgba(176, 126, 255, 0.04),
            0 0 6px rgba(176, 126, 255, 0.08),
            var(--tg-shadow);
    }

    100% {
        box-shadow:
            0 0 0 0 rgba(176, 126, 255, 0),
            0 0 0 0 rgba(176, 126, 255, 0),
            var(--tg-shadow);
        transform: translateY(0) scale(1);
    }
}
