#kestrelChatMount{display:flex;flex-direction:column;height:100%;min-height:0;font-size:calc(1rem*var(--chat-scale,1));--text-tertiary:var(--muted);--border-color:var(--border);--accent-color:var(--accent);--accent-hover:var(--accent-deep);--user-bubble:var(--accent);--agent-bubble:var(--surface);--code-bg:var(--tint);--code-text:var(--ink);--card-shadow:var(--shadow-soft);}
#kestrelOverlayRoot{--text-tertiary:var(--muted);--border-color:var(--border);--accent-color:var(--accent);--accent-hover:var(--accent-deep);--user-bubble:var(--accent);--agent-bubble:var(--surface);--code-bg:var(--tint);--code-text:var(--ink);--card-shadow:var(--shadow-soft);}
#companionsPane{--text-tertiary:var(--muted);--border-color:var(--border);--accent-color:var(--accent);--accent-hover:var(--accent-deep);--user-bubble:var(--accent);--agent-bubble:var(--surface);--code-bg:var(--tint);--code-text:var(--ink);--card-shadow:var(--shadow-soft);}
@scope (#kestrelChatMount, #kestrelOverlayRoot, #companionsPane) {
/* Theme-aware CSS using system preferences */
:root {
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Monaco', 'Menlo', 'Consolas', monospace;
    /* Composer auto-grow cap: how tall the chat input may grow, as a
       unitless percentage of the chat panel height, before it stops
       growing and scrolls internally (read by autosizeComposer in
       chat.js). Override here or in a theme to tune it. */
    --composer-max-height-pct: 40;
}

/* Light theme (default) */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --user-bubble: #3b82f6;
    --agent-bubble: #f1f5f9;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-tertiary: #64748b;
        --border-color: #334155;
        --accent-color: #60a5fa;
        --accent-hover: #3b82f6;
        --user-bubble: #3b82f6;
        --agent-bubble: #334155;
        --code-bg: #0f172a;
        --code-text: #e2e8f0;
        --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
    }
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Navigation */
nav {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--card-shadow);
}

.console-chrome-hidden nav {
    display: none;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-brand h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.nav-brand .kestrel-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 6px;
    padding: 2px;
}

.nav-brand .kestrel-icon img,
.nav-brand .kestrel-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.nav-tabs {
    display: flex;
    gap: 0.5rem;
}

.nav-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--accent-color);
    color: white;
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Main content area */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Pane Sidebars (Agents + Conversations) */
.pane-sidebar {
    width: 280px;
    min-width: 200px;
    max-width: 500px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
}

.pane-sidebar.collapsed {
    width: 48px;
    min-width: 48px;
}

.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.pane-header h3 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.pane-sidebar.collapsed .pane-header h3,
.pane-sidebar.collapsed .btn-icon {
    display: none;
}

.collapse-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.collapse-btn:hover {
    color: var(--text-primary);
}

.pane-sidebar.collapsed .collapse-btn {
    transform: rotate(180deg);
}

.btn-icon {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: var(--accent-hover);
}

.pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.pane-sidebar.collapsed .pane-content {
    display: none;
}

/* Agent items in Agents pane */
.agent-item {
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.15s;
}

.agent-item:hover {
    background: var(--bg-tertiary);
}

.agent-item.selected {
    background: var(--accent-color);
    color: white;
}

.agent-item.offline {
    opacity: 0.5;
    cursor: default;
}

.agent-item.offline:hover {
    background: transparent;
}

.agent-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.agent-status-dot.online {
    background: var(--success);
}

.agent-status-dot.offline {
    background: var(--text-tertiary);
}

.agent-info {
    flex: 1;
    min-width: 0;
}

.agent-info .agent-name {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-info .agent-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-item.selected .agent-description {
    color: rgba(255, 255, 255, 0.8);
}

/* Per-agent activity indicator. Hidden by default; the row's
   `.agent-thinking` class (toggled by refreshAgentThinkingDot
   based on state.waitingAgents) gates its visibility. Lets a
   user know Agent A is still thinking while they're chatting
   with Agent B. */
.agent-thinking-dot {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;  /* amber */
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
    flex-shrink: 0;
    animation: agentThinkingPulse 1.4s ease-in-out infinite;
}
.agent-item.agent-thinking .agent-thinking-dot {
    display: inline-block;
}
@keyframes agentThinkingPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.65); opacity: 1; }
    50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);   opacity: 0.55; }
}

/* Per-agent stop control: hidden until the agent is actually
   thinking. Clicking aborts that agent's stream client-side
   and tells THAT agent's backend to stop (api_client.stop
   takes the agent name explicitly). */
.agent-stop-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1;
    padding: 0.125rem 0.45rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.agent-stop-btn:hover {
    background: var(--error, #dc2626);
    color: white;
    border-color: var(--error, #dc2626);
}
.agent-item.agent-thinking .agent-stop-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.agent-item.selected .agent-stop-btn {
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.85);
}

/* mountAgentList (#2278, design §3.2): the shared list surface budgets vertical
   room for a per-card actions row by DEFAULT so a host's portrait-card renderer
   has real space for buttons under the portrait — that budget is a component
   responsibility, not a per-host CSS patch. The console row lays out
   horizontally and its actions anchor is usually empty; `:not(:empty)` keeps
   the budget from adding height to a bare console row, so the standalone list is
   visually unchanged from the pre-#2278 hand-rolled loop. */
.agent-list-component .agent-card-actions:not(:empty) {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 1.75rem;
    margin-top: 0.25rem;
}

/* Per-agent chat pane element. Each agent owns one of these
   detached fragments; mountChatPane() attaches the visible
   agent's pane as the sole child of #chat-container (the scroll
   viewport). The pane is just a passthrough container — actual
   overflow is on #chat-container so scroll position is shared
   machinery, not per-pane. */
.chat-container-pane {
    display: contents;
}

/* Conversation items in Conversations pane */
.conversation-item {
    /* #2254: reserve right padding so the tile's text (meta row + preview)
       never underlaps the kebab, which is now absolutely pinned to the tile's
       right edge and vertically centered (see `.conversation-item .kebab-btn`). */
    padding: 0.75rem 2.25rem 0.75rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: background-color 0.15s;
    position: relative;
}

.conversation-item:hover {
    background: var(--bg-tertiary);
}

/* Hover-reveal delete affordance on conversation rows (#715). */
.conversation-item .conv-delete-btn,
.conversation-item .conv-rename-btn {
    display: none;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(239, 68, 68, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.7rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.conversation-item .conv-rename-btn {
    right: 0.5rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.conversation-item:hover .conv-delete-btn,
.conversation-item:hover .conv-rename-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-item .conv-delete-btn:hover {
    background: #dc2626;
}

.conversation-item .conv-rename-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.conversation-item.active .conv-rename-btn {
    background: rgba(255, 255, 255, 0.16);
    color: white;
    border-color: rgba(255, 255, 255, 0.35);
}

.conversation-item.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.conversation-preview {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Full-text search hit context: decrypted excerpt around the first matching
   message, rendered under the preview with the term <mark>-highlighted. */
.conversation-match-snippet {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.conversation-match-snippet mark {
    background: var(--accent-color);
    color: white;
    border-radius: 2px;
    padding: 0 1px;
}

/* Inline rename input (#716).  Sits inside .conversation-preview
   and matches its size/weight so the row doesn't shift on edit. */
.conversation-rename-input {
    width: 100%;
    font-size: 0.875rem;
    padding: 0.125rem 0.25rem;
    margin: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    font-family: inherit;
    box-sizing: border-box;
}

.conversation-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.conversation-item.active .conversation-time {
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================================================
   Conversation-list component (#2149 / #2159).
   Styles for the classes emitted by conversations.js + kebab_menu.js. These
   MUST live in index.css (not a separate sheet) so embedding hosts like Frinz,
   which generate their scoped @scope sheet from index.css at request time, pick
   them up with zero host change. All colors ride theme vars; new shadow/blur
   values carry inline fallbacks so they survive the @scope embed path.
   ============================================================================ */
.conversations-root {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.conversations-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* View bar: segmented Active / Archived / Trash buttons. Matches the
   .nav-tab idiom — quiet by default, accent fill when active. */
.conversations-view-bar {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.2rem;
}

.conversations-view-btn {
    flex: 1;
    padding: 0.35rem 0.6rem;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.conversations-view-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.conversations-view-btn.active {
    background: var(--accent-color);
    color: white;
}

/* Search input. */
.conversations-search {
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
}

.conversations-search:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Stats line under the controls. */
.conversations-stats {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0 0.25rem;
}

.conversations-list-body {
    display: flex;
    flex-direction: column;
}

/* #2199: pane chrome added by mountConversationsPane. The body is a plain
   scroll region (when the export builds its own, absent an adopted
   #conversations-list); the filters disclosure toggle in the header dims when
   its controls are hidden. */
.conversations-pane-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversations-filters-toggle {
    opacity: 0.65;
    transition: opacity 0.15s;
}

.conversations-filters-toggle.active {
    opacity: 1;
}

/* #2216 / #2279: both sidebar panes now have exactly TWO states — open (full
   pane) and fully HIDDEN. "Closed" is NOT the thin `.pane-sidebar.collapsed`
   chevron rail (48px, see above); it is `display:none`, taking zero width.
   mountConversationsPane / mountAgentListPane set `display:none` inline and
   toggle `.collapsed` in lock-step; these rules back the inline hide so no rail
   can leak through. The conversations pane lives inside #panel-chat (scoped to
   the chat tab); the agents pane is a top-level nav surface reopened by the
   nav's #agents-toggle-btn (identity.js toggleAgentsPane). The 48px
   `.pane-sidebar.collapsed` rail above is no longer used by either pane. */
.conversations-pane.collapsed,
.agent-list-pane.collapsed {
    display: none;
}

/* Date groups: a muted section header above each day's rows. */
.date-group {
    margin-bottom: 0.5rem;
}

.date-group-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 0.5rem 0.25rem 0.25rem;
}

/* Meta row: time + message count on the left. Never wraps (#2165) — at ~220px
   the compact time truncates with an ellipsis while the count holds its size.
   #2254: the kebab no longer lives in this row's flow; it is absolutely pinned
   to the RIGHT of the whole tile, vertically centered (see below). */
.conversation-item .conversation-meta-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.conversation-msg-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    white-space: nowrap;
}

.conversation-item.active .conversation-msg-count {
    color: rgba(255, 255, 255, 0.8);
}

/* Kebab (⋯) button: a quiet icon button. Hover-reveal on row hover, but
   always focusable (keyboard) — matching the old conv-delete-btn pattern. */
.kebab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s;
}

/* #2254: pin the kebab to the RIGHT side of the tile, VERTICALLY CENTERED in
   the row, rather than at the right end of the meta (time + count) line where
   it read as awkward. `.conversation-item` is `position: relative`, so the
   absolute kebab centers against the whole tile; the tile reserves right
   padding so text never underlaps it. Hover-reveal + focusability are preserved
   by the shared rules below, which are class-based (not layout-dependent). */
.conversation-item .kebab-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
}

.conversation-item:hover .kebab-btn,
.kebab-btn:focus,
.kebab-btn:focus-visible {
    opacity: 1;
}

.kebab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.conversation-item.active .kebab-btn {
    color: rgba(255, 255, 255, 0.85);
    opacity: 1;
}

.conversation-item.active .kebab-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: white;
}

/* Kebab menu popover. The JS positions it fixed and sets a few inline styles;
   these give it a themed surface even if those are stripped by the embed. */
.kebab-menu {
    position: fixed;
    min-width: 180px;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--card-shadow, 0 4px 12px rgba(0, 0, 0, 0.15));
    padding: 0.25rem;
    z-index: 2000;
}

.kebab-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.6rem;
    background: none;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--text-primary);
    cursor: pointer;
}

.kebab-menu-item:hover,
.kebab-menu-item:focus {
    background: var(--bg-tertiary);
}

/* The background highlight above loses to kebab_menu.js's inline
 * `background: none`, so it cannot be the focus indicator. Keep a real
 * outline for keyboard users — inline styles can't override it. */
.kebab-menu-item:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
}

.kebab-menu-item-danger {
    color: var(--error, #ef4444);
}

.kebab-menu-item-danger:hover,
.kebab-menu-item-danger:focus,
.kebab-menu-item-danger:focus-visible {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error, #ef4444);
}

.kebab-menu-separator {
    height: 1px;
    margin: 0.25rem 0;
    background: var(--border-color);
}

/* Error state parity with .empty-state. */
.conversations-error {
    color: var(--error, #ef4444);
    padding: 1rem;
    text-align: center;
}

/* Trash sub-view (#765). Same shell as conversations but uses
   a softer affordance set: permanent-delete sits next to a
   Restore button, both visible by default (the user is
   already in a destructive context, no need to hover-reveal). */
.trash-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 0.75rem 0.5rem 0.25rem;
}

.trash-item {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.trash-item .trash-preview {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trash-item .trash-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.trash-actions {
    display: flex;
    gap: 0.4rem;
}

.trash-actions button {
    flex: 1;
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.trash-actions .btn-restore {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: transparent;
}

.trash-actions .btn-restore:hover {
    background: var(--accent-color);
    color: white;
}

.trash-actions .btn-purge {
    border-color: #dc2626;
    color: #ef4444;
    background: transparent;
}

.trash-actions .btn-purge:hover {
    background: #dc2626;
    color: white;
}

/* Conversation row gets a second hover button: permanent delete.
   Sits to the left of the soft ✕ so the user has to slow down to
   hit it intentionally (#765). */
.conversation-item .conv-purge-btn {
    display: none;
    position: absolute;
    top: 0.5rem;
    right: 2.1rem;
    background: rgba(220, 38, 38, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.65rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.conversation-item:hover .conv-purge-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-item .conv-purge-btn:hover {
    background: #b91c1c;
}

/* Trash retention notice rendered at the bottom of the trash
   sub-view. Soft, informational; not a CTA. */
.trash-retention-notice {
    padding: 0.75rem 0.5rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

/* Pane Resize Handles */
.resize-handle {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
    transition: background 0.15s;
}

.resize-handle:hover {
    background: var(--accent-color);
}

.pane-sidebar {
    position: relative;
}

/* Content panels */
.panel {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.panel.active {
    display: flex;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Identity Panel */
.identity-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--card-shadow);
}

.identity-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.identity-avatar {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.identity-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.identity-info h2 {
    margin: 0;
    font-size: 1rem;
}

.identity-did {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    max-width: 360px;
}

/* Hybrid identity row (post-Quantum-Hardening rotation).
   Sits beneath the legacy DID line and surfaces the new
   did:web identity + a HYBRID badge. */
.identity-hybrid-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    max-width: 480px;
    flex-wrap: wrap;
}
.hybrid-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: #0d8a4a;
    color: #fff;
    cursor: help;
}
.identity-signing-did-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Identity danger zone (#2208): visually separated destructive-actions
   section at the bottom of the Identity panel. */
.identity-danger-zone {
    border: 1px solid var(--error);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-top: 1.5rem;
    background: color-mix(in srgb, var(--error) 6%, transparent);
}

.identity-danger-zone-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--error);
}

.identity-danger-zone-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--error);
}

.identity-danger-zone-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.identity-danger-zone-copy {
    min-width: 0;
}

.identity-danger-zone-action-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.identity-danger-zone-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.identity-danger-zone-btn {
    flex: 0 0 auto;
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.identity-danger-zone-btn:hover {
    background: var(--error);
    color: white;
}

.hybrid-chain-depth {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-style: italic;
    cursor: help;
}

/* Profile Editor */
.identity-avatar-wrapper {
    position: relative;
}
.avatar-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.375rem;
}
.avatar-actions button {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s;
}
.avatar-actions button:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.profile-editor-name {
    font-size: 1rem;
    font-weight: 600;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    width: 100%;
    margin: 0;
    font-family: inherit;
}
.profile-editor-name:hover,
.profile-editor-name:focus {
    border-color: var(--border-color);
    background: var(--bg-tertiary);
    outline: none;
}
.profile-editor-desc {
    font-size: 0.8rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    width: 100%;
    resize: vertical;
    min-height: 1.8rem;
    max-height: 6rem;
    font-family: inherit;
    margin-top: 0.25rem;
}
.profile-editor-desc:hover,
.profile-editor-desc:focus {
    border-color: var(--border-color);
    background: var(--bg-tertiary);
    outline: none;
}
.profile-editor-desc::placeholder {
    color: var(--text-tertiary);
}
.avatar-generate-panel {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.avatar-generate-panel input {
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: inherit;
    margin-bottom: 0.375rem;
    box-sizing: border-box;
}
.avatar-generate-panel button {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}
.avatar-generate-panel button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.avatar-options {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.avatar-options img {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}
.avatar-options img:hover {
    border-color: var(--accent);
}

.identity-did-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Constitution Panel */
.constitution-viewer {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.constitution-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.constitution-content {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.constitution-content h1, .constitution-content h2, .constitution-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.constitution-content h1:first-child, .constitution-content h2:first-child {
    margin-top: 0;
}

/* Chat Panel */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1rem;
    gap: 0.75rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    line-height: 1.5;
    position: relative;
}

/* Per-message overflow ("⋯") menu on chat bubbles (#2410). Replaces the twin
   red delete/purge circles with one hover/focus-revealed kebab, reusing the
   conversation-card pattern (`.conversation-item .kebab-btn`). `.message` is
   position: relative, so the absolute kebab pins to the bubble's top-right.
   Base `.kebab-btn` (js/kebab_menu.js output) supplies size/shape/hover; these
   rules only position it and drive the hover/focus reveal. */
.message .msg-kebab-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    z-index: 1;
}

.message:hover .msg-kebab-btn,
.message .msg-kebab-btn:focus,
.message .msg-kebab-btn:focus-visible {
    opacity: 1;
}

.user-message {
    background-color: var(--user-bubble);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.agent-message {
    background-color: var(--agent-bubble);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-model-footer {
    margin-top: 0.45rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.72rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

/* #1522: autonomous cognition wake (A2A reply resumption, scheduled
   wake, etc.) rendered live into the active pane. A subtle accent +
   attribution header distinguishes it from a reply to a user prompt. */
.signal-wake-message {
    border-left: 3px solid var(--accent, #6366f1);
}

.signal-wake-attribution {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    opacity: 0.85;
}

/* A persisted COGNITION wake prompt rendered from history: the internal
   instruction template stays available for audit but collapsed by default,
   so it reads as a compact "Autonomous wake" chip rather than a raw user
   message. Mirrors the live wake bubble, which never shows the prompt. */
.signal-wake-details > summary {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.7;
    cursor: pointer;
    list-style: revert;
}
.signal-wake-prompt {
    margin-top: 0.375rem;
    padding: 0.5rem 0.625rem;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
    background: var(--surface-2, rgba(127, 127, 127, 0.06));
    border-radius: 6px;
    opacity: 0.9;
}

/* #1551: restart/update lifecycle events rendered as chat-visible
   system/status bubbles. Audited deployment primitive — the Sovereign
   gets first-class evidence (request id, operation, state, deferral
   reason) rather than trusting agent prose. The left-border accent is
   set inline per lifecycle state by handleRestartStatus(). */
.restart-status-message {
    border-left: 3px solid var(--accent, #6366f1);
    background: var(--surface-2, rgba(127, 127, 127, 0.06));
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    margin: 0.5rem 0;
    font-size: 0.8125rem;
}

.restart-status-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.375rem;
}

.restart-status-title {
    font-weight: 600;
}

.restart-status-state {
    margin-left: auto;
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    padding: 0.0625rem 0.4375rem;
    border-radius: 999px;
    border: 1px solid currentColor;
    opacity: 0.9;
}

.restart-status-body {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.restart-status-row {
    display: flex;
    gap: 0.5rem;
}

.restart-status-key {
    flex: 0 0 8.5rem;
    color: var(--text-secondary);
}

.restart-status-val {
    flex: 1 1 auto;
    word-break: break-word;
}

.message-content {
    word-wrap: break-word;
    line-height: 1.55;
}

/* Markdown block typography.
 *
 * The chat bubble renders marked.js output, but historically nothing
 * styled the generated block elements, so headings/lists/quotes fell
 * back to bare UA defaults with zero margins — reading as flat,
 * undifferentiated text (kestrel-sovereign #1547). These rules give
 * the rendered markdown a real vertical rhythm. First/last-child
 * margin collapse keeps the bubble from gaining stray top/bottom gaps. */
.message-content > :first-child,
.response-content > :first-child {
    margin-top: 0;
}

.message-content > :last-child,
.response-content > :last-child {
    margin-bottom: 0;
}

.message-content p {
    margin: 0.5rem 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 1rem 0 0.5rem;
    line-height: 1.25;
    font-weight: 600;
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.3rem; }
.message-content h3 { font-size: 1.15rem; }
.message-content h4 { font-size: 1rem; }
.message-content h5 { font-size: 0.9rem; }
.message-content h6 { font-size: 0.85rem; color: var(--text-secondary); }

.message-content ul,
.message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin: 0.2rem 0;
}

.message-content li > ul,
.message-content li > ol {
    margin: 0.2rem 0;
}

.message-content blockquote {
    margin: 0.5rem 0;
    padding: 0.25rem 0 0.25rem 1rem;
    border-left: 3px solid var(--border-color);
    color: var(--text-secondary);
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

.message-content table {
    border-collapse: collapse;
    margin: 0.5rem 0;
    display: block;
    overflow-x: auto;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.6rem;
    text-align: left;
}

.message-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-content a {
    color: var(--accent-color);
    text-decoration: underline;
}

.message-content pre {
    background-color: var(--code-bg);
    color: var(--code-text);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    /* Anchor for the absolutely-positioned copy button (#1574). */
    position: relative;
}

/* Copy-to-clipboard button on fenced code blocks (#1574). Hover-reveal on
 * fine pointers; always visible on touch/coarse pointers where there is no
 * hover. Sits top-right, inside the pre's padding box. */
.code-copy-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    padding: 0.15rem 0.5rem;
    font-family: var(--font-sans, inherit);
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--code-text, #e2e8f0);
    background: rgba(125, 125, 140, 0.22);
    border: 1px solid rgba(125, 125, 140, 0.40);
    border-radius: 5px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s ease, background 0.12s ease;
    z-index: 1;
}

.message-content pre:hover .code-copy-btn,
.code-copy-btn:focus-visible {
    opacity: 1;
}

.code-copy-btn:hover {
    background: rgba(125, 125, 140, 0.38);
}

.code-copy-btn--ok {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.5);
}

/* No hover on touch/coarse pointers — keep the button reachable. */
@media (hover: none), (pointer: coarse) {
    .code-copy-btn {
        opacity: 0.7;
    }
}

.message-content code {
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

/* Inline code must stand out FROM the bubble. The bubble background is
 * --bg-tertiary, so the old `background: var(--bg-tertiary)` made every
 * `code` chip the exact same color as the bubble — invisible, and the
 * chip padding then made the following punctuation float ("running=0 ,").
 * A translucent neutral fill + border reads as a chip on both the light
 * and dark bubble, and the accent text color makes backticked tokens pop. */
.message-content :not(pre) > code {
    background: rgba(125, 125, 140, 0.16);
    border: 1px solid rgba(125, 125, 140, 0.30);
    padding: 0.05rem 0.3rem;
    border-radius: 5px;
    /* Inherit the bubble's text color so the chip stays legible on every
     * surface — light/dark agent bubbles and the blue user bubble. The
     * fill + border + monospace already make it read as code. */
    color: inherit;
    white-space: pre-wrap;
}

/* Tool activity indicators */
.tool-activity-container {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    gap: 0.35rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 3px solid var(--accent-color);
}

/* #1914: typed component parts render as their own agent bubbles. The
   built-in ``notice`` core renderer; feature renderers (todo #1894, …) add
   their own classes. Accent reflects the notice level. */
.part-notice {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-color);
}
.part-notice-success { border-left-color: #22c55e; }
.part-notice-warning { border-left-color: #f59e0b; }
.part-notice-error { border-left-color: #ef4444; }
.part-notice-title {
    font-weight: 600;
    font-size: 0.85rem;
}
.part-notice-body {
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* #1894: a todo mutation (delta) rendered as its own component bubble —
   status chip + title + terminal condition + external links. Accent reflects
   the todo status. */
.part-todo {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-color);
}
.part-todo.todo-status-in_progress { border-left-color: #3b82f6; }
.part-todo.todo-status-waiting { border-left-color: #f59e0b; }
.part-todo.todo-status-blocked { border-left-color: #ef4444; }
.part-todo.todo-status-done { border-left-color: #22c55e; }
.part-todo.todo-status-cancelled { border-left-color: #6b7280; }
.todo-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.todo-status-chip {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}
.todo-status-chip.todo-status-in_progress { color: #3b82f6; }
.todo-status-chip.todo-status-waiting { color: #f59e0b; }
.todo-status-chip.todo-status-blocked { color: #ef4444; }
.todo-status-chip.todo-status-done { color: #22c55e; }
.todo-status-chip.todo-status-cancelled { color: #6b7280; }
.todo-title {
    font-weight: 600;
    font-size: 0.85rem;
    word-break: break-word;
}
.todo-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.72rem;
    opacity: 0.85;
}
.todo-scope,
.todo-priority {
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
.todo-priority-high { color: #f59e0b; }
.todo-priority-urgent { color: #ef4444; }
.todo-terminal {
    font-size: 0.78rem;
    opacity: 0.9;
    word-break: break-word;
}
.todo-links {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.todo-link {
    font-size: 0.72rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    text-decoration: none;
}
a.todo-link:hover { text-decoration: underline; }

.tool-activity-expandable {
    display: block;
}

.tool-activity-call + .tool-activity-call {
    border-top: 1px solid var(--border-color);
    padding-top: 0.35rem;
}

.tool-activity-summary {
    align-items: center;
    cursor: pointer;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    list-style: none;
    user-select: none;
}

.tool-activity-summary::-webkit-details-marker {
    display: none;
}

.tool-activity-summary::before {
    content: '\25B8';
    color: var(--text-secondary);
    flex: 0 0 auto;
    font-size: 0.75rem;
    transition: transform 0.15s ease;
}

.tool-activity-expandable[open] .tool-activity-summary::before {
    transform: rotate(90deg);
}

.tool-activity-count {
    color: var(--text-secondary);
    font-size: 0.72rem;
    margin-left: auto;
}

.tool-activity-list {
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.35rem;
}

.tool-activity {
    font-family: var(--font-mono);
    padding: 0.15rem 0;
    opacity: 0.85;
}

.tool-activity.tool-start {
    color: var(--text-secondary);
}

.tool-activity.tool-done {
    color: #22c55e;
}

.tool-activity.tool-error {
    color: #ef4444;
}

.response-content {
    margin-top: 0.5rem;
}

/* Input area */
.input-area {
    display: flex;
    /* Pin the attach/send buttons to the bottom edge while the
       auto-growing textarea gets taller. */
    align-items: flex-end;
    padding: 1rem;
    gap: 0.75rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* #1257 send-while-busy mode toggle (input footer, left side). */
.composer-mode-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-tertiary);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    font-size: 0.7rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.composer-mode-toggle:hover {
    color: var(--text-primary);
    border-color: var(--accent-color);
}
.composer-mode-toggle[data-mode="queue"] {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* #1257 pending queued-message chip (bottom of the pane). */
.queued-message-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 1rem;
    padding: 0.4rem 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-tertiary);
    font-size: 0.85rem;
    opacity: 0.85;
}
.queued-message-chip::before {
    content: "queued";
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: var(--bg-primary);
    color: var(--text-tertiary);
}
.queued-message-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.queued-message-cancel {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}
.queued-message-cancel:hover {
    color: var(--error-color, #ef4444);
}

.input-area textarea {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.input-area textarea:focus {
    border-color: var(--accent-color);
}

.input-area button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.input-area button:hover {
    background-color: var(--accent-hover);
}

/* #1662 attachment composer: attach button (subtle, not accent like send) */
.input-area button.attach-button {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 1.1rem;
}
.input-area button.attach-button:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Staged attachment tray (above the input) */
.attachment-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 1rem 0;
}
.attachment-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--text-tertiary);
}
.attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.attachment-doc-icon { font-size: 1.5rem; }
.attachment-doc-name {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 2px;
}
.attachment-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Read-only attachment thumbnails inside a sent user bubble + on reload */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.msg-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 160px;
    border-radius: 6px;
    overflow: hidden;
}
.msg-attachment img {
    max-width: 160px;
    max-height: 160px;
    border-radius: 6px;
    display: block;
}
.msg-attachment-doc {
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
    text-decoration: none;
    font-size: 0.8rem;
}

/* Model Selector */
.model-selector {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    min-width: 120px;
    max-width: 180px;
}

.model-selector:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Unified Model-settings popover (#2264) */
.model-settings-button {
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 280px;
}

.model-settings-button:hover,
.model-settings-button[aria-expanded="true"] {
    border-color: var(--accent-color);
}

.model-settings-summary {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-settings-panel {
    /* Positioned as a fixed overlay by ModelSettingsPopover on open; these
       styles cover the resting appearance and scoped-embed fallback. */
    min-width: 260px;
    max-width: 340px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary, var(--bg-primary));
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.model-settings-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-settings-section .model-selector {
    max-width: none;
    width: 100%;
}

.model-settings-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, var(--text-primary));
}

.embedding-dim-readout {
    font-size: 0.72rem;
    color: var(--text-secondary, var(--text-primary));
}

.embedding-dim-warning {
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--warning-color, #b45309);
    background: rgba(180, 83, 9, 0.1);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
}

/* #2336 — actionable "Re-embed N memories" control + progress readout. */
.embedding-reindex-button {
    align-self: flex-start;
    margin-top: 0.15rem;
}

.embedding-reindex-status {
    font-size: 0.72rem;
    color: var(--text-secondary, var(--text-primary));
}

/* #2290 — shared local/cloud embedding space, rendered as one entry. */
.embedding-shared-space {
    font-size: 0.72rem;
    color: var(--text-secondary, var(--text-primary));
}

/* #2337 — featured "Universal" option pinned at the top of the section. */
.embedding-universal {
    align-self: stretch;
    text-align: left;
    font-size: 0.75rem;
    line-height: 1.3;
    border-color: var(--accent-color, #2563eb);
}

.embedding-setup-status {
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-secondary, var(--text-primary));
}

/* #2418 — the guided-setup status line must never wear success styling
   around a failure. Each state (set by EmbeddingSelector._setSetupStatus as
   both a class and a data-status attr) reads as one unmistakable outcome:
   configured (ok), failed (error), degraded (warn), or in-flight (pending). */
.embedding-setup-status.embed-setup-ok {
    color: var(--success, #16a34a);
}
.embedding-setup-status.embed-setup-error {
    color: var(--danger, #dc2626);
    font-weight: 600;
}
.embedding-setup-status.embed-setup-warn {
    color: var(--warning, #d97706);
}
.embedding-setup-status.embed-setup-pending {
    color: var(--text-secondary, var(--text-primary));
    opacity: 0.85;
}

/* Model Controls Container */
.model-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

/* Provider filter UI now integrated into dropdown via SharedModelSelector */

/* Wave 5C: revising placeholder shown when the server retracts
   pre-tool prose via the `revising` SSE event. The next streaming
   chunk replaces this with the post-tool synthesis. */
.revising-placeholder {
    color: var(--text-secondary);
    opacity: 0.75;
    font-style: italic;
}

.thinking-bubble {
    margin: 0 0 0.75rem 0;
    border: 1px solid rgba(96, 165, 250, 0.28);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.28);
    color: var(--text-secondary);
}

.thinking-bubble summary {
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-color);
    user-select: none;
}

.thinking-bubble-content {
    border-top: 1px solid rgba(96, 165, 250, 0.18);
    padding: 0.65rem 0.75rem 0.75rem;
    font-size: 0.84rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* Thinking Indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-color);
    animation: thinking-bounce 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes thinking-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Memory list */
.memory-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.memory-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.memory-item .type-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-tertiary);
}

/* Sovereignty Panel */
.export-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary.active {
    background: var(--accent-color);
    color: white;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.feature-filter-btn.active {
    background: var(--accent-color) !important;
    color: white !important;
    border-color: var(--accent-color) !important;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 0.75rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Layout helpers ─── */
.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.row-center {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.row-flex {
    display: flex;
    gap: 0.5rem;
}
.row-gap-sm { gap: 0.25rem; }
.row-gap-lg { gap: 0.75rem; }
.row-wrap   { flex-wrap: wrap; }

.section-divider {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.chart-canvas-wrap {
    position: relative;
    height: 250px;
}

.scroll-y-md { max-height: 250px; overflow-y: auto; }
.scroll-y-lg { max-height: 300px; overflow-y: auto; }

.empty-state {
    color: var(--text-secondary);
    padding: 1rem;
    text-align: center;
}

.card-heading {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
}

.heading-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: normal;
}

.callout {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ─── Spacing utilities ─── */
.m-0    { margin: 0; }
.mb-0   { margin-bottom: 0; }
.mb-1   { margin-bottom: 0.5rem; }
.mb-2   { margin-bottom: 0.75rem; }
.mb-3   { margin-bottom: 1rem; }
.mb-4   { margin-bottom: 1.5rem; }
.mb-5   { margin-bottom: 2rem; }
.mt-5   { margin-top: 2rem; }

/* ─── Text utilities ─── */
.text-muted    { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-xs       { font-size: 0.75rem; }
.text-sm       { font-size: 0.85rem; }
.text-md       { font-size: 0.875rem; }
.text-center   { text-align: center; }
.text-mono     { font-family: monospace; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .nav-tabs {
        overflow-x: auto;
    }
}

}
