/* ============================================================
   TOKSY — App styles (полный, adaptive, Apple-style)
   ============================================================ */

/* ============================================================
   1. КОНТЕЙНЕР
   ============================================================ */

.app {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-app);
    position: relative;
}

/* ============================================================
   2. SIDEBAR
   ============================================================ */

.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    overflow: hidden;
    flex: 1;
    min-height: 0;
    min-width: 0;
    position: relative;
}

.view { display: none; flex-direction: column; height: 100%; min-height: 0; }
.view.active { display: flex; }

.view[data-view="profile"].active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-sidebar);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-md) var(--sp-md) var(--sp-sm);
    padding-top: calc(var(--sp-md) + var(--safe-top));
    flex-shrink: 0;
    gap: var(--sp-sm);
}

.app-title {
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.search-box {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    margin: 0 var(--sp-sm) var(--sp-sm);
    padding: var(--sp-xs) var(--sp-sm);
    background: var(--bg-input);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: background var(--dur-fast) var(--ease-out);
}
.search-box:focus-within {
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--blue-soft);
}
.search-box input {
    flex: 1;
    font-size: var(--fs-base);
    min-width: 0;
    color: var(--text-primary);
    padding: var(--sp-2xs) 0;
}
.search-box input::placeholder { color: var(--text-tertiary); }

.tabs-bar {
    display: flex;
    gap: var(--sp-2xs);
    padding: 0 var(--sp-sm) var(--sp-sm);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
.tabs-bar::-webkit-scrollbar { display: none; }

.tab-item {
    padding: var(--sp-2xs) var(--sp-md);
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--dur-fast), color var(--dur-fast);
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    min-height: 32px;
    touch-action: manipulation;
    font-family: inherit;
}
.tab-item.active {
    background: var(--text-primary);
    color: var(--bg-app);
}

/* ============================================================
   3. CHAT ITEMS + SWIPE
   ============================================================ */

.list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 var(--sp-sm) var(--sp-md);
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.list-section {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--sp-md) var(--sp-sm) var(--sp-2xs);
}

.chat-item,
.contact-item {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-xs) var(--sp-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-bottom: var(--sp-3xs);
    transition: background var(--dur-fast);
    min-height: 44px;
    touch-action: manipulation;
}
.chat-item:hover,
.contact-item:hover { background: var(--bg-sidebar-hover); }

.chat-item.active { background: var(--blue); }
.chat-item.active .chat-name,
.chat-item.active .chat-preview,
.chat-item.active .chat-time { color: #fff; }
.chat-item.active .chat-preview { opacity: 0.85; }
.chat-item.active .badge { background: #fff; color: var(--blue); }

.chat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-xs);
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    font-size: var(--fs-chat-name);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    display: flex;
    align-items: center;
    min-width: 0;
}

.chat-time {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.chat-preview {
    font-size: var(--fs-chat-preview);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    background: var(--blue);
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 2px var(--sp-xs);
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.type-icon {
    font-size: var(--fs-sm);
    margin-right: 2px;
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
}

.contact-action {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-soft);
    color: var(--blue);
    flex-shrink: 0;
    transition: background var(--dur-fast);
    touch-action: manipulation;
}
.contact-action:hover { background: var(--blue); color: #fff; }

.people-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2xs);
    padding: var(--sp-xs) var(--sp-sm) var(--sp-sm);
}

.people-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2xs);
    padding: var(--sp-sm);
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--blue);
    transition: transform var(--dur-fast), background var(--dur-fast);
    text-align: center;
    min-height: 52px;
    cursor: pointer;
    touch-action: manipulation;
    font-family: inherit;
}
.people-action-btn:active {
    transform: scale(0.97);
    background: var(--blue-soft);
}

.chat-item-wrap {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-3xs);
    isolation: isolate;
    z-index: 1;
}
.chat-item-wrap .chat-item {
    position: relative;
    z-index: 2;
    background: var(--bg-sidebar);
    transition: transform 0.2s var(--ease-out);
    margin-bottom: 0;
    border-radius: var(--radius-md);
    transform: translateX(0);
}
.chat-item-wrap.swiping .chat-item { transition: none; }

.chat-item-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0s linear 0.25s;
}
.chat-item-wrap[data-reveal="left"]  .chat-item-actions-left,
.chat-item-wrap[data-reveal="right"] .chat-item-actions-right {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
}
.chat-item-actions-left  { left: 0; }
.chat-item-actions-right { right: 0; }

.chat-action-btn {
    width: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 6px 4px;
    touch-action: manipulation;
}
.chat-action-btn svg { width: 22px; height: 22px; }
.chat-action-btn.pin    { background: var(--green); }
.chat-action-btn.delete { background: var(--red);   }

.chat-item-wrap.pinned .chat-item {
    background: linear-gradient(rgba(52, 199, 89, 0.06), rgba(52, 199, 89, 0.06)),
                var(--bg-sidebar);
}
@keyframes chatPinnedAppear {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-item-wrap.pinned { animation: chatPinnedAppear 0.35s var(--ease-out); }

/* ============================================================
   4. СВОЙ ПРОФИЛЬ
   ============================================================ */

.profile-scroll-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    overscroll-behavior: contain;
    padding-bottom: calc(96px + var(--safe-bottom));
}

.profile-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 2.5 / 1;
    max-height: 220px;
    background: var(--grad-blue);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    flex-shrink: 0;
    overflow: visible;
    z-index: 1;
}

.profile-cover-title {
    position: absolute;
    top: calc(var(--sp-md) + var(--safe-top));
    left: var(--sp-md);
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    margin: 0;
    z-index: 2;
    pointer-events: none;
}

.profile-cover-btn {
    position: absolute;
    right: var(--sp-sm);
    bottom: var(--sp-sm);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #1d1d1f;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    z-index: 20;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    padding: 0;
    transition: transform var(--dur-fast) var(--ease-spring);
}
.profile-cover-btn:hover { background: #fff; transform: scale(1.05); }
.profile-cover-btn:active { transform: scale(0.92); }
.profile-cover-btn svg { pointer-events: none; display: block; }

.profile-hero {
    position: relative;
    text-align: center;
    padding: 0 var(--sp-md) var(--sp-md);
    margin-top: -50px;
    z-index: 3;
    pointer-events: none;
}
.profile-hero > * { pointer-events: auto; }

.profile-hero .profile-big {
    border: 4px solid var(--bg-app);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.profile-big {
    width: 96px;
    height: 96px;
    font-size: 36px;
    margin: 0 auto var(--sp-sm);
}

.profile-name {
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.profile-handle {
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
    margin-top: 2px;
}
.profile-bio {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    margin-top: var(--sp-xs);
    padding: 0 var(--sp-md);
    word-break: break-word;
}

.btn-edit-profile {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-xs);
    margin-top: var(--sp-md);
    padding: var(--sp-xs) var(--sp-md);
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: 600;
    font-size: var(--fs-sm);
    border-radius: var(--radius-full);
    transition: background var(--dur-fast), transform var(--dur-fast);
    border: none;
    cursor: pointer;
    min-height: 40px;
    touch-action: manipulation;
    font-family: inherit;
}
.btn-edit-profile:active { transform: scale(0.97); }

.profile-body { padding: 0 var(--sp-md) var(--sp-lg); }

/* ============================================================
   5. НАСТРОЙКИ
   ============================================================ */

.settings-block-title {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--sp-md) var(--sp-2xs) var(--sp-2xs);
    margin-top: var(--sp-2xs);
}
.settings-block-title:first-child { padding-top: 4px; }

.settings-group {
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--sp-md);
}

.settings-item {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-md);
    border-bottom: 1px solid var(--separator);
    cursor: pointer;
    transition: background var(--dur-fast);
    min-height: 52px;
    touch-action: manipulation;
}
.settings-item:last-child { border-bottom: none; }
.settings-item:hover { background: var(--bg-sidebar-hover); }

.settings-info { flex: 1; min-width: 0; }
.settings-title {
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text-primary);
}
.settings-sub {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-top: 2px;
    word-break: break-all;
}

.settings-arrow {
    color: var(--text-tertiary);
    font-size: var(--fs-lg);
    flex-shrink: 0;
}
.settings-item.danger .settings-title { color: var(--red); }
.settings-item.danger:hover { background: var(--red-soft); }

.verified-badge-inline {
    color: var(--blue);
    font-weight: 700;
    font-size: var(--fs-lg);
}

/* ============================================================
   6. ИКОНКИ-ПЛИТКИ
   ============================================================ */

.icon-box {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    margin-right: 2px;
}
.icon-box svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.bg-blue   { background: #007aff; }
.bg-green  { background: #34c759; }
.bg-red    { background: #ff3b30; }
.bg-orange { background: #ff9500; }
.bg-purple { background: #af52de; }
.bg-gray   { background: #8e8e93; }
.bg-teal   { background: #5ac8fa; }
.bg-yellow { background: #ffcc00; }

/* ============================================================
   7. ПЕРЕКЛЮЧАТЕЛЬ
   ============================================================ */

.switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(120, 120, 128, 0.25);
    border-radius: 31px;
    transition: background var(--dur-base) var(--ease-out);
    touch-action: manipulation;
}
.slider::before {
    content: '';
    position: absolute;
    height: 27px;
    width: 27px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform var(--dur-base) var(--ease-spring);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============================================================
   8. MAIN CHAT
   ============================================================ */

.main {
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    min-width: 0;
    position: absolute;
    inset: 0;
    z-index: 20;
    transition: transform var(--dur-base) var(--ease-out);
}
.main.chat-hidden { display: none; }

.main-empty-state {
    display: none;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-xs);
    text-align: center;
    padding: var(--sp-xl);
    color: var(--text-tertiary);
}
.mes-icon { opacity: 0.6; color: var(--text-tertiary); margin-bottom: var(--sp-xs); }
.mes-title { font-size: var(--fs-lg); font-weight: 700; color: var(--text-primary); }
.mes-sub { font-size: var(--fs-base); color: var(--text-tertiary); max-width: 260px; }

/* ============================================================
   9. ШАПКА ЧАТА + BACK BTN
   ============================================================ */

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-xs) var(--sp-md);
    padding-top: calc(var(--sp-xs) + var(--safe-top));
    padding-left: calc(var(--sp-md) + var(--safe-left));
    padding-right: calc(var(--sp-md) + var(--safe-right));
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--separator);
    min-height: 62px;
    flex-shrink: 0;
    gap: var(--sp-xs);
    z-index: 5;
}
@supports not (backdrop-filter: blur(20px)) {
    .chat-header { background: var(--bg-chat); }
}

.back-btn {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--blue);
    margin-right: 4px;
    border: none;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: background var(--dur-fast);
    padding: 0;
}
.back-btn:hover { background: var(--blue-soft); }
.back-btn:active { transform: scale(0.92); }
.back-btn svg { pointer-events: none; display: block; }

@media (max-width: 1099px) {
    body.chat-open .back-btn { display: inline-flex; }
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    flex: 1;
    min-width: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 4px;
    margin: -4px;
}
.chat-title-block { min-width: 0; flex: 1; }
.chat-title-block h2 {
    font-size: var(--fs-md);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    line-height: 1.2;
}
.status-online { font-size: var(--fs-xs); color: var(--green); }
.status-muted { font-size: var(--fs-xs); color: var(--text-tertiary); }

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-3xs);
    flex-shrink: 0;
}
.chat-header-actions .icon-btn,
.icon-btn.topics-toggle-btn,
.icon-btn.secret-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: background var(--dur-fast), color var(--dur-fast);
    touch-action: manipulation;
    padding: 0;
}
.chat-header-actions .icon-btn:hover,
.icon-btn.topics-toggle-btn:hover,
.icon-btn.secret-toggle-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}
.chat-header-actions .icon-btn:active,
.icon-btn.topics-toggle-btn:active,
.icon-btn.secret-toggle-btn:active { transform: scale(0.94); }

/* ============================================================
   10. СООБЩЕНИЯ
   ============================================================ */

.messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-md);
    padding-bottom: calc(var(--composer-h, 56px) + 26px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: var(--sp-3xs);
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: var(--bg-chat);
    scroll-padding-bottom: calc(var(--composer-h, 56px) + 26px);
}

.message {
    display: flex;
    max-width: 78%;
    animation: messageAppear 0.2s var(--ease-out);
}
@keyframes messageAppear {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.message.incoming { align-self: flex-start; }
.message.outgoing { align-self: flex-end; }

.msg-bubble {
    padding: 10px 14px 6px;
    border-radius: 20px;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.45;
}
.message.incoming .msg-bubble {
    background: var(--bg-bubble-in);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
}
.message.outgoing .msg-bubble {
    background: var(--bg-bubble-out);
    color: var(--text-inverse);
    border-bottom-right-radius: 6px;
}

.msg-text {
    font-size: var(--fs-msg);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.msg-text b, .msg-text strong { font-weight: 700; }
.msg-text i, .msg-text em { font-style: italic; }
.msg-text u { text-decoration: underline; text-underline-offset: 2px; }
.msg-text s, .msg-text del, .msg-text strike {
    text-decoration: line-through;
    opacity: 0.85;
}
.msg-text code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 1px 6px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.08);
    white-space: pre-wrap;
    word-break: break-word;
}
.message.outgoing .msg-text code {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}
.msg-text pre {
    margin: 4px 0;
    padding: var(--sp-xs);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.08);
    font-family: var(--font-mono);
    font-size: 0.9em;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}
.message.outgoing .msg-text pre {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.msg-text a {
    color: var(--blue);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 122, 255, 0.4);
    word-break: break-all;
    transition: border-color var(--dur-fast);
}
.msg-text a:hover { border-bottom-color: var(--blue); }
.message.outgoing .msg-text a {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.5);
}
.msg-text ul,
.msg-text ol { margin: 4px 0; padding-left: 22px; }
.msg-text li { margin: 2px 0; line-height: 1.4; }

.msg-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-msg-meta);
    margin-top: 5px;
    font-variant-numeric: tabular-nums;
}
.message.incoming .msg-meta { color: var(--text-tertiary); }
.message.outgoing .msg-meta { color: rgba(255, 255, 255, 0.75); }
.msg-edited { font-style: italic; opacity: .75; margin-right: 6px; }

.msg-sender {
    font-size: var(--fs-xs);
    font-weight: 600;
    margin-bottom: 2px;
}
.msg-deleted { font-style: italic; opacity: 0.6; }
.message.incoming .msg-deleted { color: var(--text-tertiary); }
.message.outgoing .msg-deleted { color: rgba(255, 255, 255, 0.7); }

.message .bubble-image {
    padding: 0 !important;
    width: min(300px, 76vw);
    max-width: min(300px, 76vw);
    overflow: hidden;
    position: relative;
    border-radius: 20px;
}
.message.outgoing .bubble-image { border-bottom-right-radius: 6px; }
.message.incoming .bubble-image { border-bottom-left-radius: 6px; }
.message .bubble-image .chat-image,
.message .bubble-image img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 400px;
    min-width: 0;
    border-radius: 0;
    object-fit: cover;
    cursor: pointer;
}
.message .bubble-image .msg-meta {
    position: absolute;
    right: var(--sp-xs);
    bottom: var(--sp-xs);
    margin: 0;
    padding: 3px var(--sp-xs);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.message .bubble-image:has(.msg-text) .msg-meta {
    position: static;
    background: none;
    color: inherit;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 2px var(--sp-sm) 6px;
    border-radius: 0;
}
.message .bubble-image .msg-text { padding: 6px var(--sp-md) 0; }

.bubble-voice {
    padding: 10px 14px;
    min-width: min(220px, 62vw);
    max-width: min(300px, 82vw);
}
.voice-player {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
}
.voice-play {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-sm);
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform var(--dur-fast);
}
.voice-play:active { transform: scale(0.92); }
.message.incoming .voice-play {
    background: var(--blue-soft);
    color: var(--blue);
}
.voice-wave {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}
.message.incoming .voice-wave { background: var(--blue-soft); }
.voice-progress {
    height: 100%;
    width: 0%;
    background: #fff;
    transition: width 0.2s linear;
}
.message.incoming .voice-progress { background: var(--blue); }
.voice-duration {
    font-size: var(--fs-xs);
    color: rgba(255, 255, 255, 0.8);
    font-variant-numeric: tabular-nums;
    min-width: 34px;
    text-align: right;
}
.message.incoming .voice-duration { color: var(--text-tertiary); }

.msg-reactions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.message.incoming .msg-reactions { border-top-color: var(--separator); }
.msg-reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px var(--sp-xs);
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    color: #fff;
    transition: background var(--dur-fast);
    border: 1px solid transparent;
    cursor: pointer;
    touch-action: manipulation;
}
.message.incoming .msg-reaction {
    background: var(--blue-soft);
    color: var(--text-primary);
}
.msg-reaction.active {
    background: rgba(255, 255, 255, 0.35);
    border-color: #fff;
}
.message.incoming .msg-reaction.active {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

.msg-reply-quote {
    display: block;
    border-left: 3px solid var(--blue);
    padding: 4px var(--sp-xs);
    margin-bottom: 4px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.12);
    touch-action: manipulation;
}
.message.incoming .msg-reply-quote { background: var(--blue-soft); }
.msg-reply-name {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--blue);
}
.message.outgoing .msg-reply-name { color: #fff; opacity: 0.9; }
.msg-reply-text {
    font-size: var(--fs-sm);
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-reply-missing { opacity: 0.5; font-style: italic; }

.reply-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-xs);
    padding: var(--sp-xs) var(--sp-md);
    background: var(--bg-input);
    border-left: 3px solid var(--blue);
    border-top: 1px solid var(--separator);
    flex-shrink: 0;
}
.reply-preview-content { min-width: 0; }
.reply-preview-name {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--blue);
}
.reply-preview-text {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reply-preview-close {
    border: none;
    background: none;
    color: var(--text-tertiary);
    font-size: var(--fs-md);
    padding: 4px;
    flex-shrink: 0;
    cursor: pointer;
    touch-action: manipulation;
}
.reply-preview-bar.editing { border-left-color: var(--blue); }

.msg-highlight {
    animation: msgHighlightFlash 1.2s ease;
    border-radius: 20px;
}
@keyframes msgHighlightFlash {
    0%   { background-color: rgba(0, 122, 255, 0.25); }
    100% { background-color: transparent; }
}

.message.msg-picked .msg-bubble {
    box-shadow: 0 0 0 2px var(--blue), 0 0 0 6px var(--blue-soft);
    transition: box-shadow 0.2s ease;
}

/* ============================================================
   11. COMPOSER (с фиксом порядка кнопок)
   ============================================================ */

.composer {
    position: absolute;
    left: 50%;
    bottom: calc(var(--sp-xs) + var(--safe-bottom));
    transform: translateX(-50%);
    width: calc(100% - var(--sp-md));
    max-width: 720px;
    display: flex;
    align-items: flex-end;
    gap: var(--sp-2xs);
    padding: 6px;
    z-index: 30;
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(26px);
    -webkit-backdrop-filter: saturate(180%) blur(26px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    transition: background var(--dur-base), box-shadow var(--dur-base);
    padding-bottom: calc(6px + var(--safe-bottom));
    flex-wrap: nowrap;
}
@supports not (backdrop-filter: blur(26px)) {
    .composer { background: var(--bg-card); }
}

.composer .icon-btn.attach,
.composer .icon-btn.pay-btn,
.composer .icon-btn.mic-btn,
.composer-expand-btn,
.send-btn {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
}
.composer .icon-btn.attach { order: 1; }
.composer .icon-btn.pay-btn { order: 2; }
.composer .composer-input { order: 3; flex: 1 1 auto; min-width: 0; }
.composer-expand-btn { order: 4; }
.composer .icon-btn.mic-btn { order: 5; }
.send-btn { order: 6; }

.composer-input {
    display: flex;
    align-items: flex-end;
    background: var(--bg-input);
    border-radius: var(--radius-xl);
    min-width: 0;
    padding: 3px 3px 3px 6px;
    transition: background var(--dur-fast), box-shadow var(--dur-fast);
}
.composer-input:focus-within {
    background: var(--bg-card);
    box-shadow: 0 0 0 1.5px var(--blue), 0 0 0 4px var(--blue-soft);
}
.composer-input textarea {
    flex: 1;
    width: 100%;
    padding: var(--sp-sm) var(--sp-xs);
    font-size: var(--fs-base);
    line-height: 20px;
    min-width: 0;
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    overflow-y: hidden;
    max-height: 140px;
    box-sizing: border-box;
}
.composer-input textarea::placeholder { color: var(--text-tertiary); }
.composer-input textarea::-webkit-scrollbar { width: 4px; }
.composer-input textarea::-webkit-scrollbar-thumb {
    background: rgba(120, 120, 128, 0.3);
    border-radius: 4px;
}

.composer .icon-btn.attach,
.composer .icon-btn.pay-btn,
.composer .icon-btn.mic-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    background: transparent;
    transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
    touch-action: manipulation;
    padding: 0;
}
.composer .icon-btn.pay-btn { color: var(--green); }
.composer .icon-btn.attach:hover,
.composer .icon-btn.mic-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}
.composer .icon-btn.pay-btn:hover { background: var(--green-soft); }
.composer .icon-btn.attach:active,
.composer .icon-btn.pay-btn:active,
.composer .icon-btn.mic-btn:active { transform: scale(0.9); }

.composer-expand-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background var(--dur-fast), transform var(--dur-fast);
    padding: 0;
}
.composer-expand-btn:hover { background: var(--blue-soft); }
.composer-expand-btn:active { transform: scale(0.92); }
.composer-expand-btn.hidden { display: none !important; }

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--grad-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.32);
    position: relative;
    overflow: hidden;
    transition: transform var(--dur-fast) var(--ease-spring);
    touch-action: manipulation;
}
.send-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), transparent 60%);
    pointer-events: none;
}
.send-btn:hover { transform: scale(1.05); }
.send-btn:active { transform: scale(0.9); }
.send-btn svg { position: relative; z-index: 1; }

.attach-menu {
    position: absolute;
    left: var(--sp-md);
    bottom: calc(var(--composer-h, 56px) + 20px + var(--safe-bottom));
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: flex;
    flex-direction: column;
    min-width: 210px;
    max-width: calc(100vw - var(--sp-md));
    z-index: 25;
    animation: attachMenuIn 0.15s var(--ease-out);
}
@keyframes attachMenuIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.attach-menu-item {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    width: 100%;
    padding: var(--sp-xs) var(--sp-sm);
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    font-size: var(--fs-base);
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    min-height: 44px;
    transition: background var(--dur-fast);
    touch-action: manipulation;
    font-family: inherit;
}
.attach-menu-item:hover { background: var(--bg-sidebar-hover); }
.ami-icon { width: 22px; text-align: center; flex-shrink: 0; }

.voice-recording {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--composer-h, 56px) + 20px + var(--safe-bottom));
    width: calc(100% - var(--sp-md));
    max-width: 720px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    padding: var(--sp-xs) var(--sp-md);
    background: var(--glass-bg-solid);
    backdrop-filter: saturate(180%) blur(40px);
    -webkit-backdrop-filter: saturate(180%) blur(40px);
    border: 1px solid rgba(255, 59, 48, 0.35);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    animation: vrPanelIn 0.25s var(--ease-out);
}
.voice-recording.hidden { display: none !important; }
@keyframes vrPanelIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.vr-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--red);
    flex-shrink: 0;
    animation: vrBlink 1s infinite;
}
@keyframes vrBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}
.vr-time {
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    font-size: var(--fs-md);
    font-weight: 600;
    min-width: 44px;
}
.vr-cancel {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: var(--fs-md);
    padding: 8px 4px;
    cursor: pointer;
    touch-action: manipulation;
    font-family: inherit;
}
.vr-send {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    padding: 8px var(--sp-md);
    font-size: var(--fs-md);
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    font-family: inherit;
}

/* ============================================================
   12. ПОЛНОЭКРАННЫЙ COMPOSER
   ============================================================ */

.composer-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: var(--bg-chat);
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    animation: cfSlideIn 0.22s var(--ease-out);
}
.composer-fullscreen.hidden { display: none !important; }
@keyframes cfSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-xs);
    padding: var(--sp-sm) var(--sp-md);
    border-bottom: 1px solid var(--separator);
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    min-height: 62px;
    flex-shrink: 0;
}
.cf-close,
.cf-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast), transform var(--dur-fast);
    touch-action: manipulation;
}
.cf-close:hover,
.cf-send:hover { background: var(--blue-soft); }
.cf-close:active,
.cf-send:active { transform: scale(0.92); }
.cf-title {
    flex: 1;
    text-align: center;
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
#cfTextarea {
    flex: 1;
    width: 100%;
    min-height: 0;
    padding: var(--sp-lg) var(--sp-md);
    font-size: var(--fs-base);
    line-height: 1.5;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-chat);
    border: none;
    outline: none;
    resize: none;
    overflow-y: auto;
}
#cfTextarea::placeholder { color: var(--text-tertiary); }
.cf-toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3xs);
    padding: var(--sp-xs) var(--sp-md);
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--separator);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
.cf-toolbar::-webkit-scrollbar { display: none; }
.cf-tool-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
    touch-action: manipulation;
}
.cf-tool-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}
.cf-tool-btn:active {
    background: var(--blue-soft);
    color: var(--blue);
    transform: scale(0.92);
}
.cf-tool-btn svg { pointer-events: none; display: block; }

/* ============================================================
   13. МОБИЛЬНЫЙ ТАББАР
   ============================================================ */

.mobile-tabbar {
    display: flex;
    position: fixed;
    bottom: calc(var(--sp-xs) + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - var(--sp-lg));
    max-width: 420px;
    height: 62px;
    padding: 0 var(--sp-xs);
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(26px);
    -webkit-backdrop-filter: saturate(180%) blur(26px);
    border: 1px solid var(--glass-border);
    border-radius: 31px;
    box-shadow: var(--shadow-md);
    z-index: 100;
    align-items: center;
    justify-content: space-around;
}
@supports not (backdrop-filter: blur(26px)) {
    .mobile-tabbar { background: var(--bg-card); }
}
.mt-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-tertiary);
    font-size: var(--fs-tabbar-label);
    font-weight: 500;
    padding: 6px 2px;
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    min-height: 44px;
    transition: color var(--dur-fast);
    touch-action: manipulation;
    font-family: inherit;
}
.mt-item svg {
    width: 22px;
    height: 22px;
    transition: transform var(--dur-base) var(--ease-spring), fill var(--dur-fast);
}
.mt-item.active { color: var(--blue); }
.mt-item.active svg { fill: currentColor; transform: scale(1.08); }
.mt-badge {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(20%);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--tabbar-bg);
    box-sizing: content-box;
}
.nav-logo,
.nav-write-btn,
.nav-user-mini { display: none; }

/* ============================================================
   14. МОДАЛКИ
   ============================================================ */

.edit-sheet {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-md);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
    padding-top: calc(var(--sp-md) + var(--safe-top));
    padding-bottom: calc(var(--sp-md) + var(--safe-bottom));
}
.edit-sheet.open { opacity: 1; }
.edit-sheet.hidden { display: none !important; }

.edit-backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.edit-card {
    position: relative;
    background: var(--sheet-bg);
    border-radius: var(--radius-2xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.92) translateY(20px);
    transition: transform var(--dur-slow) var(--ease-spring);
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
    overscroll-behavior: contain;
}
.edit-card-small { max-width: 440px; }
.edit-card-wide  { max-width: 560px; }
.edit-sheet.open .edit-card { transform: scale(1) translateY(0); }

.edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-md) var(--sp-lg);
    border-bottom: 1px solid var(--separator);
    position: sticky;
    top: 0;
    background: var(--sheet-bg);
    z-index: 2;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    gap: var(--sp-xs);
}
.edit-header h3 {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.edit-btn-cancel,
.edit-btn-save {
    font-size: var(--fs-md);
    font-weight: 500;
    padding: 6px 4px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
    font-family: inherit;
}
.edit-btn-cancel { color: var(--text-secondary); }
.edit-btn-save { color: var(--blue); font-weight: 600; }
.edit-btn-save:disabled { opacity: 0.5; cursor: wait; }

.edit-body { padding: var(--sp-lg); }
.edit-field { margin-bottom: var(--sp-md); }
.edit-field label {
    display: block;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-xs);
    padding-left: 4px;
}
.edit-field input,
.edit-field textarea {
    width: 100%;
    padding: var(--sp-sm) var(--sp-md);
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--fs-base);
    transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-fast);
    resize: none;
    font-family: inherit;
}
.edit-field input:focus,
.edit-field textarea:focus {
    background: var(--bg-card);
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-soft);
    outline: none;
}
.edit-hint {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-top: 6px;
    padding-left: 4px;
}

/* ============================================================
   15. МЕНЮ СООБЩЕНИЯ + ЭМОДЗИ
   ============================================================ */

.msg-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.18s ease;
}
.msg-menu-overlay.closing { opacity: 0; pointer-events: none; }
.msg-menu-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.18s ease;
}
.msg-menu-overlay .msg-menu-backdrop { opacity: 1; }
.msg-menu-overlay.closing .msg-menu-backdrop { opacity: 0; }

.msg-menu-popover {
    position: fixed;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transform: scale(0.92);
    transform-origin: center;
    transition: opacity 0.16s ease,
                transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
    max-width: calc(100vw - 24px);
    pointer-events: auto;
}
.msg-menu-popover.open { opacity: 1; transform: scale(1); }

.msg-emoji-quickbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--glass-bg-solid, #fff);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--glass-border, rgba(255,255,255,0.6));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.msg-emoji-quickbar::-webkit-scrollbar { display: none; }
.msg-emoji-quick {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}
.msg-emoji-quick:hover { background: var(--bg-sidebar-hover); }
.msg-emoji-quick:active {
    transform: scale(1.2);
    background: var(--blue-soft);
}
.msg-emoji-plus {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--bg-input);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.12s ease;
    margin-left: 2px;
}
.msg-emoji-plus:hover { background: var(--bg-sidebar-hover); }
.msg-emoji-plus:active {
    transform: scale(0.92);
    background: var(--blue-soft);
    color: var(--blue);
}

.msg-menu {
    min-width: 240px;
    max-width: calc(100vw - 24px);
    background: var(--glass-bg-solid, #fff);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--glass-border, rgba(255,255,255,0.6));
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
}
.msg-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: var(--fs-base);
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}
.msg-menu-item + .msg-menu-item { border-top: 1px solid var(--separator); }
.msg-menu-item svg { flex-shrink: 0; opacity: 0.85; color: var(--text-primary); }
.msg-menu-item span { flex: 1; }
.msg-menu-item:hover { background: var(--bg-sidebar-hover); }
.msg-menu-item:active { background: var(--bg-sidebar-active); }
.msg-menu-item.danger { color: var(--red); }
.msg-menu-item.danger svg { color: var(--red); }

.emoji-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    opacity: 1;
    transition: opacity 0.2s ease;
}
.emoji-panel-overlay.closing { opacity: 0; pointer-events: none; }
.emoji-panel-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.emoji-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70vh;
    background: var(--bg-sidebar, #fff);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    padding-bottom: calc(var(--safe-bottom, 0px) + 4px);
}
.emoji-panel.open { transform: translateY(0); }
.emoji-panel-header {
    padding: 8px 0 4px;
    display: flex;
    justify-content: center;
}
.emoji-panel-grab {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(120, 120, 128, 0.35);
}
.emoji-panel-search { padding: 6px 14px 10px; }
.emoji-panel-search input {
    width: 100%;
    border: none;
    outline: none;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: var(--fs-base);
    color: var(--text-primary);
    font-family: inherit;
    box-sizing: border-box;
}
.emoji-panel-search input::placeholder { color: var(--text-tertiary); }
.emoji-panel-tabs {
    display: flex;
    gap: 6px;
    padding: 0 14px 10px;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--separator);
}
.emoji-panel-tabs::-webkit-scrollbar { display: none; }
.emoji-panel-tab {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}
.emoji-panel-tab:hover { background: var(--blue-soft); color: var(--blue); }
.emoji-panel-tab.active { background: var(--blue); color: #fff; }
.emoji-panel-grid {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 4px;
    overscroll-behavior: contain;
}
.emoji-panel-btn {
    border: none;
    background: transparent;
    font-size: 26px;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.emoji-panel-btn:hover { background: var(--blue-soft); }
.emoji-panel-btn:active {
    transform: scale(0.85);
    background: var(--blue-soft);
}
@media (min-width: 520px) {
    .emoji-panel {
        left: 50%;
        right: auto;
        transform: translate(-50%, 100%);
        width: 480px;
        border-radius: var(--radius-2xl);
        margin-bottom: 24px;
    }
    .emoji-panel.open { transform: translate(-50%, 0); }
}

/* ============================================================
   16. ЗАКРЕП
   ============================================================ */

.pinned-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--separator);
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 44px;
    z-index: 4;
}
.pinned-banner:hover { background: var(--bg-sidebar-hover); }
.pinned-banner.hidden { display: none !important; }
.pinned-banner-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--blue-soft);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.pinned-banner-content { flex: 1; min-width: 0; }
.pinned-banner-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
}
.pinned-banner-text {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    line-height: 1.3;
}
.pinned-banner-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.pinned-banner-close:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

/* ============================================================
   17. ПОЛОСА ПОДПИСКИ
   ============================================================ */

.channel-subscribed-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px calc(12px + var(--safe-bottom));
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--separator);
    flex-shrink: 0;
}
.channel-subscribed-bar.hidden { display: none !important; }
.csb-info { flex: 1; min-width: 0; }
.csb-title { font-size: var(--fs-base); font-weight: 600; color: var(--text-primary); }
.csb-sub { font-size: var(--fs-sm); color: var(--text-tertiary); margin-top: 2px; }
.csb-btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--separator);
    background: transparent;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    min-height: 36px;
    transition: 0.15s;
    font-family: inherit;
}
.csb-btn:hover {
    background: var(--red-soft);
    color: var(--red);
    border-color: rgba(255, 59, 48, 0.2);
}
.csb-btn:active { transform: scale(0.96); }

/* ============================================================
   18. ГРУППА / КАНАЛ — ПОЛНЫЙ ЭКРАН
   ============================================================ */

#groupInfoSheet {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
}
#groupInfoSheet .edit-backdrop { display: none; }
#groupInfoSheet .edit-card.gi-page {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    overflow: hidden;
    background: var(--bg-sidebar);
    transform: translateY(24px);
    transition: transform var(--dur-slow) var(--ease-out);
    display: flex;
    flex-direction: column;
}
#groupInfoSheet.open .edit-card.gi-page { transform: translateY(0); }

.gi-header {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--sp-xs);
    padding: calc(var(--safe-top) + var(--sp-xs)) var(--sp-md) var(--sp-xs);
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(30px);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    border-bottom: 1px solid var(--separator);
    z-index: 5;
    min-height: 56px;
}
.gi-header h3 {
    margin: 0;
    text-align: center;
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gi-close,
#groupInfoSheet .edit-btn-cancel {
    padding: 8px 12px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--fs-base);
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
    font-family: inherit;
    min-height: 40px;
}
.gi-close:hover,
#groupInfoSheet .edit-btn-cancel:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}
.gi-header-spacer { width: 40px; }

.gi-tabs,
#groupInfoTabs {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(30px);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    border-bottom: 1px solid var(--separator);
    overflow-x: auto;
    scrollbar-width: none;
    z-index: 4;
}
.gi-tabs::-webkit-scrollbar { display: none; }
.gi-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    font-family: inherit;
    min-height: 36px;
    touch-action: manipulation;
}
.gi-tab:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); }
.gi-tab.active {
    color: var(--blue);
    background: var(--blue-soft);
    font-weight: 600;
}

.gi-body,
#groupInfoBody {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 var(--sp-md) calc(var(--sp-lg) + var(--safe-bottom));
    overscroll-behavior: contain;
}

.gx-hero {
    position: relative;
    margin: 0 calc(-1 * var(--sp-md));
    text-align: center;
    padding-top: 40px;
}
.gx-cover {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 260px;
    background: var(--grad-blue);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
}
.gx-cover.nocover { opacity: 0.5; }
.gx-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.10),
        var(--bg-sidebar) 96%
    );
}
.gx-cover-btn {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 3;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    background: var(--glass-bg, rgba(255,255,255,0.82));
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.15s;
}
.gx-cover-btn svg { width: 18px; height: 18px; }
.gx-cover-btn:active { transform: scale(0.92); }

.gx-head {
    position: relative;
    z-index: 2;
    padding: 0 var(--sp-md);
}
.gx-avatar {
    position: relative;
    width: 124px;
    height: 124px;
    margin: 0 auto var(--sp-md);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 46px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--grad-blue);
    background-size: cover;
    background-position: center;
    border: 4px solid var(--bg-sidebar);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    overflow: visible;
}
.gx-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.gx-avatar-btn {
    position: absolute;
    right: 0;
    bottom: 2px;
    z-index: 3;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 3px solid var(--bg-sidebar);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--blue);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.15s;
}
.gx-avatar-btn:active { transform: scale(0.9); }

.gx-name {
    margin: 0;
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    word-break: break-word;
}
.gx-sub {
    margin-top: 4px;
    font-size: var(--fs-md);
    color: var(--text-tertiary);
    line-height: 1.4;
}
.gx-online { color: var(--green); font-weight: 500; }

.gx-actions {
    display: grid;
    gap: var(--sp-xs);
    margin-top: var(--sp-lg);
}
.gx-act {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 4px 12px;
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--blue);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.12s ease, background 0.15s ease;
    font-family: inherit;
    min-height: 64px;
}
.gx-act svg { width: 22px; height: 22px; }
.gx-act:active {
    transform: scale(0.96);
    background: var(--bg-sidebar-hover);
}
.gx-act.off { color: var(--text-tertiary); }

.gx-chev {
    margin-left: auto;
    color: var(--text-tertiary);
    opacity: 0.6;
    display: flex;
}
.gx-desc {
    white-space: pre-wrap;
    font-size: var(--fs-base);
    font-weight: 400;
    line-height: 1.4;
}
.up-ico svg { width: 18px; height: 18px; }
.up-row .switch { margin-left: auto; }
.gx-last { margin-bottom: var(--sp-xs); }
.gx-pad { padding-top: 4px; }

.gx-sect {
    padding: var(--sp-lg) 6px var(--sp-xs);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}
.gx-form { padding: var(--sp-sm) var(--sp-md) 10px; }
.gx-form .edit-field label { margin-bottom: 6px; }
.gx-form .edit-hint {
    text-align: right;
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-top: 6px;
}
.gx-slug { padding: 4px var(--sp-md) 14px 64px; }
.gx-slug-label {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-bottom: 6px;
}
.up-card .up-act { text-align: left; }
.gx-save { width: 100%; margin-top: var(--sp-lg); }

#groupInfoBody .gih-members,
#groupInfoBody .gih-topics,
#groupInfoBody .chat-links-list {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    gap: 0;
    padding: 4px 0;
}
#groupInfoBody .gih-members .member-item {
    border-radius: 0;
    padding: 10px 16px;
}
#groupInfoBody .gih-section-title { padding: var(--sp-lg) 6px var(--sp-xs); }
#groupInfoBody .gi-topic-item {
    background: none;
    border: 0;
    border-radius: 0;
    padding: 10px 16px;
}
#groupInfoBody .role-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-left: 4px;
}

.gih-section-title {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--sp-lg) 6px var(--sp-xs);
}
.gih-members { display: flex; flex-direction: column; gap: 2px; }
.gih-topics { display: flex; flex-direction: column; gap: 6px; }

.gih-link-block {
    background: var(--blue-soft);
    border: 1px solid rgba(0, 122, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: var(--sp-md);
}
.gih-link-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.gih-link-row { display: flex; align-items: center; gap: 6px; }
.gih-link-text {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--blue);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    padding: 8px 0;
    word-break: break-all;
}
.gih-link-text:hover { opacity: 0.75; }
.gih-link-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--separator);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: 0.15s;
}
.gih-link-btn:hover {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}
.gih-link-btn:active { transform: scale(0.94); }

.gih-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--radius-md);
}
.gih-toggle-text { flex: 1; min-width: 0; }
.gih-toggle-title {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-primary);
}
.gih-toggle-sub {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-top: 2px;
}
.gih-linked {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
}
.gih-linked-title {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-discuss {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--blue);
    background: var(--blue-soft);
    border: 1px solid rgba(0, 122, 255, 0.16);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease;
    font-family: inherit;
}
.msg-discuss:active {
    transform: scale(0.97);
    background: rgba(0, 122, 255, 0.18);
}

.section-action {
    padding: 6px 12px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--blue);
    background: var(--blue-soft);
    border: 0;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: inherit;
    min-height: 32px;
}
.section-action:disabled { opacity: 0.5; cursor: default; }
.section-action:active:not(:disabled) {
    background: rgba(0, 122, 255, 0.2);
}

.role-badge {
    display: inline-block;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
    border-radius: var(--radius-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 6px;
}
.role-badge.admin { background: var(--blue-soft); color: var(--blue); }
.role-badge.moderator { background: var(--purple-soft); color: var(--purple); }

.member-actions-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: var(--fs-lg);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.member-actions-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}
.member-actions-btn:active { transform: scale(0.94); }

.gi-topic-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--separator);
    min-height: 52px;
}
.gi-topic-emoji {
    font-size: 20px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}
.gi-topic-info { flex: 1; min-width: 0; }
.gi-topic-name {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-primary);
}
.gi-topic-sub {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
    margin-top: 2px;
}
.gi-topic-default {
    display: inline-block;
    padding: 1px 6px;
    background: var(--green-soft);
    color: var(--green);
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-xs);
    margin-left: 6px;
    text-transform: uppercase;
}
.gi-topic-remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--red-soft);
    color: var(--red);
    font-size: var(--fs-sm);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.slug-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: 0.15s;
}
.slug-input-wrap:focus-within {
    background: var(--bg-card);
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-soft);
}
.slug-prefix {
    padding: 14px 0 14px 16px;
    color: var(--text-tertiary);
    font-size: var(--fs-base);
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
    pointer-events: none;
}
.slug-input-wrap input {
    flex: 1;
    min-width: 0;
    padding: 14px 16px 14px 4px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: var(--fs-base);
    font-family: inherit;
    outline: none;
}
.slug-status {
    font-size: var(--fs-sm);
    margin-top: 6px;
    padding-left: 4px;
    min-height: 16px;
    transition: color 0.15s;
}
.slug-status.checking { color: var(--text-tertiary); }
.slug-status.valid { color: var(--green); font-weight: 600; }
.slug-status.invalid { color: var(--red); font-weight: 600; }

.slug-type-group { display: flex; flex-direction: column; gap: 8px; }
.slug-type-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: 0.15s;
    position: relative;
    font-family: inherit;
    min-height: 60px;
}
.slug-type-option:hover { background: var(--blue-soft); }
.slug-type-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.slug-type-radio {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--text-tertiary);
    flex-shrink: 0;
    position: relative;
    transition: 0.15s;
}
.slug-type-radio::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--blue);
    opacity: 0;
    transform: scale(0.5);
    transition: 0.15s;
}
.slug-type-option input:checked ~ .slug-type-radio { border-color: var(--blue); }
.slug-type-option input:checked ~ .slug-type-radio::after {
    opacity: 1;
    transform: scale(1);
}
.slug-type-option input:checked ~ .slug-type-text .slug-type-title {
    color: var(--blue);
}
.slug-type-text { flex: 1; min-width: 0; }
.slug-type-title {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.slug-type-sub {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
}
.slug-type-option:has(input:checked) {
    background: var(--blue-soft);
    border-color: rgba(0, 122, 255, 0.3);
}

.link-group-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    max-height: 220px;
    overflow-y: auto;
}
.link-group-item {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--separator);
    font-size: var(--fs-base);
    color: var(--text-primary);
    cursor: pointer;
    transition: 0.15s;
}
.link-group-item:hover {
    background: var(--blue-soft);
    border-color: rgba(0, 122, 255, 0.25);
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
    margin-top: var(--sp-xs);
}
.member-item {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-xs) var(--sp-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--dur-fast);
    min-height: 44px;
    touch-action: manipulation;
}
.member-item:hover { background: var(--bg-sidebar-hover); }
.member-item.selected { background: var(--blue-soft); }
.member-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-sm);
    font-weight: 700;
    flex-shrink: 0;
}
.member-remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--red-soft);
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-md);
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    touch-action: manipulation;
}
.member-remove:active { background: var(--red); color: #fff; }
.admin-badge {
    display: inline-block;
    padding: 1px 6px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: var(--fs-xs);
    font-weight: 600;
    border-radius: var(--radius-xs);
    margin-left: 6px;
    text-transform: uppercase;
}

.chat-links-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: var(--sp-md);
}
.chat-link-item {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.chat-link-url {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    padding: var(--sp-sm);
    text-decoration: none;
    color: var(--text-primary);
    font-size: var(--fs-base);
    font-weight: 500;
    min-width: 0;
    transition: background var(--dur-fast);
}
.chat-link-url:hover { background: var(--blue-soft); }
.chat-link-icon { flex-shrink: 0; }
.chat-link-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.chat-link-remove {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--red);
    font-size: var(--fs-md);
    background: transparent;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    border-left: 1px solid var(--separator);
    touch-action: manipulation;
}
.chat-links-empty {
    text-align: center;
    padding: var(--sp-md);
    color: var(--text-tertiary);
    font-size: var(--fs-sm);
    background: var(--bg-input);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-md);
}
.invite-link-block {
    background: var(--blue-soft);
    border: 1px solid rgba(0, 122, 255, 0.15);
    border-radius: var(--radius-md);
    padding: var(--sp-sm) var(--sp-md);
    margin-bottom: var(--sp-md);
}
.invite-link-label {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-xs);
}
.invite-link-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.invite-link-row input {
    flex: 1;
    padding: var(--sp-xs) var(--sp-sm);
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    min-width: 0;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* ============================================================
   19. ПРОФИЛЬ ПОЛЬЗОВАТЕЛЯ — ПОЛНЫЙ ЭКРАН (СТИЛЬ TWITTER/X)
   ============================================================ */

#userProfileSheet {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
}
#userProfileSheet .edit-backdrop { display: none; }
#userProfileSheet .edit-card.up-page {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    overflow: hidden;
    background: var(--bg-sidebar);
    transform: translateY(24px);
    transition: transform var(--dur-slow) var(--ease-out);
    display: flex;
    flex-direction: column;
}
#userProfileSheet.open .edit-card.up-page { transform: translateY(0); }

#userProfileSheet .up-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-xs);
    padding: calc(var(--safe-top) + var(--sp-xs)) var(--sp-md) var(--sp-xs);
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(30px);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    border-bottom: 1px solid var(--separator);
    z-index: 5;
    min-height: 56px;
}
#userProfileSheet .up-header h3 {
    margin: 0;
    text-align: center;
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#userProfileSheet .up-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-input);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: background 0.15s, transform 0.12s;
    font-family: inherit;
    padding: 0;
}
#userProfileSheet .up-close:hover { background: var(--bg-sidebar-hover); }
#userProfileSheet .up-close:active {
    transform: scale(0.92);
    background: var(--bg-sidebar-active);
}
#userProfileSheet .up-close svg {
    display: block;
    width: 22px;
    height: 22px;
}
#userProfileSheet .up-header-spacer {
    width: 40px;
    flex-shrink: 0;
}

#userProfileSheet .up-scroll {
    flex: 1;
    position: relative;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(var(--sp-lg) + var(--safe-bottom));
}

#userProfileSheet .user-profile-body {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
    padding: 0;
}

/* Шапка профиля: обложка + аватар */
#userProfileSheet .user-profile-hero {
    position: relative;
    margin-bottom: 0;
    padding: 0;
    text-align: center;
}

#userProfileSheet .user-profile-cover {
    width: 100%;
    height: 180px !important;
    max-height: 200px !important;
    aspect-ratio: auto !important;
    background: var(--grad-blue);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 0;
    margin: 0;
    position: relative;
    flex-shrink: 0;
}
#userProfileSheet .user-profile-cover.has-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.12), var(--bg-sidebar) 96%);
    pointer-events: none;
}

#userProfileSheet .user-profile-avatar {
    width: 110px !important;
    height: 110px !important;
    font-size: 44px;
    border-radius: 50%;
    border: 4px solid var(--bg-sidebar);
    margin: -55px auto 12px;
    position: relative;
    z-index: 2;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    overflow: hidden;
}
#userProfileSheet .user-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

#userProfileSheet .user-profile-name {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-align: center;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 var(--sp-md);
}

#userProfileSheet .user-profile-status {
    text-align: center;
    font-size: var(--fs-md);
    color: var(--text-tertiary);
    margin-bottom: var(--sp-lg);
    padding: 0 var(--sp-md);
}
#userProfileSheet .user-profile-status.status-online { color: var(--green); }
#userProfileSheet .user-profile-status.status-muted { color: var(--text-tertiary); }

/* Бейджи (Верифицирован, Premium, Дата) */
.up-badges-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 0 var(--sp-md);
    margin-bottom: var(--sp-lg);
}

.up-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--separator);
    line-height: 1;
}

.up-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.up-badge-verified {
    background: var(--blue-soft);
    color: var(--blue);
    border-color: rgba(0, 122, 255, 0.2);
}

.up-badge-premium {
    background: linear-gradient(135deg, rgba(255, 179, 71, 0.15), rgba(255, 95, 141, 0.15));
    color: #ff7a45;
    border-color: rgba(255, 122, 69, 0.2);
}

.up-badge-date {
    background: var(--bg-input);
    color: var(--text-tertiary);
    border-color: var(--separator);
}

/* Кнопки действий (Написать, Позвонить) */
#userProfileSheet .user-profile-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 0 var(--sp-md);
    margin-bottom: var(--sp-lg);
}

#userProfileSheet .user-action-btn {
    background: var(--bg-card);
    border: 1px solid var(--separator);
    border-radius: 14px;
    padding: 12px 6px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--blue);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    min-height: 70px;
    font-family: inherit;
}

#userProfileSheet .user-action-btn:hover {
    background: var(--blue-soft);
}

#userProfileSheet .user-action-btn:active {
    transform: scale(0.97);
}

#userProfileSheet .user-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
}

#userProfileSheet .user-action-icon svg {
    width: 20px;
    height: 20px;
}

/* Блоки с информацией */
#userProfileSheet .up-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    margin: 0 var(--sp-md) var(--sp-md) var(--sp-md);
    border: 1px solid var(--separator);
}

#userProfileSheet .up-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    width: 100%;
    text-align: left;
    min-height: 56px;
}

#userProfileSheet .up-row + .up-row {
    border-top: 1px solid var(--separator);
}

#userProfileSheet .up-row-click {
    cursor: pointer;
}

#userProfileSheet .up-row-click:active {
    background: var(--bg-sidebar-hover);
}

#userProfileSheet .up-ico {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

#userProfileSheet .up-ico svg {
    width: 18px;
    height: 18px;
}

#userProfileSheet .up-row-text {
    min-width: 0;
    flex: 1;
}

#userProfileSheet .up-row-value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.3;
}

#userProfileSheet .up-row-label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 1px;
}

#userProfileSheet .up-act {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: none;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    min-height: 56px;
    font-family: inherit;
}

#userProfileSheet .up-act:active {
    background: var(--bg-sidebar-hover);
}

#userProfileSheet .up-act.danger {
    color: var(--red);
}

#userProfileSheet .up-act.danger .up-ico {
    color: var(--red);
}

#userProfileSheet .up-act + .up-act {
    border-top: 1px solid var(--separator);
}

/* Скрываем старые цветные квадраты, если они остались в HTML */
#userProfileSheet .up-ico-blue,
#userProfileSheet .up-ico-green,
#userProfileSheet .up-ico-purple,
#userProfileSheet .up-ico-orange,
#userProfileSheet .up-ico-red,
#userProfileSheet .up-ico-gray {
    background: none !important;
    color: var(--text-secondary) !important;
}

/* ============================================================
   20. INFO PANEL
   ============================================================ */

.info-panel { display: none; }

@media (max-width: 768px) {
    .info-panel {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 500;
        width: 100%;
        max-width: none;
        background: var(--bg-sidebar);
        border: none;
        box-shadow: none;
        flex-direction: column;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform var(--dur-base) var(--ease-out);
        visibility: hidden;
        padding-top: var(--safe-top);
        padding-bottom: var(--safe-bottom);
        overscroll-behavior: contain;
    }
    .app.info-open .info-panel {
        transform: translateX(0);
        visibility: visible;
    }
    .info-panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--sp-md);
        border-bottom: 1px solid var(--separator);
        flex-shrink: 0;
        background: var(--glass-bg);
        backdrop-filter: saturate(180%) blur(30px);
        -webkit-backdrop-filter: saturate(180%) blur(30px);
    }
    .info-panel-header h3 {
        font-size: var(--fs-lg);
        font-weight: 700;
        color: var(--text-primary);
    }
    .info-panel-header .icon-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: var(--bg-input);
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-primary);
        cursor: pointer;
        touch-action: manipulation;
    }
    .info-profile {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: var(--sp-lg) var(--sp-md);
        gap: var(--sp-xs);
    }
    .info-profile .avatar {
        width: 96px;
        height: 96px;
        font-size: 34px;
        margin-bottom: var(--sp-sm);
    }
    .info-name { font-size: var(--fs-xl); font-weight: 700; color: var(--text-primary); }
    .info-status { font-size: var(--fs-sm); color: var(--text-tertiary); }
    .info-rows { padding: var(--sp-xs) var(--sp-md); border-top: 1px solid var(--separator); background: var(--bg-card); }
    .info-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--sp-md) var(--sp-xs);
        font-size: var(--fs-base);
        color: var(--text-primary);
        cursor: pointer;
        border-radius: var(--radius-sm);
        min-height: 48px;
        touch-action: manipulation;
    }
    .info-row:active { background: var(--bg-sidebar-hover); }
    .info-row-arrow { color: var(--text-tertiary); }
}

@media (min-width: 769px) {
    .info-panel {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 320px;
        max-width: 80vw;
        border-left: 1px solid var(--separator);
        display: none;
        flex-direction: column;
        background: var(--bg-sidebar);
        overflow-y: auto;
        z-index: 30;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.1);
    }
    .app.info-open .info-panel { display: flex; }
    .info-panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--sp-md) var(--sp-md) var(--sp-xs);
    }
    .info-panel-header h3 {
        font-size: var(--fs-md);
        font-weight: 700;
        color: var(--text-primary);
    }
    .info-panel-header .icon-btn {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        border: none;
        background: var(--bg-input);
        color: var(--text-secondary);
        font-size: var(--fs-sm);
        cursor: pointer;
    }
    .info-profile {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: var(--sp-md);
        gap: var(--sp-2xs);
    }
    .info-profile .avatar { width: 84px; height: 84px; font-size: 30px; margin-bottom: var(--sp-xs); }
    .info-name { font-size: var(--fs-md); font-weight: 700; color: var(--text-primary); }
    .info-status { font-size: var(--fs-sm); color: var(--text-tertiary); }
    .info-rows { padding: var(--sp-xs) var(--sp-md); border-top: 1px solid var(--separator); }
    .info-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--sp-sm) var(--sp-xs);
        font-size: var(--fs-base);
        color: var(--text-primary);
        cursor: pointer;
        border-radius: var(--radius-sm);
    }
    .info-row:hover { background: var(--bg-sidebar-hover); }
    .info-row-arrow { color: var(--text-tertiary); }
}

@media (min-width: 1100px) {
    .info-panel {
        position: relative;
        flex: 0 0 320px;
        width: 320px;
        border-left: 1px solid var(--separator);
        display: none;
        flex-direction: column;
        background: var(--bg-sidebar);
        overflow-y: auto;
        box-shadow: none;
        max-width: none;
        z-index: auto;
    }
    .app.info-open .info-panel { display: flex; }
}
@media (min-width: 1440px) {
    .info-panel { flex: 0 0 360px; width: 360px; }
}

/* ============================================================
   21. АДАПТИВ: iPad
   ============================================================ */

@media (min-width: 769px) and (max-width: 1099px) {
    body { padding-bottom: 0; }
    .app { position: relative; }

    .sidebar {
        position: relative;
        flex: 0 0 clamp(280px, 34vw, 360px);
        width: clamp(280px, 34vw, 360px);
        max-width: 360px;
        border-right: 1px solid var(--separator);
    }
    .main {
        position: relative;
        inset: auto;
        flex: 1;
        min-width: 0;
        z-index: auto;
    }

    body.chat-open .back-btn { display: inline-flex; }

    .main.chat-hidden { display: flex !important; }
    .main.chat-hidden > .chat-header,
    .main.chat-hidden > .messages,
    .main.chat-hidden > .composer,
    .main.chat-hidden > .attach-menu,
    .main.chat-hidden > .voice-recording,
    .main.chat-hidden > .pinned-banner { display: none !important; }

    .main-empty-state { display: none; }
    .main.chat-hidden .main-empty-state { display: flex; }
    .chat-header-actions { display: flex; }
    .mobile-tabbar { display: none; }
}

/* ============================================================
   22. АДАПТИВ: MacBook
   ============================================================ */

@media (min-width: 1100px) {
    body { padding-bottom: 0; padding-left: 264px; }
    .app { position: relative; }

    .mobile-tabbar {
        top: 0;
        bottom: 0;
        left: 0;
        right: auto;
        transform: none;
        width: 264px;
        height: 100%;
        max-width: none;
        border-radius: 0;
        border: none;
        border-right: 1px solid var(--separator);
        background: var(--bg-sidebar);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: var(--sp-md) var(--sp-sm);
        padding-top: calc(var(--sp-md) + var(--safe-top));
        gap: 2px;
        z-index: 200;
    }

    .nav-logo {
        display: flex;
        align-items: center;
        gap: var(--sp-xs);
        padding: 6px var(--sp-xs) var(--sp-md);
    }
    .nav-logo-icon {
        width: 38px;
        height: 38px;
        border-radius: var(--radius-md);
        background: var(--blue);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: var(--fs-lg);
        flex-shrink: 0;
    }
    .nav-logo-title { font-size: var(--fs-md); font-weight: 700; color: var(--text-primary); line-height: 1.15; }
    .nav-logo-sub { font-size: var(--fs-sm); color: var(--text-tertiary); }
    .nav-write-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: var(--sp-xs);
        background: var(--blue);
        color: #fff;
        border: none;
        border-radius: var(--radius-md);
        font-size: var(--fs-base);
        font-weight: 600;
        padding: var(--sp-sm) var(--sp-md);
        margin-bottom: var(--sp-md);
        cursor: pointer;
        touch-action: manipulation;
        transition: transform var(--dur-fast);
        font-family: inherit;
    }
    .nav-write-btn:active { transform: scale(0.97); }

    .mt-item {
        flex: none;
        flex-direction: row;
        justify-content: flex-start;
        gap: var(--sp-md);
        font-size: var(--fs-base);
        font-weight: 600;
        padding: var(--sp-sm) var(--sp-md);
        border-radius: var(--radius-md);
        min-height: 44px;
    }
    .mt-item svg { width: 21px; height: 21px; flex-shrink: 0; }
    .mt-item.active { background: var(--blue); color: #fff; }
    .mt-item.active svg { transform: none; fill: none; }
    .mt-badge {
        position: static;
        margin-left: auto;
        transform: none;
        border: none;
    }
    .nav-user-mini {
        display: flex;
        align-items: center;
        gap: var(--sp-xs);
        margin-top: auto;
        padding: var(--sp-xs);
        border-radius: var(--radius-md);
        cursor: pointer;
        transition: background var(--dur-fast);
    }
    .nav-user-mini:hover { background: var(--bg-sidebar-hover); }
    .nav-user-mini-info { flex: 1; min-width: 0; }
    .nav-user-mini-name {
        font-size: var(--fs-sm);
        font-weight: 600;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .nav-user-mini-status { font-size: var(--fs-xs); color: var(--green); }
    .nav-user-mini-gear { color: var(--text-tertiary); flex-shrink: 0; }

    .sidebar {
        position: relative;
        flex: 0 0 360px;
        width: 360px;
        max-width: 360px;
        border-right: 1px solid var(--separator);
    }

    .main {
        position: relative;
        inset: auto;
        flex: 1;
        min-width: 0;
        z-index: auto;
    }

    .back-btn { display: none !important; }

    .main.chat-hidden { display: flex !important; }
    .main.chat-hidden > .chat-header,
    .main.chat-hidden > .messages,
    .main.chat-hidden > .composer,
    .main.chat-hidden > .attach-menu,
    .main.chat-hidden > .voice-recording,
    .main.chat-hidden > .pinned-banner { display: none !important; }

    .main-empty-state { display: none; }
    .main.chat-hidden .main-empty-state { display: flex; }
    .chat-header-actions { display: flex; }
}

/* ============================================================
   23. АДАПТИВ: iMac
   ============================================================ */

@media (min-width: 1440px) {
    body { padding-left: 280px; }
    .mobile-tabbar {
        width: 280px;
        padding: var(--sp-lg) var(--sp-md);
        padding-top: calc(var(--sp-lg) + var(--safe-top));
    }
    .nav-logo-icon { width: 42px; height: 42px; }
    .sidebar {
        flex: 0 0 clamp(360px, 28vw, 420px);
        width: clamp(360px, 28vw, 420px);
        max-width: 420px;
    }
    .main-empty-state .mes-icon { font-size: 72px; }
    .mes-title { font-size: var(--fs-xl); }
    .mes-sub { font-size: var(--fs-md); max-width: 320px; }
}

/* ============================================================
   24. АДАПТИВ: 4K / TV
   ============================================================ */

@media (min-width: 1920px) {
    body { padding-left: 300px; }
    .mobile-tabbar {
        width: 300px;
        padding: var(--sp-lg) var(--sp-md);
        padding-top: calc(var(--sp-lg) + var(--safe-top));
        gap: var(--sp-2xs);
    }
    .nav-logo-icon { width: 48px; height: 48px; font-size: var(--fs-xl); }
    .nav-logo-title { font-size: var(--fs-lg); }
    .nav-logo-sub { font-size: var(--fs-base); }
    .nav-write-btn {
        padding: var(--sp-md) var(--sp-lg);
        font-size: var(--fs-md);
        margin-bottom: var(--sp-lg);
    }
    .mt-item {
        padding: var(--sp-md) var(--sp-md);
        gap: var(--sp-md);
        font-size: var(--fs-md);
        min-height: 56px;
    }
    .mt-item svg { width: 26px; height: 26px; }

    .sidebar {
        flex: 0 0 440px;
        width: 440px;
        max-width: 440px;
    }
    .messages { padding: var(--sp-lg); }
    .message { max-width: 65%; }
    .msg-bubble { padding: var(--sp-sm) var(--sp-md) var(--sp-xs); }
    .composer {
        max-width: 900px;
        padding: var(--sp-xs);
        border-radius: 36px;
    }
    .composer-input textarea {
        padding: var(--sp-md) var(--sp-md);
        font-size: var(--fs-md);
    }
    .send-btn { width: 48px; height: 48px; }
    .composer .icon-btn.attach,
    .composer .icon-btn.mic-btn { width: 46px; height: 46px; }

    .edit-card { max-width: 700px; }
    .edit-card-wide { max-width: 820px; }
    .edit-sheet { padding: var(--sp-2xl) var(--sp-xl); }

    .gx-avatar { width: 160px; height: 160px; font-size: 56px; }
    .gx-cover { height: 320px; }
    #userProfileSheet .user-profile-avatar { width: 160px; height: 160px; font-size: 56px; }
    .info-profile .avatar { width: 120px; height: 120px; font-size: 42px; }
}

/* ============================================================
   25. УТИЛИТЫ + ПОДЛОЖКИ
   ============================================================ */

.hidden { display: none !important; }
.err {
    color: var(--red);
    font-size: var(--fs-sm);
    text-align: center;
    min-height: 18px;
}
.lazy-image {
    background: var(--bg-input);
    min-height: 200px;
    min-width: 200px;
    display: block;
}
.chat-image { transition: opacity var(--dur-base); }
.main.has-subscribe-bar .messages { padding-bottom: 20px; }

@media (max-width: 768px) {
    body.in-chat .mobile-tabbar,
    body.chat-open .mobile-tabbar { display: none; }

    .msg-menu-popover {
        bottom: calc(var(--safe-bottom) + var(--sp-md)) !important;
        top: auto !important;
        left: var(--sp-md) !important;
        right: var(--sp-md) !important;
        transform: none !important;
        max-width: none;
        width: auto;
    }
    .msg-menu-popover.open { transform: none !important; }
    .msg-menu { width: 100%; min-width: 0; }

    .emoji-panel { max-height: 60vh; }
    .emoji-panel-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 2px;
        padding: 8px 10px 16px;
    }
    .emoji-panel-btn { font-size: 24px; }

    body::after {
        content: '';
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: calc(104px + var(--safe-bottom));
        background: linear-gradient(
            to top,
            var(--bg-sidebar) 0%,
            var(--bg-sidebar) 42%,
            transparent 100%
        );
        pointer-events: none;
        z-index: 99;
    }
    body.in-chat::after,
    body.chat-open::after { display: none; }

    .main::after {
        content: '';
        position: absolute;
        left: 0; right: 0; bottom: 0;
        height: calc(32px + var(--safe-bottom));
        background: linear-gradient(
            to top,
            var(--bg-chat) 0%,
            var(--bg-chat) 70%,
            transparent 100%
        );
        pointer-events: none;
        z-index: 29;
    }
    .main.chat-hidden::after,
    .main.has-subscribe-bar::after { display: none; }
}

/* ============================================================
   26. LANDSCAPE iPhone
   ============================================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .chat-header { min-height: 52px; padding: 4px var(--sp-md); }
    .messages { padding: var(--sp-sm); }
    .composer { padding: 4px; }
    .composer-input textarea { max-height: 80px; }
    .profile-cover { max-height: 120px; }
    .profile-big { width: 72px; height: 72px; font-size: 28px; }
    .profile-hero { margin-top: -36px; }
}

/* ============================================================
   27. REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .message,
    .chat-item-wrap.pinned,
    .attach-menu,
    .composer-fullscreen,
    .edit-card,
    .msg-menu-popover,
    .emoji-panel {
        animation: none;
        transition: none;
    }
}

/* ============================================================
   28. FOCUS / TV
   ============================================================ */

@media (hover: none) and (pointer: coarse) and (min-width: 1920px) {
    button:focus-visible,
    a:focus-visible,
    .chat-item:focus-visible,
    .contact-item:focus-visible,
    .member-item:focus-visible,
    .settings-item:focus-visible {
        outline: 4px solid var(--blue);
        outline-offset: 4px;
        border-radius: var(--radius-md);
        transform: scale(1.02);
        transition: transform var(--dur-fast) var(--ease-spring);
    }
}
@media (hover: hover) and (pointer: fine) {
    :focus-visible {
        outline: 2px solid var(--blue);
        outline-offset: 2px;
    }
}

/* ============================================================
   29. ТЁМНАЯ ТЕМА — фиксы
   ============================================================ */

.theme-dark .msg-menu,
.theme-dark .msg-emoji-quickbar,
[data-theme="dark"] .msg-menu,
[data-theme="dark"] .msg-emoji-quickbar {
    background: rgba(28, 28, 30, 0.95);
    border-color: rgba(255, 255, 255, 0.12);
}
.theme-dark .msg-menu-item,
[data-theme="dark"] .msg-menu-item { color: #f5f5f7; }
.theme-dark .msg-menu-item svg,
[data-theme="dark"] .msg-menu-item svg { color: #f5f5f7; }
.theme-dark .msg-emoji-plus,
[data-theme="dark"] .msg-emoji-plus {
    background: rgba(120, 120, 128, 0.28);
    color: #f5f5f7;
}
.theme-dark .msg-emoji-quick:hover,
[data-theme="dark"] .msg-emoji-quick:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ============================================================
   30. ЗВОНКИ
   ============================================================ */

.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: #0b0b0f;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    padding: calc(24px + var(--safe-top)) 24px calc(48px + var(--safe-bottom));
}
.call-overlay.hidden { display: none !important; }

.call-video-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #000;
}
.call-video-layer video { display: none; }

.call-overlay.call-video #callRemoteVideo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.call-overlay.call-video #callLocalVideo {
    display: block;
    position: absolute;
    right: 16px;
    top: calc(24px + var(--safe-top));
    width: 96px;
    height: 140px;
    object-fit: cover;
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    transform: scaleX(-1);
    z-index: 1;
}

.call-info {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: auto;
}
.call-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--grad-blue);
}
.call-avatar .avatar { width: 100%; height: 100%; font-size: 34px; }
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }

.call-name {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}
.call-status {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.65);
    text-align: center;
}

.call-actions {
    position: relative;
    z-index: 1;
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding-top: 40px;
}
.call-actions.hidden { display: none !important; }

.call-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.15s;
    padding: 0;
}
.call-btn:active { transform: scale(0.92); }
.call-btn.accept { background: #34c759; color: #fff; }
.call-btn.decline { background: #ff3b30; color: #fff; transform: rotate(135deg); }
.call-btn.decline:active { transform: rotate(135deg) scale(0.92); }
.call-btn.secondary {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 22px;
}
.call-btn.secondary.active {
    background: #fff;
    color: #0b0b0f;
}
.call-btn svg { pointer-events: none; display: block; }

.call-overlay.call-video .call-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-areas: "av name" "av status";
    column-gap: 12px;
    row-gap: 1px;
    align-items: center;
    justify-items: start;
    padding: calc(var(--safe-top) + 12px) 16px 32px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
    text-align: left;
    z-index: 2;
    pointer-events: none;
}
.call-overlay.call-video .call-avatar {
    grid-area: av;
    width: 44px;
    height: 44px;
    font-size: 16px;
}
.call-overlay.call-video .call-name {
    grid-area: name;
    font-size: 17px;
    line-height: 1.2;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.call-overlay.call-video .call-status {
    grid-area: status;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.call-overlay.call-video #callLocalVideo {
    top: auto;
    right: 16px;
    bottom: calc(150px + var(--safe-bottom));
    z-index: 2;
}
.call-overlay.call-video .call-actions { z-index: 3; }

/* ============================================================
   ЗАПРЕТ ВЫДЕЛЕНИЯ ТЕКСТА ИЗ СООБЩЕНИЙ (iOS + Android)
   ============================================================ */

.msg-bubble,
.msg-bubble *,
.msg-text,
.msg-text *,
.bubble-image,
.bubble-image *,
.bubble-voice,
.bubble-voice *,
.msg-meta,
.msg-meta *,
.msg-sender,
.msg-reply-quote,
.msg-reply-quote * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.msg-text a,
.msg-text code {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (hover: hover) and (pointer: fine) {
    .msg-bubble,
    .msg-bubble *,
    .msg-text,
    .msg-text * {
        -webkit-user-select: text;
        user-select: text;
        -webkit-touch-callout: default;
    }
}

/* ============================================================
   ДИАЛОГ ПОДТВЕРЖДЕНИЯ (confirmDialog)
   ============================================================ */

.cd-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-md);
    opacity: 0;
    transition: opacity 0.2s ease;
    padding-top: calc(var(--sp-md) + var(--safe-top));
    padding-bottom: calc(var(--sp-md) + var(--safe-bottom));
}
.cd-overlay.open { opacity: 1; }

.cd-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.cd-card {
    position: relative;
    width: 100%;
    max-width: 320px;
    background: var(--sheet-bg);
    color: var(--text-primary);
    border-radius: var(--radius-2xl);
    overflow: hidden;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.28s var(--ease-spring);
}
.cd-overlay.open .cd-card { transform: scale(1); }

.cd-body {
    padding: var(--sp-lg) var(--sp-md) var(--sp-md);
}
.cd-title {
    font-size: var(--fs-md);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.cd-text {
    font-size: var(--fs-sm);
    line-height: 1.4;
    color: var(--text-secondary);
}

.cd-btn {
    display: block;
    width: 100%;
    padding: 15px 12px;
    font-family: inherit;
    font-size: var(--fs-md);
    font-weight: 500;
    background: transparent;
    color: var(--text-primary);
    border: none;
    border-top: 1px solid var(--separator);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.12s ease;
}
.cd-btn:hover { background: var(--bg-sidebar-hover); }
.cd-btn:active { background: var(--bg-sidebar-active); }
.cd-confirm { font-weight: 700; color: var(--blue); }
.cd-confirm.danger { color: var(--red); }


/* ============================================================
   26. АНИМАЦИЯ МЕНЮ (добавлено)
   ============================================================ */

.mt-indicator { display: none; }

@keyframes mtPop {
    0%   { transform: scale(.78) translateY(3px); }
    40%  { transform: scale(1.28) translateY(-4px); }
    70%  { transform: scale(.96) translateY(0); }
    100% { transform: scale(1.08) translateY(0); }
}
@keyframes mtPopFlat {
    0%   { transform: scale(.8); }
    45%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}
@keyframes mtBadgePop {
    0%   { transform: translateX(20%) scale(0); }
    60%  { transform: translateX(20%) scale(1.25); }
    100% { transform: translateX(20%) scale(1); }
}
@keyframes viewFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.mt-item svg { will-change: transform; }
.mt-item.active svg { animation: mtPop .5s var(--ease-spring); }
.mt-item:active svg,
.mt-item.active:active svg { transform: scale(.86); transition-duration: .1s; animation: none; }
.mt-item span:not(.mt-badge) { transition: color var(--dur-fast), transform .3s var(--ease-spring); }
.mt-item.active span:not(.mt-badge) { transform: translateY(-1px); }
.mt-badge { animation: mtBadgePop .4s var(--ease-spring); }

.view.active { animation: viewFadeIn .22s ease both; }

@media (max-width: 1099px) {
    .mobile-tabbar .mt-indicator {
        display: block;
        position: absolute;
        top: 8px;
        left: 0;
        height: 46px;
        width: var(--ind-w, 0px);
        transform: translateX(var(--ind-x, 0px));
        border-radius: 23px;
        background: var(--blue-soft);
        z-index: 0;
        pointer-events: none;
        opacity: 0;
        transition: transform .42s var(--ease-spring),
                    width .42s var(--ease-spring),
                    opacity .2s ease;
    }
    .mobile-tabbar .mt-indicator.ready { opacity: 1; }
    .mobile-tabbar .mt-indicator.no-anim { transition: none; }
    .mobile-tabbar .mt-item { z-index: 1; }
}

@media (min-width: 1100px) {
    .mt-item {
        transition: background-color .25s ease, color .25s ease, transform .2s ease;
    }
    .mt-item:not(.active):hover { background: var(--bg-sidebar-hover); }
    .mt-item.active svg { animation: mtPopFlat .4s var(--ease-spring); }
    .mt-item:active { transform: scale(.98); }
    .mt-badge { animation: none; }
}

@media (max-width: 768px) {
    .mobile-tabbar {
        transition: transform .38s var(--ease-spring), opacity .22s ease, visibility 0s;
        will-change: transform;
    }
    body.in-chat .mobile-tabbar,
    body.chat-open .mobile-tabbar {
        display: flex;
        transform: translate(-50%, calc(100% + var(--safe-bottom) + 28px));
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: transform .3s cubic-bezier(.4, 0, 1, 1), opacity .2s ease, visibility 0s linear .3s;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mt-indicator,
    .mobile-tabbar,
    .mt-item,
    .mt-item svg,
    .mt-item span,
    .mt-badge,
    .view.active {
        animation: none !important;
        transition-duration: .01ms !important;
        transition-delay: 0s !important;
    }
}


/* ============================================================
   27. НЕДОСТАЮЩИЕ СТИЛИ (добавлено)
   ============================================================ */

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 30000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--safe-top, 0px) + 12px) 12px calc(var(--safe-bottom, 0px) + 12px);
    background: rgba(0, 0, 0, 0.94);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    opacity: 0;
    transition: opacity .2s ease;
    touch-action: pinch-zoom;
    cursor: zoom-out;
}
.image-viewer.open { opacity: 1; }
.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    transform: scale(.96);
    transition: transform .28s var(--ease-spring), filter .3s ease;
    -webkit-user-drag: none;
    user-select: none;
}
.image-viewer.open img { transform: scale(1); }
.image-viewer.is-loading img { filter: blur(6px); }
.image-viewer.is-loading::after {
    content: '';
    position: absolute;
    width: 34px;
    height: 34px;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ivSpin .8s linear infinite;
}
.image-viewer-close {
    position: absolute;
    top: calc(var(--safe-top, 0px) + 10px);
    right: 12px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}
.image-viewer-close:active { background: rgba(255, 255, 255, .3); }
body.viewer-open { overflow: hidden; }
@keyframes ivSpin { to { transform: rotate(360deg); } }

.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border: 0;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: background var(--dur-fast), transform var(--dur-fast);
}
.btn-secondary { background: var(--bg-input); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-input-hover); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-secondary:active,
.btn-danger:active { transform: scale(.97); }
.add-link-actions { display: flex; gap: var(--sp-xs); margin-top: var(--sp-sm); }
.add-link-actions > button { flex: 1; width: auto; margin-top: 0; }
.add-link-form { margin: var(--sp-sm) 0; padding: var(--sp-sm); background: var(--bg-input); border-radius: var(--radius-md); }
.add-link-form.hidden { display: none; }
.cd-cancel { color: var(--text-secondary); }

.edit-input-prefix {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding-left: var(--sp-md);
    transition: box-shadow var(--dur-fast);
}
.edit-input-prefix:focus-within { box-shadow: 0 0 0 2px var(--blue-soft), 0 0 0 1px var(--blue); }
.edit-input-prefix .prefix { color: var(--text-tertiary); font-weight: 600; margin-right: 2px; }
.edit-input-prefix input {
    flex: 1;
    min-width: 0;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding-left: 0 !important;
}

.theme-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--sp-sm); }
.theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
    padding: var(--sp-xs);
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    touch-action: manipulation;
    transition: border-color var(--dur-base), transform var(--dur-base) var(--ease-spring);
}
.theme-card:active { transform: scale(.97); }
.theme-card.active { border-color: var(--blue); }
.theme-card-name { font-size: var(--fs-sm); font-weight: 600; }
.theme-card-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(.4);
    transition: opacity var(--dur-fast), transform var(--dur-base) var(--ease-spring);
}
.theme-card.active .theme-card-check { opacity: 1; transform: scale(1); }
.theme-preview { display: flex; height: 84px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--separator); }
.theme-prev-sidebar { width: 32%; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.theme-prev-item { height: 8px; border-radius: 4px; }
.theme-prev-chat { flex: 1; padding: 8px 6px; display: flex; flex-direction: column; gap: 5px; justify-content: flex-end; }
.theme-prev-bubble { height: 14px; width: 70%; border-radius: 8px; }
.theme-prev-out { align-self: flex-end; }
.theme-preview-light .theme-prev-sidebar { background: #f2f2f7; }
.theme-preview-light .theme-prev-item { background: #d1d1d6; }
.theme-preview-light .theme-prev-chat { background: #ffffff; }
.theme-preview-light .theme-prev-in { background: #e9e9eb; }
.theme-preview-light .theme-prev-out { background: #007aff; }
.theme-preview-dark .theme-prev-sidebar { background: #1c1c1e; }
.theme-preview-dark .theme-prev-item { background: #3a3a3c; }
.theme-preview-dark .theme-prev-chat { background: #000000; }
.theme-preview-dark .theme-prev-in { background: #2c2c2e; }
.theme-preview-dark .theme-prev-out { background: #0a84ff; }
.theme-preview-nord .theme-prev-sidebar { background: #e5e9f0; }
.theme-preview-nord .theme-prev-item { background: #c8d0de; }
.theme-preview-nord .theme-prev-chat { background: #eceff4; }
.theme-preview-nord .theme-prev-in { background: #ffffff; }
.theme-preview-nord .theme-prev-out { background: #5e81ac; }

.sound-list { display: flex; flex-direction: column; margin-top: var(--sp-xs); background: var(--bg-input); border-radius: var(--radius-md); overflow: hidden; }
.sound-item {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    width: 100%;
    padding: var(--sp-sm) var(--sp-md);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--separator);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--fs-base);
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    transition: background var(--dur-fast);
}
.sound-item:last-child { border-bottom: 0; }
.sound-item:hover { background: var(--bg-input-hover); }
.sound-play {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blue-soft);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sound-name { flex: 1; font-weight: 500; }
.sound-check { color: var(--blue); font-weight: 700; opacity: 0; transform: scale(.5); transition: opacity var(--dur-fast), transform var(--dur-base) var(--ease-spring); }
.sound-item.active .sound-check { opacity: 1; transform: scale(1); }
.sound-item.active .sound-name { color: var(--blue); }

.faq-item {
    background: var(--bg-input);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-xs);
    overflow: hidden;
    cursor: pointer;
}
.faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-md);
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-primary);
}
.faq-arrow { color: var(--text-tertiary); font-size: 22px; line-height: 1; transition: transform var(--dur-base) var(--ease-spring); }
.faq-item.open .faq-arrow { transform: rotate(90deg); color: var(--blue); }
.faq-answer {
    max-height: 0;
    overflow: hidden;
    padding: 0 var(--sp-md);
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--text-secondary);
    transition: max-height .3s ease, padding .3s ease;
}
.faq-item.open .faq-answer { max-height: 400px; padding: 0 var(--sp-md) var(--sp-md); }

.ticket-item {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-md);
    background: var(--bg-input);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-xs);
    cursor: pointer;
    touch-action: manipulation;
    transition: background var(--dur-fast);
}
.ticket-item:hover { background: var(--bg-input-hover); }
.ticket-info { flex: 1; min-width: 0; }
.ticket-subject { font-size: var(--fs-base); font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-meta { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 2px; }
.ticket-status { flex-shrink: 0; padding: 3px 10px; border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 600; }
.ticket-status.status-new      { background: var(--blue-soft);   color: var(--blue); }
.ticket-status.status-progress { background: var(--orange-soft); color: var(--orange); }
.ticket-status.status-resolved { background: var(--green-soft);  color: var(--green); }
.ticket-status.status-closed   { background: var(--bg-input-hover); color: var(--text-tertiary); }
.ticket-message { max-width: 88%; margin-bottom: var(--sp-xs); padding: var(--sp-xs) var(--sp-sm); border-radius: var(--radius-lg); }
.ticket-message.ticket-user  { margin-left: auto; background: var(--blue); color: #fff; border-bottom-right-radius: 6px; }
.ticket-message.ticket-admin { margin-right: auto; background: var(--bg-input); color: var(--text-primary); border-bottom-left-radius: 6px; }
.ticket-message-author { font-size: var(--fs-xs); font-weight: 700; color: var(--blue); margin-bottom: 2px; }
.ticket-message-body { font-size: var(--fs-base); line-height: 1.4; word-break: break-word; }
.ticket-message-time { font-size: 10px; opacity: .65; margin-top: 3px; text-align: right; }

.crop-container {
    position: relative;
    width: min(100%, 320px);
    aspect-ratio: 1;
    margin: 0 auto var(--sp-sm);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    touch-action: none;
}
.crop-container canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.crop-container canvas:active { cursor: grabbing; }
.crop-controls { display: flex; align-items: center; gap: var(--sp-sm); max-width: 320px; margin: 0 auto; }
.crop-controls button {
    width: 36px; height: 36px; flex-shrink: 0;
    border: 0; border-radius: 50%;
    background: var(--bg-input); color: var(--text-primary);
    font-size: 20px; cursor: pointer; touch-action: manipulation;
}
.crop-controls input[type="range"] { flex: 1; accent-color: var(--blue); }
.crop-hint { text-align: center; margin-top: var(--sp-xs); font-size: var(--fs-xs); color: var(--text-tertiary); }

.verify-intro { text-align: center; padding: var(--sp-md) var(--sp-sm) var(--sp-lg); }
.verify-icon {
    width: 64px; height: 64px; margin: 0 auto var(--sp-sm);
    border-radius: 50%; background: var(--green-soft);
    display: flex; align-items: center; justify-content: center;
}
.verify-intro h3 { margin: 0 0 4px; font-size: var(--fs-lg); color: var(--text-primary); }
.verify-intro p  { margin: 0; font-size: var(--fs-sm); color: var(--text-secondary); line-height: 1.45; }

.edit-sheet.wallet-inner-sheet { z-index: 1600; }

.settings-icon {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--blue-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
}
.channel-icon { font-size: .9em; margin-left: 4px; }

.typing-row { transition: opacity .2s ease, transform .2s ease; }
.typing-row.typing-hide { opacity: 0; transform: translateY(4px); }
.bubble-typing { display: inline-flex; flex-direction: column; gap: 3px; padding: 10px 14px; min-width: 56px; }
.typing-name { font-size: var(--fs-xs); font-weight: 600; color: var(--blue); }
.typing-dots { display: flex; align-items: center; gap: 4px; height: 12px; }
.typing-dots span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

.unread-divider { display: flex; align-items: center; justify-content: center; margin: var(--sp-sm) 0; }
.unread-divider span {
    padding: 4px 14px; border-radius: var(--radius-full);
    background: var(--blue-soft); color: var(--blue);
    font-size: var(--fs-xs); font-weight: 600;
}
.quarantine-badge {
    display: inline-block; margin-bottom: 4px; padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--orange-soft); color: var(--orange);
    font-size: var(--fs-xs); font-weight: 600;
}
.message.message-sending { opacity: .6; }
.message.message-sending img { filter: saturate(.7); }
.msg-meta .check.read { color: #7fd3ff; }
.copy-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom, 0px) + 90px);
    transform: translate(-50%, 12px);
    z-index: 40000;
    padding: 9px 18px;
    border-radius: var(--radius-full);
    background: rgba(30, 30, 32, .92);
    color: #fff;
    font-size: var(--fs-sm);
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .3s var(--ease-spring);
}
.copy-toast.show { opacity: 1; transform: translate(-50%, 0); }

.msg-secret-invite { min-width: 220px; padding: 4px 2px; }
.msg-secret-invite-header { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 700; opacity: .9; margin-bottom: 6px; }
.msg-secret-invite-title { font-size: var(--fs-base); font-weight: 600; }
.msg-secret-invite-sub { font-size: var(--fs-xs); opacity: .75; margin-top: 2px; }
.msg-secret-invite-actions { display: flex; gap: 8px; margin-top: 10px; }
.msg-secret-invite-btn {
    flex: 1; padding: 8px 12px; border: 0; border-radius: var(--radius-md);
    background: rgba(255, 255, 255, .22); color: inherit;
    font-family: inherit; font-weight: 600; font-size: var(--fs-sm);
    cursor: pointer; touch-action: manipulation;
}
.message.incoming .msg-secret-invite-btn { background: var(--blue); color: #fff; }
.msg-secret-invite-status { margin-top: 8px; font-size: var(--fs-xs); font-weight: 600; opacity: .85; }

.topic-item {
    display: flex; align-items: center; gap: var(--sp-sm);
    padding: var(--sp-xs) var(--sp-sm);
    border-radius: var(--radius-md);
    cursor: pointer; touch-action: manipulation;
    transition: background var(--dur-fast);
}
.topic-item:hover { background: var(--bg-sidebar-hover); }
.topic-item.active { background: var(--blue-soft); }
.topic-emoji { width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--radius-md); background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.topic-info { flex: 1; min-width: 0; }
.topic-name { font-size: var(--fs-base); font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-default { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: var(--radius-full); background: var(--blue-soft); color: var(--blue); vertical-align: middle; }
.topic-sub { font-size: var(--fs-xs); color: var(--text-tertiary); }
.topic-remove { width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--text-tertiary); cursor: pointer; }
.topic-remove:hover { background: var(--red-soft); color: var(--red); }
.gi-role-option {
    display: block; width: 100%; padding: 12px var(--sp-md);
    border: 0; border-bottom: 1px solid var(--separator);
    background: transparent; color: var(--text-primary);
    font-family: inherit; font-size: var(--fs-base); text-align: left; cursor: pointer;
}
.gi-role-option.active { color: var(--blue); font-weight: 600; }
body.gi-open { overscroll-behavior: contain; }


/* ============================================================
   28. ГРУППЫ И КАНАЛЫ: звонки, окно «О группе», обложка, «Пульс» (добавлено)
   ============================================================ */

#mainChat[data-chat-type="group"] .hdr-call,
#mainChat[data-chat-type="channel"] .hdr-call { display: none !important; }

body.gi-open .composer,
body.gi-open #channelSubscribedBar,
body.gi-open .pinned-banner { visibility: hidden; opacity: 0; pointer-events: none; }
@media (max-width: 1099px) {
    body.gi-open .mobile-tabbar { visibility: hidden; opacity: 0; pointer-events: none; }
}

.gx-cover {
    height: auto;
    aspect-ratio: 3 / 2;
    max-height: 320px;
}
#cropChatContainer { aspect-ratio: 3 / 2; width: min(100%, 420px); }

.gx-pulse {
    margin: var(--sp-sm) 0;
    padding: 14px 16px 14px;
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    border: 1px solid var(--separator);
    box-shadow: var(--shadow-sm);
    text-align: left;
}
.gx-pulse-loading { min-height: 120px; position: relative; overflow: hidden; }
.gx-pulse-loading::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(100deg, transparent 20%, var(--bg-input) 50%, transparent 80%);
    animation: pulseShimmer 1.2s infinite;
}
@keyframes pulseShimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.gx-pulse-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gx-pulse-title { font-size: var(--fs-sm); font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.gx-pulse-trend { padding: 2px 9px; border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 700; }
.gx-pulse-trend.up   { background: var(--green-soft); color: var(--green); }
.gx-pulse-trend.down { background: var(--red-soft);   color: var(--red); }
.gx-pulse-num { margin-top: 4px; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); }
.gx-pulse-num span { font-size: var(--fs-base); font-weight: 600; color: var(--text-tertiary); letter-spacing: 0; }
.gx-pulse-empty { margin-top: 6px; font-size: var(--fs-sm); color: var(--text-tertiary); }

.gx-pulse-bars { display: flex; gap: 8px; margin-top: 14px; }
.gx-pulse-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.gx-pulse-col { width: 100%; height: 64px; display: flex; align-items: flex-end; }
.gx-pulse-col i {
    display: block; width: 100%; min-height: 4px;
    border-radius: 7px;
    background: var(--blue-soft);
    transform-origin: bottom;
    animation: pulseGrow .6s var(--ease-spring) both;
}
.gx-pulse-bar.today .gx-pulse-col i { background: var(--grad-blue); }
.gx-pulse-bar.best  .gx-pulse-col i { background: var(--grad-orange); }
.gx-pulse-bar span { font-size: 10px; font-weight: 600; color: var(--text-tertiary); }
.gx-pulse-bar.today span { color: var(--blue); }
@keyframes pulseGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.gx-pulse-note { margin-top: 10px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); }

.gx-pulse-top-title { margin-top: 14px; font-size: var(--fs-xs); font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .04em; }
.gx-pulse-top { display: flex; gap: 8px; margin-top: 8px; }
.gx-pulse-user {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 10px 4px 8px;
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    cursor: pointer; touch-action: manipulation;
    transition: transform var(--dur-fast);
}
.gx-pulse-user:active { transform: scale(.96); }
.gx-pulse-user .avatar img { width: 100%; height: 100%; object-fit: cover; }
.gx-pulse-uname { max-width: 100%; font-size: var(--fs-xs); font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gx-pulse-ucount { font-size: 10px; font-weight: 700; color: var(--blue); }

@media (prefers-reduced-motion: reduce) {
    .gx-pulse-col i, .gx-pulse-loading::after { animation: none !important; }
}


/* ============================================================
   29. «О группе/канале»: полный экран без app.php, шапка без обрезки (добавлено)
   ============================================================ */

#groupInfoSheet { padding: 0; align-items: stretch; justify-content: stretch; }
#groupInfoSheet .edit-backdrop { display: none; }
#groupInfoSheet .edit-card {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    overflow: hidden;
    background: var(--bg-sidebar);
    transform: translateY(24px);
    transition: transform var(--dur-slow) var(--ease-out);
    display: flex;
    flex-direction: column;
}
#groupInfoSheet.open .edit-card { transform: translateY(0); }
#groupInfoSheet .edit-header { padding-top: calc(var(--safe-top) + var(--sp-xs)); flex-shrink: 0; }

.gx-hero { display: grid; padding-top: 0; }
.gx-cover {
    position: relative;
    grid-area: 1 / 1;
    top: auto; left: auto; right: auto;
    width: 100%;
}
.gx-head { grid-area: 1 / 1; align-self: start; padding-top: 40px; }

.gx-cover::after {
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.12) 0%,
        rgba(0, 0, 0, 0) 30%,
        color-mix(in srgb, var(--bg-sidebar) 70%, transparent) 70%,
        var(--bg-sidebar) 97%
    );
}
.gx-name { text-shadow: 0 1px 12px var(--bg-sidebar); }
.gx-sub  { text-shadow: 0 1px 10px var(--bg-sidebar); }


/* ============================================================
   30. СООБЩЕНИЯ КАК В TELEGRAM (добавлено)
   ============================================================ */

.message:has(.bubble-image) { max-width: min(320px, 84%); }
.msg-bubble:has(> .bubble-image) {
    padding: 0;
    overflow: hidden;
    width: min(300px, 74vw);
}
.msg-bubble:has(> .bubble-image) > .msg-sender,
.msg-bubble:has(> .bubble-image) > .msg-reply-quote { margin: 8px 12px 0; }
.message .bubble-image {
    width: 100%;
    max-width: none;
    border-radius: 0;
}
.message .bubble-image .msg-text { padding: 6px 12px 6px; }
.msg-bubble:has(> .bubble-image) .msg-footer { padding: 4px 10px 8px; margin-top: 0; }

.msg-text .msg-meta.msg-meta-inline {
    float: right;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    position: relative;
    top: 4px;
    margin: 5px -4px -6px 12px;
    padding: 0;
    background: none;
    border-radius: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    line-height: 1;
    white-space: nowrap;
    color: inherit;
    right: auto; bottom: auto;
}
.message.incoming .msg-text .msg-meta-inline { color: var(--text-tertiary); }
.message.outgoing .msg-text .msg-meta-inline { color: rgba(255, 255, 255, 0.78); }
.msg-text::after { content: ''; display: block; clear: both; }
.msg-text.msg-deleted .msg-meta-inline { font-style: normal; }

.msg-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 6px;
}
.msg-footer .msg-reactions {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    gap: 4px;
}
.msg-footer .msg-meta {
    flex-shrink: 0;
    margin: 0 -2px 3px auto;
    padding: 0;
    line-height: 1;
    white-space: nowrap;
}

.msg-reaction {
    height: 26px;
    padding: 0 9px 0 7px;
    gap: 5px;
    font-size: var(--fs-sm);
    font-weight: 600;
}
.msg-reaction-emoji { font-size: 15px; line-height: 1; }
.msg-reaction-count { font-variant-numeric: tabular-nums; }
.msg-reaction-avatars { display: inline-flex; align-items: center; }
.msg-reaction-av {
    width: 18px;
    height: 18px;
    margin-left: -5px;
    border-radius: 50%;
    border: 1.5px solid var(--bg-bubble-in);
    box-sizing: content-box;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: #fff;
}
.msg-reaction-av:first-child { margin-left: 0; }
.msg-reaction-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.message.outgoing .msg-reaction-av { border-color: var(--bg-bubble-out); }
.message.outgoing .msg-reaction.active .msg-reaction-av { border-color: #fff; }
.message.incoming .msg-reaction.active .msg-reaction-av { border-color: var(--blue); }
.message.outgoing .msg-reaction.active { background: #fff; color: var(--blue); border-color: #fff; }
.msg-reaction:active { transform: scale(.94); }

.msg-menu-overlay .msg-menu-backdrop {
    background: rgba(0, 0, 0, 0.30);
    backdrop-filter: blur(20px) saturate(1.25);
    -webkit-backdrop-filter: blur(20px) saturate(1.25);
}
.msg-focus-clone {
    z-index: 10001;
    pointer-events: none;
    will-change: transform;
    transition: transform .34s var(--ease-spring);
}
.msg-focus-clone .msg-bubble { box-shadow: 0 14px 44px rgba(0, 0, 0, 0.32); }
.msg-focus-bar,
.msg-focus-menu {
    position: fixed;
    z-index: 10002;
    opacity: 0;
    transform: scale(.82);
    transition: opacity .16s ease, transform .3s var(--ease-spring);
    pointer-events: auto;
}
.msg-focus-bar  { max-width: calc(100vw - 24px); }
.msg-focus-menu { width: min(280px, calc(100vw - 24px)); }
.msg-focus-bar.open,
.msg-focus-menu.open { opacity: 1; transform: scale(1); }
.msg-focus-menu .msg-menu { min-width: 0; width: 100%; }

@media (prefers-reduced-motion: reduce) {
    .msg-focus-clone, .msg-focus-bar, .msg-focus-menu { transition: none !important; }
}


/* ============================================================
   31. ДИЗАЙН «APPLE × TELEGRAM» (добавлено)
   ============================================================ */

:root,
.theme-light,
[data-theme="light"] {
    color-scheme: light;

    /* Фоны */
    --bg-app:          #ffffff;
    --bg-sidebar:      #f5f5f7;
    --bg-sidebar-hover:#ebebef;
    --bg-sidebar-active:#e5e5ea;
    --bg-chat:         #ffffff;
    --bg-input:        #f2f2f7;
    --bg-input-hover:  #e8e8ed;
    --bg-bubble-in:    #f2f2f7;
    --bg-bubble-out:   #007aff;
    --bg-menu:         #fafafa;
    --bg-card:         #ffffff;
    --bg-overlay:      rgba(0, 0, 0, 0.45);

    /* Текст */
    --text-primary:    #1d1d1f;
    --text-secondary:  #6e6e73;
    --text-tertiary:   #8e8e93;
    --text-inverse:    #ffffff;
    --text-link:       #007aff;

    /* Акценты */
    --blue:            #007aff;
    --blue-hover:      #0066d6;
    --blue-soft:       rgba(0, 122, 255, 0.12);

    --green:           #34c759;
    --green-soft:      rgba(52, 199, 89, 0.12);

    --red:             #ff3b30;
    --red-soft:        rgba(255, 59, 48, 0.12);

    --orange:          #ff9500;
    --orange-soft:     rgba(255, 149, 0, 0.12);

    --purple:          #af52de;
    --purple-soft:     rgba(175, 82, 222, 0.12);

    --pink:            #ff2d55;
    --pink-soft:       rgba(255, 45, 85, 0.12);

    /* Градиенты */
    --grad-blue:   linear-gradient(135deg, #5ac8fa, #007aff);
    --grad-purple: linear-gradient(135deg, #bf5af2, #af52de);
    --grad-green:  linear-gradient(135deg, #a2e876, #34c759);
    --grad-orange: linear-gradient(135deg, #ffcc00, #ff9500);
    --grad-pink:   linear-gradient(135deg, #ff6482, #ff2d55);
    --grad-gray:   linear-gradient(135deg, #aeaeb2, #8e8e93);

    /* Разделители и границы */
    --separator:      rgba(60, 60, 67, 0.08);
    --separator-med:  rgba(60, 60, 67, 0.12);
    --border:         rgba(60, 60, 67, 0.16);

    /* Стекло */
    --glass-bg:       rgba(255, 255, 255, 0.82);
    --glass-bg-solid: rgba(255, 255, 255, 0.92);
    --glass-border:   rgba(255, 255, 255, 0.6);
    --header-bg:      rgba(255, 255, 255, 0.85);
    --tabbar-bg:      rgba(255, 255, 255, 0.92);
    --sheet-bg:       #ffffff;

    /* Бренд (алиасы) */
    --brand:        var(--blue);
    --brand-hover:  var(--blue-hover);
}
.theme-dark,
[data-theme="dark"] {
    --bg-chat:        #0b121b;
    --bg-input:       rgba(118, 118, 128, 0.24);
    --bg-input-hover: rgba(118, 118, 128, 0.32);
    --bg-bubble-in:   #222b38;
    --glass-bg:       rgba(30, 30, 34, 0.66);
    --glass-bg-solid: rgba(30, 30, 34, 0.94);
    --glass-border:   rgba(255, 255, 255, 0.10);
    --header-bg:      rgba(12, 12, 14, 0.74);
}

/* 31b. ТЁМНАЯ И СЕРАЯ ТЕМЫ — ПОЛНЫЙ НАБОР ТОКЕНОВ (добавлено)
   Секция 31 выше перезаписывала токены светлыми значениями, а часть токенов
   (--bg-card, --text-primary, --blue …) оставалась светлой — отсюда белые
   карточки и тёмный текст на тёмном фоне. Здесь все токены задаются заново
   с повышенной специфичностью (html.theme-*), чтобы их не перебивал :root. */
html.theme-dark,
html[data-theme="dark"] {
    color-scheme: dark;

    --bg-app:          #000000;
    --bg-sidebar:      #0a0a0a;
    --bg-sidebar-hover:#1a1a1a;
    --bg-sidebar-active:#242424;
    --bg-chat:         #0b121b;
    --bg-input:        rgba(118, 118, 128, 0.24);
    --bg-input-hover:  rgba(118, 118, 128, 0.32);
    --bg-bubble-in:    #222b38;
    --bg-bubble-out:   #0a84ff;
    --bg-menu:         #0a0a0a;
    --bg-card:         #141416;
    --bg-overlay:      rgba(0, 0, 0, 0.7);

    --text-primary:    #f5f5f7;
    --text-secondary:  #a0a0a5;
    --text-tertiary:   #7a7a80;
    --text-inverse:    #ffffff;
    --text-link:       #4c9aff;

    --blue:            #0a84ff;
    --blue-hover:      #0a74e0;
    --blue-soft:       rgba(10, 132, 255, 0.18);

    --green:           #30d158;
    --green-soft:      rgba(48, 209, 88, 0.18);

    --red:             #ff453a;
    --red-soft:        rgba(255, 69, 58, 0.18);

    --orange:          #ff9f0a;
    --orange-soft:     rgba(255, 159, 10, 0.18);

    --purple:          #bf5af2;
    --purple-soft:     rgba(191, 90, 242, 0.18);

    --pink:            #ff375f;
    --pink-soft:       rgba(255, 55, 95, 0.18);

    --grad-blue:   linear-gradient(135deg, #0a84ff, #5ac8fa);
    --grad-purple: linear-gradient(135deg, #bf5af2, #9a3fc7);
    --grad-green:  linear-gradient(135deg, #30d158, #1fa844);
    --grad-orange: linear-gradient(135deg, #ff9f0a, #d87f00);
    --grad-pink:   linear-gradient(135deg, #ff375f, #d02548);
    --grad-gray:   linear-gradient(135deg, #48484a, #2c2c2e);

    --separator:      rgba(255, 255, 255, 0.08);
    --separator-med:  rgba(255, 255, 255, 0.12);
    --border:         rgba(255, 255, 255, 0.16);

    --glass-bg:       rgba(30, 30, 34, 0.66);
    --glass-bg-solid: rgba(30, 30, 34, 0.94);
    --glass-border:   rgba(255, 255, 255, 0.10);
    --header-bg:      rgba(12, 12, 14, 0.74);
    --tabbar-bg:      rgba(10, 10, 10, 0.92);
    --sheet-bg:       #1c1c1e;

    --brand:        var(--blue);
    --brand-hover:  var(--blue-hover);

    /* Пересчитываем тени (в тёмной теме они почти невидимы) */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4),
                 0 0 0 0.5px rgba(255, 255, 255, 0.05);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5),
                 0 0 0 0.5px rgba(255, 255, 255, 0.06);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6),
                 0 0 0 0.5px rgba(255, 255, 255, 0.08);
}

html.theme-nord,
html[data-theme="nord"] {
    color-scheme: light;

    --bg-app:          #eceff4;
    --bg-sidebar:      #e5e9f0;
    --bg-sidebar-hover:#d8dee9;
    --bg-sidebar-active:#cbd3e0;
    --bg-chat:         #eceff4;
    --bg-input:        #e5e9f0;
    --bg-input-hover:  #d8dee9;
    --bg-bubble-in:    #d8dee9;
    --bg-bubble-out:   #5e81ac;
    --bg-menu:         #e5e9f0;
    --bg-card:         #ffffff;
    --bg-overlay:      rgba(46, 52, 64, 0.45);

    --text-primary:    #2e3440;
    --text-secondary:  #4c566a;
    --text-tertiary:   #7a8599;
    --text-inverse:    #ffffff;
    --text-link:       #5e81ac;

    --blue:            #5e81ac;
    --blue-hover:      #4c6f99;
    --blue-soft:       rgba(94, 129, 172, 0.15);

    --green:           #a3be8c;
    --green-soft:      rgba(163, 190, 140, 0.2);

    --red:             #bf616a;
    --red-soft:        rgba(191, 97, 106, 0.18);

    --orange:          #d08770;
    --orange-soft:     rgba(208, 135, 112, 0.18);

    --purple:          #b48ead;
    --purple-soft:     rgba(180, 142, 173, 0.18);

    --pink:            #bf616a;
    --pink-soft:       rgba(191, 97, 106, 0.18);

    --grad-blue:   linear-gradient(135deg, #81a1c1, #5e81ac);
    --grad-purple: linear-gradient(135deg, #b48ead, #8f6b8f);
    --grad-green:  linear-gradient(135deg, #a3be8c, #7fa068);
    --grad-orange: linear-gradient(135deg, #ebcb8b, #d08770);
    --grad-pink:   linear-gradient(135deg, #d08770, #bf616a);
    --grad-gray:   linear-gradient(135deg, #a8b2c1, #7a8599);

    --separator:      rgba(46, 52, 64, 0.08);
    --separator-med:  rgba(46, 52, 64, 0.12);
    --border:         rgba(46, 52, 64, 0.16);

    --glass-bg:       rgba(236, 239, 244, 0.85);
    --glass-bg-solid: rgba(236, 239, 244, 0.95);
    --glass-border:   rgba(255, 255, 255, 0.7);
    --header-bg:      rgba(236, 239, 244, 0.9);
    --tabbar-bg:      rgba(236, 239, 244, 0.94);
    --sheet-bg:       #eceff4;

    --brand:        var(--blue);
    --brand-hover:  var(--blue-hover);
}

::selection { background: var(--blue-soft); }

.app-title {
    font-size: clamp(28px, 6.8vw, 34px);
    font-weight: 700;
    letter-spacing: -0.03em;
}
.search-box {
    border-radius: 12px;
    padding: 8px 12px;
}
.search-box:focus-within {
    background: var(--bg-card);
    box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.45), 0 4px 14px rgba(0, 122, 255, 0.10);
}
.tab-item {
    font-weight: 600;
    letter-spacing: -0.005em;
    transition: background var(--dur-base) var(--ease-out), color var(--dur-base), transform var(--dur-fast);
}
.tab-item:active { transform: scale(0.95); }
.tab-item.active { background: var(--blue-soft); color: var(--blue); }

.list { padding: 0 6px var(--sp-md); }
.chat-item,
.contact-item {
    position: relative;
    margin-bottom: 0;
    padding: 9px 12px;
    gap: 12px;
    border-radius: 14px;
    min-height: 66px;
    transition: background var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.chat-item:active,
.contact-item:active { background: var(--bg-sidebar-active); }
.chat-item::after {
    content: '';
    position: absolute;
    left: 76px;
    right: 8px;
    bottom: 0;
    height: 0.5px;
    background: var(--separator-med);
    pointer-events: none;
}
.chat-item.active::after,
.chat-item:hover::after { opacity: 0; }
.chat-name { font-size: clamp(15px, 0.3vw + 14px, 17px); font-weight: 600; letter-spacing: -0.012em; }
.chat-preview { font-size: clamp(14px, 0.3vw + 12.5px, 15px); }
.chat-time { font-size: 13px; }
.badge {
    min-width: 22px;
    height: 22px;
    line-height: 22px;
    padding: 0 7px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
}

.settings-group {
    border: 0;
    border-radius: 16px;
    box-shadow: 0 0 0 0.5px var(--separator-med);
}
.settings-item { border-bottom-width: 0.5px; min-height: 54px; }
.settings-item:active { background: var(--bg-sidebar-active); }
.settings-block-title { letter-spacing: 0.02em; }

.chat-header {
    backdrop-filter: saturate(190%) blur(30px);
    -webkit-backdrop-filter: saturate(190%) blur(30px);
    border-bottom: 0.5px solid var(--separator-med);
}

.messages {
    background:
        radial-gradient(60% 38% at 12% 6%,  rgba(110, 165, 255, 0.24), transparent 70%),
        radial-gradient(55% 38% at 92% 28%, rgba(190, 150, 255, 0.17), transparent 70%),
        radial-gradient(62% 42% at 18% 96%, rgba(90, 200, 250, 0.20),  transparent 70%),
        var(--bg-chat);
}
.theme-dark .messages,
[data-theme="dark"] .messages {
    background:
        radial-gradient(60% 38% at 12% 6%,  rgba(10, 132, 255, 0.20), transparent 70%),
        radial-gradient(55% 38% at 92% 28%, rgba(120, 80, 255, 0.15), transparent 70%),
        radial-gradient(62% 42% at 18% 96%, rgba(48, 170, 210, 0.14), transparent 70%),
        var(--bg-chat);
}

.msg-bubble { border-radius: 18px; padding: 8px 12px 6px; }
.message.incoming .msg-bubble {
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 1.5px rgba(20, 30, 60, 0.10);
}
.message.outgoing .msg-bubble {
    background: linear-gradient(180deg, #3d99ff 0%, #007aff 100%);
    border-bottom-right-radius: 5px;
    box-shadow: 0 1px 1.5px rgba(0, 60, 160, 0.28);
}
.theme-dark .message.outgoing .msg-bubble,
[data-theme="dark"] .message.outgoing .msg-bubble {
    background: linear-gradient(180deg, #2b93ff 0%, #0a74ee 100%);
}
.theme-dark .message.incoming .msg-bubble,
[data-theme="dark"] .message.incoming .msg-bubble { box-shadow: none; }

.composer {
    border: 0.5px solid var(--glass-border);
    border-radius: 26px;
    backdrop-filter: saturate(200%) blur(32px);
    -webkit-backdrop-filter: saturate(200%) blur(32px);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.composer-input { border-radius: 20px; }
.composer-input:focus-within {
    background: var(--bg-card);
    box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.45);
}
.mobile-tabbar {
    border: 0.5px solid var(--glass-border);
    backdrop-filter: saturate(200%) blur(32px);
    -webkit-backdrop-filter: saturate(200%) blur(32px);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}
.theme-dark .composer,
[data-theme="dark"] .composer,
.theme-dark .mobile-tabbar,
[data-theme="dark"] .mobile-tabbar {
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.btn-primary {
    border-radius: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base);
}
.btn-primary:active { transform: scale(0.975); }

.edit-card { border-radius: 28px; box-shadow: var(--shadow-lg); }
.edit-backdrop {
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

@media (max-width: 768px) {
    .edit-sheet { align-items: flex-end; padding: 0; }
    .edit-card {
        max-width: none;
        border-radius: 28px 28px 0 0;
        max-height: 92dvh;
        padding-bottom: var(--safe-bottom);
        transform: translateY(40px);
    }
    .edit-sheet.open .edit-card { transform: none; }
}

.avatar { box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06); }
.icon-btn:active { transform: scale(0.92); }


/* ============================================================
   32. РАСШИРЕНИЯ: опросы, просмотры, профиль, устройства, поддержка (добавлено)
   ============================================================ */

.tx-muted { color: var(--text-tertiary); font-size: var(--fs-sm); }
.tx-pad { padding: var(--sp-md); text-align: center; }
.tx-sect {
    margin: var(--sp-md) 0 var(--sp-xs);
    font-size: var(--fs-xs); font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-tertiary);
}
.tx-wide { width: 100%; margin-top: var(--sp-md); }
.tx-pill {
    display: inline-block; margin-left: 4px; padding: 1px 8px;
    border-radius: var(--radius-full);
    background: var(--green-soft); color: var(--green);
    font-size: 10px; font-weight: 700; vertical-align: middle;
}

#mainChat[data-chat-type="private"] #attachPollBtn { display: none; }

.msg-views { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; opacity: .85; }
.msg-views b { font-weight: 600; font-variant-numeric: tabular-nums; }
.msg-views svg { flex-shrink: 0; }

.message:has(.poll-card) { max-width: min(340px, 90%); }
.msg-bubble:has(.poll-card) { min-width: min(280px, 76vw); }
.poll-card { padding: 2px 0 0; transition: opacity var(--dur-fast); }
.poll-card.busy { opacity: .6; pointer-events: none; }
.poll-kind { font-size: var(--fs-xs); font-weight: 600; opacity: .7; margin-bottom: 2px; }
.poll-q { font-size: var(--fs-base); font-weight: 700; line-height: 1.3; margin-bottom: 10px; word-break: break-word; }
.poll-opts { display: flex; flex-direction: column; gap: 6px; }
.poll-opt {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 12px;
    border: 0; border-radius: 12px; overflow: hidden;
    background: rgba(120, 120, 128, 0.12);
    color: inherit; font-family: inherit; font-size: var(--fs-base); text-align: left;
    cursor: pointer; touch-action: manipulation;
    transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast);
}
.poll-opt:active { transform: scale(.985); }
.message.outgoing .poll-opt { background: rgba(255, 255, 255, 0.18); }
.poll-opt > * { position: relative; z-index: 1; }
.poll-bar {
    position: absolute !important; z-index: 0 !important;
    left: 0; top: 0; bottom: 0;
    background: rgba(0, 122, 255, 0.20);
    transition: width .6s var(--ease-out);
}
.message.outgoing .poll-bar { background: rgba(255, 255, 255, 0.30); }
.poll-text { flex: 1; min-width: 0; word-break: break-word; }
.poll-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.poll-mark {
    flex-shrink: 0; width: 20px; height: 20px;
    border: 2px solid currentColor; opacity: .55;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800; line-height: 1;
    transition: all var(--dur-base) var(--ease-spring);
}
.poll-mark.rd { border-radius: 50%; }
.poll-mark.sq { border-radius: 6px; }
.poll-opt.sel .poll-mark { opacity: 1; background: var(--blue); border-color: var(--blue); color: #fff; }
.poll-opt.sel .poll-mark::after { content: '✓'; }
.message.outgoing .poll-opt.sel .poll-mark { background: #fff; border-color: #fff; color: var(--blue); }
.poll-opt.res .poll-mark { border-color: transparent; opacity: 0; width: 0; margin-right: -10px; }
.poll-opt.res.mine .poll-mark { opacity: 1; width: 20px; margin-right: 0; background: var(--blue); color: #fff; }
.poll-opt.res.mine .poll-mark::after { content: '✓'; }
.message.outgoing .poll-opt.res.mine .poll-mark { background: #fff; color: var(--blue); }
.poll-opt.correct .poll-bar { background: rgba(52, 199, 89, 0.34); }
.poll-opt.correct .poll-mark { opacity: 1; width: 20px; margin-right: 0; background: var(--green); color: #fff; border-color: var(--green); }
.poll-opt.correct .poll-mark::after { content: '✓'; }
.poll-opt.wrong .poll-bar { background: rgba(255, 59, 48, 0.30); }
.poll-opt.wrong .poll-mark { opacity: 1; width: 20px; margin-right: 0; background: var(--red); color: #fff; border-color: var(--red); }
.poll-opt.wrong .poll-mark::after { content: '✕'; }
.poll-submit {
    width: 100%; margin-top: 8px; padding: 10px;
    border: 0; border-radius: 12px;
    background: var(--blue); color: #fff;
    font-family: inherit; font-size: var(--fs-base); font-weight: 600; cursor: pointer;
    transition: opacity var(--dur-fast), transform var(--dur-fast);
}
.poll-submit:disabled { opacity: .4; cursor: default; }
.poll-submit:not(:disabled):active { transform: scale(.98); }
.message.outgoing .poll-submit { background: #fff; color: var(--blue); }
.poll-links { display: flex; gap: 14px; margin-top: 8px; }
.poll-link {
    padding: 0; border: 0; background: none;
    color: var(--blue); font-family: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.message.outgoing .poll-link { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.poll-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 8px; }
.poll-total { font-size: var(--fs-xs); opacity: .7; }
.poll-foot .msg-meta { margin: 0; flex-shrink: 0; }

.tx-add {
    width: 100%; padding: 11px; margin-top: 6px;
    border: 0; border-radius: var(--radius-md);
    background: var(--blue-soft); color: var(--blue);
    font-family: inherit; font-size: var(--fs-base); font-weight: 600; cursor: pointer;
}
.tx-opt { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tx-opt input[type="text"] { flex: 1; min-width: 0; }
.tx-del {
    width: 30px; height: 30px; flex-shrink: 0;
    border: 0; border-radius: 50%;
    background: var(--bg-input); color: var(--text-secondary);
    font-size: 20px; line-height: 1; cursor: pointer;
}
.tx-correct { display: none; }
.tx-quiz .tx-correct { display: inline-flex; }
.tx-correct input { position: absolute; opacity: 0; pointer-events: none; }
.tx-correct span {
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--text-tertiary);
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--dur-base) var(--ease-spring);
}
.tx-correct input:checked + span { background: var(--green); border-color: var(--green); }
.tx-correct input:checked + span::after { content: '✓'; color: #fff; font-size: 14px; font-weight: 800; }

.tx-card {
    display: flex; flex-direction: column; gap: 6px;
    margin: var(--sp-sm) 0; padding: 12px 16px;
    border-radius: var(--radius-xl);
    background: var(--bg-card); border: 1px solid var(--separator);
    text-align: left;
}
.tx-card.tx-slow { flex-direction: row; align-items: center; gap: 12px; }
.tx-card-head { display: flex; align-items: center; gap: 8px; font-size: var(--fs-base); }
.tx-card-ico { font-size: 22px; }
.tx-rules-text {
    font-size: var(--fs-sm); line-height: 1.5; color: var(--text-secondary);
    max-height: 4.5em; overflow: hidden; position: relative;
}
.tx-rules-text.open { max-height: none; }
.tx-card .tx-muted { margin-top: 2px; }
.tx-tip-btn {
    display: flex; align-items: center; gap: 12px;
    width: 100%; margin: var(--sp-sm) 0; padding: 12px 16px;
    border: 0; border-radius: var(--radius-xl);
    background: linear-gradient(135deg, #ff9f43, #ff6b81);
    color: #fff; font-family: inherit; text-align: left; cursor: pointer;
    box-shadow: 0 8px 22px rgba(255, 107, 129, 0.30);
    transition: transform var(--dur-fast) var(--ease-out);
}
.tx-tip-btn:active { transform: scale(.98); }
.tx-tip-btn > span { font-size: 26px; }
.tx-tip-btn div { flex: 1; display: flex; flex-direction: column; }
.tx-tip-btn b { font-size: var(--fs-base); }
.tx-tip-btn small { font-size: var(--fs-xs); opacity: .9; }
.tx-tip-btn i { font-style: normal; font-size: 24px; opacity: .8; }
.tx-tip-head { text-align: center; padding: var(--sp-sm) 0 var(--sp-md); }
.tx-tip-emoji { font-size: 46px; }
.tx-tip-title { margin-top: 4px; font-size: var(--fs-lg); font-weight: 700; }
.tx-tip-sub { margin-top: 4px; font-size: var(--fs-sm); color: var(--text-secondary); }
.tx-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--sp-md); }
.tx-chip {
    padding: 8px 14px; border: 0; border-radius: var(--radius-full);
    background: var(--blue-soft); color: var(--blue);
    font-family: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.tx-chip:active { transform: scale(.95); }

.up-status-chip {
    display: inline-block; margin-top: 8px; padding: 5px 14px;
    border-radius: var(--radius-full);
    background: var(--bg-input); color: var(--text-primary);
    font-size: var(--fs-sm); font-weight: 500;
}
.up-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.up-badge {
    padding: 3px 10px; border-radius: var(--radius-full);
    background: var(--blue-soft); color: var(--blue);
    font-size: var(--fs-xs); font-weight: 600;
}
.tx-media { margin-top: var(--sp-md); }
.tx-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.tx-tabs::-webkit-scrollbar { display: none; }
.tx-tab {
    flex-shrink: 0; padding: 7px 14px; border: 0; border-radius: var(--radius-full);
    background: var(--bg-input); color: var(--text-secondary);
    font-family: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
    transition: background var(--dur-base), color var(--dur-base);
}
.tx-tab span { opacity: .6; margin-left: 2px; }
.tx-tab.active { background: var(--blue); color: #fff; }
.tx-media-body { min-height: 60px; }
.tx-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; border-radius: var(--radius-lg); overflow: hidden; }
.tx-thumb { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: var(--bg-input); cursor: pointer; overflow: hidden; }
.tx-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--dur-slow) var(--ease-out); }
.tx-thumb:active img { transform: scale(1.06); }
.tx-media-list { display: flex; flex-direction: column; background: var(--bg-card); border-radius: var(--radius-lg); overflow: hidden; }
.tx-file, .tx-link, .tx-voice {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-bottom: 0.5px solid var(--separator-med);
    color: var(--text-primary); text-decoration: none;
}
.tx-file:last-child, .tx-link:last-child, .tx-voice:last-child { border-bottom: 0; }
.tx-file-ico { font-size: 22px; }
.tx-file-name, .tx-link-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.tx-link-url { color: var(--blue); }
.tx-file small, .tx-link small, .tx-voice small { color: var(--text-tertiary); font-size: var(--fs-xs); flex-shrink: 0; }
.tx-voice { flex-direction: column; align-items: stretch; gap: 4px; }
.tx-voice audio { width: 100%; height: 36px; }
.tx-more {
    display: block; width: 100%; margin-top: 8px; padding: 10px;
    border: 0; border-radius: var(--radius-md);
    background: var(--bg-input); color: var(--blue);
    font-family: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}

.tx-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--sp-md); }
.tx-quick button {
    width: 42px; height: 42px; border: 0; border-radius: 50%;
    background: var(--bg-input); font-size: 22px; cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-spring);
}
.tx-quick button:active { transform: scale(.88); }
.tx-card-qr { text-align: center; padding: var(--sp-md) 0; }
.tx-qr {
    display: inline-flex; padding: 14px; border-radius: 24px; background: #fff;
    box-shadow: var(--shadow-md); min-width: 100px; min-height: 100px; align-items: center; justify-content: center;
    font-size: var(--fs-xs); word-break: break-all; color: #111;
}
.tx-qr img, .tx-qr canvas { display: block; border-radius: 6px; }
.tx-qr-name { margin-top: 14px; font-size: var(--fs-lg); font-weight: 700; }
.tx-qr-link { margin-top: 2px; font-size: var(--fs-sm); color: var(--blue); font-weight: 600; }
.tx-qr-actions { display: flex; gap: var(--sp-sm); margin-top: var(--sp-md); }
.tx-qr-actions button { flex: 1; width: auto; margin-top: 0; }
.tx-sess-note { margin-bottom: var(--sp-sm); font-size: var(--fs-sm); line-height: 1.45; color: var(--text-secondary); }
.tx-sess { align-items: center; }
.tx-sess-ico {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px;
    background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.tx-sess-out {
    flex-shrink: 0; padding: 6px 12px; border: 0; border-radius: var(--radius-full);
    background: var(--red-soft); color: var(--red);
    font-family: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.tx-sess-out:disabled { opacity: .5; }


/* ============================================================
   33. «СЛОЖИТЬСЯ» И «ВСТРЕЧИ» — фирменные карточки TOKSY (добавлено)
   ============================================================ */
#mainChat[data-chat-type="private"] .tx-grp-only { display: none; }

.message:has(.coll-card),
.message:has(.event-card) { max-width: min(340px, 90%); }
.msg-bubble:has(.coll-card),
.msg-bubble:has(.event-card) { min-width: min(280px, 76vw); }
.coll-card, .event-card { transition: opacity var(--dur-fast); }
.event-card.busy, .coll-card.busy { opacity: .6; pointer-events: none; }

.coll-kind, .ev-kind { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .03em; opacity: .75; margin-bottom: 4px; }
.coll-title, .ev-title { font-size: var(--fs-md); font-weight: 700; line-height: 1.25; margin-bottom: 10px; word-break: break-word; }

.coll-bar { height: 10px; border-radius: 6px; background: rgba(120, 120, 128, 0.18); overflow: hidden; }
.message.outgoing .coll-bar { background: rgba(255, 255, 255, 0.25); }
.coll-bar i {
    display: block; height: 100%; border-radius: 6px;
    background: linear-gradient(90deg, #34c759, #30d5c8);
    transition: width .7s var(--ease-out);
}
.coll-nums { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 8px; }
.coll-nums b { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.coll-nums span { font-size: var(--fs-xs); opacity: .75; }
.coll-badge {
    display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: var(--radius-full);
    background: rgba(120, 120, 128, 0.16); font-size: var(--fs-xs); font-weight: 700;
}
.coll-badge.ok { background: var(--green-soft); color: var(--green); }
.message.outgoing .coll-badge { background: rgba(255, 255, 255, 0.22); color: #fff; }
.coll-top, .ev-going { display: flex; align-items: center; margin-top: 10px; }
.coll-top-txt { margin-left: 8px; font-size: var(--fs-xs); opacity: .8; }
.tx-av {
    width: 24px; height: 24px; margin-left: -6px; border-radius: 50%;
    border: 2px solid var(--bg-bubble-in); box-sizing: content-box; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700; color: #fff;
}
.message.outgoing .tx-av { border-color: #2a8cff; }
.tx-av:first-child { margin-left: 0; }
.tx-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.coll-mine { margin-top: 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--green); }
.message.outgoing .coll-mine { color: #fff; }
.coll-actions { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.coll-pay {
    flex: 1; padding: 11px; border: 0; border-radius: 12px;
    background: linear-gradient(135deg, #34c759, #30b0c7); color: #fff;
    font-family: inherit; font-size: var(--fs-base); font-weight: 700; cursor: pointer;
    box-shadow: 0 6px 16px rgba(52, 199, 89, 0.30);
    transition: transform var(--dur-fast) var(--ease-out);
}
.coll-pay:active { transform: scale(.97); }

.ev-row { display: flex; gap: 10px; margin-bottom: 8px; }
.ev-row > span { font-size: 18px; line-height: 1.3; }
.ev-row b { display: block; font-size: var(--fs-base); text-transform: capitalize; }
.ev-row small { display: block; opacity: .7; font-size: var(--fs-xs); margin-top: 1px; }
.ev-btns { display: flex; gap: 6px; margin-top: 10px; }
.ev-btns.past { opacity: .6; }
.ev-btn {
    flex: 1; padding: 9px 4px; border: 0; border-radius: 12px;
    background: rgba(120, 120, 128, 0.14); color: inherit;
    font-family: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-spring), background var(--dur-base);
}
.ev-btn span { opacity: .7; font-variant-numeric: tabular-nums; }
.ev-btn:active { transform: scale(.94); }
.message.outgoing .ev-btn { background: rgba(255, 255, 255, 0.20); }
.ev-btn.active.ev-yes   { background: var(--green);  color: #fff; }
.ev-btn.active.ev-maybe { background: var(--orange); color: #fff; }
.ev-btn.active.ev-no    { background: var(--red);    color: #fff; }


/* ============================================================
   34. TOKSY PREMIUM (добавлено)
   ============================================================ */
.prem-star { margin-left: 3px; font-size: .85em; vertical-align: baseline; }
.avatar.prem-ring { box-shadow: 0 0 0 3px var(--bg-card), 0 0 0 6px #f5a623, 0 8px 22px rgba(245, 166, 35, .35); }

.prem-card {
    display: flex; align-items: center; gap: 12px;
    width: 100%; margin: 0 0 var(--sp-md); padding: 14px 16px;
    border: 0; border-radius: var(--radius-xl);
    background: linear-gradient(135deg, #ffb347 0%, #ff7a45 55%, #ff5f8d 100%);
    color: #fff; font-family: inherit; text-align: left; cursor: pointer;
    box-shadow: 0 10px 26px rgba(255, 122, 69, 0.32);
    transition: transform var(--dur-fast) var(--ease-out);
}
.prem-card:active { transform: scale(.985); }
.prem-card-star { font-size: 30px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.2)); }
.prem-card div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.prem-card b { font-size: var(--fs-md); letter-spacing: -0.01em; }
.prem-card small { font-size: var(--fs-xs); opacity: .92; }
.prem-card i { font-style: normal; font-size: 26px; opacity: .8; }
.prem-card.on { background: linear-gradient(135deg, #1f2937, #3b2f63 60%, #6d4cff); box-shadow: 0 10px 26px rgba(80, 60, 160, 0.35); }

.prem-hero { text-align: center; padding: var(--sp-md) 0; }
.prem-star-big {
    width: 84px; height: 84px; margin: 0 auto 10px; border-radius: 28px;
    display: flex; align-items: center; justify-content: center; font-size: 46px;
    background: linear-gradient(135deg, #ffb347, #ff5f8d);
    box-shadow: 0 14px 34px rgba(255, 95, 141, 0.35);
    animation: premFloat 3.2s ease-in-out infinite;
}
@keyframes premFloat { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(2deg); } }
.prem-h { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.prem-sub { margin-top: 4px; font-size: var(--fs-sm); color: var(--text-secondary); }
.prem-active {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--sp-sm); padding: 12px 16px; border-radius: var(--radius-lg);
    background: var(--green-soft); color: var(--green); font-size: var(--fs-sm);
}
.prem-perks { display: flex; flex-direction: column; gap: 4px; margin: var(--sp-md) 0; }
.prem-perk { display: flex; gap: 12px; padding: 10px 4px; align-items: flex-start; }
.prem-perk > span { font-size: 24px; width: 34px; text-align: center; flex-shrink: 0; }
.prem-perk b { display: block; font-size: var(--fs-base); }
.prem-perk small { display: block; margin-top: 1px; font-size: var(--fs-sm); color: var(--text-secondary); line-height: 1.35; }
.prem-plans { display: flex; gap: 10px; margin-bottom: var(--sp-md); }
.prem-plan {
    position: relative; flex: 1; display: flex; flex-direction: column; gap: 2px; align-items: center;
    padding: 14px 8px; border: 2px solid var(--separator-med); border-radius: var(--radius-lg);
    background: var(--bg-card); color: var(--text-primary); font-family: inherit; cursor: pointer;
    transition: border-color var(--dur-base), transform var(--dur-base) var(--ease-spring), background var(--dur-base);
}
.prem-plan b { font-size: var(--fs-base); }
.prem-plan span { font-size: var(--fs-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.prem-plan em {
    position: absolute; top: -10px; right: 10px; padding: 2px 8px; border-radius: var(--radius-full);
    background: linear-gradient(135deg, #ff7a45, #ff5f8d); color: #fff; font-style: normal; font-size: 11px; font-weight: 800;
}
.prem-plan.active { border-color: #ff7a45; background: rgba(255, 122, 69, 0.08); transform: scale(1.02); }
.prem-auto { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 var(--sp-sm); font-size: var(--fs-sm); color: var(--text-secondary); line-height: 1.4; }
.prem-auto input { margin-top: 2px; accent-color: #ff7a45; }
.prem-buy {
    width: 100%; padding: 15px; border: 0; border-radius: 16px;
    background: linear-gradient(135deg, #ffb347, #ff7a45 55%, #ff5f8d); color: #fff;
    font-family: inherit; font-size: var(--fs-md); font-weight: 800; letter-spacing: -0.01em; cursor: pointer;
    box-shadow: 0 10px 26px rgba(255, 122, 69, 0.35);
    transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
}
.prem-buy:active { transform: scale(.98); }
.prem-buy:disabled { opacity: .45; box-shadow: none; cursor: default; }
.prem-need { margin-top: 8px; text-align: center; font-size: var(--fs-sm); color: var(--red); }
.prem-themes { display: flex; flex-wrap: wrap; gap: 8px; }
.prem-theme {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px;
    border: 2px solid transparent; border-radius: var(--radius-full);
    background: var(--bg-input); color: var(--text-primary);
    font-family: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.prem-theme i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.prem-theme.active { border-color: var(--blue); }

.gx-pulse-range { display: inline-flex; gap: 4px; margin-top: 8px; padding: 3px; border-radius: var(--radius-full); background: var(--bg-input); }
.gx-pulse-range button {
    padding: 4px 12px; border: 0; border-radius: var(--radius-full); background: transparent;
    color: var(--text-secondary); font-family: inherit; font-size: var(--fs-xs); font-weight: 700; cursor: pointer;
}
.gx-pulse-range button.on { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.gx-pulse-bars.dense { gap: 2px; }
.gx-pulse-bars.dense .gx-pulse-col i { border-radius: 3px; }
.gx-pulse-bars.dense .gx-pulse-bar span { font-size: 9px; min-height: 11px; }

html.pt-aurora { --blue: #7c5cff; --blue-soft: rgba(124, 92, 255, 0.14); --grad-blue: linear-gradient(135deg, #9a7bff, #5b8cff); }
html.pt-sunset { --blue: #ff6a3d; --blue-soft: rgba(255, 106, 61, 0.14); --grad-blue: linear-gradient(135deg, #ff9a56, #ff4f81); }
html.pt-cosmos { --blue: #18b8d9; --blue-soft: rgba(24, 184, 217, 0.14); --grad-blue: linear-gradient(135deg, #22d3ee, #6366f1); }
html.pt-mint   { --blue: #12a77a; --blue-soft: rgba(18, 167, 122, 0.14); --grad-blue: linear-gradient(135deg, #34d399, #0ea5a4); }
html.pt-aurora .message.outgoing .msg-bubble { background: linear-gradient(180deg, #9a7bff, #6a4cf5); }
html.pt-sunset .message.outgoing .msg-bubble { background: linear-gradient(180deg, #ff9a56, #ff5a4d); }
html.pt-cosmos .message.outgoing .msg-bubble { background: linear-gradient(180deg, #2dd4ef, #4f6df0); }
html.pt-mint   .message.outgoing .msg-bubble { background: linear-gradient(180deg, #34d399, #0f9a78); }
html.pt-aurora .messages { background: radial-gradient(60% 38% at 12% 6%, rgba(124, 92, 255, .26), transparent 70%), radial-gradient(55% 38% at 92% 30%, rgba(236, 72, 153, .16), transparent 70%), radial-gradient(62% 42% at 18% 96%, rgba(91, 140, 255, .20), transparent 70%), var(--bg-chat); }
html.pt-sunset .messages { background: radial-gradient(60% 38% at 12% 6%, rgba(255, 154, 86, .30), transparent 70%), radial-gradient(55% 38% at 92% 30%, rgba(255, 79, 129, .18), transparent 70%), radial-gradient(62% 42% at 18% 96%, rgba(255, 196, 80, .20), transparent 70%), var(--bg-chat); }
html.pt-cosmos .messages { background: radial-gradient(60% 38% at 12% 6%, rgba(34, 211, 238, .26), transparent 70%), radial-gradient(55% 38% at 92% 30%, rgba(99, 102, 241, .22), transparent 70%), radial-gradient(62% 42% at 18% 96%, rgba(14, 165, 233, .20), transparent 70%), var(--bg-chat); }
html.pt-mint   .messages { background: radial-gradient(60% 38% at 12% 6%, rgba(52, 211, 153, .28), transparent 70%), radial-gradient(55% 38% at 92% 30%, rgba(14, 165, 164, .18), transparent 70%), radial-gradient(62% 42% at 18% 96%, rgba(163, 230, 53, .16), transparent 70%), var(--bg-chat); }
/* 35. ПРОФИЛЬ КАК В X + ФИКСЫ (добавлено) */

/* текст в списках всегда берёт цвет темы */
.chat-item,
.contact-item { color: var(--text-primary); }

.theme-dark .msg-text code, [data-theme="dark"] .msg-text code,
.theme-dark .msg-text pre,  [data-theme="dark"] .msg-text pre {
    background: rgba(255, 255, 255, 0.10);
}

/* ------------------------------------------------------------
   2. АКТИВНЫЙ ЧАТ: на телефоне после выхода из чата
      название не должно оставаться белым
   ------------------------------------------------------------ */

@media (max-width: 1099px) {
    .chat-item-wrap .chat-item.active { background: var(--bg-sidebar); }
    .chat-item.active .chat-name    { color: var(--text-primary); }
    .chat-item.active .chat-preview { color: var(--text-secondary); opacity: 1; }
    .chat-item.active .chat-time    { color: var(--text-tertiary); }
    .chat-item.active .badge        { background: var(--blue); color: #fff; }
}

/* ------------------------------------------------------------
   3. ПРОФИЛЬ ДРУГОГО ПОЛЬЗОВАТЕЛЯ — КАК В X
   ------------------------------------------------------------ */

/* пустой синий блок над обложкой */
#upCover { display: none !important; }

/* обложка 3:1, без «таяния» */
#userProfileSheet .user-profile-cover {
    height: auto !important;
    max-height: none !important;
    aspect-ratio: 3 / 1 !important;
}
#userProfileSheet .user-profile-cover.has-cover::after { display: none; }

/* аватарка слева, наполовину на обложке */
#userProfileSheet .user-profile-avatar {
    --av: clamp(88px, 26vw, 128px);
    width: var(--av) !important;
    height: var(--av) !important;
    margin: calc(var(--av) / -2) 0 12px var(--sp-md);
    border: 4px solid var(--bg-sidebar);
    box-shadow: none;
}

/* имя (с галочкой) и статус слева */
#userProfileSheet .user-profile-name {
    justify-content: flex-start;
    text-align: left;
    font-size: 22px;
    margin: 0 0 2px;
    gap: 0;
}
#userProfileSheet .user-profile-name .verified-icon {
    width: 22px;
    height: 22px;
    margin-left: 6px;
}
#userProfileSheet .user-profile-name .prem-star {
    margin-left: 4px;
    font-size: 18px;
}
#userProfileSheet .user-profile-status {
    text-align: left;
    margin-bottom: var(--sp-md);
}

/* плашки */
#userProfileSheet .up-badges-row {
    justify-content: flex-start;
    gap: 8px;
    padding: 0 var(--sp-md);
    margin-bottom: var(--sp-md);
}
#userProfileSheet .up-badges-row:empty { display: none; }
#userProfileSheet .up-badge {
    padding: 7px 13px 7px 10px;
    border: 0;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-secondary);
    box-shadow: 0 0 0 0.5px var(--separator-med);
}
#userProfileSheet .up-badge svg { width: 16px; height: 16px; }
#userProfileSheet .up-badge-premium {
    background: linear-gradient(135deg, #ffb347, #ff7a45 55%, #ff5f8d);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 122, 69, 0.30);
}
/* «Верифицирован» теперь показывает галочка у имени */
#userProfileSheet .up-badge-verified { display: none; }

/* дубль плашек из tx.js */
#userProfileBody:has(.up-badges-row) .up-badges { display: none; }

/* заголовки и медиа из tx.js — с отступами от края экрана */
#userProfileSheet .tx-sect {
    padding: 0 var(--sp-md);
    margin: var(--sp-lg) 0 var(--sp-xs);
}
#userProfileSheet .tx-media { padding: 0 var(--sp-md); }

/* ------------------------------------------------------------
   4. СВОЙ ПРОФИЛЬ — ТОТ ЖЕ СТИЛЬ
   ------------------------------------------------------------ */

.profile-cover { aspect-ratio: 3 / 1; max-height: none; }
.profile-hero { text-align: left; margin-top: -40px; }
.profile-hero .profile-big { margin: 0 0 var(--sp-sm); box-shadow: none; }
.profile-bio { padding: 0; }
.btn-edit-profile {
    position: absolute;
    right: var(--sp-md);
    top: 52px;
    margin-top: 0;
}


/* ============================================================
   36. КАРТОЧКИ ПЕРЕВОДОВ И ЗАПРОСОВ (новый дизайн)
   ============================================================ */

.message:has(.tx-card) { max-width: min(340px, 90%); }
.msg-bubble:has(.tx-card) {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    min-width: 0;
}
.message.incoming .msg-bubble:has(.tx-card),
.message.outgoing .msg-bubble:has(.tx-card) { border-radius: 0; }

.tx-card {
    border-radius: 20px;
    padding: 18px 20px 16px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    min-width: min(260px, 76vw);
}

/* Дефолт — зелёный перевод */
.tx-card {
    background: linear-gradient(135deg, #34c759 0%, #1f8a3f 100%);
}
.tx-card.accepted { background: linear-gradient(135deg, #34c759 0%, #1f8a3f 100%); }
.tx-card.declined { background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%); }
.tx-card.expired  { background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%); opacity: 0.8; }
/* Запрос — серый */
.tx-card.request  { background: linear-gradient(135deg, #5b6472 0%, #3a4250 100%); }

.tx-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    opacity: 0.9;
    margin-bottom: 10px;
}
.tx-head svg { flex-shrink: 0; }

.tx-amount {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
}
.tx-amount .tx-currency {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.75;
    letter-spacing: 0;
    margin-left: 4px;
}

.tx-fee {
    font-size: 12.5px;
    opacity: 0.75;
    letter-spacing: 0;
    margin-top: 4px;
}

.tx-comment {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 13.5px;
    line-height: 1.4;
}

.tx-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.tx-btn {
    flex: 1;
    padding: 11px 14px;
    border: 0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast);
}
.tx-btn:active { transform: scale(0.97); }
.tx-btn-accept { background: rgba(255, 255, 255, 0.26); }
.tx-btn-decline { background: rgba(255, 255, 255, 0.14); }

.tx-status-pill {
    display: inline-block;
    margin-top: 14px;
    padding: 8px 18px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    min-width: 120px;
}

/* ============================================================
   37. РЕАКЦИИ — ПИЛЮЛЯ С АВАТАРКАМИ (как в Telegram)
   ============================================================ */

.msg-reaction {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px 0 8px;
    border-radius: 980px;
    border: 1px solid transparent;
    background: var(--blue-soft);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-spring),
                background var(--dur-fast), border-color var(--dur-fast);
    -webkit-tap-highlight-color: transparent;
}
.msg-reaction:active { transform: scale(0.94); }

.message.outgoing .msg-reaction {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.msg-reaction.active {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}
.message.outgoing .msg-reaction.active {
    background: #fff;
    color: var(--blue);
    border-color: #fff;
}

.msg-reaction-emoji {
    font-size: 16px;
    line-height: 1;
}

.msg-reaction-count {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

.msg-reaction-avatars {
    display: inline-flex;
    align-items: center;
}
.msg-reaction-av {
    width: 18px;
    height: 18px;
    margin-left: -6px;
    border-radius: 50%;
    border: 1.5px solid var(--bg-bubble-in);
    box-sizing: content-box;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.msg-reaction-av:first-child { margin-left: 0; }
.msg-reaction-av img { width: 100%; height: 100%; object-fit: cover; display: block; }

.message.outgoing .msg-reaction-av { border-color: var(--bg-bubble-out); }
.message.outgoing .msg-reaction.active .msg-reaction-av { border-color: #fff; }
.message.incoming .msg-reaction.active .msg-reaction-av { border-color: var(--blue); }

/* Отключаем старые счётчики (если попадутся в вёрстке) */
.msg-reaction .reaction-count-old { display: none; }

/* ============================================================
   38. ОКНО ГРУППЫ / КАНАЛА: строки, карточки, значки (добавлено)
   Раньше стили .up-card / .up-row / .up-ico были только у профиля
   пользователя, поэтому в группах и каналах всё шло столбиком.
   ============================================================ */

/* Блоки с информацией */
#groupInfoSheet .up-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    margin: 0 var(--sp-md) var(--sp-md) var(--sp-md);
    border: 1px solid var(--separator);
}

#groupInfoSheet .up-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    width: 100%;
    text-align: left;
    min-height: 56px;
}

#groupInfoSheet .up-row + .up-row {
    border-top: 1px solid var(--separator);
}

#groupInfoSheet .up-row-click {
    cursor: pointer;
}

#groupInfoSheet .up-row-click:active {
    background: var(--bg-sidebar-hover);
}

#groupInfoSheet .up-ico {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

#groupInfoSheet .up-ico svg {
    width: 18px;
    height: 18px;
}

#groupInfoSheet .up-row-text {
    min-width: 0;
    flex: 1;
}

#groupInfoSheet .up-row-value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.3;
}

#groupInfoSheet .up-row-label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 1px;
}

#groupInfoSheet .up-act {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: none;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    min-height: 56px;
    font-family: inherit;
}

#groupInfoSheet .up-act:active {
    background: var(--bg-sidebar-hover);
}

#groupInfoSheet .up-act.danger {
    color: var(--red);
}

#groupInfoSheet .up-act.danger .up-ico {
    color: var(--red);
}

#groupInfoSheet .up-act + .up-act {
    border-top: 1px solid var(--separator);
}

/* Скрываем старые цветные квадраты, если они остались в HTML */

#groupInfoSheet .up-card { margin: 0 0 var(--sp-md); }
#groupInfoSheet .up-ico-blue   { color: var(--blue); }
#groupInfoSheet .up-ico-green  { color: var(--green); }
#groupInfoSheet .up-ico-purple { color: var(--purple); }
#groupInfoSheet .up-ico-orange { color: var(--orange); }
#groupInfoSheet .up-ico-red    { color: var(--red); }
#groupInfoSheet .up-ico-gray   { color: var(--text-secondary); }
#groupInfoSheet .up-row .switch { margin-left: auto; }
