.comment-item[draggable="true"] {
    cursor: grab;
}

.comment-item[draggable="true"]:active {
    cursor: grabbing;
}

#comments-list.dragging-comments .comment-item:not(.selected-for-move) {
    opacity: 0.5;
}

/* Hide the topic link if the message is displayed within that topic's context */
/* Use Javascript to set data-current-topic-id on the list container */
.comment-topic-link {
    margin-top: 0.25em;
    font-size: 0.9em;
}

/* 
   We want: if #comments-list[data-current-topic-id="123"] 
   Then: .comment-item[data-topic-id="123"] .comment-topic-link { display: none; }
   
   Since we can't do dynamic matching in pure CSS (attr(x) == attr(y)), we rely on 
   Stimulus list_controller to either set a specialized class or we just accept 
   that we need to hide it using a more generic approach if possible, 
   OR we use the fact that we can't easily do this in pure CSS without many rules.
   
   Wait, the requirement is "Show without #topic" if in that topic.
   
   If I am in topic 123, list_controller sets dataset.currentTopicId = 123.
   The comment has dataset.topicId = 123.
   
   I can't write a CSS rule `[data-current-topic-id=data-topic-id]`
   
   However, I can do this in Javascript when filtering/rendering? 
   No, user asked for "If current user is in matching topic".
   
   Let's use a simpler approach: 
   If I am in a topic, I only see messages from that topic (filtered by server or client).
   So ALL messages visible in Topic 123 are BY DEFINITION belonging to Topic 123.
   (Except pinned? No pinned mentions).
   
   So, IF data-current-topic-id is set (meaning we are NOT in Main), 
   we can hide ALL topic links inside the list?
   
   Wait, "Main" shows ALL messages. So currentTopicId is empty. Topic links shown.
   "Topic A" shows ONLY A messages. So currentTopicId is A. 
   
   YES! If we are in a specific topic, we only see that topic's messages.
   So we can hide ALL topic links when in a specific topic context.
   
   #comments-list:not([data-current-topic-id=""]) .comment-topic-link { display: none; }
*/

#comments-list:not([data-current-topic-id=""]) .comment-topic-link {
    display: none;
}

.topic-creation-container {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

/* Class rule above outranks the UA [hidden] rule, so restate it. */
.topic-creation-container[hidden] {
    display: none;
}

.topic-input {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-active);
    color: var(--color-text);
    font-size: 0.85em;
    width: 100px;
    outline: none;
}

.topic-edit-input {
    display: inline-block;
    padding: 0.1em 0.4em;
    border-radius: 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-active);
    color: var(--color-text);
    font-size: 0.85em;
    width: 80px;
    outline: none;
}

/* Archive topic styles */
.topic-archived-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.15em var(--space-2);
    border-radius: var(--radius-3);
    font-size: var(--text-0);
    cursor: pointer;
    opacity: 0.6;
    border: 1px dashed var(--border-color);
}
.topic-archived-toggle:hover {
    opacity: 1;
}
/* Archived topics still receive messages. When the section is collapsed there is
   no chip to badge, so the toggle carries the unread dot instead. */
.topic-archived-toggle.has-new-messages {
    position: relative;
    opacity: 1;
    border-color: var(--color-active);
}
.topic-archived-toggle.has-new-messages::after {
    content: "";
    position: absolute;
    top: -3px;
    right: -3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--color-danger);
}
.topic-tag.topic-archived {
    opacity: 0.5;
    font-style: italic;
    cursor: pointer;
}
/* Archived topics are readable and selectable — the dimming marks them as
   archived, it must not make the one you are reading illegible. */
.topic-tag.topic-archived:hover,
.topic-tag.topic-archived.active {
    opacity: 1;
}

/* Topic list popup button (pinned right of the scrolling tab bar) */
.comment-topics-bar {
    display: flex;
    align-items: center;
    gap: 0.5em;
}
.comment-topics-bar .comment-topics-list {
    flex: 1;
    min-width: 0;
}
.topic-list-btn,
.bar-list-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-3);
    border: 1px solid var(--color-border);
    background: transparent;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0;
}
.topic-list-btn:hover,
.bar-list-btn:hover {
    background: var(--color-section-bg);
    color: var(--color-text);
}
.topic-list-btn[aria-expanded="true"],
.bar-list-btn[aria-expanded="true"] {
    background: var(--color-section-bg);
    color: var(--color-text);
}

/* Rows inside the shared entity list popup (contexts, users) */
.entity-list-item {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 0.3em;
    width: 100%;
}
.common-popup-item:has(> .entity-list-item-link) {
    display: flex;
    align-items: center;
    gap: 0.4em;
}
.entity-list-item-link {
    display: grid;
    flex: none;
    place-items: center;
    width: 24px;
    height: 24px;
    margin-left: auto;
    border-radius: var(--radius-3);
    color: inherit;
    text-decoration: none;
}
.entity-list-item-link:hover,
.entity-list-item-link:focus-visible {
    background: var(--color-section-bg);
}
.entity-list-item--muted {
    font-style: italic;
}
.entity-list-item--muted > svg,
.entity-list-item--muted > .entity-list-item-avatar,
.entity-list-item--muted > .entity-list-item-label {
    opacity: 0.5;
}
.entity-list-item-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}
.entity-list-item-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.entity-list-item-badge {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 0.75em;
    opacity: 0.6;
}
.entity-list-item-status {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Archived entries inside the topic list popup */
.topic-list-item {
    display: flex;
    align-items: center;
    gap: 0.3em;
    width: 100%;
}
.topic-list-item--archived {
    font-style: italic;
}
.topic-list-item--archived > svg,
.topic-list-item--archived > .topic-list-item-label {
    opacity: 0.5;
}
.topic-list-item .topic-unread-badge {
    flex-shrink: 0;
    margin-left: auto;
}
.topic-branch-icon {
    font-size: 0.75em;
    opacity: 0.6;
    margin-right: 1px;
    cursor: pointer;
}
.topic-branch-icon:hover {
    opacity: 1;
}
/* ⚡ in place of "#": a loop is in progress in this topic. Dimmed while it
   waits (paused, awaiting the user, stuck). */
.topic-loop-marker {
    margin-right: 1px;
    opacity: 0.55;
}
.topic-loop-marker--active {
    opacity: 1;
}
.archive-topic-btn,
.unarchive-topic-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 var(--space-1);
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
}
.topic-tag:not(.active) .archive-topic-btn:not(:hover),
.topic-tag:not(.active) .unarchive-topic-btn:not(:hover) {
    opacity: 0.6;
}
.topic-tag.active .archive-topic-btn,
.topic-tag.active .unarchive-topic-btn {
    color: var(--color-badge-text);
}
.delete-topic-btn {
    margin-left: var(--space-1);
}
