/* ── Help AI chat ── */
.ed-chat {
    flex: 0 0 auto;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 42vh;
}
.ed-chat-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.ed-chat-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    flex-shrink: 0;
}
.ed-chat-model {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
}
.ed-chat-msgs {
    flex: 1 1 auto;
    min-height: 64px;
    max-height: 28vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}
.ed-chat-empty {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
    padding: 6px 0;
}
.ed-chat-msg {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    line-height: 1.4;
    word-break: break-word;
}

/* Shared Markdown body (AI chat: agent + editor) */
.md-body { line-height: 1.45; }
.md-body .md-p { margin: 0 0 6px; }
.md-body .md-p:last-child { margin-bottom: 0; }
.md-body .md-h { margin: 8px 0 4px; font-size: 1.05em; color: var(--text-primary, #e6edf3); font-weight: 700; }
.md-body .md-list { margin: 4px 0 6px; padding-left: 18px; }
.md-body .md-list li { margin: 2px 0; }
.md-body .md-quote {
    margin: 6px 0;
    padding: 4px 10px;
    border-left: 3px solid var(--accent, #5b7cfa);
    color: var(--text-muted, #8b949e);
    background: rgba(91, 124, 250, 0.08);
}
.md-body .md-hr { border: none; border-top: 1px solid var(--border-color, #1a2744); margin: 8px 0; }
.md-body .md-code-inline {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.92em;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color, #1a2744);
    border-radius: 4px;
    padding: 1px 5px;
    word-break: break-all;
}
.md-body pre.md-code {
    margin: 6px 0;
    padding: 8px 10px;
    background: #070b16;
    border: 1px solid var(--border-color, #1a2744);
    border-radius: var(--radius-sm, 6px);
    overflow: auto;
    max-height: 280px;
}
.md-body pre.md-code code {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 11.5px;
    color: #c9d1d9;
    white-space: pre;
}
.md-body .md-table-wrap { overflow-x: auto; margin: 6px 0; }
.md-body .md-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 12px;
}
.md-body .md-table th,
.md-body .md-table td {
    border: 1px solid var(--border-color, #1a2744);
    padding: 4px 8px;
    text-align: left;
    vertical-align: top;
}
.md-body .md-table th { background: rgba(255, 255, 255, 0.05); color: var(--text-primary, #e6edf3); font-weight: 600; }
.md-body a { color: var(--accent, #5b7cfa); }
.md-body strong { color: var(--text-primary, #e6edf3); }
.ed-chat-user {
    background: rgba(91, 124, 250, 0.12);
    border-color: rgba(91, 124, 250, 0.35);
    color: var(--text-primary);
}
.ed-chat-ai {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}
.ed-chat-code {
    margin-top: 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #070b16;
    overflow: hidden;
}
.ed-chat-code pre {
    margin: 0;
    padding: 8px;
    max-height: 160px;
    overflow: auto;
    font-size: 11px;
    font-family: Consolas, 'Courier New', monospace;
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
}
.ed-chat-code .ed-chat-apply {
    width: 100%;
    border-radius: 0;
    border-top: 1px solid var(--border-color);
}
.ed-chat-form {
    display: flex;
    gap: 6px;
    align-items: center;
}
.ed-chat-form input[type="text"] {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
}
.ed-chat-status {
    font-size: 10px;
    color: var(--text-muted);
    min-height: 12px;
}
.ed-chat-warn { color: var(--warning); }
.ed-chat-pending { font-size: 10px; font-weight: 700; background: rgba(210,153,34,0.16); color: #f0c674; border-radius: 20px; padding: 1px 8px; white-space: nowrap; }
.ed-chat-thinking { display: flex; gap: 5px; align-items: center; padding: 10px 12px; }
.ed-chat-thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: ed-think 1.2s ease-in-out infinite; }
.ed-chat-thinking span:nth-child(2) { animation-delay: 0.2s; }
.ed-chat-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ed-think { 0%, 60%, 100% { opacity: 0.25; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
.ed-diff { margin-top: 6px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: #070b16; overflow: hidden; }
.ed-diff-summary { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 6px 8px; font-size: 11px; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); }
.ed-diff-summary .n-del { color: var(--danger); font-weight: 700; }
.ed-diff-summary .n-add { color: var(--success); font-weight: 700; }
.ed-diff-summary .n-mod { color: var(--warning); font-weight: 700; }
.ed-diff-hhead { padding: 4px 8px; font-size: 10px; color: var(--text-muted); font-family: Consolas, 'Courier New', monospace; background: rgba(255,255,255,0.03); }
.ed-diff-line { display: flex; gap: 6px; align-items: baseline; padding: 1px 8px 1px 0; font-family: Consolas, 'Courier New', monospace; font-size: 11px; white-space: pre-wrap; word-break: break-word; border-left: 3px solid transparent; }
.ed-diff-ln { flex: 0 0 64px; text-align: right; color: var(--text-muted); opacity: 0.7; user-select: none; white-space: pre; }
.ed-diff-sign { flex: 0 0 12px; text-align: center; user-select: none; font-weight: 700; }
.ed-diff-line.ctx { color: #8b949e; }
.ed-diff-line.del { background: rgba(248,81,73,0.10); border-left-color: var(--danger); color: #ffb4ac; }
.ed-diff-line.del .ed-diff-sign { color: var(--danger); }
.ed-diff-line.add { background: rgba(63,185,80,0.10); border-left-color: var(--success); color: #9ee6a8; }
.ed-diff-line.add .ed-diff-sign { color: var(--success); }
.ed-diff-line.mod { background: rgba(210,153,34,0.13); border-left-color: var(--warning); color: #f0c674; }
.ed-diff-line.mod .ed-diff-sign { color: var(--warning); }
.ed-diff-actions { display: flex; gap: 6px; border-top: 1px solid var(--border-color); padding: 6px; }
.ed-diff-actions .btn { flex: 1; }
.ed-diff-note { padding: 6px 8px; font-size: 11px; color: var(--text-muted); }
.ed-diff-note.applied { color: var(--success); font-weight: 700; }
.ed-diff-legend { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.ed-diff-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.ed-diff-chip.del { background: rgba(248,81,73,0.14); color: #ff9d94; }
.ed-diff-chip.mod { background: rgba(210,153,34,0.16); color: #f0c674; }
.ed-diff-chip.add { background: rgba(63,185,80,0.14); color: #9ee6a8; }
.ed-diff-preview { max-height: 50vh; overflow: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: #070b16; padding: 6px 0; }

/* ── Per-server AI agent ── */
.agent-intro { color: var(--text-muted); font-size: 12px; margin: 0 0 10px; line-height: 1.5; }
.agent-msgs { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; padding-right: 4px; }
.agent-empty { color: var(--text-muted); font-size: 12px; padding: 8px 0; }
.agent-msg { padding: 6px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); line-height: 1.45; word-break: break-word; }
.agent-user { background: rgba(91, 124, 250, 0.12); border-color: rgba(91, 124, 250, 0.35); color: var(--text-primary); }
.agent-ai { background: rgba(255, 255, 255, 0.03); color: var(--text-secondary); }
.agent-calls { color: var(--accent); font-size: 11px; }
.agent-trace { color: var(--text-muted); font-size: 11px; font-family: Consolas, 'Courier New', monospace; padding: 1px 4px; opacity: 0.9; }
.agent-thinking { display: flex; gap: 5px; align-items: center; padding: 10px 12px; }
.agent-thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: ed-think 1.2s ease-in-out infinite; }
.agent-thinking span:nth-child(2) { animation-delay: 0.2s; }
.agent-thinking span:nth-child(3) { animation-delay: 0.4s; }
.agent-calls-only { padding: 4px 9px; font-size: 11px; background: transparent; border-style: dashed; }
.agent-status { font-size: 11px; color: var(--text-muted); min-height: 14px; margin: 6px 0; }
.agent-status:empty { display: none; }
.agent-warn { color: var(--warning); }
.agent-form { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.agent-form input[type="text"] { flex: 1; min-width: 0; font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); background: var(--bg-input); color: var(--text-primary); }
.agent-card { margin-top: 8px; border: 1px solid var(--warning); background: var(--warning-bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.agent-card-head { font-weight: 700; color: var(--warning); font-size: 12px; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.agent-card-line { font-size: 12px; margin: 2px 0; }
.agent-card-line code { font-size: 11px; }
.agent-card-line.muted { color: var(--text-muted); }
.agent-card-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.agent-mods-hint { font-size: 11px; color: var(--text-muted); margin: 6px 0 4px; }
.agent-mods { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow-y: auto; overflow-x: hidden; padding: 4px 2px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: rgba(0, 0, 0, 0.22); }
.agent-mod-row { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; font-size: 12px; padding: 8px 10px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.03); border: 1px solid transparent; cursor: pointer; color: var(--text-primary); line-height: 1.35; min-width: 0; width: 100%; box-sizing: border-box; }
.agent-mod-row:hover { border-color: var(--border-color); background: rgba(255, 255, 255, 0.06); }
.agent-mod-check { width: 16px !important; height: 16px !important; min-width: 16px; max-width: 16px; margin: 2px 0 0; padding: 0 !important; border: none !important; border-radius: 4px; background: transparent !important; box-shadow: none !important; accent-color: var(--accent); cursor: pointer; flex: 0 0 16px; align-self: flex-start; appearance: auto; -webkit-appearance: checkbox; font-size: inherit; transition: none; }
.agent-mod-check:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: transparent !important; box-shadow: none !important; }
.agent-mod-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; color: var(--text-primary); }
.agent-mod-title { font-weight: 600; color: var(--text-primary); word-break: break-word; }
.agent-mod-sub { font-size: 10px; color: var(--text-muted); word-break: break-all; line-height: 1.3; }
.agent-settled { font-size: 11px; padding: 4px 6px; border-radius: var(--radius-sm); margin-top: 4px; }
.agent-settled.ok { color: var(--success); }
.agent-settled.bad { color: var(--danger); }
.agent-settled.muted { color: var(--text-muted); }
.agent-action-hint { font-size: 11px; padding: 5px 8px; border-radius: var(--radius-sm); border: 2px solid #f0a030; background: rgba(240,160,48,0.10); color: #f0c674; margin-top: 6px; font-weight: 600; }

/* Loading / progress bar for AI install/download tasks */
.agent-progress { padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid rgba(91,124,250,0.25); background: rgba(91,124,250,0.08); margin-top: 4px; }
.agent-progress-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; }
.agent-progress-bar-fill { height: 100%; width: 30%; border-radius: 3px; background: linear-gradient(90deg, #5b7cfa, #8aa4ff); animation: agent-progress-fill 2.5s ease-in-out infinite alternate; }
@keyframes agent-progress-fill { from { width: 15%; } to { width: 85%; } }

/* Determinate fill: real job % — no oscillation, smooth transitions */
.agent-progress-bar-fill.determinate { animation: none; transition: width 0.5s ease; }
.agent-progress-bar-fill.determinate.failed { background: linear-gradient(90deg, #f07178, #f0a0a5); }
.agent-progress-sub { font-size: 10px; color: var(--text-muted); margin-top: 3px; word-break: break-word; }
.agent-progress.agent-failed { border-color: rgba(240,113,120,0.4); background: rgba(240,113,120,0.08); }

/* Purple "reply ready" state (AI processing/replying) */
.agent-ready { border-color: var(--accent); background: rgba(91,124,250,0.08); }

/* Green "completed/installation" state */
.agent-done { border-color: var(--success); background: rgba(45,212,160,0.08); }

/* Red "error" state (OpenRouter failures, provider errors) */
.agent-error { border-color: var(--danger); background: rgba(239,68,68,0.08); }
