/* ============================================================
   AI Agent Chat Widget — "Hermes"
   Floating bottom-right popup chat
   ============================================================ */

/* ---- Raised position: avoid overlapping footer bars (wizard, chat) ---- */
.agent-fab.agent-fab-raised {
  bottom: auto;
}
.agent-panel.agent-fab-raised {
  --agent-panel-bottom: 152px;
  bottom: var(--agent-panel-bottom);
  max-height: calc(
    100vh - var(--agent-panel-safe-top, 72px) - var(--agent-panel-bottom)
  );
}
.agent-fab-scraping-indicator.agent-fab-raised {
  bottom: 80px;
}

/* ---- Floating Action Button ---- */
.vigilia-agent-logo { display: inline-flex; width: 26px; height: 26px; flex: 0 0 26px; }
.vigilia-agent-logo img { width: 100%; height: 100%; object-fit: contain; }
html :is(.agent-fab, .agent-header-avatar, .hermes-avatar, .hermes-bubble-avatar) {
  background: #1F2429;
  color: #D9DDE2;
}
:is(.agent-fab, .agent-header-avatar, .hermes-avatar, .hermes-bubble-avatar) .product-light { display: none; }
:is(.agent-fab, .agent-header-avatar, .hermes-avatar, .hermes-bubble-avatar) .product-dark { display: block; }
html.dark :is(.agent-fab, .agent-header-avatar, .hermes-avatar, .hermes-bubble-avatar) .product-light { display: block; }
html.dark :is(.agent-fab, .agent-header-avatar, .hermes-avatar, .hermes-bubble-avatar) .product-dark { display: none; }

.agent-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xl), 0 0 0 0 rgba(24, 24, 27, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.agent-fab:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-xl), 0 0 0 8px rgba(24, 24, 27, 0.08);
}

.agent-fab:active {
  transform: scale(0.96);
}

.agent-fab svg {
  width: 26px;
  height: 26px;
  transition: transform 0.5s ease;
}

.agent-fab:not(.agent-command).open svg {
  transform: rotate(360deg);
}

/* WhatsApp has its own full-screen conversation workspace. Keep every global
   Hermes surface out of it without interrupting background scraper work. */
body.hermes-whatsapp-chat-open .agent-fab,
body.hermes-whatsapp-chat-open .agent-fab-scraping-indicator {
  pointer-events: auto;
}
body.hermes-whatsapp-chat-open:not(.hermes-global-agent-open) .agent-panel { display: none !important; }

/* Automatic court-update status attached to the Hermes button. */
.agent-fab-monitor-status {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 19px;
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--background, #fff);
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
}

.agent-fab-monitor-status > svg {
  width: 11px;
  height: 11px;
  transform: none !important;
}

.agent-fab-monitor-status.checking > svg {
  animation: fab-scraping-spin 0.8s linear infinite;
}

.agent-fab-monitor-status.ok { background: #16a34a; }
.agent-fab-monitor-status.waiting { background: #d97706; }
.agent-fab-monitor-status.error { background: #dc2626; }
.agent-fab-monitor-status.unavailable { background: #71717a; }

.agent-fab-monitor-tooltip {
  position: absolute;
  right: -4px;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: 300px;
  padding: 8px 10px;
  border: 1px solid var(--border, #d4d4d8);
  border-radius: 8px;
  background: var(--popover, #18181b);
  color: var(--popover-foreground, #fafafa);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.2));
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.agent-fab-monitor-status:hover .agent-fab-monitor-tooltip,
.agent-fab:focus-visible .agent-fab-monitor-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Unread badge */
.agent-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--destructive);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ---- Chat Panel ---- */
.agent-activity { display: none; }
.agent-activity-visible .agent-activity { display: flex; flex-direction: column; max-height: 220px; overflow: auto; border-bottom: 1px solid var(--border); }
.agent-activity h3 { font-size: 14px; margin: 0; padding: 16px; }
.agent-activity-list { margin: 0; padding: 0 16px 16px; list-style: none; overflow: auto; }
.agent-activity-empty { color: var(--muted-foreground); font-size: 13px; margin: 0; }
.agent-activity-row { display: grid; gap: 6px; padding: 12px 0; border-top: 1px solid var(--border); font-size: 13px; overflow-wrap: anywhere; }
.agent-activity-row span { color: var(--muted-foreground); font-size: 12px; }
.agent-activity-row[data-status="FAILED"] span { color: var(--destructive); }
.agent-activity-row[data-status="PROPOSED"] span { color: var(--foreground); }
.agent-fab::after { content: ''; position: absolute; inset: 3px; border-radius: 6px; border: 2px solid transparent; pointer-events: none; }
.agent-fab[data-activity="thinking"]::after,
.agent-fab[data-activity="speaking"]::after,
.agent-fab[data-activity="working"]::after,
.agent-fab[data-activity="scraping"]::after { border-color: var(--brand); animation: agent-dock-working 1.6s ease-in-out infinite; }
.agent-fab[data-activity="speaking"]::after { animation-duration: 2.4s; }
.agent-fab[data-activity="scraping"]::after { border-bottom-color: var(--brand-light); }
.agent-fab[data-activity="waiting"]::after { border-color: var(--brand-light); }
@keyframes agent-activity-orbit { to { transform: rotate(360deg); } }
body.agent-workspace-open .agent-fab,
body.agent-workspace-open .agent-fab-scraping-indicator { display: none; }
.dashboard-main.agent-workspace-active { padding: 0; overflow: hidden; gap: 0; }
#agent-workspace-content { flex: 1; min-width: 0; min-height: 0; height: 100%; container-type: inline-size; }
#agent-workspace-content .agent-workspace-panel {
  position: relative; inset: auto; width: 100%; height: 100%; max-height: none;
  border: 0; border-radius: 0; box-shadow: none; transform: none; opacity: 1;
  display: grid; grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr) auto; transition: none;
  background: var(--background); pointer-events: auto;
}
.agent-workspace-panel > .agent-header { grid-column: 2; grid-row: 1; border-bottom: 1px solid var(--border); padding: 12px 20px; }
.agent-workspace-panel > .agent-sessions { position: relative; inset: auto; grid-column: 1; grid-row: 1 / 4; transform: none; border-right: 1px solid var(--border); min-height: 0; transition: none; }
.agent-workspace-panel .agent-sessions-header { min-height: 64px; box-sizing: border-box; padding: 12px; }
.agent-workspace-panel .agent-sessions-header h3 { font-size: 14px; }
.agent-workspace-panel > .agent-messages { grid-column: 2; grid-row: 2; min-width: 0; padding: 24px max(20px, calc((100% - 760px) / 2)); overflow: auto; }
.agent-workspace-panel > .agent-input-area { grid-column: 2; grid-row: 3; min-width: 0; padding: 16px max(20px, calc((100% - 760px) / 2)); background: var(--background); }
.agent-workspace-panel > .agent-activity { display: none; }
.agent-workspace-panel.agent-has-actions > .agent-activity { display: block; position: absolute; right: 20px; top: 88px; width: 192px; max-height: calc(100% - 220px); border: 0; background: transparent; overflow: auto; }
.agent-workspace-panel .agent-activity h3 { padding: 0 0 8px; }
.agent-workspace-panel .agent-activity-list { padding: 0; }
.agent-reversal-controls { display: flex; gap: 4px; }
.agent-header-btn:disabled { opacity: .45; cursor: not-allowed; }
#agent-workspace-content .agent-workspace-panel.browser-active { grid-template-rows: 64px auto minmax(0, 1fr) auto; }
.agent-workspace-panel.browser-active > .agent-browser-viewport { grid-column: 2; grid-row: 2; min-width: 0; }
.agent-workspace-panel.browser-active > .agent-browser-viewport .agent-browser-frame { height: min(30vh, 280px); min-height: 0; }
.agent-workspace-panel.browser-active > .agent-browser-viewport.minimized .agent-browser-frame { height: 0; }
.agent-workspace-panel.browser-active > .agent-messages { grid-row: 3; min-height: 0; }
.agent-workspace-panel.browser-active > .agent-input-area { grid-row: 4; }
.agent-workspace-panel.browser-active > .agent-activity { grid-row: 2 / 5; }
.agent-workspace-panel.browser-active > .agent-sessions { grid-row: 1 / 5; }
.agent-workspace-panel .agent-msg-bubble { overflow-wrap: anywhere; }
.agent-workspace-panel .agent-header-btn[data-action="close"],
.agent-workspace-panel .agent-header-btn[data-action="close-sessions"] { display: none; }
@media (min-width: 641px) {
  .agent-workspace-panel .agent-header-btn[data-action="history"] { display: none; }
}
@media (min-width: 1181px) {
  .agent-workspace-panel .agent-header-btn[data-action="activity"] { display: none; }
}
.agent-panel .agent-header-btn { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 6px; }
.agent-panel .agent-header-actions { gap: 4px; }
.agent-panel .agent-header-title { font-size: 14px; }
.agent-panel:not(.agent-workspace-panel) { width: min(560px, calc(100vw - 16px)); border-radius: 8px; }
.agent-panel button:focus-visible,
.agent-session-title:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.agent-panel .agent-input { min-width: 0; }
.agent-panel [data-action="activity"] { display: none; }
.agent-workspace-panel .agent-msg.assistant { max-width: 100%; }
.agent-workspace-panel .agent-msg.assistant .agent-msg-bubble { background: transparent; padding-inline: 0; font-size: 15px; line-height: 1.65; }
.agent-msg-bubble blockquote { margin: 12px 0; padding: 4px 16px; border-left: 1px solid var(--border); color: var(--muted-foreground); }
.agent-msg-bubble a { color: var(--primary); text-decoration: underline; overflow-wrap: anywhere; }
.agent-msg-bubble table { display: block; max-width: 100%; overflow-x: auto; }
@container (max-width: 1460px) {
  #agent-workspace-content .agent-workspace-panel { grid-template-columns: 200px minmax(0, 1fr); }
  .agent-workspace-panel > .agent-header { grid-column: 2; }
  .agent-workspace-panel.agent-has-actions > .agent-activity { position: static; grid-column: 2; grid-row: 2; width: auto; max-height: 160px; margin: 12px 20px; }
  #agent-workspace-content .agent-workspace-panel.agent-has-actions { grid-template-rows: 64px auto minmax(0, 1fr) auto; }
  .agent-workspace-panel.agent-has-actions > .agent-messages { grid-row: 3; }
  .agent-workspace-panel.agent-has-actions > .agent-input-area { grid-row: 4; }
  #agent-workspace-content .agent-workspace-panel.agent-has-actions.browser-active { grid-template-rows: 64px auto auto minmax(0, 1fr) auto; }
  .agent-workspace-panel.agent-has-actions.browser-active > .agent-activity { grid-row: 3; }
  .agent-workspace-panel.agent-has-actions.browser-active > .agent-messages { grid-row: 4; }
  .agent-workspace-panel.agent-has-actions.browser-active > .agent-input-area { grid-row: 5; }
  .agent-workspace-panel.agent-has-actions > .agent-sessions { grid-row: 1 / -1; }
}
@media (max-width: 640px) {
  #agent-workspace-content .agent-workspace-panel { grid-template-columns: minmax(0, 1fr); }
  .agent-workspace-panel > .agent-header,
  .agent-workspace-panel > .agent-input-area,
  .agent-workspace-panel > .agent-messages { grid-column: 1; padding-inline: 12px; }
  .agent-workspace-panel.agent-has-actions > .agent-activity { grid-column: 1; margin-inline: 12px; }
  .agent-workspace-panel.browser-active > .agent-browser-viewport { grid-column: 1; }
  .agent-workspace-panel > .agent-sessions { display: none; }
  .agent-workspace-panel > .agent-sessions.visible { display: flex; position: absolute; grid-area: auto; inset: 64px 0 0; z-index: 5; }
  .agent-workspace-panel .agent-header-btn[data-action="close-sessions"] { display: flex; }
  .agent-panel .agent-header-info { min-width: 0; }
  .agent-panel .agent-header-subtitle { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .agent-panel .agent-header-avatar { display: none; }
}
:where(html[data-motion-reduced="true"]) {
  .agent-fab::after { animation: none !important; }
}
.agent-panel {
  --agent-panel-safe-top: 72px;
  --agent-panel-bottom: 96px;
  position: fixed;
  bottom: var(--agent-panel-bottom);
  right: 24px;
  z-index: 10000;
  width: 360px;
  height: 680px;
  /* Keep the sticky application header and its controls unobstructed. */
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, height 0.25s ease, max-height 0.25s ease;
}

.agent-panel.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---- Panel Header ---- */
.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.agent-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.agent-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.agent-header-avatar svg {
  width: 18px;
  height: 18px;
}

.agent-header-info {
  min-width: 0;
}

.agent-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-header-subtitle {
  font-size: 12px;
  color: var(--muted-foreground);
}

.agent-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-header-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  transition: background 0.15s, color 0.15s;
}

.agent-header-btn:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.agent-header-btn svg {
  width: 16px;
  height: 16px;
}

/* ---- Sessions Sidebar ---- */
.agent-project-navigation { padding: 8px; border-bottom: 1px solid var(--border); overflow-y: auto; flex: 0 1 auto; max-height: 40%; }
.agent-project-heading { display: flex; align-items: center; justify-content: space-between; padding: 8px; font-size: 12px; }
.agent-project-link { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; border: 0; border-radius: 6px; padding: 8px; background: transparent; color: var(--foreground); text-align: left; font: inherit; font-size: 13px; cursor: pointer; }
.agent-project-link:hover, .agent-project-link[aria-pressed="true"] { background: var(--secondary); }
.agent-project-link > span:not(:only-child) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-project-link small { margin-left: auto; font-size: 10px; color: var(--muted-foreground); }
.agent-project-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.agent-project-dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); margin: auto; box-sizing: border-box; border: 1px solid var(--border); border-radius: 8px; padding: 20px; background: var(--card); color: var(--foreground); overflow-y: auto; }
.agent-project-dialog::backdrop { background: rgb(0 0 0 / 55%); }
.agent-project-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.agent-project-dialog h3 { font-size: 18px; overflow-wrap: anywhere; margin: 0; }
.agent-project-dialog h4 { font-size: 14px; margin: 20px 0 12px; }
.agent-project-dialog label { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: 13px; }
.agent-project-dialog input:not([type="checkbox"]), .agent-project-dialog textarea, .agent-project-dialog select { width: 100%; box-sizing: border-box; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--background); color: var(--foreground); font: inherit; }
.agent-project-dialog input[type="file"]::file-selector-button { margin-right: 10px; border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; background: var(--secondary); color: var(--foreground); font: inherit; cursor: pointer; }
.agent-project-dialog input[type="file"]:not(:disabled) { opacity: 1; cursor: pointer; }
.agent-project-dialog textarea { resize: vertical; min-height: 120px; }
.agent-project-dialog .agent-action-btn { min-height: 36px; padding: 8px 12px; font-size: 13px; }
.agent-project-dialog .agent-action-btn:not(.agent-action-btn-confirm) { background: var(--secondary); color: var(--foreground); border: 1px solid var(--border); }
.agent-project-dialog label:has(input[type="checkbox"]) { flex-direction: row-reverse; justify-content: flex-end; align-items: flex-start; }
.agent-project-dialog input[type="checkbox"] { flex-shrink: 0; margin: 2px 4px 0 0; accent-color: var(--primary); }
.agent-project-dialog ul { list-style: none; padding: 0; }
.agent-project-dialog li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.agent-project-dialog li > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.agent-project-status { font-size: 13px; color: var(--muted-foreground); min-height: 20px; }
.agent-project-sharing { margin: 20px 0; border-top: 1px solid var(--border); padding-top: 16px; }
.agent-project-sharing summary { cursor: pointer; font-size: 14px; }
.agent-project-link:focus-visible, .agent-project-dialog :is(button,input,textarea,select,summary):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.agent-sessions {
  position: absolute;
  inset: 0;
  background: var(--card);
  z-index: 2;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.agent-filings {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  background: var(--card);
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.agent-filings.visible { transform: translateX(0); }
.agent-filing-toolbar { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.agent-filings-list { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.agent-filing-empty { padding: 28px 12px; text-align: center; color: var(--muted-foreground); font-size: 13px; }
.agent-filing-card { border: 1px solid var(--border); border-radius: 8px; padding: 11px; background: var(--background); }
.agent-filing-card-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.agent-filing-meta { margin-top: 6px; color: var(--muted-foreground); font-size: 11px; }
.agent-filing-status { padding: 2px 6px; border-radius: 4px; background: var(--secondary); white-space: nowrap; }
.agent-filing-error { color: var(--destructive); font-size: 12px; margin-top: 7px; }
.agent-filing-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.agent-filing-actions button,
.agent-filing-modal button { border: 1px solid var(--border); background: var(--card); color: var(--foreground); border-radius: 5px; padding: 6px 10px; cursor: pointer; }
.agent-filing-actions button.primary,
.agent-filing-modal button.primary { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }

.agent-filing-modal-overlay { position: fixed; inset: 0; z-index: 30000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.55); }
.agent-filing-modal { width: min(620px, 100%); max-height: 88vh; overflow-y: auto; padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--foreground); box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.agent-filing-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.agent-filing-modal-head h3 { margin: 0; font-size: 16px; }
.agent-filing-modal label { display: grid; gap: 5px; margin-bottom: 12px; font-size: 12px; font-weight: 600; }
.agent-filing-modal input,
.agent-filing-modal select { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 5px; padding: 8px; background: var(--background); color: var(--foreground); }
.agent-filing-modal .agent-filing-check { display: flex; flex-direction: row; align-items: center; font-weight: 400; }
.agent-filing-modal .agent-filing-check input { width: auto; }
.agent-filing-section-title { margin: 12px 0 8px; font-size: 12px; font-weight: 700; }
.agent-filing-document-row { display: grid; grid-template-columns: 1fr 1fr 30px; gap: 7px; margin-top: 7px; }
[data-documents] .agent-filing-document-row { grid-template-columns: 1fr 1fr; }
.agent-filing-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.agent-sessions.visible {
  transform: translateX(0);
}

.agent-sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.agent-sessions-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

.agent-sessions-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.agent-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.agent-session-item:hover {
  background: var(--secondary);
}

.agent-session-item.active {
  background: var(--secondary);
}

.agent-session-title {
  font-size: 13px;
  color: var(--foreground);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

.agent-session-date {
  font-size: 11px;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.agent-session-delete {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
  margin-left: 4px;
}

.agent-session-item:hover .agent-session-delete {
  opacity: 1;
}

.agent-session-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive);
}

.agent-session-delete svg {
  width: 14px;
  height: 14px;
}

.agent-sessions-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--muted-foreground);
  font-size: 13px;
}

/* ---- Messages Area ---- */
.agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.agent-messages::-webkit-scrollbar {
  width: 4px;
}

.agent-messages::-webkit-scrollbar-track {
  background: transparent;
}

.agent-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ---- Welcome State ---- */
.agent-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
}

.agent-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--foreground);
}

.agent-welcome-icon svg {
  width: 28px;
  height: 28px;
}

.agent-welcome h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--foreground);
}

.agent-welcome p {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.5;
  max-width: 280px;
}

.agent-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 300px;
  margin-top: 4px;
}

.agent-suggestion-btn {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--foreground);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.agent-suggestion-btn:hover {
  background: var(--secondary);
  border-color: var(--ring);
}

/* ---- Message Bubbles ---- */
.agent-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: agentMsgIn 0.2s ease;
}

@keyframes agentMsgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

:where(html[data-motion-reduced="true"]) {
  .agent-msg { animation: none; }
}

.agent-msg.user {
  align-self: flex-end;
}

.agent-msg.assistant {
  align-self: flex-start;
}

.agent-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.agent-msg.user .agent-msg-bubble {
  background: var(--primary);
  color: var(--primary-foreground);
  border-bottom-right-radius: 4px;
}

.agent-msg.assistant .agent-msg-bubble {
  background: var(--secondary);
  color: var(--foreground);
  border-bottom-left-radius: 4px;
}

/* Markdown inside assistant messages */
.agent-msg.assistant .agent-msg-bubble p {
  margin: 0 0 8px 0;
}

.agent-msg.assistant .agent-msg-bubble p:last-child {
  margin-bottom: 0;
}

.agent-msg.assistant .agent-msg-bubble strong {
  font-weight: 600;
}

.agent-msg.assistant .agent-msg-bubble em {
  font-style: italic;
}

.agent-msg.assistant .agent-msg-bubble code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.agent-msg.assistant .agent-msg-bubble pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.5;
}

.agent-msg.assistant .agent-msg-bubble pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.agent-msg.assistant .agent-msg-bubble ul,
.agent-msg.assistant .agent-msg-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.agent-msg.assistant .agent-msg-bubble li {
  margin: 2px 0;
}

.agent-msg.assistant .agent-msg-bubble h1,
.agent-msg.assistant .agent-msg-bubble h2,
.agent-msg.assistant .agent-msg-bubble h3,
.agent-msg.assistant .agent-msg-bubble h4 {
  margin: 10px 0 4px 0;
  font-weight: 600;
}

.agent-msg.assistant .agent-msg-bubble h1 { font-size: 16px; }
.agent-msg.assistant .agent-msg-bubble h2 { font-size: 15px; }
.agent-msg.assistant .agent-msg-bubble h3 { font-size: 14px; }
.agent-msg.assistant .agent-msg-bubble h4 { font-size: 13.5px; }

.agent-msg.assistant .agent-msg-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.agent-msg.assistant .agent-msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12.5px;
}

.agent-msg.assistant .agent-msg-bubble th,
.agent-msg.assistant .agent-msg-bubble td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: left;
}

.agent-msg.assistant .agent-msg-bubble th {
  background: rgba(0, 0, 0, 0.03);
  font-weight: 600;
}

.agent-msg-time {
  font-size: 10.5px;
  color: var(--muted-foreground);
  margin-top: 4px;
  padding: 0 4px;
}

.agent-msg.user .agent-msg-time {
  text-align: right;
}

/* ---- Tool Execution Indicator ---- */
.agent-tool-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--secondary);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted-foreground);
  align-self: flex-start;
  animation: agentMsgIn 0.2s ease;
}

.agent-tool-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: agentSpin 0.6s linear infinite;
}

@keyframes agentSpin {
  to { transform: rotate(360deg); }
}

.agent-tool-indicator.done {
  color: var(--success-color);
}

.agent-tool-indicator.done .agent-tool-spinner {
  border: none;
  animation: none;
}

.agent-tool-indicator.done .agent-tool-spinner::after {
  content: '✓';
  font-size: 12px;
  font-weight: 700;
}

/* ---- Typing Indicator ---- */
.agent-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: var(--secondary);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  animation: agentMsgIn 0.2s ease;
}

.agent-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--muted-foreground);
  border-radius: 50%;
  animation: agentBounce 1.4s ease-in-out infinite;
}

.agent-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.agent-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes agentBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---- Input Area ---- */
.agent-panel:has(.agent-composer-options) .agent-input-area { flex-wrap: wrap; align-items: flex-end; }
.agent-panel:has(.agent-composer-options) .agent-input-wrapper { flex: 1 1 72px; }
.agent-composer-options { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex: 0 0 auto; min-width: 0; }
.agent-composer-options .agent-experience-btn { width: 44px; height: 44px; }
.agent-input-area > .agent-experience-status { flex-basis: 100%; }
.agent-input-area > .agent-experience-status:empty { display: none; }
.agent-composer-options select { min-height: 32px; max-width: 180px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--foreground); padding: 4px 8px; font: inherit; font-size: 12px; }
.agent-panel .agent-composer-options select, dialog.agent-project-dialog select { appearance: auto; background-image: none; background-repeat: no-repeat; }
.agent-panel .agent-composer-options select { width: auto; min-width: 0; flex: 0 1 180px; }
.agent-experience-btn, .agent-message-more > summary { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0; padding: 6px; border: 0; border-radius: 6px; background: transparent; color: var(--muted-foreground); cursor: pointer; box-sizing: border-box; }
.agent-experience-btn:hover, .agent-experience-btn[aria-pressed="true"], .agent-message-more > summary:hover { background: var(--secondary); color: var(--foreground); }
.agent-experience-btn:disabled { opacity: .45; cursor: default; }
.agent-experience-btn[hidden], .agent-composer-options select[hidden] { display: none; }
.agent-message-queue[hidden] { display: none; }
.agent-message-queue { flex-basis: 100%; min-width: 0; max-height: 180px; overflow-y: auto; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.agent-queue-header, .agent-queue-row { display: flex; align-items: center; gap: 6px; }
.agent-queue-header { justify-content: space-between; font-size: 12px; color: var(--muted-foreground); }
.agent-queue-row textarea { flex: 1; min-width: 0; min-height: 36px; max-height: 90px; resize: vertical; box-sizing: border-box; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--foreground); font: inherit; font-size: 12px; }
.agent-queue-row + .agent-queue-row { margin-top: 4px; }
.agent-queue-row textarea:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.agent-experience-icon { display: block; width: 18px; height: 18px; background: currentColor; mask: var(--agent-icon) center / contain no-repeat; }
.agent-experience-btn:focus-visible, .agent-session-search:focus-visible, .agent-composer-options select:focus-visible, .agent-message-more > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.agent-message-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
.agent-message-more { display: flex; align-items: center; }
.agent-message-more > summary { list-style: none; }
.agent-message-more > summary::-webkit-details-marker { display: none; }
.agent-message-more[open] { border: 1px solid var(--border); border-radius: 6px; }
.agent-msg-bubble pre { position: relative; }
.agent-msg-bubble pre > .agent-experience-btn { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 1px solid #737373; background: #303030; color: #f5f5f5; }
.agent-msg-bubble pre > .agent-experience-btn:hover { background: #454545; color: #ffffff; }
.agent-msg-bubble pre > .agent-experience-btn:focus-visible { outline-color: #ffffff; }
.agent-msg-bubble pre:has(> .agent-experience-btn) { min-height: 44px; box-sizing: border-box; }
.agent-msg-bubble pre code { display: block; padding-right: 40px; }
.agent-record-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; }
.agent-record-links a { color: var(--foreground); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.agent-experience-status { color: var(--muted-foreground); font-size: 12px; overflow-wrap: anywhere; }
.agent-session-search { flex-shrink: 0; margin: 8px; width: calc(100% - 16px); max-width: calc(100% - 16px); min-width: 0; min-height: 36px; box-sizing: border-box; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--background); color: var(--foreground); font: inherit; font-size: 12px; }
.agent-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.agent-input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  min-width: 0;
  min-height: 44px;
}

.agent-input-wrapper:focus-within {
  border-color: transparent;
}

.agent-input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--secondary);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--foreground);
  resize: none;
  outline: none;
  padding: 11px 12px;
  margin: 0;
  min-height: 44px;
  height: 44px;
  box-sizing: border-box;
  max-height: 120px;
  line-height: 1.45;
  transition: border-color 0.15s;
}

.agent-input:focus {
  border-color: var(--ring);
}

.agent-input::placeholder {
  color: var(--muted-foreground);
}

.agent-send-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  margin: 0;
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.agent-send-btn:hover {
  opacity: 0.9;
}

.agent-send-btn:active {
  transform: scale(0.94);
}

.agent-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.agent-send-btn svg {
  width: 18px;
  height: 18px;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .agent-panel {
    --agent-panel-bottom: 72px;
    width: calc(100vw - 16px);
    height: calc(
      100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
    );
    max-height: calc(
      100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
    );
    bottom: var(--agent-panel-bottom);
    right: 8px;
    border-radius: 12px;
  }

  .agent-fab {
    bottom: 12px;
    right: 12px;
    width: 50px;
    height: 50px;
  }

  .agent-fab-scraping-indicator {
    right: 68px;
    bottom: 16px;
    max-width: 180px;
    font-size: 11px;
    padding: 5px 10px 5px 8px;
  }
}

/* ---- Error message ---- */
.agent-error {
  padding: 8px 12px;
  background: var(--destructive-foreground);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  color: var(--destructive);
  font-size: 12.5px;
  align-self: center;
  text-align: center;
  animation: agentMsgIn 0.2s ease;
}

/* ---- Action Confirmation Card ---- */
.agent-action-confirm {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  align-self: flex-start;
  max-width: 90%;
  animation: agentMsgIn 0.25s ease;
}

.agent-action-confirm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--foreground);
}

.agent-action-confirm-icon {
  font-size: 16px;
  line-height: 1;
}

.agent-action-confirm-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--background);
  border-radius: 8px;
  font-size: 12.5px;
}

.agent-action-field {
  display: flex;
  gap: 4px;
  line-height: 1.4;
}

.agent-action-field-label {
  color: var(--muted-foreground);
  font-weight: 500;
  white-space: nowrap;
}

.agent-action-field-value {
  color: var(--foreground);
  word-break: break-word;
}

.agent-action-confirm-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.agent-action-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.agent-action-btn:hover {
  opacity: 0.85;
}

.agent-action-btn:active {
  transform: scale(0.97);
}

.agent-action-btn-cancel {
  background: var(--muted);
  color: var(--muted-foreground);
}

.agent-action-btn-confirm {
  background: var(--primary);
  color: var(--primary-foreground, #fff);
}

.agent-action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5 !important;
}

.agent-action-confirm-resolved {
  border-color: transparent;
  padding: 10px 14px;
}

.agent-action-confirm-result {
  font-size: 13px;
  font-weight: 500;
}

.agent-action-confirm-result.success {
  color: var(--success-color, #22c55e);
}

.agent-action-confirm-result.cancelled {
  color: var(--muted-foreground);
}

.agent-action-confirm-result.error {
  color: var(--destructive);
}

/* ============================================================
   Embedded Browser Viewport (Electron desktop only)
   ============================================================ */

/* When the browser viewport is open, expand only into the space below
   the application header. The header buttons must remain clickable. */
.agent-panel.browser-active {
  height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
}

/* The raised variant supplies a larger --agent-panel-bottom above. */
.agent-panel.agent-fab-raised.browser-active {
  height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
}

/* When the browser is minimized inside an active viewport, shrink
   the panel back closer to its default height.                      */
.agent-panel.browser-active.browser-minimized {
  height: 680px;
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
}

.agent-panel.agent-fab-raised.browser-active.browser-minimized {
  height: 680px;
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
}

/* Ensure flex shrink works: messages must be able to collapse
   instead of overflowing behind the native overlay.              */
.agent-panel.browser-active .agent-messages {
  min-height: 120px;
}

/* Browser viewport container */
.agent-browser-viewport {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
  flex-shrink: 0;
  overflow: hidden;
}

/* Minimized browser: collapse frame, keep thin toolbar */
.agent-browser-viewport.minimized .agent-browser-frame {
  height: 0;
  min-height: 0;
  overflow: hidden;
}

.agent-browser-viewport.minimized .agent-browser-toolbar {
  min-height: 30px;
  padding: 4px 10px;
}

.agent-browser-viewport.minimized {
  border-bottom: 1px solid var(--border);
}

/* Toolbar with URL and controls */
.agent-browser-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  gap: 8px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}

.agent-browser-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.agent-browser-url {
  font-size: 11.5px;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'SFMono-Regular', 'Consolas', monospace;
}

.agent-browser-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: agentSpin 0.7s linear infinite;
  flex-shrink: 0;
}

.agent-browser-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-browser-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  transition: background 0.15s, color 0.15s;
}

.agent-browser-btn:hover {
  background: var(--muted);
  color: var(--foreground);
}

.agent-browser-btn.active {
  background: var(--primary, #2563eb);
  color: #fff;
}

.agent-browser-btn svg {
  width: 14px;
  height: 14px;
}

/* The frame area where Electron overlays the WebContentsView */
.agent-browser-frame {
  position: relative;
  height: clamp(140px, 36vh, 340px);
  min-height: 100px;
  background: #f8f9fa;
  overflow: hidden;
}

.agent-browser-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.agent-browser-error {
  color: var(--destructive);
  font-size: 12.5px;
}

/* ============================================================
   Captcha Overlay (full-screen modal for solving captchas)
   ============================================================ */
.agent-captcha-overlay {
  position: fixed;
  inset: 0;
  z-index: 10002;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.agent-captcha-card {
  width: calc(100vw - 60px);
  max-width: 1300px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
}

.agent-captcha-banner {
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-captcha-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.agent-captcha-icon svg {
  width: 18px;
  height: 18px;
  color: var(--warning-color, #f59e0b);
}

.agent-captcha-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
}

.agent-captcha-subtitle {
  font-size: 13px;
  color: var(--muted-foreground);
  margin: 2px 0 0;
}

.agent-captcha-frame {
  width: 100%;
  height: 600px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 16px 16px;
  position: relative;
  /* Let clicks pass through to the native WebContentsView behind this DOM element */
  pointer-events: none;
}

/* Screenshot inserted in chat */
.agent-browser-screenshot {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.agent-browser-screenshot:hover {
  opacity: 0.9;
}

/* Scraper step indicators in chat */
.agent-tool-indicator.scraper-step {
  border-left: 3px solid var(--accent, #52606D);
}

/* Responsive adjustments for browser viewport */
@media (max-width: 480px) {
  .agent-browser-frame {
    height: 160px;
    min-height: 100px;
  }
}

/* ---- Scraping Activity Indicator (beside FAB) ---- */
.agent-fab-scraping-indicator {
  position: fixed;
  bottom: 24px;
  right: 80px;
  z-index: 10001;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
  min-height: 26px;
  padding: 3px 8px;
  box-sizing: border-box;
  background: #172033;
  border: 1px solid #6478d8;
  border-radius: 999px;
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(18px) saturate(165%);
  backdrop-filter: blur(18px) saturate(165%);
  font-size: 11px;
  font-weight: 600;
  color: #f8fafc;
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  cursor: default;
  transition: max-width 0.18s ease, box-shadow 0.18s ease;
  animation: fab-scraping-fadein 0.3s ease;
}

.agent-fab-scraping-indicator:hover,
.agent-fab-scraping-indicator:focus-within {
  max-width: 350px;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

@keyframes fab-scraping-fadein {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.fab-scraping-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(199, 210, 254, 0.46);
  border-top-color: #a5b4fc;
  border-radius: 50%;
  animation: fab-scraping-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.fab-scraping-spinner.done {
  border: none;
  animation: none;
}
.fab-scraping-spinner.done::after {
  content: '✓';
  font-size: 11px;
  font-weight: 700;
  color: #16a34a;
}

.fab-scraping-spinner.error {
  border: none;
  animation: none;
}
.fab-scraping-spinner.error::after {
  content: '✗';
  font-size: 11px;
  font-weight: 700;
  color: #dc2626;
}

@keyframes fab-scraping-spin {
  to { transform: rotate(360deg); }
}

.fab-scraping-label {
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fab-scraping-count {
  min-width: 37px;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  font-weight: 700;
}

.fab-scraping-details {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  max-width: 0;
  margin-left: 0;
  padding-left: 0;
  border-left: 1px solid transparent;
  overflow: hidden;
  opacity: 0;
  transition:
    max-width 0.18s ease,
    margin-left 0.18s ease,
    padding-left 0.18s ease,
    opacity 0.12s ease;
}

.agent-fab-scraping-indicator:hover .fab-scraping-details,
.agent-fab-scraping-indicator:focus-within .fab-scraping-details {
  max-width: 330px;
  margin-left: 4px;
  padding-left: 8px;
  border-left-color: rgba(199, 210, 254, 0.28);
  opacity: 1;
}

@media (max-width: 480px) {
  .agent-fab-scraping-indicator:hover,
  .agent-fab-scraping-indicator:focus-within {
    max-width: calc(100vw - 92px);
  }

  .agent-fab-scraping-indicator:hover .fab-scraping-details,
  .agent-fab-scraping-indicator:focus-within .fab-scraping-details {
    max-width: 150px;
  }
}

/* Header launcher and anchored popover never reserve page-content space. */
body > header .agent-fab.agent-header-launcher {
  position: relative; inset: auto; transform: none; flex: 0 0 168px;
  width: 168px; height: 36px; min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: transparent;
  color: var(--foreground); box-shadow: none; display: inline-flex; flex-direction: row;
  justify-content: flex-start; gap: 8px; -webkit-app-region: no-drag;
  transition: background-color .15s ease;
}
body > header .agent-header-launcher:hover,
body > header .agent-header-launcher[aria-expanded="true"] { transform: none; background: var(--secondary); box-shadow: none; }
body > header .agent-header-launcher::after { content: none; }
.agent-header-launcher .vigilia-agent-logo { width: 20px; height: 20px; flex-shrink: 0; }
.agent-header-launcher .agent-dock-name { font-size: 12px; line-height: 1; }
.agent-header-launcher .agent-dock-state { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--muted-foreground); }
.agent-header-launcher[data-activity="idle"] .agent-dock-state { visibility: hidden; }
.agent-header-launcher:is([data-activity="thinking"],[data-activity="speaking"],[data-activity="working"],[data-activity="scraping"]) .vigilia-agent-logo { animation: agent-header-working 1.6s ease-in-out infinite; }
body > header .agent-header-launcher[data-activity="scraping"] { border-color: var(--primary); overflow: hidden; }
.agent-header-launcher[data-activity="scraping"] .agent-dock-state { color: var(--foreground); }
body > header .agent-header-launcher[data-activity="scraping"]::after {
  content: ''; position: absolute; bottom: 0; left: 0; top: auto; right: auto;
  width: 40%; height: 2px; border: 0; border-radius: 0; background: var(--primary);
  opacity: 1; animation: agent-header-sync 1.4s ease-in-out infinite;
  pointer-events: none;
}
.agent-header-launcher .agent-fab-monitor-status { display: none; }
.agent-header-launcher .agent-fab-monitor-status:is(.error,.waiting),
.agent-header-launcher[data-activity="waiting"] .agent-fab-monitor-status { display: block; position: absolute; top: 3px; right: 3px; left: auto; width: 6px; height: 6px; min-width: 0; border: 0; border-radius: 50%; background: var(--warning-color, #f59e0b); box-shadow: none; }
.agent-header-launcher[data-activity="error"] .agent-fab-monitor-status { display: block; position: absolute; top: 3px; right: 3px; left: auto; width: 6px; height: 6px; min-width: 0; border: 0; border-radius: 50%; background: var(--destructive); box-shadow: none; }
.agent-header-launcher .agent-fab-monitor-status > svg { display: none; }
.agent-header-launcher .agent-fab-monitor-tooltip { display: none; }
.agent-header-launcher:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.agent-panel:not(.agent-workspace-panel) {
  top: var(--agent-popover-top, 64px); right: var(--agent-popover-right, 12px); bottom: auto;
  width: min(560px, calc(100vw - 16px)); height: min(760px, calc(100dvh - var(--agent-popover-top, 64px) - 8px));
  max-height: calc(100dvh - var(--agent-popover-top, 64px) - 8px); border-radius: 8px; transform-origin: top right;
}
.agent-fab-scraping-indicator { display: none !important; }
.agent-run-summary[hidden] { display: none; }
.agent-run-summary { flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 12px; }
.agent-run-summary strong { font-weight: 600; color: var(--foreground); }
.agent-run-summary span { color: var(--muted-foreground); overflow-wrap: anywhere; }
.agent-run-summary progress { appearance: none; width: 100%; height: 4px; border: 0; border-radius: 2px; background: var(--secondary); accent-color: var(--primary); }
.agent-run-summary progress::-webkit-progress-bar { background: var(--secondary); border-radius: 2px; }
.agent-run-summary progress::-webkit-progress-value { background: var(--primary); border-radius: 2px; }
.agent-run-summary progress::-moz-progress-bar { background: var(--primary); }
.agent-run-summary[data-state="error"] strong { color: var(--destructive); }
/* The workspace already has a header status; an auto-placed summary creates
   an implicit grid row and moves the composer whenever its text wraps. */
.agent-workspace-panel > .agent-run-summary { display: none; }
@keyframes agent-header-working { 50% { opacity: .55; transform: scale(.92); } }
@keyframes agent-header-sync { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(150%); } }
@keyframes agent-dock-working { 50% { opacity: .35; } }
@media (max-width: 900px) {
  body > header .agent-fab.agent-header-launcher { width: 36px; flex-basis: 36px; padding: 7px; }
  .agent-header-launcher .agent-dock-name, .agent-header-launcher .agent-dock-state { display: none; }
}
@media (max-width: 600px) {
  .agent-panel:not(.agent-workspace-panel) { right: 8px; left: 8px; width: auto; max-width: none; }
}
:where(html[data-motion-reduced="true"]) {
  .agent-header-launcher .vigilia-agent-logo { animation: none !important; }
  body > header .agent-header-launcher[data-activity="scraping"]::after { animation: none; width: 100%; }
}

/* One stable command surface for quick messages, live work and contextual results. */
body > header .agent-fab.agent-command {
  width: 300px; flex: 0 0 300px; padding: 3px; gap: 2px; overflow: visible;
  background: var(--background); border-color: var(--border); border-radius: 8px;
  transition: border-color 160ms ease, background-color 160ms ease;
}
body > header .agent-command:focus-within { border-color: var(--primary); }
body > header .agent-command :is(button,input) { -webkit-app-region: no-drag; app-region: no-drag; }
body > header .agent-command [hidden] { display: none !important; }
body > header .agent-command button {
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  height: 28px; min-height: 28px; min-width: 28px; border: 0; border-radius: 6px;
  background: transparent; color: var(--foreground); box-shadow: none; cursor: pointer;
}
body > header .agent-command button:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
body > header .agent-command button:hover { background: var(--secondary); }
body > header .agent-command .agent-command-input {
  width: 0; flex: 1 1 0; min-width: 0; height: 28px; padding: 0 5px; margin: 0;
  border: 0; outline: none; border-radius: 0; box-shadow: none; background: transparent;
  font: inherit; font-size: 12px; line-height: 28px; color: var(--foreground);
}
.agent-command-input::placeholder { color: var(--muted-foreground); opacity: 1; }
body > header .agent-command .agent-command-send { flex: 0 0 28px; color: var(--primary); }
body > header .agent-command .agent-command-send:disabled { color: var(--muted-foreground); opacity: .55; cursor: default; }
body > header .agent-command .agent-command-status { flex: 1; min-width: 0; gap: 8px; padding: 0 5px; justify-content: space-between; font-size: 12px; }
.agent-command-status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.agent-command-state-icon { display: flex; flex: 0 0 14px; color: var(--primary); }
.agent-command-state-icon svg { width: 14px; height: 14px; }
.agent-command:is([data-activity="thinking"],[data-activity="working"],[data-activity="speaking"],[data-activity="scraping"]) .agent-command-state-icon { animation: nav-btn-spin 1.4s linear infinite; }
body > header .agent-command:is([data-activity="thinking"],[data-activity="working"],[data-activity="speaking"],[data-activity="scraping"]) { border-color: var(--primary); }
body > header .agent-command[data-activity="scraping"]::after { content: none; }
.agent-command[data-activity="done"] .agent-command-state-icon { color: var(--success-color); }
.agent-command[data-activity="error"] .agent-command-state-icon { color: var(--destructive); }
.agent-command-preview {
  position: absolute; top: calc(100% + 10px); right: 0; width: min(360px,calc(100vw - 24px));
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--foreground);
  box-shadow: var(--shadow-md); z-index: 10; pointer-events: none;
  font-size: 12px; line-height: 1.5; text-align: left; white-space: normal; overflow-wrap: anywhere;
  visibility: hidden; opacity: 0; transform: translateY(-4px);
  transition: opacity 140ms ease, transform 180ms cubic-bezier(.16,1,.3,1), visibility 140ms;
}
.agent-command-preview strong { font-size: 12px; font-weight: 600; }
.agent-command-preview span { color: var(--muted-foreground); }
.agent-command:not(.open,.preview-dismissed):is(:hover,:focus-within) .agent-command-preview { visibility: visible; opacity: 1; transform: none; }
body > header #eproc-check-btn {
  width: 148px; min-width: 148px; height: 36px; padding: 0 10px; gap: 8px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--foreground); justify-content: flex-start;
  transition: border-color 160ms ease, background-color 160ms ease;
}
body > header #eproc-check-btn:is(:hover,:focus-visible) { width: 148px; background: var(--secondary); }
body > header #eproc-check-btn .nav-command-label { display: block; min-width: 0; opacity: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
body > header #eproc-check-btn.nav-icon-btn--loading { border-color: var(--primary); color: var(--foreground); background: var(--background); }
body > header #eproc-check-btn[data-check-state="success"] { color: var(--success-color); }
body > header #eproc-check-btn[data-check-state="attention"] { color: var(--warning-color); }
body > header #eproc-check-btn[data-check-state="error"] { color: var(--destructive); }
@media (max-width: 1100px) {
  body > header .agent-fab.agent-command { width: 240px; flex-basis: 240px; }
  body > header #eproc-check-btn, body > header #eproc-check-btn:is(:hover,:focus-visible) { width: 36px; min-width: 36px; padding: 0 9px; }
  body > header #eproc-check-btn .nav-command-label { display: none; }
}
@media (max-width: 640px) {
  body > header .agent-fab.agent-command { width: max(128px,calc(100vw - 190px)); flex-basis: max(128px,calc(100vw - 190px)); }
  .agent-command-preview { position: fixed; top: 62px; right: 12px; }
  body > header .agent-command .vigilia-agent-logo { width: 18px; height: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .agent-command-state-icon, .agent-command .vigilia-agent-logo { animation: none !important; }
  .agent-command-preview { transition: none; transform: none; }
}
html[data-motion-reduced="true"] .agent-command-state-icon { animation: none; }
html[data-motion-reduced="true"] .agent-command-preview { transition: none; transform: none; }

/* Compact, consistently sized controls with persistent working indicators. */
body > header .agent-command button svg { width: 16px; height: 16px; flex: none; transition: none; }
body > header .agent-command .agent-command-send:not(:disabled) { background: var(--primary); color: var(--primary-foreground); }
body > header .agent-command .agent-command-send:not(:disabled):hover { filter: brightness(.95); }
.agent-command-preview { box-sizing: border-box; width: 100%; max-height: min(240px, 50vh); overflow: hidden; }
.agent-command-preview span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.agent-panel:not(.agent-workspace-panel) { position: fixed; bottom: auto; width: min(560px, calc(100vw - 16px)); }
.agent-panel.agent-fab-raised:not(.agent-workspace-panel) { bottom: auto; max-height: calc(100dvh - var(--agent-popover-top, 64px) - 8px); }
body > header #eproc-check-btn { width: 36px; min-width: 36px; padding: 0 9px; overflow: hidden; opacity: 1; flex-shrink: 0; transition: width 260ms cubic-bezier(.16,1,.3,1), background-color 160ms, border-color 160ms; }
body > header #eproc-check-btn .nav-command-label { opacity: 0; max-width: 0; transition: opacity 160ms, max-width 260ms cubic-bezier(.16,1,.3,1); }
@media (min-width: 1101px) {
  body > header #eproc-check-btn:is(:hover,:focus-visible,.nav-icon-btn--loading) { width: 208px; }
  body > header #eproc-check-btn:is(:hover,:focus-visible,.nav-icon-btn--loading) .nav-command-label { max-width: 170px; opacity: 1; }
}
@keyframes guto-busy-spin { to { rotate: 360deg; } }
body > header #eproc-check-btn.nav-icon-btn--loading > svg,
body > header .agent-command:is([data-activity="thinking"],[data-activity="working"],[data-activity="speaking"],[data-activity="scraping"]) .agent-command-state-icon { animation: guto-busy-spin 1s linear infinite; transform-origin: center; }
@media (max-width: 640px) {
  .agent-command-preview { width: calc(100vw - 24px); }
  body > header .agent-fab.agent-command { width: 36px; flex-basis: 36px; }
  body > header .agent-command :is(.agent-command-input,.agent-command-send,.agent-command-status-text) { display: none; }
  body > header .agent-command:not([data-activity="idle"]) .agent-command-open { display: none; }
  body > header .agent-command .agent-command-status { justify-content: center; padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  body > header #eproc-check-btn, body > header #eproc-check-btn .nav-command-label { transition: none; }
  body > header #eproc-check-btn.nav-icon-btn--loading > svg, body > header .agent-command .agent-command-state-icon { animation: none; }
}
html[data-motion-reduced="true"] body > header #eproc-check-btn,
html[data-motion-reduced="true"] body > header #eproc-check-btn .nav-command-label { transition: none; }
html[data-motion-reduced="true"] body > header #eproc-check-btn.nav-icon-btn--loading > svg,
html[data-motion-reduced="true"] body > header .agent-command .agent-command-state-icon { animation: none; }

/* Busy feedback is functional, including when Windows disables decorative motion. */
body > header .agent-command:is([data-activity="thinking"],[data-activity="working"],[data-activity="speaking"],[data-activity="scraping"]) .agent-command-state-icon,
body > header #eproc-check-btn.nav-icon-btn--loading > svg {
  animation: guto-busy-spin 1s linear infinite !important;
  transform-origin: center;
}
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion-reduced="false"]) body > header .agent-command .agent-command-state-icon,
  html:not([data-motion-reduced="false"]) body > header #eproc-check-btn.nav-icon-btn--loading > svg { animation-duration: 4s !important; animation-timing-function: steps(4, end) !important; }
}
html[data-motion-reduced="true"] body > header .agent-command .agent-command-state-icon,
html[data-motion-reduced="true"] body > header #eproc-check-btn.nav-icon-btn--loading > svg { animation-duration: 4s !important; animation-timing-function: steps(4, end) !important; }
.fab-scraping-count[hidden] { display: none !important; }

/* The refresh command shares the message surface, not a second status pill. */
body > header .agent-command #eproc-check-btn,
body > header .agent-command #eproc-check-btn:is(:hover,:focus-visible,.nav-icon-btn--loading) {
  width: 28px; min-width: 28px; height: 28px; min-height: 28px; flex: 0 0 28px;
  margin-left: 4px; padding: 0; border: 0; border-left: 1px solid var(--border);
  border-radius: 0 5px 5px 0; background: transparent; color: var(--primary);
  justify-content: center; transition: color 160ms ease, background-color 160ms ease;
  pointer-events: auto;
}
body > header .agent-command #eproc-check-btn:hover { color: var(--primary); background: var(--secondary); }
body > header .agent-command #eproc-check-btn:disabled { cursor: wait; opacity: .55; }
body > header .agent-command #eproc-check-btn .nav-command-label { display: none; }
.agent-command:has(#eproc-check-btn:is(:hover,:focus-visible)) .agent-command-preview { visibility: hidden; opacity: 0; }
body > header .agent-command #eproc-check-btn.nav-icon-btn--loading > svg { animation: guto-busy-spin 1s linear infinite !important; }
body > header .agent-command #eproc-check-btn[data-check-state="success"] { color: var(--success-color); }
body > header .agent-command #eproc-check-btn[data-check-state="error"] { color: var(--destructive); }
@media (max-width: 640px) {
  body > header .agent-fab.agent-command { width: 70px; flex-basis: 70px; }
  body > header .agent-command.agent-scraper-only .agent-command-open { display: flex; }
}
.agent-update-tooltip {
  position: absolute; top: calc(100% + 10px); right: 0; width: min(320px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 5px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--foreground);
  box-shadow: var(--shadow-md); font-size: 12px; line-height: 1.5; pointer-events: none;
  visibility: hidden; opacity: 0; transform: translateY(-3px); z-index: 11;
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
}
.agent-update-tooltip span { color: var(--muted-foreground); }
.agent-command:has(#eproc-check-btn:is(:hover,:focus-visible)) .agent-update-tooltip { visibility: visible; opacity: 1; transform: none; }
body > header .agent-command.agent-scraper-only { border-color: var(--border); }
body > header .agent-command.agent-scraper-only .vigilia-agent-logo { animation: none !important; }
/* Keep a useful conversation area and a fixed composer below native previews. */
.agent-panel:not(.agent-workspace-panel).browser-active > .agent-browser-viewport { flex: 0 1 auto; min-height: 30px; }
.agent-panel:not(.agent-workspace-panel).browser-active { height: min(820px, calc(100dvh - var(--agent-popover-top, 64px) - 8px)); }
.agent-panel:not(.agent-workspace-panel).browser-active > .agent-messages { min-height: 90px; flex: 1 1 0; }
.agent-panel:not(.agent-workspace-panel).browser-active > .agent-input-area { flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) {
  .agent-update-tooltip { transition: none; transform: none; }
  html:not([data-motion-reduced="false"]) body > header .agent-command #eproc-check-btn.nav-icon-btn--loading > svg { animation-duration: 4s !important; animation-timing-function: steps(4, end) !important; }
}
html[data-motion-reduced="true"] body > header .agent-command #eproc-check-btn.nav-icon-btn--loading > svg { animation-duration: 4s !important; animation-timing-function: steps(4, end) !important; }
.agent-msg-bubble .agent-local-action {
  min-height: 36px;
  padding: 8px 12px;
  color: var(--foreground);
  background: var(--secondary);
  border: 1px solid var(--border);
  text-align: left;
}
.agent-msg-bubble .agent-local-action:hover:not(:disabled) {
  background: var(--accent);
}
.agent-msg-bubble .agent-local-action:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
