/* AI-асистент (S3): плаваюча кнопка + панель чату + AI-партіали. Токени — з design.css. */
.ai-dock { position: fixed; right: 16px; bottom: 16px; z-index: 40; }
.ai-dock-raised { bottom: 84px; }
@media (min-width: 640px) { .ai-dock-raised { bottom: 16px; } }

.ai-fab {
  display: inline-flex; align-items: center; gap: 6px; height: 48px; min-width: 48px;
  padding: 0 16px; border-radius: 999px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-fg); font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .15s var(--ease);
}
.ai-fab:hover { background: var(--brand-hover); }
.ai-fab:active { transform: scale(.97); }
.ai-fab:focus-visible, .ai-panel button:focus-visible, .ai-panel textarea:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.ai-fab-icon { font-size: 18px; line-height: 1; }
.ai-dock.is-open .ai-fab { display: none; }

.ai-panel {
  position: fixed; z-index: 41; display: flex; flex-direction: column;
  background: var(--surface); color: var(--fg); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  inset: auto 0 0 0; height: 88vh; height: 88dvh; border-radius: 16px 16px 0 0;
}
.ai-panel[hidden] { display: none; }
@media (min-width: 640px) {
  .ai-panel { inset: auto 16px 16px auto; width: 400px; height: 600px; max-height: calc(100vh - 32px);
    border-radius: var(--radius-xl); }
}
.ai-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.ai-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.ai-badge {
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px;
  background: var(--bg-subtle); color: var(--fg-muted); border: 1px solid var(--border);
}
.ai-disclaimer { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.ai-head-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ai-thread {
  flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}
.ai-msg { max-width: 88%; font-size: 14px; line-height: 1.5; padding: 8px 12px; border-radius: 14px;
  overflow-wrap: anywhere; }
.ai-msg p + p { margin-top: 6px; }
.ai-msg ul { margin-top: 4px; }
.ai-msg a { color: var(--brand); }
.ai-msg-user { align-self: flex-end; background: var(--brand); color: var(--brand-fg);
  border-bottom-right-radius: 4px; white-space: pre-wrap; }
.ai-msg-bot { align-self: flex-start; background: var(--bg-subtle); border-bottom-left-radius: 4px; }
.ai-msg-error { align-self: flex-start; background: transparent; border: 1px solid var(--danger);
  color: var(--danger); }
.ai-sources { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--fg-muted); }
.ai-sources a { color: var(--brand); text-decoration: underline; }
.ai-card { align-self: stretch; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; background: var(--surface); font-size: 14px; }
.ai-card-title { font-size: 12px; color: var(--fg-muted); font-weight: 600; text-transform: uppercase;
  letter-spacing: .02em; }
.ai-card-body { margin-top: 4px; font-weight: 600; }
.ai-card-note { margin-top: 4px; font-size: 12px; color: var(--fg-muted); }
.ai-card-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.ai-status { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600; }
.ai-status-done { color: var(--success); }
.ai-status-failed { color: var(--danger); }
.ai-status-muted { color: var(--fg-muted); }
.ai-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 14px;
  border-top: 1px solid var(--border); }
.ai-form textarea { flex: 1; resize: none; min-height: 44px; max-height: 140px; font-size: 16px;
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); }
@media (min-width: 640px) { .ai-form textarea { font-size: 14px; } }
.ai-form .btn { height: 44px; }
.ai-typing { display: none; align-self: flex-start; font-size: 13px; color: var(--fg-muted); }
.ai-typing.htmx-request { display: block; }
.ai-welcome { color: var(--fg-muted); font-size: 14px; }

/* AI-партіали на сторінках (переклад, CV, поради, докази) */
.ai-box { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-subtle); padding: 12px 14px; font-size: 14px; }
.ai-box-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; font-weight: 600; }
.ai-note { font-size: 12px; color: var(--fg-muted); }
.ai-issue { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.ai-sev { flex-shrink: 0; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--border); }
.ai-sev-high { color: var(--danger); border-color: var(--danger); }
.ai-sev-medium { color: var(--warning); border-color: var(--warning); }
.ai-sev-low { color: var(--fg-muted); }
.ai-evidence { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ai-check { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.ai-link-btn { color: var(--brand); font-size: 14px; background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline; }
.ai-help-grid { display: grid; gap: 12px; margin-top: 20px; }
@media (min-width: 640px) { .ai-help-grid { grid-template-columns: 1fr 1fr; } }
.ai-prose h2 { font-size: 18px; font-weight: 700; margin-top: 20px; }
.ai-prose p, .ai-prose ul { margin-top: 8px; line-height: 1.65; }
.ai-prose ul { list-style: disc; padding-left: 20px; }
.ai-prose a { color: var(--brand); text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .ai-fab { transition: none; } }
.ai-msg ul { list-style: disc; padding-left: 20px; }
.ai-msg li + li { margin-top: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }
@media (max-width: 639px) { .ai-fab { padding: 0; width: 52px; height: 52px; justify-content: center; }
  .ai-fab-text { display: none; } .ai-fab-icon { font-size: 22px; } }
