/* ═══ Autowhat Copilot — docked left panel in the app shell (not a floating popup) ═══ */

.copilot-dock { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.copilot-resize-handle {
  position: absolute; left: 0; top: 0; bottom: 0; width: 7px; margin-left: -3px;
  cursor: col-resize; z-index: 12; touch-action: none;
}
.copilot-resize-handle::after {
  content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 1px;
  background: transparent; transition: background .15s ease, box-shadow .15s ease;
}
.copilot-resize-handle:hover::after,
.copilot-resize-handle.active::after {
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
@media (max-width: 768px) {
  .copilot-resize-handle { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 7px; margin: 0; cursor: row-resize; }
  .copilot-resize-handle::after { left: 0; right: 0; top: 3px; bottom: auto; width: auto; height: 1px; }
  .app.shell.copilot-open { grid-template-rows: 48px var(--copilot-height, min(38vh, 420px)) minmax(0, 1fr); }
}

.copilot-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7c3aed));
  box-shadow: 0 6px 14px rgba(16, 24, 40, .22), 0 14px 34px rgba(58, 85, 199, .35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.copilot-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 20px rgba(16, 24, 40, .26), 0 18px 44px rgba(58, 85, 199, .42); }
.copilot-fab:active { transform: scale(.97); }
.copilot-fab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.copilot-fab::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--good); border: 2px solid #fff;
}
/* Fallback when #copilot-mount is missing (tests / legacy) */
body:not(:has(#copilot-mount)) .copilot-fab { display: grid; }
#copilot-mount ~ .copilot-fab, .app.shell .copilot-fab { display: none !important; }

.copilot {
  flex: 1; min-height: 0; min-width: 0; width: 100%;
  display: flex; flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}
/* Legacy floating panel (no dock mount) */
body:not(:has(#copilot-mount)) .copilot {
  position: fixed; right: 20px; bottom: 82px; z-index: 79;
  width: min(400px, calc(100vw - 24px)); height: min(600px, calc(100vh - 110px));
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 8px 20px rgba(16, 24, 40, .16), 0 24px 70px rgba(16, 24, 40, .24);
}

.copilot-h { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, var(--accent-soft), transparent 60%); flex: none; }
.copilot-avatar { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), #7c3aed); }
.copilot-avatar svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.copilot-who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.copilot-who b { font-size: 12.5px; font-weight: 600; }
.copilot-who span { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copilot-stop {
  flex: none; font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--danger, #c0392b); cursor: pointer;
}
.copilot-stop[hidden] { display: none !important; }
.copilot-log-toggle {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--muted);
  font-size: 10px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px; cursor: pointer;
}
.copilot-log-toggle.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.copilot-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 6px; }
.copilot-close:hover { background: var(--surface-2); color: var(--ink); }
.copilot-msg-stream { opacity: .95; }
.copilot-cursor { animation: copilot-blink 1s step-end infinite; color: var(--accent); margin-left: 1px; }
@keyframes copilot-blink { 50% { opacity: 0; } }

.copilot-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.copilot-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.copilot-hood {
  flex: none; max-height: 42%; min-height: 120px; overflow: hidden; display: flex; flex-direction: column;
  border-top: 1px solid var(--line); background: var(--surface-2);
}
.copilot-hood[hidden] { display: none !important; }
.copilot-hood-head { flex: none; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 12px 4px; border-bottom: 1px dashed var(--line); }
.copilot-hood-head b { font-size: 11px; }
.copilot-hood-body { flex: 1; overflow-y: auto; padding: 8px 12px 10px; font-size: 12px; }
.copilot-log-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.copilot-log-block { margin-bottom: 10px; }
.copilot-log-block h4 { margin: 0 0 4px; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.copilot-log-block .v { margin: 0; font-size: 11.5px; color: var(--ink-2); word-break: break-word; }
.copilot-log-raw { margin-top: 8px; font-size: 11px; }
.copilot-log-raw pre { margin: 6px 0 0; padding: 8px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); overflow: auto; max-height: 140px; font-size: 10px; }
.copilot-steps { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.copilot-steps li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 6px 0; position: relative; }
.copilot-steps li::before { content: ''; position: absolute; left: 10px; top: 26px; bottom: -6px; width: 2px; background: var(--line); }
.copilot-steps li:last-child::before { display: none; }
.copilot-steps .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); z-index: 1; }
.copilot-steps .dot.ok { background: var(--good-soft); color: var(--good-text); }
.copilot-steps .dot.no { background: var(--crit-soft); color: var(--crit-text); }
.copilot-steps b { font-size: 12px; display: block; }
.copilot-steps .v { font-size: 12px; color: var(--ink-2); word-break: break-word; }
.copilot-apis { margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.copilot-apis li { display: flex !important; justify-content: space-between; gap: 6px; padding: 0 !important; font-family: var(--font-mono); font-size: 11px; }
.copilot-apis li::before { display: none; }
.copilot-msg { max-width: 92%; padding: 8px 11px; border-radius: 12px; font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.copilot-msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.copilot-msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; max-width: 100%; }
.copilot-msg.ai.copilot-msg-wide { max-width: 100%; width: 100%; }
.copilot-msg.ai .copilot-md { white-space: normal; }
.copilot-msg.ai .copilot-md p { margin: 0 0 8px; }
.copilot-msg.ai .copilot-md h4.copilot-md-h { margin: 10px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.copilot-msg.ai .copilot-md-list { margin: 4px 0 8px; padding-left: 18px; }
.copilot-msg.ai .copilot-md code { font-family: var(--font-mono); font-size: 11px; background: var(--surface); padding: 1px 4px; border-radius: 4px; }
.copilot-md-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.copilot-md-link:hover { text-decoration: underline; }
.copilot-rich-slot { margin-top: 10px; min-height: 120px; }
.copilot-rich-slot.loading { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; min-height: 80px; }
.an-root.copilot-rich-root { --an-pad: 0; padding: 0; background: transparent; }
.copilot-rich-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.copilot-rich-head b { display: block; font-size: 13px; }
.copilot-rich-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 10px; }
.copilot-rich-kpi { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 2px; }
.copilot-rich-kpi .cap { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.copilot-rich-kpi b { font-size: 14px; }
.copilot-rich-mix { margin-bottom: 12px; }
.copilot-rich-sec { margin-top: 12px; }
.copilot-rich-sec h4 { margin: 0 0 4px; font-size: 12px; }
.copilot-rich-chart { min-height: 120px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 4px; background: var(--surface); }
.copilot-msg.sys { align-self: center; background: transparent; color: var(--muted); text-align: center; font-size: 11px; max-width: 100%; }
.copilot-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.copilot-chips span { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2); }
.copilot-chips span.ok { background: var(--good-soft); color: var(--good-text); border-color: transparent; }
.copilot-chips span.skip { background: var(--surface-3); color: var(--muted); }
.copilot-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.copilot-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent); cursor: pointer; text-decoration: none; }
.copilot-btn:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.copilot-btn.add { border-color: var(--good); background: var(--good-soft); color: var(--good-text); }
.copilot-btn.add:hover { background: var(--good); color: #fff; border-color: var(--good); }
.copilot-btn.save { border-color: var(--good); background: var(--good); color: #fff; }
.copilot-btn.save:hover { background: var(--good-text); border-color: var(--good-text); }

.copilot-sugg { display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto; border-top: 1px dashed var(--line); flex: none; }
.copilot-sugg:empty, .copilot-sugg[hidden] { display: none; }
.copilot-chip { flex: none; font-size: 10.5px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.copilot-chip:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }

.copilot-pending {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 0; font-size: 11px; color: var(--ink-2);
}
.copilot-pending[hidden] { display: none !important; }
.copilot-pending img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.copilot-pending-clear { border: 0; background: var(--surface-2); color: var(--muted); cursor: pointer; border-radius: 6px; padding: 2px 8px; font-size: 14px; line-height: 1; }
.copilot-attach-preview { margin-bottom: 6px; }
.copilot-attach-preview img { max-width: 120px; max-height: 80px; border-radius: 8px; border: 1px solid rgba(255,255,255,.35); display: block; }
.copilot-icon-btn {
  width: 34px; height: 34px; flex: none; border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--surface-2); cursor: pointer; font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.copilot-icon-btn:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.copilot-icon-btn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); animation: copilot-pulse 1.2s ease-in-out infinite; }
@keyframes copilot-pulse { 50% { opacity: .65; } }
.copilot-ask { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); flex: none; align-items: center; }
.copilot-ask input { flex: 1; min-width: 0; height: 34px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface-2); color: var(--ink); padding: 0 11px; font: inherit; font-size: 12px; }
.copilot-ask input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.copilot-send { width: 34px; height: 34px; flex: none; border: 0; border-radius: 9px; cursor: pointer; color: #fff; background: var(--accent); display: grid; place-items: center; }
.copilot-send:hover { filter: brightness(1.06); }
.copilot-send svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#chat-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#chat-btn.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
body.copilot-resizing { cursor: col-resize; user-select: none; }
@media (max-width: 768px) { body.copilot-resizing { cursor: row-resize; } }

@media (max-width: 760px) {
  body:not(:has(#copilot-mount)) .copilot-fab { right: 14px; bottom: 14px; width: 48px; height: 48px; }
  body:not(:has(#copilot-mount)) .copilot { right: 12px; bottom: 72px; left: 12px; width: auto; }
}

/* the card of a photo Hermes read (core/copilot.js photoCardHtml) */
.copilot-photo .copilot-photo-checks { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; font-size: 12px; }
.copilot-photo-checks li span { color: var(--muted); }
.copilot-photo-checks li.ok b { color: var(--good-text); }
.copilot-photo-checks li.warn b { color: var(--warn-text); }
.copilot-photo-checks li.bad b { color: var(--crit-text); }
.copilot-photo-ask { margin: 6px 0 0; }
.copilot-photo-done { margin-top: 6px; font-weight: 600; }
