.ai-history-button {
  position: fixed; right: max(18px, env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 8500;
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: 50%; cursor: pointer; box-shadow: 0 3px 12px rgba(0,0,0,.15);
}
.ai-history-button[hidden] { display: none; }
.ai-history-button:hover, .ai-history-button:focus-visible { color: var(--accent-primary, #7c3aed); border-color: currentColor; }
.ai-history-button::before {
  content: attr(aria-label); position: absolute; right: 0; bottom: calc(100% + 8px);
  white-space: nowrap; background: var(--bg-card); border: 1px solid var(--border-card);
  color: var(--text-main); padding: 7px 10px; border-radius: 6px; font-size: 11px;
  opacity: 0; pointer-events: none;
}
.ai-history-button:hover::before, .ai-history-button:focus-visible::before { opacity: 1; }
.ai-history-overlay { position: fixed; inset: 0; z-index: 9700; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(17,24,39,.6); }
.ai-history-dialog { width: 580px; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 22px; background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-card); border-radius: 12px; box-shadow: var(--shadow-glass); }
.ai-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.ai-history-heading h2 { margin: 0; font-size: 16px; font-weight: 700; }
.ai-history-close { width: 32px; height: 32px; flex-shrink: 0; border: 1px solid var(--border-card); background: transparent; color: var(--text-muted); border-radius: 6px; cursor: pointer; }
.ai-history-note { margin: 0 0 16px; font-size: 12px; line-height: 1.6; color: var(--text-muted); }
.ai-history-card { border: 1px solid var(--border-card); padding: 14px; border-radius: 9px; margin-top: 10px; }
.ai-history-card-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12px; }
.ai-history-status { font-size: 11px; color: var(--text-muted); }
.ai-history-status.current { color: #10b981; }
.ai-history-metrics { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0; font-size: 12px; }
.ai-history-description { font-size: 11px; color: var(--text-muted); line-height: 1.6; margin: 6px 0; }
.ai-history-dialog .btn-secondary, .ai-history-dialog .btn-cyan-action { font-size: 12px; padding: 9px 12px; justify-content: center; }
.ai-history-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.ai-history-message { font-size: 12px; padding: 10px; margin-bottom: 12px; border: 1px solid var(--border-card); border-radius: 7px; line-height: 1.5; }
.ai-history-dialog button:focus-visible { outline: 2px solid var(--accent-primary, #7c3aed); outline-offset: 3px; }
.ai-history-dialog button:disabled { opacity: .55; cursor: default; }
@media (pointer: coarse) { .ai-history-button { width: 44px; height: 44px; } }
@media (max-width: 480px) { .ai-history-dialog { padding: 16px; } .ai-history-actions > button { flex: 1; } }
