/* ── Agent page ─────────────────────────────────────────────────────── */
.agent-wrap { max-width: 1100px; margin: 0 auto; }
.agent-history {
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 0; margin-bottom: 0;
}
.agent-history:empty::before { content: none; }
.agent-msg { display: flex; gap: 10px; align-items: flex-start; }
.agent-msg-avatar {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.agent-msg-user .agent-msg-avatar { background: var(--accent-btn); color: #fff; }
.agent-msg-assistant .agent-msg-avatar { background: rgba(91,141,238,.18); color: #5b8dee; }
.agent-msg-tool .agent-msg-avatar { background: rgba(180,180,180,.16); color: var(--muted-hi); font-size: 11px; }
.agent-msg-content {
  flex: 1; min-width: 0;
  font-size: 13.5px; line-height: 1.55; color: var(--text);
  background: var(--glass-input);
  border: 1px solid var(--border-dim); border-radius: 10px;
  padding: 10px 14px; word-wrap: break-word;
}
.agent-msg-user .agent-msg-content { background: rgba(91,141,238,.10); border-color: rgba(91,141,238,.25); }
.agent-msg-tool .agent-msg-content {
  background: var(--glass-dark); font-family: 'SF Mono', Menlo, monospace;
  font-size: 11.5px; color: var(--muted-hi);
  white-space: pre-wrap;
  max-height: 180px; overflow-y: auto;
}
.agent-msg-content h2,h3 { margin-top: 12px; margin-bottom: 4px; font-size: 14px; }
.agent-msg-content code { background: rgba(0,0,0,.18); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: 'SF Mono', Menlo, monospace; }
.agent-msg-content pre { background: rgba(0,0,0,.18); padding: 8px 10px; border-radius: 6px; font-size: 12px; overflow-x: auto; margin: 6px 0; }
.agent-input-wrap {
  display: flex; gap: 8px;
  background: transparent;
  border: none; border-radius: 0;
  padding: 4px 0;
}
#agent-history.streaming::after {
  content: ''; display: inline-block; width: 8px; height: 14px;
  background: var(--accent); margin-left: 4px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Per-agent block in the timeline */
.agent-block { transition: opacity .2s; }
.agent-block.finished { opacity: .92; }
.agent-msg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.agent-msg-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--muted-hi);
  padding: 0 0 2px 0;
}
.agent-block.agent-manager   .agent-msg-label { color: #a8b3c7; }
.agent-block.agent-audit     .agent-msg-label { color: #5b8dee; }
.agent-block.agent-speed      .agent-msg-label { color: #ff9500; }
.agent-block.agent-analytics  .agent-msg-label { color: #30d158; }
.agent-block.agent-benchmark  .agent-msg-label { color: #ffcc00; }
.agent-block.agent-copywriter .agent-msg-label { color: #f59e0b; }
.agent-block.agent-manager   .agent-msg-content { border-color: rgba(168,179,199,.30); }
.agent-block.agent-audit     .agent-msg-content { border-color: rgba(91,141,238,.30); background: rgba(91,141,238,.05); }
.agent-block.agent-speed      .agent-msg-content { border-color: rgba(255,149,0,.30);  background: rgba(255,149,0,.05); }
.agent-block.agent-analytics  .agent-msg-content { border-color: rgba(48,209,88,.30);   background: rgba(48,209,88,.05); }
.agent-block.agent-benchmark  .agent-msg-content { border-color: rgba(255,204,0,.30);   background: rgba(255,204,0,.05); }
.agent-block.agent-copywriter .agent-msg-content { border-color: rgba(245,158,11,.30);  background: rgba(245,158,11,.05); }

.agent-avatar-manager   { background: rgba(168,179,199,.18) !important; color: #a8b3c7 !important; }
.agent-avatar-audit     { background: rgba(91,141,238,.18) !important; color: #5b8dee !important; }
.agent-avatar-speed     { background: rgba(255,149,0,.18) !important; color: #ff9500 !important; }
.agent-avatar-analytics { background: rgba(48,209,88,.18) !important; color: #30d158 !important; }
.agent-avatar-benchmark { background: rgba(255,204,0,.18) !important; color: #ffcc00 !important; }

/* Tool rows inside an agent block */
.agent-tool-list { display: flex; flex-direction: column; gap: 2px; }
.agent-tool-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; font-size: 11.5px; line-height: 1.4;
  background: var(--glass-dark); border-radius: 6px;
}
.agent-tool-row .icon { font-size: 12px; flex-shrink: 0; }
.agent-tool-row .name { font-weight: 700; min-width: 110px; flex-shrink: 0; }
.agent-tool-row .args { color: var(--muted); flex: 1; min-width: 0; word-break: break-all; font-family: 'SF Mono', Menlo, monospace; font-size: 11px; }
.agent-tool-row .status { flex-shrink: 0; font-size: 11px; }
.agent-tool-row.running { border-left: 2px solid var(--accent); }
.agent-tool-row.running .status { color: #5b8dee; }
.agent-tool-row.running .status::before {
  content: ''; display: inline-block; width: 8px; height: 8px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; margin-right: 4px;
  animation: spin .8s linear infinite; vertical-align: -1px;
}
.agent-tool-row.done    { border-left: 2px solid #30d158; }
.agent-tool-row.done    .status { color: #30d158; }
.agent-tool-row.error   { border-left: 2px solid #ff453a; }
.agent-tool-row.error   .status { color: #ff453a; }
.agent-tool-row.has-preview { cursor: pointer; }
.agent-tool-row.has-preview:hover { background: var(--glass-input); }
.agent-tool-row.expanded .icon { transform: rotate(90deg); transition: transform .15s; }

.agent-tool-inspector {
  margin: 4px 0 6px 18px;
  padding: 8px 12px;
  background: rgba(0,0,0,.20);
  border-left: 2px solid var(--border-std);
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px; line-height: 1.45;
  color: var(--muted-hi);
  max-height: 280px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}

/* Session stats bar — live cost / tokens / timing */
.agent-session-stats {
  display: flex; gap: 14px; flex-wrap: wrap;
  padding: 8px 12px; margin-top: 8px;
  background: var(--glass-input); border: 1px solid var(--border-dim);
  border-radius: 8px;
  font-size: 11.5px; color: var(--muted-hi);
  font-variant-numeric: tabular-nums;
}
.agent-session-stats span { display: inline-flex; align-items: center; gap: 5px; }

/* ── Audit action panel (phase 1: error list + fix buttons) ── */
.audit-action-panel {
  margin: 10px 0 4px; padding: 14px 16px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-std);
  border-radius: 14px;
}
.audit-action-header {
  font-size: 11.5px; font-weight: 600; color: var(--muted-hi); margin-bottom: 10px;
}
.audit-errors-list {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
}
.audit-error-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 99px; cursor: pointer;
  font-size: 12px; font-weight: 500;
  background: rgba(255,69,58,.08); border: 1px solid rgba(255,69,58,.22);
  color: var(--text); transition: all .14s;
}
.audit-error-chip:hover { background: rgba(255,69,58,.18); border-color: rgba(255,69,58,.5); }
.audit-error-chip .aec-count { font-weight: 700; color: #ff6e62; }
.audit-action-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.audit-btn-all {
  flex: 1; min-width: 140px; padding: 9px 18px; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 600;
  background: linear-gradient(135deg, #30d158, #34d399);
  color: #0a1a0e; border: 0; transition: filter .14s;
}
.audit-btn-all:hover { filter: brightness(1.08); }

/* ── Audit done panel (phase 3: export / telegram / continue) ── */
.audit-done-panel {
  margin: 10px 0 4px; padding: 14px 16px;
  background: rgba(48,209,88,.05); border: 1px solid rgba(48,209,88,.2);
  border-radius: 14px;
}
.audit-done-header {
  font-size: 12px; font-weight: 600; color: #34d399; margin-bottom: 10px;
}
.audit-done-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.audit-done-btn {
  padding: 8px 14px; border-radius: 9px; cursor: pointer;
  font-size: 12px; font-weight: 600; border: 1px solid var(--border-std);
  background: var(--glass-input); color: var(--text); transition: all .14s;
  display: inline-flex; align-items: center; gap: 6px;
}
.audit-done-btn:hover { background: var(--glass-hover); border-color: var(--accent); }
.audit-done-btn.tg { border-color: rgba(41,182,246,.4); color: #29b6f6; }
.audit-done-btn.tg:hover { background: rgba(41,182,246,.1); }

/* Smart suggestions chips after agent finishes */
.agent-suggestions {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 12px 0; margin-top: 6px;
  border-top: 1px dashed var(--border-dim);
  align-items: center;
}
.agent-suggestions-label {
  font-size: 11px; color: var(--muted); flex-basis: 100%; margin-bottom: 2px;
}
.agent-suggestion-chip {
  background: var(--glass-input); border: 1px solid var(--border-std);
  border-radius: 14px; padding: 6px 12px;
  font-size: 12px; color: var(--text);
  cursor: pointer; transition: all .15s;
}
.agent-suggestion-chip:hover {
  background: rgba(91,141,238,.16); border-color: var(--accent); color: var(--text);
  transform: translateY(-1px);
}

/* Agent chat history list */
.agent-history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; margin-bottom: 4px;
  background: var(--glass-input); border: 1px solid var(--border-dim);
  border-radius: 8px; cursor: pointer;
  transition: all .15s;
}
.agent-history-item:hover { border-color: var(--accent); }
.agent-history-item.active { background: rgba(91,141,238,.12); border-color: var(--accent); }
.agent-history-item .ahi-title { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-history-item .ahi-meta  { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.agent-history-item .ahi-del   {
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
  background: transparent; border: none; color: var(--muted); cursor: pointer;
}
.agent-history-item .ahi-del:hover { color: #ff453a; background: rgba(255,69,58,.12); }

/* ── Multi-agent debate progress ────────────────────────────────────── */
.multi-progress {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 10px; padding: 8px 10px;
  background: var(--glass-input); border: 1px solid var(--border-dim);
  border-radius: 8px;
}
.multi-progress-step {
  font-size: 12px; padding: 4px 8px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 8px;
}
.multi-progress-step.pending { color: var(--muted); }
.multi-progress-step.active  { color: var(--text); background: rgba(91,141,238,.10); font-weight: 600; }
.multi-progress-step.done    { color: #30d158; }
.multi-progress-step.active::before {
  content: ''; display: inline-block; width: 10px; height: 10px;
  border: 2px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.multi-final {
  border-top: 1px solid var(--border-dim);
  padding-top: 10px; margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════
   AGENT PAGE — ChatGPT-style Design
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Sidebar (agent mode) ───────────────────────────────────────────── */
.sidebar--agent {
  background: rgba(8,8,12,0.98) !important;
  border-right: 1px solid rgba(255,255,255,0.06) !important;
}

/* ─── Sidebar (copywriter mode — Editor session history) ─────────────── */
.sidebar--copywriter {
  background: rgba(8,8,12,0.96) !important;
  border-right: 1px solid rgba(255,255,255,0.05) !important;
  padding: 18px 14px !important;
}
[data-theme="light"] .sidebar--copywriter {
  background: rgba(252,252,250,0.98) !important;
  border-right-color: rgba(0,0,0,0.06) !important;
}
.cw-sidebar-header {
  padding: 4px 4px 14px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 14px;
}
[data-theme="light"] .cw-sidebar-header {
  border-bottom-color: rgba(0,0,0,0.06);
}
.cw-sidebar-eyebrow {
  font-size: 9px; font-weight: 700; letter-spacing: 0.20em;
  text-transform: uppercase; color: rgba(245,158,11,0.60);
  margin-bottom: 4px;
}
.cw-sidebar-title {
  font-family: 'Georgia', 'Source Serif 4', 'Source Serif Pro', ui-serif, serif;
  font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
  color: rgba(255,255,255,0.94);
  line-height: 1.1;
}
[data-theme="light"] .cw-sidebar-title { color: rgba(0,0,0,0.92); }

.cw-sidebar-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0;
  scrollbar-width: thin; scrollbar-color: rgba(245,158,11,0.18) transparent;
  padding-right: 2px;
}
.cw-sidebar-list::-webkit-scrollbar { width: 3px; }
.cw-sidebar-list::-webkit-scrollbar-thumb { background: rgba(245,158,11,0.18); border-radius: 3px; }

.cw-sidebar-clear {
  margin-top: 14px; padding: 8px 10px;
  background: transparent; border: none;
  border-top: 1px solid rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.30);
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; cursor: pointer;
  transition: color .15s; text-align: left;
}
.cw-sidebar-clear:hover { color: #f87171; }
[data-theme="light"] .cw-sidebar-clear {
  border-top-color: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.35);
}

/* History items inside the sidebar — denser, refined */
.sidebar--copywriter .cw-history-item {
  padding: 10px 12px 10px 14px;
  margin: 0 -4px;
  border-left: 2px solid transparent;
  border-radius: 0;
  transition: background .15s, border-color .15s;
  cursor: pointer;
  position: relative;
}
.sidebar--copywriter .cw-history-item + .cw-history-item {
  border-top: 1px solid rgba(255,255,255,0.04);
}
.sidebar--copywriter .cw-history-item:hover {
  background: rgba(245,158,11,0.04);
  border-left-color: rgba(245,158,11,0.30);
}
.sidebar--copywriter .cw-history-item.active {
  background: rgba(245,158,11,0.08);
  border-left-color: #f59e0b;
}
.sidebar--copywriter .cw-history-domain {
  font-size: 12.5px; font-weight: 600;
  color: rgba(255,255,255,0.84);
  letter-spacing: -0.005em;
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
[data-theme="light"] .sidebar--copywriter .cw-history-domain { color: rgba(0,0,0,0.84); }
.sidebar--copywriter .cw-history-meta {
  display: flex; gap: 10px; align-items: center;
  font-size: 10px; color: rgba(255,255,255,0.32);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
[data-theme="light"] .sidebar--copywriter .cw-history-meta { color: rgba(0,0,0,0.40); }
.sidebar--copywriter .cw-history-meta span {
  display: inline-flex; gap: 3px; align-items: center;
}
.sidebar--copywriter .cw-history-empty {
  padding: 24px 12px;
  font-size: 11.5px; font-style: italic;
  color: rgba(255,255,255,0.26);
  line-height: 1.5;
  font-family: 'Georgia', ui-serif, serif;
}
[data-theme="light"] .sidebar--copywriter .cw-history-empty {
  color: rgba(0,0,0,0.40);
}
#agent-sidebar-new {
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid rgba(255,255,255,0.10) !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
  color: rgba(255,255,255,0.85) !important;
  transition: background 0.15s, border-color 0.15s !important;
}
#agent-sidebar-new:hover { background: rgba(255,255,255,0.10) !important; }
.agent-sidebar-item {
  padding: 8px 12px !important; border-radius: 8px !important;
  font-size: 12.5px !important; color: rgba(255,255,255,0.55) !important;
  transition: all 0.14s !important; border: 1px solid transparent;
}
.agent-sidebar-item:hover { background: rgba(255,255,255,0.06) !important; color: rgba(255,255,255,0.85) !important; }
.agent-sidebar-item.active {
  background: rgba(255,255,255,0.09) !important;
  color: rgba(255,255,255,0.95) !important;
}

