/**
 * conversation-rendering.css — shared message pane styles.
 *
 * Covers: message bubbles, timestamps, tool/thinking/todo/subagent blocks,
 * queue separators, activity indicator, error/system notes, empty state,
 * markdown rendering inside messages.
 *
 * Host pages provide: CSS custom properties (--accent, --text-primary,
 * --text-secondary, --bg-tertiary, --border), container layout, send button.
 */

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    color: #1a1a1a;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.message.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.message.user.queued {
    opacity: 0.7;
    background: #7a5f3a;
    position: relative;
}
.queue-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.queue-parallel-btn {
    position: absolute;
    top: 4px;
    right: 28px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.message.user.queued:hover .queue-delete-btn,
.message.user.queued:hover .queue-parallel-btn {
    opacity: 1;
}
.queue-delete-btn:hover {
    background: rgba(233, 69, 96, 0.8);
    color: #fff;
}
.queue-parallel-btn:hover {
    background: rgba(100, 160, 255, 0.8);
    color: #fff;
}
.message.user.pending-queue {
    opacity: 0.5;
    background: #6b5232;
}

/* Queue separator */
.queue-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin: 8px 0;
}
.queue-separator::before,
.queue-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #ddd, transparent);
}
.queue-separator span {
    white-space: nowrap;
    padding: 4px 12px;
    background: #f5f5f5;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}


/* Assistant message */
.message.assistant {
    align-self: flex-start;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}
.message.assistant a {
    color: #0066cc;
    text-decoration: none;
    border-bottom: 1px solid #0066cc40;
    transition: border-color 0.2s;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}
.message.assistant a:hover {
    border-bottom-color: #0066cc;
}
.message.assistant pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 6px;
    overflow-x: hidden;
    white-space: pre-wrap;
    margin: 8px 0;
}
.message.assistant code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.message.assistant pre code {
    white-space: pre-wrap;
}
.message.assistant p code {
    background: #e8e8e8;
    color: #c7254e;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}
.message.assistant p { margin: 8px 0; }
.message.assistant p:first-child { margin-top: 0; }
.message.assistant p:last-child { margin-bottom: 0; }
.message.assistant ul, .message.assistant ol {
    margin: 8px 0;
    padding-left: 20px;
}
.message.assistant table {
    border-collapse: collapse;
    margin: 12px 0;
}
/* RAY internal message (debug mode only) */
.message.ray {
    align-self: flex-start;
    background: transparent;
    border: 1px dashed #9e9e9e;
    border-bottom-left-radius: 4px;
    opacity: 0.7;
}
.message.ray .ray-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #9e9e9e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.message.ray p { margin: 8px 0; }
.message.ray p:first-child { margin-top: 0; }
.message.ray p:last-child { margin-bottom: 0; }

/* System notice (e.g. the related-past-conversation hint delivered when the
   steering prompt itself is configured invisible): a centered, muted,
   smaller block distinct from user/assistant bubbles. */
.message.system {
    align-self: center;
    max-width: 92%;
    background: var(--card-bg, rgba(139, 111, 71, 0.05));
    border: 1px solid var(--border, #e8e5e0);
    color: var(--text-secondary, #7a7a7a);
    font-size: 0.8125rem;
    border-radius: 10px;
}
.message.system a { color: var(--accent, #8b6f47); }
.message.system p { margin: 6px 0; }
.message.system p:first-child { margin-top: 0; }
.message.system p:last-child { margin-bottom: 0; }
.message.system ul { margin: 6px 0; padding-left: 20px; }

.message .table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
.message .table-scroll > table {
    width: 100%;
    table-layout: fixed;
}
.message th,
.message td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.message.assistant th {
    background: #f0f0f0;
    font-weight: 600;
}
.message.assistant tr:nth-child(even) {
    background: #fafafa;
}

/* Message timestamp */
.message-timestamp {
    font-size: 0.625rem;
    color: #999;
    margin-top: 4px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}
.message.user .message-timestamp {
    color: rgba(255, 255, 255, 0.7);
}
.copy-msg-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 1px 2px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
    color: inherit;
    display: inline-flex;
    align-items: center;
}
.copy-msg-btn svg { width: 12px; height: 12px; }
.message:hover .copy-msg-btn { opacity: 0.6; }
.copy-msg-btn:hover { opacity: 1 !important; }
.message-cost {
    font-size: 0.625rem;
    color: #555;
}

/* File reference */
span.file-ref {
    background: rgba(21, 101, 192, 0.1);
    color: #0066cc;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.9em;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    border: 1px solid rgba(21, 101, 192, 0.15);
    transition: background-color 120ms ease, border-color 120ms ease;
}
span.file-ref:hover {
    background: rgba(21, 101, 192, 0.2);
    border-color: rgba(21, 101, 192, 0.35);
    color: #0d47a1;
}

/* Clickable user-scoped paths that appear inside inline code */
.message.assistant p code.file-ref,
.message.assistant code.file-ref {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    transition: background-color 120ms ease, color 120ms ease;
}
.message.assistant p code.file-ref:hover,
.message.assistant code.file-ref:hover {
    background: #d8d8d8;
    color: #a01f42;
}

/* Tool use formatting */
.tool-block {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
    padding: 8px 12px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.75rem;
}
.tool-block.tool-error {
    background: #ffebee;
    border-left-color: #f44336;
}
.tool-block.tool-error .tool-header {
    color: #c62828;
}
/* Severity-aware tinting for the inline tool block (renderToolActions).
   tool-error remains the default red shape (legacy + severity="error");
   notice/warning override only the colours so layout is unchanged. */
.tool-block.tool-error.tool-notice {
    background: #eceff1;
    border-left-color: #90a4ae;
}
.tool-block.tool-error.tool-notice .tool-header { color: #546e7a; }
.tool-block.tool-error.tool-notice .tool-error-content {
    color: #455a64;
    background: rgba(144, 164, 174, 0.10);
}
.tool-block.tool-error.tool-warning {
    background: #fff8e1;
    border-left-color: #f59e0b;
}
.tool-block.tool-error.tool-warning .tool-header { color: #b45309; }
.tool-block.tool-error.tool-warning .tool-error-content {
    color: #92400e;
    background: rgba(245, 158, 11, 0.10);
}
.tool-block .tool-error-content {
    color: #b71c1c;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.6875rem;
    margin-top: 6px;
    padding: 8px;
    background: rgba(244, 67, 54, 0.1);
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 150px;
    overflow-y: auto;
}
.tool-block .tool-header {
    color: #1565c0;
    font-weight: 600;
    margin-bottom: 4px;
}
.tool-block .tool-input {
    color: #0d47a1;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.6875rem;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Search results in tool blocks */
.search-results-container {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(21, 101, 192, 0.2);
}
.search-query {
    font-size: 0.625rem;
    color: #5e92f3;
    margin-bottom: 6px;
    font-style: italic;
}
.search-result-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(21, 101, 192, 0.1);
    font-size: 0.6875rem;
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-source {
    color: #1976d2;
    font-weight: 500;
    flex-shrink: 0;
}
.search-result-score {
    background: rgba(21, 101, 192, 0.15);
    color: #1565c0;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.5625rem;
    font-weight: 600;
    flex-shrink: 0;
}
.search-result-preview {
    color: #546e7a;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-more {
    font-size: 0.625rem;
    color: #90a4ae;
    margin-top: 4px;
    font-style: italic;
}

/* Thinking block */
.thinking-block {
    background: #f3e5f5;
    border-left: 3px solid #9c27b0;
    padding: 8px 12px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.75rem;
    color: #6a1b9a;
    font-style: italic;
}
.thinking-block .thinking-header {
    color: #7b1fa2;
    font-weight: 600;
    font-style: normal;
    margin-bottom: 4px;
}

/* Aggregated chips (tool calls / thinking) */
.tools-chip,
.thinking-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin: 8px 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-left: 3px solid transparent;
    text-align: left;
    max-width: 100%;
    overflow: hidden;
    transition: opacity 0.15s, transform 0.05s;
}
.tools-chip:hover,
.thinking-chip:hover {
    opacity: 0.85;
}
.tools-chip:active,
.thinking-chip:active {
    transform: translateY(1px);
}
.tools-chip {
    background: #e3f2fd;
    color: #1565c0;
    border-left-color: #2196f3;
}
/* Chip border tints to the worst severity present.
   .tools-chip-notice keeps the neutral background so noisy retries don’t
   look alarming; warning + error tint the whole chip. */
.tools-chip.tools-chip-notice {
    background: #eceff1;
    color: #455a64;
    border-left-color: #90a4ae;
}
.tools-chip.tools-chip-warning {
    background: #fff8e1;
    color: #b45309;
    border-left-color: #f59e0b;
}
.tools-chip.tools-chip-error {
    background: #ffebee;
    color: #c62828;
    border-left-color: #f44336;
}
.thinking-chip {
    background: #f3e5f5;
    color: #7b1fa2;
    border-left-color: #9c27b0;
}
.tools-chip .chip-label,
.thinking-chip .chip-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tools-chip .chip-chevron,
.thinking-chip .chip-chevron {
    font-size: 0.875rem;
    line-height: 1;
    opacity: 0.7;
    flex-shrink: 0;
}

/* Pip row — one dot per tool, ordered by call sequence. Each pip is colour-
   coded by the underlying tool’s severity so the chip is a literal visual
   summary of the turn. Used when total tools ≤ 12 (PIP_INLINE_THRESHOLD in
   stream-renderer.js). */
.tools-chip .tool-pips {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
    line-height: 1;
    font-size: 0.6875rem;
    letter-spacing: 0;
}
.tools-chip .tool-pip {
    display: inline-block;
    line-height: 1;
    opacity: 0.95;
}
.tools-chip .tool-pip-success { color: #43a047; }
.tools-chip .tool-pip-notice  { color: #90a4ae; }
.tools-chip .tool-pip-warning { color: #f59e0b; }
.tools-chip .tool-pip-error   { color: #e53935; }

/* Severity count badges — used when total tools > 12 (pips would be illegible
   at small sizes). Only non-zero severities are rendered. */
.tools-chip .severity-counts {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 600;
}
.tools-chip .severity-count {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 5px;
    border-radius: 8px;
    line-height: 1.4;
}
.tools-chip .severity-count-notice  { color: #455a64; background: rgba(144, 164, 174, 0.18); }
.tools-chip .severity-count-warning { color: #92400e; background: rgba(245, 158, 11, 0.18); }
.tools-chip .severity-count-error   { color: #b71c1c; background: rgba(229, 57, 53, 0.18); }

/* Prep-phase collapsible wrapper (the assistant's working narration, wrapped
   inline — above the deliverable it precedes — by shared/prep-section.js's
   marker parsing + shared/markdown-utils.js's renderContentWithPrep /
   renderStreamingMarkdown). Themed to echo .thinking-chip's left-accent
   treatment, but via CSS vars (not hardcoded hex) so it tracks the page's
   light/dark theme. */
.prep-wrapper {
    margin: 8px 0;
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
    background: var(--card-bg);
}
.prep-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 6px 10px;
    margin: 0;
    background: none;
    border: none;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
}
.prep-header:hover {
    color: var(--accent);
}
.prep-header-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.prep-body {
    padding: 0 12px 10px 12px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.prep-wrapper.collapsed .prep-body {
    display: none;
}

/* Audience wrapper (owner-only / thread-facing sections marked by
   <!--ray:to:owner--> / <!--ray:to:thread--> sentinels, parsed by
   shared/prep-section.js and rendered by shared/markdown-utils.js's
   renderContentWithPrep / renderStreamingMarkdown). Sibling to .prep-wrapper
   above but NON-collapsible - there's no state to hide, only a badge that
   labels the audience, so the visual weight is quieter than the prep chrome
   (no header button, no collapse affordance). Themed entirely via existing
   CSS vars so both light/dark themes work with no new hex literals: owner
   reads "private" via --warning (the same amber already used for warning
   states elsewhere), thread reads "delivered" via --success-text (the same
   green already used for success states). The badge uses `border:
   1px solid currentColor` instead of a separate tinted background so it needs
   no extra color token. */
.audience-wrapper {
    margin: 8px 0;
    padding: 2px 12px 10px 12px;
    border-left: 3px solid var(--border);
    border-radius: 0 6px 6px 0;
    background: var(--card-bg);
}
.audience-wrapper--owner {
    border-left-color: var(--warning);
}
.audience-wrapper--thread {
    border-left-color: var(--success-text);
}
.audience-badge {
    display: inline-block;
    margin: 8px 0 6px 0;
    padding: 1px 8px;
    border: 1px solid currentColor;
    border-radius: 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.4;
}
.audience-wrapper--owner .audience-badge {
    color: var(--warning);
}
.audience-wrapper--thread .audience-badge {
    color: var(--success-text);
}
.audience-body {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Detail overlay (bottom sheet style) */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 2100;
}
.detail-overlay.hidden { display: none; }
.detail-overlay .detail-sheet {
    background: var(--bg-secondary, #ffffff);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    border: 1px solid var(--border, #e8e5e0);
    border-bottom: none;
    width: 100%;
    max-width: 720px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
}
.detail-overlay.thinking .detail-sheet {
    background: #faf5ff;
}
.detail-overlay.tools .detail-sheet {
    background: #f5fbff;
}
.detail-overlay .detail-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}
.detail-overlay .detail-sheet-title {
    font-size: 0.9375rem;
    font-weight: 600;
}
.detail-overlay.tools .detail-sheet-title { color: #1565c0; }
.detail-overlay.thinking .detail-sheet-title { color: #7b1fa2; }
.detail-overlay .detail-sheet-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary, #7a7a7a);
    cursor: pointer;
    padding: 0 4px;
}
.detail-overlay .detail-sheet-close:hover { color: var(--text-primary, #2c2c2c); }
.detail-overlay .detail-sheet-body {
    padding: 16px 18px 24px;
    overflow-y: auto;
    font-size: 0.8125rem;
    line-height: 1.55;
}
.detail-overlay .detail-entry-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 12px 0;
}
.detail-overlay .detail-tool-entry {
    padding: 4px 0;
}
.detail-overlay .detail-tool-header {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1565c0;
    line-height: 1.4;
    word-break: break-word;
}
.detail-overlay .detail-tool-header.error { color: #c62828; }
.detail-overlay .detail-tool-header.warning { color: #b45309; }
.detail-overlay .detail-tool-header.notice { color: #546e7a; }
.detail-overlay .detail-tool-entry.error .detail-tool-header { color: #c62828; }
.detail-overlay .detail-tool-entry.warning .detail-tool-header { color: #b45309; }
.detail-overlay .detail-tool-entry.notice .detail-tool-header { color: #546e7a; opacity: 0.85; }
/* Per-row category chip (e.g. remote_4xx, auth_refreshable) shown next to the
   tool name when the failure is classified. Stable snake_case identifier from
   the backend’s tool_severity classifier. */
.detail-overlay .detail-tool-category {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.detail-overlay .detail-tool-category-notice  { color: #455a64; background: rgba(144, 164, 174, 0.18); }
.detail-overlay .detail-tool-category-warning { color: #92400e; background: rgba(245, 158, 11, 0.18); }
.detail-overlay .detail-tool-category-error   { color: #b71c1c; background: rgba(229, 57, 53, 0.18); }
.detail-overlay .detail-tool-error {
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(244, 67, 54, 0.08);
    color: #b71c1c;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.6875rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}
/* Expandable tool entries */
.detail-overlay .detail-tool-entry .detail-tool-header {
    display: flex;
    align-items: center;
    gap: 4px;
}
.detail-overlay .detail-tool-entry.expandable .detail-tool-header {
    cursor: pointer;
    user-select: none;
}
.detail-overlay .detail-tool-entry.expandable .detail-tool-header:hover {
    opacity: 0.8;
}
.detail-overlay .tool-expand-chevron {
    display: inline-block;
    width: 14px;
    font-size: 0.6875rem;
    opacity: 0.6;
    transition: transform 0.15s;
    flex-shrink: 0;
}
.detail-overlay .detail-tool-result {
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(21, 101, 192, 0.05);
    color: #37474f;
    font-size: 0.6875rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.5;
}
.detail-overlay .detail-tool-params-label {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #90a4ae;
    margin-bottom: 4px;
}
.detail-overlay .detail-tool-params {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.6875rem;
    margin: 0 0 8px 0;
    padding-bottom: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #546e7a;
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid rgba(21, 101, 192, 0.12);
}
.detail-overlay .detail-tool-context {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.75rem;
    line-height: 1.5;
    color: #1a237e;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(21, 101, 192, 0.12);
}
.detail-overlay .detail-tool-raw {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.6875rem;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: #546e7a;
}
.detail-overlay .detail-tool-loading {
    color: #90a4ae;
    font-size: 0.6875rem;
    font-style: italic;
}
.detail-overlay .tool-result-retry {
    color: #1565c0;
    cursor: pointer;
    text-decoration: underline;
}
.detail-overlay .detail-thought {
    color: #4a148c;
    font-style: italic;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Todo list */
.todo-block {
    background: #e8f5e9;
    border-left: 3px solid #4caf50;
    padding: 12px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.8125rem;
    color: #1b5e20;
}
.todo-block .todo-header {
    color: #2e7d32;
    font-weight: 600;
    margin-bottom: 8px;
}
.todo-block .todo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.todo-block .todo-icon {
    width: 16px;
    text-align: center;
}
.todo-block .todo-completed { color: #2e7d32; }
.todo-block .todo-completed .todo-text { text-decoration: line-through; }
.todo-block .todo-in-progress { color: #f57c00; }
.todo-block .todo-pending { color: #757575; }
.todo-block .todo-cancelled { color: #757575; }
.todo-block .todo-cancelled .todo-text { text-decoration: line-through; }

/* Sub-agent progress */
.subagent-block {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
    padding: 12px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.8125rem;
    color: #0d47a1;
}
.subagent-block .subagent-header {
    color: #1565c0;
    font-weight: 600;
    margin-bottom: 8px;
}
.subagent-block .subagent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.subagent-block .subagent-icon {
    width: 20px;
    text-align: center;
}
.subagent-block .subagent-running { color: #1565c0; }
.subagent-block .subagent-running .subagent-icon { animation: pulse 1s infinite; }
.subagent-block .subagent-done { color: #2e7d32; }
.subagent-block .subagent-error { color: #c62828; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* File content blocks */
.file-content {
    background: #2d2d2d;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 12px 0;
    max-height: 300px;
    overflow: auto;
}
.file-content pre {
    margin: 0;
    padding: 12px;
}
.file-content code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.6875rem;
    color: #f8f8f2;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Section dividers */
.section-divider {
    border-top: 1px solid #e0e0e0;
    margin: 16px 0;
    padding-top: 8px;
}

/* Streaming */
.message.streaming {
    border: 2px solid var(--accent);
    position: relative;
}
.message.streaming::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--accent);
    margin-left: 4px;
    animation: blink 0.8s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Activity indicator */
.activity-indicator {
    align-self: flex-start;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.activity-indicator .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #2e7d32;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error message */
.error-message {
    align-self: center;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.8125rem;
}

/* System note */
.system-note {
    align-self: center;
    background: var(--bg-tertiary);
    color: #b85c3a;
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.75rem;
    margin: 8px 0;
}

/* Empty state */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9e9e9e;
    font-size: 0.875rem;
    padding: 40px 20px;
    text-align: center;
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.7;
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}
.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.empty-state-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.empty-state.compact {
    padding: 20px;
}
.empty-state.compact .empty-state-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}
.empty-state.compact .empty-state-title {
    font-size: 0.875rem;
}

/* Loading state — shown while a selected session's messages are being
   fetched. Distinct from .empty-state so a not-yet-loaded conversation is
   never mistaken for a brand-new "Start a Conversation" one. */
.loading-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    padding: 40px 20px;
    text-align: center;
}
.loading-state-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    margin-bottom: 16px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Context usage indicator (debug mode) */
.context-usage-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}
.context-usage-indicator .context-usage-bar {
    flex: 1;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    max-width: 120px;
}
.context-usage-indicator .context-usage-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--text-secondary);
    transition: width 0.3s ease;
}
.context-usage-indicator.normal .context-usage-fill {
    background: #4aff88;
}
.context-usage-indicator.warning .context-usage-fill {
    background: #ffb347;
}
.context-usage-indicator.critical .context-usage-fill {
    background: #e94560;
}
.context-usage-indicator.compacting .context-usage-fill {
    background: #ffb347;
    animation: pulse-bar 1s ease-in-out infinite;
}
@keyframes pulse-bar {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.context-usage-indicator .context-usage-label {
    white-space: nowrap;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── AskUserQuestion card ─────────────────────────────────────────────
   Rendered by conversation-embed.js (renderPendingAskCard /
   _renderAskQuestionCardHtml). Lives here — a shared stylesheet loaded by
   both index.html and conversation.html (the desktop/macOS host) — so the
   card is styled in every conversation surface, not just index.html. */
.ask-question-card {
    background: var(--bg-secondary, #16213e);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    max-width: 480px;
}
.ask-question-card.answered {
    opacity: 0.7;
}
/* Active question pinned after the conversation (no inline anchor yet). */
.ask-question-card.ask-footer {
    margin-top: 16px;
}
.ask-q-header {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary, #888);
    margin-bottom: 4px;
}
.ask-q-text {
    font-size: 0.875rem;
    color: var(--text-primary, #eee);
    margin-bottom: 10px;
}
.ask-q-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.ask-opt {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, #333);
    transition: background 0.15s;
}
.ask-opt:hover {
    background: rgba(255,255,255,0.05);
}
.ask-opt > input {
    margin-top: 2px;
    flex-shrink: 0;
}
.ask-opt-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ask-opt-label {
    font-size: 0.8125rem;
    color: var(--text-primary, #eee);
}
.ask-opt-desc {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-secondary, #888);
    margin-top: 2px;
}
.ask-other-input {
    width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, #333);
    background: var(--bg-primary, #1a1a2e);
    color: var(--text-primary, #eee);
    font-size: 0.8125rem;
    margin-top: 4px;
}
.ask-other-input.hidden {
    display: none;
}
.ask-submit-btn {
    background: var(--accent, #e94560);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.ask-submit-btn:hover {
    opacity: 0.85;
}
.ask-submit-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.ask-q-block + .ask-q-block {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border, #333);
}

/* ── Per-message delivery chips (Channel Bindings Phase 6) ────────────────
   Compact indicators of where an assistant message was actually delivered
   (Slack thread, email draft, Asana comment). One row per source message,
   injected by shared/conversation-deliveries.js after the message content.
   Colour convention mirrors .tools-chip: neutral/green ok, amber drafted,
   red blocked/failed. */
.delivery-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0 2px;
}
.delivery-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
    border: 1px solid transparent;
}
.delivery-chip-sent {
    background: #e6f4ea;
    color: #1e7d34;
    border-color: #b7e0c2;
}
.delivery-chip-drafted {
    background: #fff8e1;
    color: #b45309;
    border-color: #f0d68a;
}
.delivery-chip-pending {
    background: #eceff1;
    color: #455a64;
    border-color: #cfd8dc;
}
.delivery-chip-blocked {
    background: #ffebee;
    color: #c62828;
    border-color: #f4b8bd;
}
.delivery-chip-failed {
    background: #ffebee;
    color: #c62828;
    border-color: #f4b8bd;
}
