.chats-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.chats-page {
    min-height: 0;
    height: 100%;
}

.chats-page__header {
    margin-bottom: 16px;
}

.chats-page__title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.4px;
    margin: 0;
}

.chats-page__segment {
    --seg-offset: 0;
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 0;
    height: 40px;
    padding: 4px;
    margin-bottom: 14px;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.chats-page__segment-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 8px) / 3);
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.35);
    transform: translateX(calc(var(--seg-offset) * 100%));
    transition: transform 0.28s ease-out;
    pointer-events: none;
}

.chats-page__segment-item {
    position: relative;
    z-index: 1;
    flex: 1;
    border: none;
    background: transparent;
    border-radius: var(--radius-pill);
    padding: 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.chats-page__segment-item--active {
    color: #fff;
}

.chats-page__segment--dragging .chats-page__segment-indicator {
    transition: none;
}

.chats-page__viewport {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: pan-y;
}

.chats-page__track {
    display: flex;
    flex: 1;
    min-height: 0;
    will-change: transform;
}

.chats-page__panel {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chats-page__refresh {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

@media (prefers-reduced-motion: reduce) {
    .chats-page__segment-indicator,
    .chats-page__track {
        transition: none !important;
    }
}

.chats-list__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 0;
    border: none;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    text-align: left;
    color: inherit;
}

.chats-list__item:last-child {
    border-bottom: none;
}

.chats-list__avatar,
.chats-list__avatar.async-image {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    flex-shrink: 0;
    background: var(--color-primary-subtle);
}

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

.chats-list__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.chats-list__body {
    flex: 1;
    min-width: 0;
}

.chats-list__title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chats-list__preview {
    font-size: 13px;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chats-list__unread {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    flex-shrink: 0;
}

.chat-thread {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

.chat-thread--back-swiping {
    transition: none;
    will-change: transform;
}

.chat-thread__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0 12px;
    flex-shrink: 0;
}

.chat-thread__back {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text);
}

.chat-thread__more {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text);
}

.chat-thread__title-wrap {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    color: inherit;
}

.chat-thread__title-wrap--link {
    cursor: pointer;
}

.chat-thread__title-wrap--link:active {
    opacity: 0.75;
}

.chat-thread__title-wrap:disabled {
    cursor: default;
}

.chat-thread__title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-thread__subtitle {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin: 0;
}

.chat-thread__messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 0 12px;
}

.chat-thread__load-more {
    align-self: center;
    margin-bottom: 4px;
}

.chat-swipe {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 100%;
    touch-action: pan-y;
}

.chat-swipe--in {
    align-self: flex-start;
    justify-content: flex-start;
    max-width: calc(78% + 40px);
}

.chat-swipe--out {
    align-self: flex-end;
    justify-content: flex-end;
    max-width: 78%;
}

.chat-swipe--clustered {
    margin-top: -8px;
}

.chat-swipe--system {
    align-self: center;
    justify-content: center;
    max-width: 92%;
}

.chat-swipe--dragging .chat-message-row,
.chat-swipe--dragging .chat-system {
    transition: none;
}

.chat-swipe__action {
    position: absolute;
    right: 4px;
    top: 50%;
    width: 36px;
    height: 36px;
    margin-top: -18px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 0;
}

.chat-swipe--highlight .chat-bubble,
.chat-swipe--highlight .chat-system {
    animation: chat-reply-highlight 1.4s ease;
}

@keyframes chat-reply-highlight {
    0% { box-shadow: 0 0 0 0 rgba(224, 122, 95, 0.45); }
    35% { box-shadow: 0 0 0 4px rgba(224, 122, 95, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(224, 122, 95, 0); }
}

.chat-thread--reply-swiping .chat-thread__messages {
    overflow-y: hidden;
}

.chat-message-row {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    transition: transform 0.18s ease;
}

.chat-message-row--in {
    max-width: 100%;
}

.chat-message-row--out {
    justify-content: flex-end;
    max-width: 100%;
}

.chat-message-row__avatar {
    width: 32px;
    flex-shrink: 0;
    align-self: flex-end;
}

.chat-message-row__avatar-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    flex-shrink: 0;
    align-self: flex-end;
    cursor: pointer;
}

.chat-message-row__avatar-btn:active {
    opacity: 0.75;
}

.chat-message-row__avatar-img.meets-avatar,
.chat-message-row__avatar-img.meets-avatar--placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 13px;
    object-fit: cover;
    overflow: hidden;
}

.chat-bubble {
    max-width: 100%;
    min-width: 0;
    flex: 1;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
}

.chat-bubble--in {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 6px;
}

.chat-bubble--out {
    background: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.chat-bubble__sender {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--color-afisha);
    cursor: pointer;
}

.chat-bubble__sender:active {
    opacity: 0.75;
}

.chat-bubble__quote {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    margin: 0 0 8px;
    padding: 6px 10px;
    border: none;
    border-left: 3px solid rgba(255, 255, 255, 0.55);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.chat-bubble--in .chat-bubble__quote {
    border-left-color: var(--color-primary);
    background: rgba(224, 122, 95, 0.1);
}

.chat-bubble__quote-author {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    opacity: 0.95;
}

.chat-bubble--in .chat-bubble__quote-author {
    color: var(--color-primary);
}

.chat-bubble__quote-text {
    font-size: 13px;
    line-height: 1.3;
    opacity: 0.85;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-bubble__meta {
    font-size: 12px;
    opacity: 0.75;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-bubble__delivery--sending {
    opacity: 0.85;
}

.chat-bubble--failed {
    outline: 1px solid rgba(255, 255, 255, 0.35);
}

.chat-bubble--in.chat-bubble--failed {
    outline-color: rgba(196, 61, 92, 0.35);
}

.chat-bubble__failed {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 12px;
}

.chat-bubble--in .chat-bubble__failed {
    border-top-color: var(--color-border);
    color: #c43d5c;
}

.chat-bubble__failed-icon {
    display: inline-flex;
    flex-shrink: 0;
}

.chat-bubble__retry {
    margin-left: auto;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.chat-bubble--in .chat-bubble__retry {
    background: rgba(196, 61, 92, 0.12);
    color: #c43d5c;
}

.chat-bubble__attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.chat-bubble__image-wrap {
    position: relative;
    display: block;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.chat-bubble__image {
    max-width: 100%;
    border-radius: 12px;
    display: block;
}

.chat-bubble__image-btn {
    display: block;
    max-width: 100%;
}

.chat-bubble__image-btn:disabled {
    pointer-events: none;
}

.chat-bubble__upload {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.38);
    border-radius: 12px;
}

.chat-bubble__upload-cancel {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    padding: 0;
    line-height: 1;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.chat-bubble__upload-progress {
    width: 52px;
    height: 52px;
    position: relative;
}

.chat-bubble__upload-ring {
    width: 52px;
    height: 52px;
    transform: rotate(-90deg);
}

.chat-bubble__upload-ring-bg {
    stroke: rgba(255, 255, 255, 0.28);
    stroke-width: 2.5;
}

.chat-bubble__upload-ring-fg {
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: stroke-dasharray 0.12s linear;
}

.chat-bubble__upload-progress--indeterminate .chat-bubble__upload-ring {
    animation: chat-upload-spin 0.9s linear infinite;
}

.chat-bubble__upload-progress--indeterminate .chat-bubble__upload-ring-fg {
    stroke-dasharray: 24 97.389;
}

@keyframes chat-upload-spin {
    to {
        transform: rotate(270deg);
    }
}

.remote-media-image {
    max-width: 100%;
    display: block;
    border-radius: inherit;
}

.remote-media-image--loading,
.remote-media-image--failed {
    min-width: 120px;
    min-height: 120px;
    border-radius: 12px;
    background: rgba(127, 127, 127, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 22px;
    font-weight: 700;
}

.remote-media-image__spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(224, 122, 95, 0.25);
    border-top-color: var(--color-primary, #e07a5f);
    animation: remote-media-spin 0.75s linear infinite;
}

@keyframes remote-media-spin {
    to { transform: rotate(360deg); }
}

.chat-image-viewer__image-wrap {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.chat-image-viewer__image-wrap .remote-media-image,
.chat-image-viewer__image {
    max-width: min(100vw - 32px, 100%);
    max-height: min(70vh, 100%);
    object-fit: contain;
    border-radius: 4px;
}

.chat-image-viewer__image-wrap .remote-media-image--loading,
.chat-image-viewer__image-wrap .remote-media-image--failed {
    min-width: 180px;
    min-height: 180px;
}

.chat-bubble__file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    text-decoration: none;
    color: inherit;
    font-size: 13px;
    text-align: left;
    width: 100%;
}

.chat-bubble__file-action {
    margin-left: auto;
    opacity: 0.75;
    font-weight: 700;
}

.chat-bubble--in .chat-bubble__file {
    background: var(--color-bg);
    color: var(--color-text);
}

.chat-day-separator {
    align-self: center;
    margin: 4px 0;
    padding: 4px 12px;
    border-radius: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text-secondary);
    text-align: center;
}

.chat-system {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(91, 79, 199, 0.08), rgba(224, 122, 95, 0.1));
    border: 1px solid rgba(91, 79, 199, 0.15);
    font-size: 13px;
    line-height: 1.45;
    color: var(--color-text-secondary);
    text-align: center;
    transition: transform 0.18s ease;
}

.chat-system__label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-afisha);
    margin-bottom: 4px;
}

.chat-reply-bar {
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-top: 4px;
    padding: 8px 0 0;
    border-top: 1px solid var(--color-border);
}

.chat-reply-bar__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 6px 12px;
    border: none;
    border-left: 3px solid var(--color-primary);
    border-radius: 10px;
    background: var(--color-surface);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.chat-reply-bar__author {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.chat-reply-bar__text {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
}

.chat-reply-bar__close {
    width: 36px;
    height: 36px;
    align-self: center;
    border: none;
    border-radius: 50%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-input-bar {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--color-border);
    background: transparent;
}

.chat-reply-bar + .chat-input-bar {
    border-top: none;
    padding-top: 8px;
}

.chat-input-bar__attach,
.chat-input-bar__send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-bar__attach {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

.chat-input-bar__send {
    background: var(--color-primary);
    color: #fff;
}

.chat-input-bar__send:disabled {
    opacity: 0.45;
}

.chat-input-bar__field {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 16px;
    border-radius: 22px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    font-size: 15px;
    resize: none;
    line-height: 1.35;
}

.chat-pending-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 8px;
}

.chat-pending-files__item {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

.chat-pending-files__item--preparing {
    background: var(--color-surface-muted, #ececf0);
}

.chat-pending-files__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-pending-files__file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 24px;
}

.chat-pending-files__preparing {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.28);
}

.chat-pending-files__preparing::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: chat-prepare-spin 0.8s linear infinite;
}

@keyframes chat-prepare-spin {
    to {
        transform: rotate(360deg);
    }
}

.chat-pending-files__remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    padding: 0;
    line-height: 1;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-image-viewer {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, var(--viewer-bg-opacity, 0.92));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    touch-action: none;
    overscroll-behavior: none;
    transition: background 0.18s ease;
}

.chat-image-viewer--dragging {
    transition: none;
}

.chat-image-viewer--dragging .chat-image-viewer__image-wrap,
.chat-image-viewer--dragging .chat-image-viewer__close,
.chat-image-viewer--dragging .chat-image-viewer__actions {
    transition: none;
}

.chat-image-viewer--dismissing .chat-image-viewer__image-wrap {
    transition: transform 0.12s ease-out;
}

.chat-image-viewer__close {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: opacity 0.18s ease;
}

.chat-image-viewer__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.chat-image-viewer__actions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
    z-index: 1;
    transition: opacity 0.18s ease;
}

.chat-image-viewer__action {
    min-width: 120px;
    height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.chat-image-viewer__action:disabled {
    opacity: 0.55;
}

.chat-image-viewer__status {
    position: absolute;
    left: 50%;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    max-width: min(90vw, 360px);
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(20, 20, 20, 0.88);
    color: #fff;
    font-size: 13px;
    text-align: center;
    z-index: 2;
    pointer-events: none;
}

.profile-hero-page__dm {
    margin-top: 12px;
}

.profile-hero-page__dm-btn {
    width: 100%;
    height: 48px;
    border-radius: 16px;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

.profile-hero-page__dm-btn:disabled {
    opacity: 0.6;
}
