/* Universal threads & messages — comments thread widget. */

.comments-thread {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: visible;
    color: var(--text, #e5e7eb);
    font-size: 13px;
    background: var(--panel-bg, rgba(20, 20, 22, 0.92));
    container-type: inline-size;
}

/* Slack-style split: основная лента + правая панель треда. */
.comments-thread__split {
    flex: 1;
    min-height: 0;
    display: flex;
    position: relative;
}
.comments-thread__main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}
.comments-thread__side {
    flex: 0 0 var(--ct-side-width, min(400px, 42%));
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    background: var(--panel-bg, rgba(20, 20, 22, 0.6));
}
.comments-thread__side[hidden] { display: none; }
/* Разделитель для регулировки ширины панели треда. */
.comments-thread__side-resizer {
    flex: 0 0 5px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 7;
}
.comments-thread__side-resizer::before {
    content: "";
    position: absolute;
    inset: 0 2px;
    border-radius: 2px;
    background: transparent;
    transition: background 0.15s;
}
.comments-thread__side-resizer:hover::before {
    background: var(--accent-border, rgba(255, 255, 255, 0.18));
}
.comments-thread:not(.has-thread-side) .comments-thread__side-resizer { display: none; }
body.ct-resizing-side { cursor: col-resize; user-select: none; }
.comments-thread__side-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: visible;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: var(--ct-msg-gap-extra, 4px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.comments-thread__side-list::-webkit-scrollbar { width: 6px; }
.comments-thread__side-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
/* Узкий контейнер (вкладка «Каналы», DM-drawer): тред — оверлей поверх ленты. */
@container (max-width: 620px) {
    .comments-thread__side {
        position: absolute;
        inset: 0;
        flex-basis: auto;
        width: 100%;
        z-index: 6;
    }
}

.comments-thread__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    flex-shrink: 0;
}
.comments-thread__header-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
}
.comments-thread__header-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, rgba(255, 255, 255, 0.9));
    letter-spacing: 0.02em;
    flex: 1;
}
.comments-thread__header-close {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    color: var(--text-muted, rgba(255, 255, 255, 0.5));
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.comments-thread__header-close:hover {
    background: rgba(127, 127, 127, 0.12);
    color: var(--text, #fff);
}
.comments-thread__header-close i { width: 14px; height: 14px; }

/* Bell-кнопка уведомлений в шапке */
.comments-thread__header-notify {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text-muted, rgba(255,255,255,0.55));
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.comments-thread__header-notify:hover {
    background: rgba(127,127,127,0.12);
    color: var(--text, #fff);
}
.comments-thread__header-notify.is-mentions { color: var(--accent, #d4ff26); }
.comments-thread__header-notify.is-muted    { color: #f59e0b; }
.comments-thread__header-notify i { width: 14px; height: 14px; }

/* Popup-меню notify_level */
.ct-notify-menu {
    position: fixed;
    z-index: 10000;
    min-width: 200px;
    padding: 4px;
    background: var(--bg, #1f2937);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.45);
    animation: ct-mention-popup-in 0.1s ease;
}
.ct-notify-menu__row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text, #e5e7eb);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.ct-notify-menu__row:hover { background: rgba(127,127,127,0.14); }
.ct-notify-menu__row.is-active {
    background: rgba(var(--accent-rgb), 0.18);
    color: var(--accent, #d4ff26);
}
.ct-notify-menu__row i { width: 16px; height: 16px; flex-shrink: 0; }
html.light .ct-notify-menu { background: #fff; border-color: rgba(0,0,0,0.1); }
html.light .ct-notify-menu__row { color: #111827; }

/* ── Presence-аватары в шапке ─────────────────────────────────────── */
.comments-thread__presence {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-right: 4px;
}
.ct-presence-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    border: 1.5px solid var(--bg, #1f2937);
    margin-left: -4px;
    box-sizing: border-box;
}
.ct-presence-dot:first-child { margin-left: 0; }
.ct-presence-dot.is-more {
    background: rgba(127,127,127,0.4);
    color: var(--text, #e5e7eb);
}

/* ── Typing-indicator над composer ────────────────────────────────── */
.comments-thread__typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px 0;
    font-size: 11px;
    color: var(--text-muted, rgba(255,255,255,0.5));
    font-style: italic;
}
.ct-typing-dots {
    display: inline-flex;
    gap: 2px;
}
.ct-typing-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted, rgba(255,255,255,0.5));
    animation: ct-typing-bounce 1s infinite ease-in-out;
}
.ct-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.ct-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ct-typing-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
    .ct-typing-dots i { animation: none; opacity: 0.6; }
}

.comments-thread__list {
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    /* Зазор между сообщениями. Регулируется слайдером в шапке DM-drawer
       через CSS-переменную --ct-msg-gap-extra (см. HearthPanel
       ._bindDmDensitySlider). 0 — сообщения вплотную, 40 — максимально
       просторно. */
    gap: var(--ct-msg-gap-extra, 4px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.comments-thread__list::-webkit-scrollbar { width: 6px; }
.comments-thread__list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
}

.comments-thread__empty {
    color: var(--text-muted, rgba(255,255,255,0.4));
    font-size: 12px;
    text-align: center;
    padding: 24px 8px;
}

.comments-thread__message {
    display: flex;
    flex-direction: column;
    /* Внутренний зазор между шапкой (avatar+login+time) и bubble.
       Регулируется тем же слайдером плотности (через --ct-msg-inner-gap),
       значение в HearthPanel._bindDmDensitySlider. */
    gap: var(--ct-msg-inner-gap, 2px);
    align-items: flex-start;
    max-width: 92%;
    user-select: text;
}
.comments-thread__message.is-own {
    align-self: flex-end;
    align-items: flex-end;
}
.comments-thread__message.is-editing {
    width: min(560px, 92%);
    max-width: 92%;
}
.comments-thread__message.is-own.is-editing {
    align-self: flex-end;
    align-items: stretch;
}
.comments-thread__message.is-pending { opacity: 0.65; }

.comments-thread.is-selecting-messages .comments-thread__message {
    max-width: calc(92% - 34px);
}
.comments-thread.is-selecting-messages .comments-thread__message.is-selectable {
    padding-left: 34px;
}

.comments-thread__select-toggle {
    position: absolute;
    top: 50%;
    left: 4px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 2px solid rgba(255,255,255,0.72);
    border-radius: 999px;
    background: rgba(15,23,42,0.42);
    color: #07110f;
    cursor: pointer;
    transform: translateY(-50%);
    transition: border-color 0.12s, background 0.12s, box-shadow 0.12s, transform 0.12s;
}
.comments-thread__select-toggle:hover {
    border-color: rgba(var(--accent-rgb), 0.9);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12);
}
.comments-thread__select-toggle[aria-pressed="true"] {
    border-color: var(--accent, #10e0b0);
    background: var(--accent, #10e0b0);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.16);
}
.comments-thread__select-toggle i,
.comments-thread__select-toggle svg {
    width: 14px;
    height: 14px;
    stroke-width: 3;
}
.comments-thread__message.is-selected .comments-thread__bubble {
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.55), 0 0 0 6px rgba(var(--accent-rgb), 0.12);
}

.comments-thread__drag-handle {
    position: absolute;
    top: 0;
    left: -20px;
    width: 30px;
    height: 30px;
    z-index: 4;
    cursor: grab;
    border-radius: 8px;
    user-select: none;
}
.comments-thread__drag-handle:active {
    cursor: grabbing;
}
.comments-thread__drag-handle::before {
    content: "::";
    position: absolute;
    top: 2px;
    left: 8px;
    color: var(--text-muted, rgba(255,255,255,0.62));
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 1px;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
}
.comments-thread__message:hover .comments-thread__drag-handle::before {
    opacity: 0.85;
}
.comments-thread__drag-handle:hover::before {
    opacity: 1;
    color: var(--text, rgba(255,255,255,0.88));
}

.comments-thread__msg-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted, rgba(255,255,255,0.5));
    padding: 0 4px;
}
.comments-thread__author {
    color: var(--text, rgba(255,255,255,0.75));
    font-weight: 600;
}
.comments-thread__avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    overflow: hidden;
    flex-shrink: 0;
    line-height: 1;
    box-sizing: border-box;
}
.comments-thread__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.comments-thread__time { color: var(--text-muted, rgba(255,255,255,0.4)); }
.comments-thread__dm-time {
    display: inline-block;
    margin-left: 8px;
    color: currentColor;
    font-size: 10px;
    line-height: 1;
    opacity: 0.5;
    vertical-align: baseline;
    white-space: nowrap;
}
.comments-thread__edited {
    color: var(--text-muted, rgba(255,255,255,0.35));
    font-style: italic;
    font-size: 10px;
}

.comments-thread__bubble {
    position: relative;
    padding: 8px 12px;
    border-radius: 14px;
    background: var(--panel-bg-elev, rgba(255,255,255,0.08));
    color: var(--text, rgba(255,255,255,0.92));
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    user-select: text;
    -webkit-user-select: text;
}
.comments-thread__message.is-own .comments-thread__bubble {
    background: var(--accent, hsl(73, 70%, 35%));
    color: var(--accent-contrast, #0a0a0a);
}
.comments-thread__message.is-dm:not(.is-own) .comments-thread__bubble {
    border-bottom-left-radius: 3px;
}
.comments-thread__message.is-dm.is-own .comments-thread__bubble {
    border-bottom-right-radius: 3px;
}
.comments-thread__message.is-dm:not(.is-own) .comments-thread__bubble::after,
.comments-thread__message.is-dm.is-own .comments-thread__bubble::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 7px;
    height: 9px;
}
.comments-thread__message.is-dm:not(.is-own) .comments-thread__bubble::after {
    left: -6px;
    background: inherit;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.comments-thread__message.is-dm.is-own .comments-thread__bubble::after {
    right: -6px;
    background: inherit;
    clip-path: polygon(0 0, 100% 100%, 0 100%);
}
.comments-thread__message.is-own .comments-thread__body::selection,
.comments-thread__message.is-own .comments-thread__bubble::selection {
    background: rgba(0, 0, 0, 0.28);
    color: #ffffff;
}
.comments-thread__message.is-editing .comments-thread__bubble {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(var(--accent-rgb), 0.45);
    background: var(--panel-bg-elev, #1f2430);
    color: var(--text, #e5e7eb);
    box-shadow: 0 10px 28px rgba(0,0,0,0.26);
    box-sizing: border-box;
}
/* System-events (kind='system'): компактная inline-строка без баббла. */
.comments-thread__message.is-system {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    grid-template-areas:
        "user main time";
    align-items: start;
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    gap: 6px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-muted, rgba(255, 255, 255, 0.45));
    background: transparent;
    border-left: 2px solid rgba(255, 255, 255, 0.08);
}
.comments-thread__message.is-system .comments-thread__sys-user {
    grid-area: user;
    min-width: 0;
    font-weight: 600;
    color: var(--ui-text-2, rgba(255, 255, 255, 0.7));
    line-height: 1.45;
}
.comments-thread__message.is-system .comments-thread__sys-main {
    grid-area: main;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 5px;
    overflow: visible;
    line-height: 1.45;
}
.comments-thread__message.is-system .comments-thread__sys-text {
    flex: 1 1 160px;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
    min-height: 0;
}
.comments-thread__message.is-system .comments-thread__sys-link {
    flex: 0 0 auto;
    text-align: left;
    padding: 0;
    background: none;
    border: none;
    font: inherit;
    color: var(--accent, #6ea8fe);
    cursor: pointer;
    text-decoration: none;
}
.comments-thread__message.is-system .comments-thread__sys-link:hover {
    text-decoration: underline;
}
/* Компактная кликабельная иконка артефакта (вместо текста события). */
.comments-thread__message.is-system .comments-thread__sys-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    padding: 0;
    background: none;
    border: none;
    color: var(--accent, #6ea8fe);
    cursor: pointer;
}
.comments-thread__message.is-system .comments-thread__sys-icon i,
.comments-thread__message.is-system .comments-thread__sys-icon svg {
    width: 15px;
    height: 15px;
}
.comments-thread__message.is-system button.comments-thread__sys-icon:hover {
    color: var(--accent-strong, #8ab4ff);
    transform: scale(1.1);
}
.comments-thread__message.is-system .comments-thread__sys-count {
    font-weight: 600;
    color: var(--accent, #6ea8fe);
}
.comments-thread__message.is-system .comments-thread__codex-system {
    flex: 1 1 100%;
    min-width: 0;
    display: grid;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--text-muted, rgba(255, 255, 255, 0.68));
}
.comments-thread__codex-title,
.comments-thread__codex-files-title {
    color: var(--text, #e5e7eb);
    font-weight: 650;
}
.comments-thread__codex-md {
    min-width: 0;
    overflow-wrap: anywhere;
    line-height: 1.5;
}
.comments-thread__codex-md > * {
    margin: 0;
}
.comments-thread__codex-md > * + * {
    margin-top: 7px;
}
.comments-thread__codex-md code,
.comments-thread__codex-file code {
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--accent, #6ea8fe);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.94em;
}
.comments-thread__codex-md a {
    color: var(--accent, #6ea8fe);
    text-decoration: none;
}
.comments-thread__codex-md a:hover {
    text-decoration: underline;
}
.comments-thread__codex-details {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    overflow: hidden;
}
.comments-thread__codex-details summary {
    cursor: pointer;
    padding: 7px 9px;
    color: var(--text, #e5e7eb);
    font-weight: 650;
    user-select: none;
}
.comments-thread__codex-details .comments-thread__codex-md {
    padding: 8px 9px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.comments-thread__codex-files {
    display: grid;
    gap: 4px;
}
.comments-thread__codex-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}
.comments-thread__codex-file code {
    min-width: 0;
    overflow-wrap: anywhere;
}
.comments-thread__codex-file-stat {
    display: inline-flex;
    gap: 6px;
    flex: 0 0 auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.comments-thread__codex-file-stat .is-add {
    color: #2fdb77;
}
.comments-thread__codex-file-stat .is-del {
    color: #ff6b8a;
}
.comments-thread__message.is-system .comments-thread__sys-time {
    grid-area: time;
    font-size: 11px;
    opacity: 0.7;
    white-space: nowrap;
    line-height: 1.45;
}
@media (max-width: 560px) {
    .comments-thread__message.is-system {
        grid-template-columns: max-content minmax(0, 1fr);
        grid-template-areas:
            "user time"
            "main main";
        row-gap: 2px;
    }
    .comments-thread__message.is-system .comments-thread__sys-main {
        padding-left: 0;
    }
}
html.light .comments-thread__message.is-system {
    color: rgba(0, 0, 0, 0.55);
    border-left-color: rgba(0, 0, 0, 0.08);
}
html.light .comments-thread__message.is-system .comments-thread__sys-user {
    color: rgba(0, 0, 0, 0.75);
}
html.light .comments-thread__message.is-system .comments-thread__codex-system {
    background: rgba(0, 0, 0, 0.035);
    border-color: rgba(0, 0, 0, 0.08);
}

/* Message Spine UI (M1): compact AI chip — сообщение ассистента в канале. */
.comments-thread__message.is-ai-chip {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-self: flex-start;
    width: fit-content;
    max-width: 92%;
    gap: 6px;
    padding: 2px 8px;
    margin: 1px 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--ui-text-2, rgba(255, 255, 255, 0.6));
    background: var(--ui-surface-2, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--ui-border, rgba(255, 255, 255, 0.08));
    border-radius: 999px;
    min-width: 0;
}
.comments-thread__message.is-ai-chip .ct-ai-chip__badge {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--accent, #6ea8fe);
    border: 1px solid currentColor;
}
.comments-thread__message.is-ai-chip .ct-ai-chip__label {
    flex: 0 0 auto;
    font-weight: 600;
    color: var(--ui-text-2, rgba(255, 255, 255, 0.75));
}
.comments-thread__message.is-ai-chip.is-working .ct-ai-chip__label {
    color: var(--accent, #6ea8fe);
}
.comments-thread__message.is-ai-chip .ct-ai-chip__preview {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.comments-thread__message.is-ai-chip .ct-ai-chip__preview:hover {
    color: var(--ui-text-1, rgba(255, 255, 255, 0.9));
}
.comments-thread__message.is-ai-chip .ct-ai-chip__replies,
.comments-thread__message.is-ai-chip .ct-ai-chip__expand {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 4px;
    border: none;
    background: none;
    color: var(--ui-text-2, rgba(255, 255, 255, 0.55));
    font-size: 11px;
    cursor: pointer;
    border-radius: 4px;
}
.comments-thread__message.is-ai-chip .ct-ai-chip__replies:hover,
.comments-thread__message.is-ai-chip .ct-ai-chip__expand:hover {
    background: var(--ui-hover, rgba(255, 255, 255, 0.07));
    color: var(--ui-text-1, rgba(255, 255, 255, 0.9));
}
.comments-thread__message.is-ai-chip .ct-ai-chip__replies i,
.comments-thread__message.is-ai-chip .ct-ai-chip__replies svg,
.comments-thread__message.is-ai-chip .ct-ai-chip__expand i,
.comments-thread__message.is-ai-chip .ct-ai-chip__expand svg {
    width: 13px;
    height: 13px;
}
.comments-thread__message.is-ai-chip .ct-ai-chip__time {
    flex: 0 0 auto;
    font-size: 11px;
    opacity: 0.7;
}
/* Message Spine UI (M8): свёрнутая группа подряд идущих AI-событий. */
.comments-thread__message.is-ai-chip.is-ai-group {
    border-left: 2px solid var(--accent, #6ea8fe);
}
.comments-thread__message.is-ai-chip.is-ai-group .ct-ai-chip__label {
    color: var(--accent, #6ea8fe);
}
/* Кнопка «свернуть» в раскрытом AI-баббле. */
.comments-thread__msg-head .ct-ai-chip__collapse {
    display: inline-flex;
    align-items: center;
    padding: 0 3px;
    border: none;
    background: none;
    color: var(--ui-text-2, rgba(255, 255, 255, 0.55));
    cursor: pointer;
    border-radius: 4px;
}
.comments-thread__msg-head .ct-ai-chip__collapse:hover {
    background: var(--ui-hover, rgba(255, 255, 255, 0.07));
    color: var(--ui-text-1, rgba(255, 255, 255, 0.9));
}
.comments-thread__msg-head .ct-ai-chip__collapse i,
.comments-thread__msg-head .ct-ai-chip__collapse svg {
    width: 14px;
    height: 14px;
}
html.light .comments-thread__codex-md code,
html.light .comments-thread__codex-file code {
    background: rgba(0, 0, 0, 0.06);
}
html.light .comments-thread__codex-details {
    border-color: rgba(0, 0, 0, 0.08);
}
html.light .comments-thread__codex-details .comments-thread__codex-md {
    border-top-color: rgba(0, 0, 0, 0.08);
}

.comments-thread__body {
    white-space: pre-wrap;
    user-select: text;
    -webkit-user-select: text;
}
.comments-thread__body.is-streaming::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    border-radius: 2px;
    vertical-align: -0.12em;
    background: currentColor;
    opacity: 0.72;
    animation: comments-thread-stream-caret 1s steps(2, start) infinite;
}
@keyframes comments-thread-stream-caret {
    50% { opacity: 0.16; }
}
.comments-thread__body code {
    background: rgba(0,0,0,0.35);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}
.comments-thread__body pre {
    background: rgba(0,0,0,0.35);
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 4px 0;
}
.comments-thread__body pre code {
    background: transparent;
    padding: 0;
}
.comments-thread__body a {
    color: #93c5fd;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.comments-thread__message.is-own .comments-thread__body a { color: inherit; }
.comments-thread__md-image {
    display: block;
    max-width: 100%;
    max-height: 520px;
    margin: 6px 0;
    border-radius: 6px;
    object-fit: contain;
}
.comments-thread__md-image-link {
    display: inline-block;
    max-width: 100%;
    cursor: zoom-in;
    background: transparent;
}
.comments-thread__md-image-link:hover .comments-thread__md-image {
    filter: brightness(1.06);
}
.comments-thread__md-image-link img.comments-thread__md-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 520px;
    object-fit: contain;
}

.comments-thread__attachments {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 4px;
    margin-top: 6px;
}
.comments-thread__attachments.is-single {
    display: flex;
    width: min(280px, 100%);
    max-width: 100%;
}
.comments-thread__message.is-own .comments-thread__attachments.is-single {
    margin-left: auto;
}
.comments-thread__attachments.is-single .comments-thread__att-image {
    width: 100%;
}
.comments-thread__att-image {
    display: block;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0,0,0,0.4);
}
.comments-thread__att-image img {
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: cover;
    display: block;
}
.comments-thread__attachments.is-single .comments-thread__att-image img {
    aspect-ratio: 1 / 1;
    height: auto;
    max-height: 280px;
}
.comments-thread__att-video {
    width: 100%;
    max-height: 280px;
    border-radius: 8px;
    background: #000;
}
.comments-thread__att-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--panel-bg-elev, rgba(0,0,0,0.3));
    border: 1px solid var(--border, transparent);
    border-radius: 8px;
    color: var(--text, #e5e7eb);
    text-decoration: none;
    font-size: 12px;
}
.comments-thread__att-file:hover { background: rgba(127,127,127,0.18); }

.ct-generation-batch {
    margin-top: 8px;
    padding: 8px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.24);
}
.ct-generation-batch__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--text, #e5e7eb);
    font-size: 12px;
    font-weight: 700;
}
.ct-generation-batch__head small {
    color: var(--muted, #94a3b8);
    font-size: 11px;
    font-weight: 600;
}
.ct-generation-batch__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 6px;
}
.ct-generation-batch__item {
    position: relative;
    display: block;
    min-width: 0;
    aspect-ratio: 1 / 1;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: rgba(2, 6, 23, 0.42);
    color: var(--text, #e5e7eb);
    cursor: default;
}
.ct-generation-batch__item.is-done { cursor: zoom-in; }
.ct-generation-batch__item.is-done:hover img { filter: brightness(1.07); }
.ct-generation-batch__item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ct-generation-batch__caption {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 6px;
    display: block;
    max-width: calc(100% - 12px);
    padding: 3px 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.72);
    color: #e5e7eb;
    font-size: 10px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ct-generation-batch__pending,
.ct-generation-batch__failed {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: var(--muted, #94a3b8);
    font-size: 11px;
}
.ct-generation-batch__pending span {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(20, 184, 166, 0.22);
    border-top-color: var(--accent, #14f5c3);
    border-radius: 999px;
    animation: ct-generation-batch-spin 0.9s linear infinite;
}
.ct-generation-batch__pending em { font-style: normal; }
.ct-generation-batch__failed { color: #fca5a5; }
.ct-generation-batch__failed svg {
    width: 22px;
    height: 22px;
}
@keyframes ct-generation-batch-spin {
    to { transform: rotate(360deg); }
}

/* Hover-тулбар сообщения: закреплён внутри нижнего правого угла bubble,
   чтобы не перекрывать автора, аватар и верхнюю строку сообщения. */
.comments-thread__message { position: relative; }
.comments-thread__visual-anchors-layer {
    position: absolute;
    top: 0;
    right: -12px;
    bottom: 0;
    width: 12px;
    pointer-events: none;
    z-index: 12;
    overflow: visible;
}
.comments-thread__visual-anchor-marker {
    content: "";
    position: absolute;
    left: 0;
    width: 6px;
    height: 12px;
    transform: translateY(-50%);
    border: 1px solid var(--ct-anchor-color, var(--accent));
    border-left: 0;
    border-radius: 0 999px 999px 0;
    background: var(--ct-anchor-color, var(--accent));
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.18);
    display: block;
}
.comments-thread__visual-anchor-marker::before {
    content: "";
    position: absolute;
    right: 50%;
    top: 50%;
    width: var(--ct-anchor-line-width, 20px);
    height: 2px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: var(--ct-anchor-color, var(--accent));
    box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
}
.comments-thread__msg-actions {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 2px;
    width: max-content;
    max-width: min(320px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--ui-surface-2, var(--bg-secondary, #1f2937));
    border: 1px solid var(--ui-border, var(--border, rgba(255, 255, 255, 0.12)));
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(4px) scale(0.98);
    transform-origin: bottom left;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 10;
}
.comments-thread__msg-actions::-webkit-scrollbar { display: none; }
.comments-thread__message.is-own .comments-thread__msg-actions {
    right: 0;
    left: auto;
    transform-origin: bottom right;
}
.comments-thread__message:hover .comments-thread__msg-actions,
.comments-thread__message:focus-within .comments-thread__msg-actions {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.comments-thread__list > .comments-thread__message:first-child .comments-thread__msg-actions {
    top: calc(100% + 6px);
    bottom: auto;
    transform: translateY(-4px) scale(0.98);
    transform-origin: top left;
}
.comments-thread__list > .comments-thread__message.is-own:first-child .comments-thread__msg-actions {
    transform-origin: top right;
}
.comments-thread__list > .comments-thread__message:first-child:hover .comments-thread__msg-actions,
.comments-thread__list > .comments-thread__message:first-child:focus-within .comments-thread__msg-actions {
    transform: translateY(0) scale(1);
}
.comments-thread__msg-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    color: var(--text-muted, rgba(255,255,255,0.55));
    border-radius: 7px;
    transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease;
    pointer-events: auto;
}
.comments-thread__msg-actions button:hover {
    color: var(--text, #e5e7eb);
    background: rgba(127,127,127,0.18);
    transform: translateY(-1px);
}
.comments-thread__msg-actions button[data-ct-action="replies"]:hover {
    color: var(--accent, #6366f1);
    background: rgba(var(--accent-rgb), 0.14);
}
.comments-thread__msg-actions button[data-ct-action="delete"]:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}
.comments-thread__msg-actions button[data-ct-action="repeat"]:hover {
    color: var(--accent, #6366f1);
    background: rgba(var(--accent-rgb), 0.14);
}
.comments-thread__msg-actions button[data-ct-action="copy"]:hover,
.comments-thread__msg-actions button[data-ct-action="copy"].is-copied {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.14);
}
.comments-thread__msg-actions button[data-ct-action="llm-snapshot"]:hover {
    color: #22d3ee;
    background: rgba(34, 211, 238, 0.14);
}
.comments-thread__msg-actions button.is-pinned { color: var(--accent, #6366f1); }
.comments-thread__msg-actions i,
.comments-thread__msg-actions svg {
    width: 14px;
    height: 14px;
    display: block;
}

/* ── Pin: бейдж в шапке + плашка закреплённых ─────────────────────── */
.comments-thread__pin-badge {
    display: inline-flex;
    align-items: center;
    color: var(--accent, #6366f1);
    margin-left: 2px;
}
.comments-thread__pin-badge i { width: 12px; height: 12px; }
.comments-thread__message.is-pinned .comments-thread__bubble {
    box-shadow: inset 2px 0 0 var(--accent, #6366f1);
}
.comments-thread__message.is-flash .comments-thread__bubble {
    animation: ct-flash 1.4s ease;
}
@keyframes ct-flash {
    0%, 100% { background-color: transparent; }
    20% { background-color: rgba(var(--accent-rgb, 99,102,241), 0.28); }
}

.comments-thread__pinned-bar {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
    background: rgba(var(--accent-rgb, 99,102,241), 0.06);
    padding: 6px 8px;
    max-height: 140px;
    overflow-y: auto;
}
.comments-thread__pinned-head {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent, #6366f1);
    padding: 2px 4px 6px;
}
.comments-thread__pinned-head i { width: 12px; height: 12px; }
.comments-thread__pinned-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text, #e5e7eb);
}
.comments-thread__pinned-item:hover { background: rgba(127,127,127,0.12); }
.comments-thread__pinned-icon { width: 11px; height: 11px; flex-shrink: 0; color: var(--accent, #6366f1); }
.comments-thread__pinned-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.comments-thread__pinned-unpin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border: 0; background: transparent; cursor: pointer;
    color: var(--text-muted, rgba(255,255,255,0.4));
    border-radius: 4px;
    flex-shrink: 0;
}
.comments-thread__pinned-unpin:hover { background: rgba(239,68,68,0.18); color: #ef4444; }
.comments-thread__pinned-unpin i { width: 13px; height: 13px; }

/* ── Search (M7.2) ────────────────────────────────────────────────── */
.comments-thread__header-search {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--text-muted, rgba(255,255,255,0.6));
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.comments-thread__header-search:hover { background: rgba(127,127,127,0.12); color: var(--text, #fff); }
.comments-thread__header-search i { width: 14px; height: 14px; }

.comments-thread__search-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
    background: rgba(127,127,127,0.06);
}
.comments-thread__search-icon { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-muted, rgba(255,255,255,0.5)); }
.comments-thread__search-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: none;
    color: var(--text, #e5e7eb);
    font-size: 13px;
    padding: 4px 0;
}
.comments-thread__search-count {
    font-size: 11px;
    color: var(--text-muted, rgba(255,255,255,0.45));
    flex-shrink: 0;
}
.comments-thread__search-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border: 0; background: transparent; cursor: pointer;
    color: var(--text-muted, rgba(255,255,255,0.4));
    border-radius: 4px;
    flex-shrink: 0;
}
.comments-thread__search-close:hover { background: rgba(127,127,127,0.12); color: var(--text, #fff); }
.comments-thread__search-close i { width: 13px; height: 13px; }
.comments-thread__search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 320px;
    overflow-y: auto;
    background: var(--panel-bg, #1f2430);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-top: 0;
    box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}
.comments-thread__search-result {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.05));
}
.comments-thread__search-result:hover { background: rgba(127,127,127,0.12); }
.comments-thread__search-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted, rgba(255,255,255,0.5));
    margin-bottom: 2px;
}
.comments-thread__search-result-time { margin-left: auto; }
.comments-thread__search-result-text {
    font-size: 12px;
    color: var(--text, #e5e7eb);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}
.comments-thread__search-result-text mark,
.comments-thread__search-result mark {
    background: rgba(var(--accent-rgb, 99,102,241), 0.4);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}
.comments-thread__search-empty {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted, rgba(255,255,255,0.45));
}
html.light .comments-thread__search-results { background: #fff; }

/* ── Reactions chips ──────────────────────────────────────────────── */
.comments-thread__reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    padding: 0 4px;
}
.ct-reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(127,127,127,0.14);
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.2;
    color: var(--text, #e5e7eb);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.ct-reaction:hover { background: rgba(127,127,127,0.22); }
.ct-reaction.is-mine {
    background: rgba(var(--accent-rgb), 0.18);
    border-color: rgba(var(--accent-rgb), 0.45);
    color: var(--accent, #d4ff26);
}
.ct-reaction__emoji {
    font-size: calc(14px * var(--messenger-font-scale, 1));
    line-height: 1;
}
.ct-reaction__emoji img {
    display: block;
    width: calc(18px * var(--messenger-font-scale, 1));
    height: calc(18px * var(--messenger-font-scale, 1));
}
.ct-reaction__count { font-size: 11px; font-variant-numeric: tabular-nums; }

/* Reaction picker (всплывает над кнопкой смайлика) */
.ct-reaction-picker {
    position: fixed;
    z-index: 10000;
    display: flex;
    gap: 2px;
    padding: 4px;
    background: var(--bg, #1f2937);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.45);
    animation: ct-mention-popup-in 0.1s ease;
}
.ct-reaction-picker__btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.1s;
}
.ct-reaction-picker__btn:hover { background: rgba(127,127,127,0.18); }
.ct-reaction-picker__btn img {
    display: block;
    width: calc(22px * var(--messenger-font-scale, 1));
    height: calc(22px * var(--messenger-font-scale, 1));
}
html.light .ct-reaction-picker { background: #fff; border-color: rgba(0,0,0,0.1); }
html.light .ct-reaction { color: #111827; }

.ct-message-menu {
    position: fixed;
    z-index: 10020;
    min-width: 210px;
    padding: 6px;
    border: 1px solid var(--border, rgba(255,255,255,0.12));
    border-radius: 8px;
    background: var(--panel-bg-elev, #1f2430);
    box-shadow: 0 14px 32px rgba(0,0,0,0.35);
}
.ct-message-menu__row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text, #e5e7eb);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.ct-message-menu__row:hover { background: rgba(127,127,127,0.14); }
.ct-message-menu__row.is-copied {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.14);
}
.ct-message-menu__row.is-danger {
    color: #f87171;
}
.ct-message-menu__row.is-danger:hover {
    background: rgba(248,113,113,0.14);
    color: #fecaca;
}
.ct-message-menu__row i {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}
html.light .ct-message-menu {
    background: #fff;
    border-color: rgba(0,0,0,0.1);
}
html.light .ct-message-menu__row { color: #111827; }
html.light .ct-message-menu__row.is-danger { color: #dc2626; }
html.light .ct-message-menu__row.is-danger:hover {
    background: rgba(220,38,38,0.1);
    color: #991b1b;
}
html.light .comments-thread__select-toggle {
    border-color: rgba(17,24,39,0.45);
    background: rgba(255,255,255,0.86);
}
html.light .comments-thread__select-toggle[aria-pressed="true"] {
    border-color: var(--accent, #84cc16);
    background: var(--accent, #84cc16);
    color: var(--accent-contrast, #111827);
}

/* ── Inline editor (правка сообщения) ────────────────────────────── */
.comments-thread__edit-textarea {
    width: 100%;
    min-height: 92px;
    max-height: 260px;
    padding: 9px 10px;
    background: rgba(0,0,0,0.22);
    border: 1px solid rgba(var(--accent-rgb), 0.55);
    border-radius: 8px;
    color: var(--text, #e5e7eb);
    font: inherit;
    resize: none;
    outline: none;
    box-sizing: border-box;
    line-height: 1.45;
    overflow-y: auto;
}
.comments-thread__edit-textarea:focus {
    border-color: var(--accent, hsl(73, 70%, 45%));
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.12);
}
.comments-thread__edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}
.comments-thread__edit-btn {
    min-width: 92px;
    padding: 7px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border, rgba(255,255,255,0.15));
    border-radius: 6px;
    color: var(--text, #e5e7eb);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.comments-thread__edit-btn:hover { background: rgba(255,255,255,0.1); }
.comments-thread__edit-btn.is-primary {
    background: var(--accent, hsl(73, 70%, 35%));
    color: var(--accent-contrast, #0a0a0a);
    border-color: transparent;
    font-weight: 600;
}
.comments-thread__edit-btn.is-primary:hover { filter: brightness(1.05); }
html.light .comments-thread__edit-textarea {
    background: #fff;
    color: #111827;
    border-color: rgba(0,0,0,0.18);
}
html.light .comments-thread__message.is-editing .comments-thread__bubble {
    background: #fff;
    color: #111827;
    border-color: rgba(0,0,0,0.12);
}
html.light .comments-thread__edit-btn {
    background: #f3f4f6;
    color: #111827;
    border-color: rgba(0,0,0,0.15);
}

/* Composer */
.comments-thread__composer {
    flex-shrink: 0;
    border-top: 1px solid var(--border, rgba(255,255,255,0.08));
    padding: 10px 12px;
    background: var(--panel-bg-elev, rgba(0,0,0,0.2));
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.comments-thread.is-drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    background: rgba(var(--accent-rgb), 0.06);
}
.comments-thread__composer.is-visual-anchor-drop,
.comments-thread__message.is-visual-anchor-drop .comments-thread__bubble {
    outline: 2px dashed var(--accent);
    outline-offset: -3px;
    background-color: rgba(var(--accent-rgb), 0.08);
}
.comments-thread__textarea {
    width: 100%;
    min-height: 36px;
    max-height: 160px;
    resize: vertical;
    background: var(--panel-bg, rgba(255,255,255,0.06));
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 8px;
    color: var(--text, #e5e7eb);
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.15s;
}
.comments-thread__textarea:focus {
    border-color: var(--accent, hsl(73, 70%, 35%));
}

.comments-thread__composer-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.comments-thread__btn-attach,
.comments-thread__btn-ai {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 6px;
    color: var(--text-muted, rgba(255,255,255,0.55));
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.comments-thread__btn-attach:hover,
.comments-thread__btn-ai:hover {
    color: var(--text, #fff);
    background: rgba(127,127,127,0.12);
}
.comments-thread__btn-ai:hover { color: var(--accent, hsl(73, 70%, 35%)); }
.comments-thread__btn-attach i,
.comments-thread__btn-ai i { width: 16px; height: 16px; }

.comments-thread__btn-send {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--accent, hsl(73, 70%, 35%));
    color: var(--accent-contrast, #0a0a0a);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: filter 0.15s, transform 0.05s;
}
.comments-thread__btn-send:hover { filter: brightness(1.1); }
.comments-thread__btn-send:active { transform: scale(0.97); }
.comments-thread__btn-send i { width: 14px; height: 14px; }

.comments-thread__btn-test-seed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 9px;
    background: rgba(127,127,127,0.14);
    color: var(--text, #e5e7eb);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}
.comments-thread__btn-test-seed:hover {
    background: rgba(127,127,127,0.22);
}
.comments-thread__btn-test-seed:disabled {
    cursor: wait;
    opacity: 0.65;
}
.comments-thread__btn-test-seed.is-busy i {
    animation: ct-test-seed-spin 0.9s linear infinite;
}
.comments-thread__btn-test-seed i { width: 14px; height: 14px; }

@keyframes ct-test-seed-spin {
    to { transform: rotate(360deg); }
}

.comments-thread__attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.comments-thread__att-tile {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--panel-bg, rgba(255,255,255,0.06));
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, rgba(255,255,255,0.6));
}
.comments-thread__att-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.comments-thread__att-tile.is-uploading i {
    width: 18px;
    height: 18px;
    color: rgba(255,255,255,0.6);
}
.comments-thread__att-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.65);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.comments-thread__att-remove i { width: 10px; height: 10px; }

/* ── Viewer comments side panel ─────────────────────────────────────── */
/* Левая панель с обсуждением в ImageViewer (симметрично card-panel). */

#imageViewer { --vcomm-width: 360px; }

.viewer-comments-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--vcomm-width, 360px);
    min-width: 280px;
    max-width: 70vw;
    background: var(--panel-bg, rgba(20, 20, 22, 0.95));
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border, rgba(255,255,255,0.06));
    display: flex;
    flex-direction: column;
    z-index: 5;
    overflow: visible;
}
.viewer-comments-panel.hidden { display: none; }

.viewer-comments-panel__thread {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.viewer-ai-description {
    flex: 0 0 auto;
    margin: 10px 10px 0;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    background: rgba(255,255,255,0.035);
    color: var(--text, #f8fafc);
}
.viewer-ai-description.hidden { display: none; }
.viewer-ai-description__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.viewer-ai-description__title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    color: var(--accent, #b7ff00);
}
.viewer-ai-description__title i {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
}
.viewer-ai-description__status {
    flex: 0 0 auto;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: #cbd5e1;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.2;
}
.viewer-ai-description__status[data-status="completed"] {
    background: rgba(34, 197, 94, 0.14);
    color: #86efac;
}
.viewer-ai-description__status[data-status="queued"],
.viewer-ai-description__status[data-status="processing"],
.viewer-ai-description__status[data-status="loading"] {
    background: rgba(59, 130, 246, 0.14);
    color: #93c5fd;
}
.viewer-ai-description__status[data-status="failed"] {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
}
.viewer-ai-description__body {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 12px;
    line-height: 1.45;
    color: #dbeafe;
}
.viewer-ai-description__body p {
    margin: 0;
}
.viewer-ai-description__lead {
    color: #ffffff;
    font-weight: 700;
}
.viewer-ai-description__muted {
    color: #94a3b8;
}
.viewer-ai-description__error {
    color: #fecaca;
}
.viewer-ai-description__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.viewer-ai-description__chips span {
    max-width: 100%;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    font-size: 10px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Когда панель видна — сдвигаем картинку, prev-кнопку и кисть, чтобы не пересекались */
#imageViewer.has-comments-panel #imageContainer {
    padding-left: calc(var(--vcomm-width) + 20px);
}
#imageViewer.has-comments-panel #prevImage {
    left: calc(var(--vcomm-width) + 24px);
}
#imageViewer.has-comments-panel .image-viewer-draw-tools {
    left: var(--image-viewer-toolbar-left, calc(var(--vcomm-width) + 28px));
}
#imageViewer.has-comments-panel .viewer-info-panel {
    left: calc(var(--vcomm-width) + 24px);
}

.viewer-comments-panel__resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    right: -3px;
    width: 6px;
    cursor: ew-resize;
    z-index: 6;
}
.viewer-comments-panel__resizer:hover,
.viewer-comments-panel__resizer.is-dragging {
    background: linear-gradient(90deg, transparent, var(--accent, hsl(73, 70%, 45%)) 50%, transparent);
}

body.viewer-comments-panel-resizing {
    cursor: ew-resize !important;
    user-select: none !important;
}

/* Кнопка-тоггл в шапке viewer'а — слева внизу, чтобы не конфликтовать
   с кнопкой кисти (top-left) и закрытием (top-right). */
.viewer-comments-toggle {
    position: absolute;
    bottom: 24px;
    left: var(--viewer-comments-toggle-left, 24px);
    /* для абсолютно позиционированного бейджа внутри */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(127,127,127,0.18);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text, #fff);
    z-index: 10;
    transition: background 0.15s, color 0.15s;
}
.viewer-comments-toggle:hover { background: rgba(127,127,127,0.28); }
.viewer-comments-toggle i { width: 20px; height: 20px; }
.viewer-comments-toggle.is-active {
    background: var(--accent, hsl(73, 70%, 35%));
    color: var(--accent-contrast, #0a0a0a);
}
.viewer-comments-toggle.is-hidden-while-open { display: flex; }

/* Бейдж непрочитанного на toggle-кнопке */
.viewer-comments-toggle__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    pointer-events: none;
}
.viewer-comments-toggle__badge[hidden] { display: none; }

/* Бейдж непрочитанных комментариев на карточках в галерее */
.card-comments-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 22px;
    height: 22px;
    padding: 0 7px 0 6px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    z-index: 5;
    pointer-events: none;
}
.card-comments-badge::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/></svg>") no-repeat center / contain;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/></svg>") no-repeat center / contain;
}
.card-comments-badge[hidden] { display: none; }

/* Прочитано, но обсуждение есть — компактная приглушённая иконка без числа. */
.card-comments-badge.is-read {
    min-width: 22px;
    padding: 0;
    justify-content: center;
    gap: 0;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.82);
    font-weight: 400;
}

/* LOD 0 (только картинка) — индикатор комментариев не показываем. */
#gallery-grid[data-lod="0"] .card-comments-badge { display: none !important; }

html.light .card-comments-badge {
    background: rgba(255,255,255,0.92);
    color: #111827;
    border-color: rgba(0,0,0,0.1);
}
html.light .card-comments-badge.is-read {
    background: rgba(255,255,255,0.78);
    color: #4b5563;
}

/* ─── Light тема ─── */
html.light .viewer-comments-panel {
    background: #ffffff;
    border-right-color: rgba(0, 0, 0, 0.08);
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.18);
}
html.light .viewer-ai-description {
    background: rgba(15, 23, 42, 0.035);
    border-color: rgba(15, 23, 42, 0.1);
    color: #111827;
}
html.light .viewer-ai-description__body {
    color: #334155;
}
html.light .viewer-ai-description__lead {
    color: #111827;
}
html.light .viewer-ai-description__muted {
    color: #64748b;
}
html.light .viewer-ai-description__chips span {
    background: rgba(15, 23, 42, 0.07);
    color: #334155;
}
html.light .comments-thread { background: transparent; color: #1f2937; }
html.light .comments-thread__header { border-bottom-color: rgba(0,0,0,0.06); }
html.light .comments-thread__header-title { color: #111827; }
html.light .comments-thread__header-icon,
html.light .comments-thread__header-close { color: #6b7280; }
html.light .comments-thread__header-close:hover { background: rgba(0,0,0,0.04); color: #111827; }
html.light .comments-thread__empty,
html.light .comments-thread__time,
html.light .comments-thread__edited,
html.light .comments-thread__msg-head { color: #6b7280; }
html.light .comments-thread__author { color: #111827; }
html.light .comments-thread__bubble {
    background: rgba(0,0,0,0.05);
    color: #111827;
}
html.light .comments-thread__message.is-own .comments-thread__bubble {
    color: var(--accent-contrast, #0a0a0a);
}
html.light .comments-thread__att-file {
    background: rgba(0,0,0,0.04);
    color: #111827;
    border-color: rgba(0,0,0,0.06);
}
html.light .comments-thread__msg-actions {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
html.light .comments-thread__msg-actions button { color: #9ca3af; }
html.light .comments-thread__msg-actions button:hover { color: #111827; background: rgba(0,0,0,0.06); }
html.light .comments-thread__composer {
    background: rgba(0,0,0,0.02);
    border-top-color: rgba(0,0,0,0.06);
}
html.light .comments-thread__textarea {
    background: #ffffff;
    border-color: rgba(0,0,0,0.12);
    color: #111827;
}
html.light .comments-thread__btn-attach { color: #6b7280; }
html.light .comments-thread__btn-attach:hover { background: rgba(0,0,0,0.05); color: #111827; }
html.light .comments-thread__att-tile {
    background: #ffffff;
    border-color: rgba(0,0,0,0.08);
    color: #6b7280;
}
html.light .viewer-comments-toggle {
    background: rgba(255,255,255,0.9);
    border-color: rgba(0,0,0,0.08);
    color: #111827;
}
html.light .viewer-comments-toggle:hover { background: #ffffff; }
html.light .viewer-comments-toggle.is-active {
    color: var(--accent-contrast, #0a0a0a);
}

/* ── Inbox bell + dropdown ─────────────────────────────────────────── */
/* TODO: колокольчик inbox временно скрыт — появлялся только после F5,
   на in-page навигации FolderManager.render() стирал его из breadcrumb-
   контейнера. Когда починим перерисовку — убрать display:none. */
.threads-inbox-bell {
    display: none !important;
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted, #9ca3af);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.threads-inbox-bell:hover {
    background: rgba(127,127,127,0.12);
    color: var(--text, #fff);
}
.threads-inbox-bell.is-active {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent, hsl(73, 70%, 45%));
    border-color: rgba(var(--accent-rgb), 0.3);
}
.threads-inbox-bell i { width: 18px; height: 18px; }
.threads-inbox-bell__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    pointer-events: none;
}
.threads-inbox-bell__badge[hidden] { display: none; }

.threads-inbox-panel {
    position: fixed;
    z-index: 1000;
    width: 380px;
    max-height: 70vh;
    background: var(--panel-bg, #18181b);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.55);
    overflow: hidden;
    display: none;
    flex-direction: column;
    transform-origin: top right;
}
.threads-inbox-panel.is-open {
    display: flex;
    animation: threads-inbox-pop 0.12s ease-out;
}
@keyframes threads-inbox-pop {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.threads-inbox-panel__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #e5e7eb);
}
.threads-inbox-panel__head i { width: 16px; height: 16px; opacity: 0.7; }
.threads-inbox-panel__count {
    margin-left: auto;
    color: var(--text-muted, #9ca3af);
    font-weight: 700;
    font-size: 12px;
}

.threads-inbox-panel__empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted, #9ca3af);
    font-size: 12px;
}

.threads-inbox-panel__list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.threads-inbox-item {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    color: var(--text, #e5e7eb);
    transition: background 0.15s;
    position: relative;
}
.threads-inbox-item:hover { background: rgba(127,127,127,0.1); }
.threads-inbox-item.is-unread { background: rgba(var(--accent-rgb), 0.06); }
.threads-inbox-item.is-unread:hover { background: rgba(var(--accent-rgb), 0.12); }

.threads-inbox-item__avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent, hsl(73, 70%, 35%));
    color: var(--accent-contrast, #0a0a0a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.threads-inbox-item__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.threads-inbox-item__row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.threads-inbox-item__author {
    font-size: 12px;
    font-weight: 600;
    color: var(--text, #f3f4f6);
}
.threads-inbox-item__time {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    flex-shrink: 0;
}
.threads-inbox-item__subject {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent, hsl(73, 70%, 45%));
    font-weight: 600;
}
.threads-inbox-item__preview {
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
            line-clamp: 2;
    -webkit-box-orient: vertical;
}
.threads-inbox-item__unread {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    align-self: center;
}

html.light .threads-inbox-bell { color: #6b7280; }
html.light .threads-inbox-bell:hover { background: rgba(0,0,0,0.05); color: #111827; }
html.light .threads-inbox-panel {
    background: #ffffff;
    border-color: rgba(0,0,0,0.08);
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    color: #111827;
}
html.light .threads-inbox-panel__head { color: #111827; border-bottom-color: rgba(0,0,0,0.06); }
html.light .threads-inbox-item { color: #111827; }
html.light .threads-inbox-item:hover { background: rgba(0,0,0,0.04); }
html.light .threads-inbox-item__author { color: #111827; }
html.light .threads-inbox-item__time,
html.light .threads-inbox-item__preview,
html.light .threads-inbox-panel__empty,
html.light .threads-inbox-panel__count { color: #6b7280; }

/* Кликабельные автор/аватар → открывают DM */
.comments-thread__author.is-clickable,
.comments-thread__avatar.is-clickable {
    cursor: pointer;
    transition: opacity 0.12s, filter 0.12s;
}
.comments-thread__author.is-clickable:hover { text-decoration: underline; }
.comments-thread__avatar.is-clickable:hover { filter: brightness(1.15); }

/* ── Mentions: pill в сообщениях + popup автокомплита ─────────────── */
.ct-mention {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    font-weight: 700;
    font-size: 0.92em;
    line-height: 1.3;
    background: rgba(0, 0, 0, 0.45);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.ct-mention:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.3);
}
.ct-mention:active { transform: translateY(1px); }
/* На своих (розовых) bubble — другой контраст */
.comments-thread__message.is-own .ct-mention {
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}
.comments-thread__message.is-own .ct-mention:hover {
    background: rgba(0, 0, 0, 0.7);
}
/* Цветовые акценты по типу — лёгкая боковая полоска */
.ct-mention--user        { box-shadow: inset 2px 0 0 hsl(73, 70%, 55%); }
.ct-mention--generation,
.ct-mention--asset,
.ct-mention--folder,
.ct-mention--moodboard,
.ct-mention--task,
.ct-mention--project     { box-shadow: inset 2px 0 0 #818cf8; }
/* @channel / @here — адресность канала */
.ct-mention--channel {
    box-shadow: inset 2px 0 0 hsl(280, 70%, 60%);
    font-weight: 600;
}

.ct-mention-popup {
    position: fixed;
    z-index: 10000;
    background: var(--bg, #1f2937);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.45);
    overflow-y: auto;
    padding: 4px;
    animation: ct-mention-popup-in 0.1s ease;
}
@keyframes ct-mention-popup-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ct-mention-popup__row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text, #e5e7eb);
}
.ct-mention-popup__row.is-selected,
.ct-mention-popup__row:hover {
    background: rgba(var(--accent-rgb), 0.18);
}
.ct-mention-popup__row.is-special .ct-mention-popup__login {
    color: hsl(280, 70%, 72%);
}
.ct-mention-popup__section {
    padding: 6px 8px 3px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, #9ca3af);
}
.ct-mention-popup__row.is-recent {
    background: rgba(var(--accent-rgb), 0.06);
}
.ct-mention-popup__avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.ct-mention-popup__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.ct-mention-popup__login {
    font-size: 12px;
    font-weight: 600;
    color: var(--text, #e5e7eb);
}
.ct-mention-popup__name {
    font-size: 10px;
    color: var(--text-muted, #9ca3af);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
html.light .ct-mention-popup {
    background: #fff;
    border-color: rgba(0,0,0,0.1);
}
html.light .ct-mention-popup__login { color: #111827; }
html.light .ct-mention-popup__name { color: #6b7280; }

/* ── Slack-style ветки (replies) ──────────────────────────────────── */

/* Индикатор «N ответов · время» под сообщением */
.ct-replies-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 0 4px;
    padding: 3px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 12px;
    color: var(--accent, #6366f1);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.ct-replies-indicator:hover {
    background: rgba(var(--accent-rgb), 0.10);
    border-color: rgba(var(--accent-rgb), 0.35);
}
.ct-replies-indicator i,
.ct-replies-indicator svg {
    width: 11px;
    height: 11px;
    stroke-width: 1.5;
    opacity: 0.75;
}
.ct-replies-indicator__count { font-weight: 600; }
.ct-replies-indicator__time {
    color: var(--text-muted, #9ca3af);
    font-size: 11px;
}
.comments-thread__message.is-own .ct-replies-indicator {
    align-self: flex-end;
    margin: 2px 4px 0 0;
}

/* Шапка thread-view */
.ct-replies-bar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: -4px -4px 6px;
    background: var(--bg, #111827);
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}
.ct-replies-bar__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text, #e5e7eb);
    cursor: pointer;
}
.ct-replies-bar__back:hover { background: rgba(var(--accent-rgb), 0.14); }
.ct-replies-bar__back i { width: 15px; height: 15px; }
.ct-replies-bar__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text, #e5e7eb);
}
.ct-replies-bar__count {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}
html.light .ct-replies-bar { background: #fff; border-color: rgba(0, 0, 0, 0.08); }

/* ── Superadmin LLM snapshot viewer ───────────────────────────────── */
.ct-llm-snapshot {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(5px);
}
.ct-llm-snapshot__panel {
    width: min(1100px, 96vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-secondary, #151922);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}
.ct-llm-snapshot__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}
.ct-llm-snapshot__header h2 {
    margin: 0;
    font-size: 16px;
    color: var(--text, #e5e7eb);
}
.ct-llm-snapshot__header p {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}
.ct-llm-snapshot__header-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ct-llm-snapshot__icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
}
.ct-llm-snapshot__icon-btn:hover,
.ct-llm-snapshot__icon-btn.is-copied {
    color: var(--text, #e5e7eb);
    background: rgba(255, 255, 255, 0.08);
}
.ct-llm-snapshot__icon-btn.is-copied {
    color: var(--accent, #00d7a7);
    background: rgba(0, 215, 167, 0.14);
}
.ct-llm-snapshot__icon-btn i,
.ct-llm-snapshot__icon-btn svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}
.ct-llm-snapshot__body {
    overflow: auto;
    padding: 14px 16px 18px;
}
.ct-llm-snapshot__call {
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.12);
}
.ct-llm-snapshot__call:not([open]) {
    background: rgba(0, 0, 0, 0.08);
}
.ct-llm-snapshot__call + .ct-llm-snapshot__call {
    margin-top: 14px;
}
.ct-llm-snapshot__call-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 11px 10px 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text, #e5e7eb);
    cursor: pointer;
    list-style: none;
}
.ct-llm-snapshot__call-head::-webkit-details-marker {
    display: none;
}
.ct-llm-snapshot__call-title {
    min-width: 0;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 6px;
    gap: 2px;
}
.ct-llm-snapshot__call-title::before {
    content: '▾';
    grid-row: 1 / span 2;
    align-self: center;
    justify-self: center;
    width: 18px;
    display: inline-block;
    text-align: center;
    color: var(--text-muted, #9ca3af);
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
}
.ct-llm-snapshot__call:not([open]) .ct-llm-snapshot__call-title::before {
    content: '▸';
}
.ct-llm-snapshot__call-head:hover .ct-llm-snapshot__call-title::before {
    color: var(--text, #e5e7eb);
}
.ct-llm-snapshot__call-title strong {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    color: var(--text, #e5e7eb);
    font-size: 13px;
}
.ct-llm-snapshot__call-title em {
    min-width: 0;
    color: var(--text-muted, #9ca3af);
    font-size: 12px;
    font-style: normal;
}
.ct-llm-snapshot__call-head span {
    color: var(--text-muted, #9ca3af);
    font-size: 12px;
}
.ct-llm-snapshot__block {
    border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.ct-llm-snapshot__block summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    padding: 8px 11px 8px 12px;
    color: var(--text, #e5e7eb);
    font-size: 12px;
    font-weight: 700;
    list-style: none;
}
.ct-llm-snapshot__block summary::-webkit-details-marker {
    display: none;
}
.ct-llm-snapshot__block-title {
    min-width: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}
.ct-llm-snapshot__block-title::before {
    content: '▾';
    display: inline-block;
    width: 16px;
    margin-right: 6px;
    text-align: center;
    color: var(--text-muted, #9ca3af);
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
}
.ct-llm-snapshot__block-title span {
    min-width: 0;
}
.ct-llm-snapshot__block-title small {
    flex: 0 0 auto;
    color: var(--text-muted, #9ca3af);
    font-size: 11px;
    font-weight: 500;
}
.ct-llm-snapshot__block:not([open]) .ct-llm-snapshot__block-title::before {
    content: '▸';
}
.ct-llm-snapshot__block summary:hover .ct-llm-snapshot__block-title::before {
    color: var(--text, #e5e7eb);
}
.ct-llm-snapshot__copy {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
}
.ct-llm-snapshot__copy:hover {
    color: var(--text, #e5e7eb);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}
.ct-llm-snapshot__copy.is-copied {
    color: var(--accent, #00d7a7);
    background: rgba(0, 215, 167, 0.14);
}
.ct-llm-snapshot__copy i,
.ct-llm-snapshot__copy svg {
    width: 11px;
    height: 11px;
    stroke-width: 2;
}
.ct-llm-snapshot__block pre {
    margin: 0;
    padding: 10px 12px 14px;
    max-height: 360px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: #cbd5e1;
    background: rgba(0, 0, 0, 0.22);
    font-size: 11px;
    line-height: 1.45;
}
.ct-llm-snapshot__refs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.16);
}
.ct-llm-snapshot__ref-card {
    min-width: 0;
    display: grid;
    grid-template-rows: 112px auto;
    gap: 7px;
    color: inherit;
    text-decoration: none;
}
.ct-llm-snapshot__ref-thumb {
    display: block;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    background: rgba(255, 255, 255, 0.04);
}
.ct-llm-snapshot__ref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ct-llm-snapshot__ref-meta {
    min-width: 0;
    display: grid;
    gap: 2px;
}
.ct-llm-snapshot__ref-meta b,
.ct-llm-snapshot__ref-meta small {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.ct-llm-snapshot__ref-meta b {
    color: var(--text, #e5e7eb);
    font-size: 11px;
}
.ct-llm-snapshot__ref-meta small {
    color: var(--text-muted, #9ca3af);
    font-size: 10px;
}
.ct-llm-snapshot__planner-body {
    display: grid;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.14);
}
.ct-llm-snapshot__planner-grid {
    display: grid;
    grid-template-columns: minmax(120px, 0.34fr) minmax(0, 1fr);
    gap: 6px 12px;
    align-items: baseline;
}
.ct-llm-snapshot__planner-grid span {
    color: var(--text-muted, #9ca3af);
    font-size: 11px;
}
.ct-llm-snapshot__planner-grid strong {
    min-width: 0;
    color: var(--text, #e5e7eb);
    font-size: 12px;
    font-weight: 700;
    word-break: break-word;
}
.ct-llm-snapshot__planner-section {
    display: grid;
    gap: 7px;
}
.ct-llm-snapshot__planner-section > b,
.ct-llm-snapshot__planner-action b,
.ct-llm-snapshot__planner-line b {
    color: var(--text, #e5e7eb);
    font-size: 12px;
}
.ct-llm-snapshot__planner-section p {
    margin: 0;
    padding: 9px 10px;
    color: #dbeafe;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.16);
    border-radius: 7px;
    font-size: 12px;
    line-height: 1.45;
    word-break: break-word;
}
.ct-llm-snapshot__planner-action {
    display: grid;
    gap: 9px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.035);
}
.ct-llm-snapshot__planner-action + .ct-llm-snapshot__planner-action {
    margin-top: 8px;
}
.ct-llm-snapshot__planner-action header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.ct-llm-snapshot__planner-action header strong {
    margin-right: 4px;
    color: var(--accent, #00d7a7);
    font-size: 12px;
}
.ct-llm-snapshot__planner-action header span {
    padding: 2px 6px;
    border-radius: 999px;
    color: var(--text-muted, #9ca3af);
    background: rgba(255, 255, 255, 0.07);
    font-size: 10px;
}
.ct-llm-snapshot__planner-line {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
}
.ct-llm-snapshot__planner-line code {
    color: #c4b5fd;
    font-size: 11px;
    word-break: break-word;
}
.ct-llm-snapshot__planner-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.ct-llm-snapshot__planner-columns > div {
    display: grid;
    gap: 5px;
}
.ct-llm-snapshot__planner .ct-llm-snapshot__planner-columns pre {
    max-height: 220px;
    padding: 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.24);
}
.ct-llm-snapshot__planner-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.ct-llm-snapshot__planner-chips span {
    padding: 3px 7px;
    border-radius: 999px;
    color: #bfffe9;
    background: rgba(0, 215, 167, 0.12);
    border: 1px solid rgba(0, 215, 167, 0.18);
    font-size: 10px;
}
.ct-llm-snapshot__planner-empty,
.ct-llm-snapshot__planner-chips em,
.ct-llm-snapshot__planner-warnings em {
    color: var(--text-muted, #9ca3af);
    font-size: 12px;
    font-style: normal;
}
.ct-llm-snapshot__planner-warnings ul {
    margin: 0;
    padding-left: 18px;
    color: #fde68a;
    font-size: 12px;
}
.ct-llm-snapshot__copy-source {
    display: none !important;
}
.ct-llm-snapshot__empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted, #9ca3af);
}
.ct-llm-snapshot__empty.is-error {
    color: #fca5a5;
}
html.light .ct-llm-snapshot__panel {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
}
html.light .ct-llm-snapshot__call {
    background: rgba(0, 0, 0, 0.02);
}
html.light .ct-llm-snapshot__call-head {
    background: rgba(0, 0, 0, 0.04);
}
html.light .ct-llm-snapshot__copy:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.08);
}
html.light .ct-llm-snapshot__block pre {
    color: #111827;
    background: rgba(0, 0, 0, 0.04);
}
html.light .ct-llm-snapshot__planner-body {
    background: rgba(0, 0, 0, 0.035);
}
html.light .ct-llm-snapshot__planner-grid strong,
html.light .ct-llm-snapshot__planner-section > b,
html.light .ct-llm-snapshot__planner-action b,
html.light .ct-llm-snapshot__planner-line b {
    color: #111827;
}
html.light .ct-llm-snapshot__planner-section p {
    color: #172554;
    background: rgba(59, 130, 246, 0.08);
}
html.light .ct-llm-snapshot__planner-action {
    background: rgba(0, 0, 0, 0.025);
    border-color: rgba(0, 0, 0, 0.08);
}
html.light .ct-llm-snapshot__planner-line code {
    color: #6d28d9;
}
html.light .ct-llm-snapshot__planner .ct-llm-snapshot__planner-columns pre {
    background: rgba(0, 0, 0, 0.055);
}
@media (max-width: 720px) {
    .ct-llm-snapshot__planner-columns {
        grid-template-columns: 1fr;
    }
    .ct-llm-snapshot__planner-grid,
    .ct-llm-snapshot__planner-line {
        grid-template-columns: 1fr;
    }
}

/* Разделитель «N ответов» между родителем и ответами */
.ct-replies-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 4px;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}
.ct-replies-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border, rgba(255, 255, 255, 0.1));
}

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .viewer-comments-panel { transition: none; }
    .comments-thread__btn-send { transition: none; }
    .threads-inbox-panel.is-open { animation: none; }
    .ct-mention-popup { animation: none; }
}
