#comment-participants {
    padding: var(--space-1) 0;
    min-height: 20px;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 0.2em;
}

#comment-participants::-webkit-scrollbar {
    display: none;
}

#comment-participants .avatar-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.add-participant-btn,
.add-context-btn,
.add-topic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: transparent;
    cursor: pointer;
    color: var(--color-muted);
    font-size: 1.2em;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.add-participant-btn:hover,
.add-context-btn:hover,
.add-topic-btn:hover {
    background: var(--color-section-bg);
    color: var(--color-text);
}

#typing-indicator-row {
    display: flex;
    align-items: center;
    min-height: var(--space-px-5);
    margin: 0.3em 0;
    gap: var(--space-1);
}

/* Horizontally-scrollable viewport for channel chips + typing indicator.
   Keeps PR/Preview badges and live typing on a single line so they never
   wrap and push the form down. The scroll-prev button stays pinned at the
   left because it is a flex sibling of (not inside) this viewport.
   min-width:0 lets this flex child shrink below its content width, which is
   what actually enables overflow scrolling. */
#typing-scroll-viewport {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scroll-behavior: smooth;
}

#typing-scroll-viewport::-webkit-scrollbar {
    height: 4px;
}

#typing-scroll-viewport::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-2);
}

.scroll-prev-msg-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-1);
    line-height: 1;
    padding: var(--space-px-1) var(--space-2);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.scroll-prev-msg-btn:hover {
    background: var(--color-section-bg);
    color: var(--color-text);
}

#typing-indicator {
    font-style: italic;
    flex: 0 0 auto;
    min-height: var(--space-px-5);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

#typing-indicator .avatar-wrapper {
    width: 20px;
    height: 20px;
    margin-right: 0.2em;
}

.comment-presence-avatar {
    margin-right: 0;
}

.comment-presence-avatar.inactive {
    opacity: 0.4;
    filter: grayscale(1);
}

.comment-presence-avatar.inactive+.avatar-initial {
    opacity: 0.4;
    filter: grayscale(1);
}

.agent-stop-btn {
    background: var(--surface-btn);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2);
    color: var(--color-danger);
    cursor: pointer;
    font-size: var(--text-00);
    padding: var(--space-px-1) var(--space-px-2);
    display: inline-flex;
    align-items: center;
    gap: var(--space-px-1);
    margin-right: var(--space-px-1);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.agent-stop-btn .agent-stop-icon {
    font-size: var(--text-00);
}

.agent-stop-btn:hover {
    background: var(--color-danger);
    color: var(--text-on-btn);
}

/* --- Channel Chips (PR monitor etc) ------------------------------------ */
#channel-chips-container,
.channel-chips {
    display: inline-flex;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: var(--space-1);
    align-items: center;
}

.channel-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-px-1);
    padding: var(--space-px-1) var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2);
    background: var(--color-section-bg);
    font-size: var(--text-0);
    line-height: 1;
    white-space: nowrap;
}

.channel-chip a {
    color: var(--color-text);
    text-decoration: none;
}

.channel-chip a:hover {
    text-decoration: underline;
}

.channel-chip button {
    background: none;
    border: 0;
    padding: 0 var(--space-px-1);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
}

.channel-chip button:hover {
    color: var(--color-danger);
}

/* Detached chips lose a touch of contrast so users can tell a closed/merged
   PR apart from one that is still actively monitored. */
.channel-chip--detached {
    opacity: 0.7;
}

.channel-chip-badge {
    display: inline-block;
    width: var(--space-2);
    height: var(--space-2);
    border-radius: 999px;
    flex-shrink: 0;
    background: var(--color-text);
}

.channel-chip-badge--open {
    background: var(--color-success);
}

.channel-chip-badge--merged {
    /* No purple token yet; --color-active (blue) is the closest neutral that
       reads as "shipped" without colliding with success/danger semantics. */
    background: var(--color-active);
}

.channel-chip-badge--closed_without_merge {
    background: var(--color-danger);
}

.channel-chip-badge--running {
    background: var(--color-success);
}

.channel-chip-badge--stopped {
    background: var(--color-text);
    opacity: 0.5;
}

/* --- Context Chips --- */
.comment-contexts-list {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.4em;
    padding: var(--space-1) 0;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
    -ms-overflow-style: none;
    min-height: 26px; /* Ensure chips (22px + padding) are never clipped */
}

.comment-contexts-list:empty {
    display: none;
}

.comment-contexts-list::-webkit-scrollbar {
    display: none;
}

.context-chip {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: var(--space-1);
    padding: 0.15em 0.5em;
    border-radius: 10px;
    background: var(--color-secondary-background);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    height: 22px;
    box-sizing: border-box;
}

.context-chip svg,
.context-toggle-btn svg,
.loop-status-btn svg {
    vertical-align: middle;
    flex-shrink: 0;
}

/* A context holding workflow rules shows ⚡ in place of the link icon. */
.context-rule-icon,
.entity-list-item-icon-rule {
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
}

.context-chip:hover {
    background: var(--surface-hover);
}

.context-chip.context-disabled {
    opacity: 0.4;
    text-decoration: line-through;
}

.context-chip.context-inherited {
    border-style: dashed;
}

.context-chip.context-dragging {
    opacity: 0.5;
}

.context-chip.dnd-over-left,
.topic-tag.dnd-over-left {
    border-left: 3px solid var(--color-active);
    margin-left: -1px;
}

.context-chip.dnd-over-right,
.topic-tag.dnd-over-right {
    border-right: 3px solid var(--color-active);
    margin-right: -1px;
}

.comment-contexts-list.dnd-over-into {
    outline: 2px dashed var(--color-link);
    outline-offset: -2px;
    background-color: color-mix(in srgb, var(--color-link) 8%, transparent);
}

.context-chip[draggable="true"] {
    cursor: grab;
}

.context-chip[draggable="true"]:active {
    cursor: grabbing;
}

.navigate-context-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9em;
    padding: 0 0.15em;
    line-height: 1;
    margin-left: 0.1em;
}

.navigate-context-btn:hover {
    color: var(--color-active);
}

.delete-context-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9em;
    padding: 0 0.15em;
    line-height: 1;
    margin-left: 0.1em;
}

.delete-context-btn:hover {
    color: var(--color-danger);
}

/* Context toggle button in header */
.context-toggle-btn {
    font-size: 0.75em;
    padding: 0.15em 0.4em;
    border-radius: 8px;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.context-toggle-btn:hover {
    background: var(--color-secondary-background);
}

.context-toggle-btn.context-toggle-active {
    background: var(--color-secondary-active);
    color: var(--color-badge-text);
    border-color: var(--color-secondary-active);
}

/* Repeat loop status button */
.loop-status-btn {
    font-size: 0.75em;
    padding: 0.15em 0.4em;
    border-radius: 8px;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.loop-status-btn:hover {
    background: var(--color-secondary-background);
}

.topic-tag {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: var(--space-1);
    padding: 0.2em 0.6em;
    border-radius: 12px;
    background: var(--color-secondary-background);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    height: 26px; /* Fixed height to prevent shrinking */
    box-sizing: border-box;
}
