/* ============================================================
   Kareta AI Chat Widget
   Токены только на .ai-widget / .ai-toggle — не :root: иначе витрина
   (Bootstrap / свои --*-переменные) может переопределить --ai-text и «съесть» шапку.
   ============================================================ */

.ai-widget,
.ai-toggle {
  --ai-accent:        #2563eb;
  --ai-accent-hover:  #1d4ed8;
  --ai-accent-text:   #ffffff;
  --ai-bg:            #ffffff;
  --ai-surface:       #f8fafc;
  --ai-border:        #e2e8f0;
  --ai-text:          #1e293b;
  --ai-text-muted:    #64748b;
  --ai-user-bg:       #2563eb;
  --ai-user-text:     #ffffff;
  --ai-bot-bg:        #f3f4f6;
  --ai-bot-text:      #1e293b;
  --ai-input-outer-border: rgba(37, 99, 235, 0.38);
  --ai-send-soft-bg:     #dbeafe;
  --ai-send-soft-fg:     #1e40af;
  --ai-error-bg:      #fef2f2;
  --ai-error-text:    #b91c1c;
  --ai-error-border:  #fecaca;
  --ai-radius:        16px;
  --ai-radius-sm:     8px;
  --ai-shadow:        0 12px 40px rgba(0,0,0,.14), 0 4px 16px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --ai-z:             9000;
  --ai-width:         380px;
  --ai-height:        580px;
  --ai-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Toggle button ── */
.ai-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--ai-z);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-accent) 0%, #4f46e5 100%);
  color: var(--ai-accent-text);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--ai-shadow);
  transition: background .15s, transform .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ai-toggle:hover  { background: var(--ai-accent-hover); transform: scale(1.07); }
.ai-toggle:active { transform: scale(.96); }
.ai-toggle svg    { width: 26px; height: 26px; }
.ai-toggle-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
.ai-toggle-badge.visible { display: block; }

/* ── Widget shell ── */
.ai-widget {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: var(--ai-z);
  width: var(--ai-width);
  height: var(--ai-height);
  min-height: 0;
  background: var(--ai-bg);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--ai-font);
  font-size: 14px;
  color: var(--ai-text);
  border: 1px solid var(--ai-border);
  transition: opacity .2s, transform .2s;
}
.ai-widget.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(.97);
}

/* ── Drag handle (mobile only) ── */
.ai-drag-handle {
  display: none;
  padding: 10px 0 4px;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.ai-drag-handle::after {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--ai-border);
  border-radius: 2px;
  margin: 0 auto;
}

/* ── Header ── */
.ai-widget > .ai-header {
  flex: 0 0 auto;
}
.ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  min-height: 52px;
  box-sizing: border-box;
  /* Явный контраст с лентой; литералы — запасной слой, если var() на странице сломан */
  background: #e8edf5;
  border-bottom: 1px solid #cbd5e1;
  flex-shrink: 0;
  flex-grow: 0;
  position: relative;
  z-index: 2;
  color: #0f172a;
}
.ai-header-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--ai-accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(37,99,235,.2);
}
.ai-header-icon svg {
  width: 19px;
  height: 19px;
  display: block;
  flex-shrink: 0;
}
.ai-header-titles { flex: 1; min-width: 0; }
.ai-header-title  { font-weight: 600; font-size: 14px; line-height: 1.3; color: #0f172a; }
.ai-header-sub    { font-size: 11px; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-header-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ai-icon-btn {
  width: 30px; height: 30px;
  border: none; background: none; cursor: pointer;
  border-radius: var(--ai-radius-sm);
  color: var(--ai-text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ai-icon-btn:hover { background: var(--ai-border); color: var(--ai-text); }
.ai-icon-btn svg  { width: 16px; height: 16px; }

/* ── Messages ── */
.ai-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 14px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--ai-bg);
}
.ai-messages::-webkit-scrollbar       { width: 4px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--ai-border); border-radius: 4px; }

/* ── Empty state ── */
.ai-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 20px;
  gap: 8px;
  color: var(--ai-text-muted);
}
.ai-empty-icon {
  width: 52px; height: 52px;
  background: var(--ai-accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
  color: #fff;
  box-shadow: 0 1px 4px rgba(37,99,235,.2);
}
.ai-empty-icon svg  { width: 26px; height: 26px; }
.ai-empty-title     { font-weight: 600; font-size: 15px; color: var(--ai-text); margin-bottom: 2px; }
.ai-empty-hint      { font-size: 12.5px; line-height: 1.55; max-width: 280px; }

/* ── Prompt chips (quick suggestions) ── */
.ai-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
  max-width: 300px;
}
.ai-prompt-chip {
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--ai-font);
  border: 1px solid var(--ai-accent);
  border-radius: 20px;
  background: var(--ai-bg);
  color: var(--ai-accent);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.3;
}
.ai-prompt-chip:hover  { background: var(--ai-send-soft-bg); color: var(--ai-send-soft-fg); border-color: rgba(37,99,235,.35); }
.ai-prompt-chip:active { transform: translateY(0); background: #bfdbfe; }

/* ── Message row (avatar + bubble) ── */
.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: ai-fade-up .18s ease both;
}
.ai-msg--user { align-self: flex-end; align-items: flex-end; }
.ai-msg--bot,
.ai-msg--refused { align-self: flex-start; align-items: flex-start; max-width: 92%; }

@keyframes ai-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* Bot avatar */
.ai-msg-avatar {
  width: 28px; height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--ai-accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(37,99,235,.2);
}
.ai-msg-avatar svg { width: 15px; height: 15px; }

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: var(--ai-radius);
  line-height: 1.6;
  word-break: break-word;
}
.ai-msg--user .ai-msg-bubble {
  background: var(--ai-user-bg);
  color: var(--ai-user-text);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
  box-shadow: 0 1px 4px rgba(37,99,235,.18);
}
.ai-msg--bot .ai-msg-bubble {
  background: var(--ai-bot-bg);
  color: var(--ai-bot-text);
  border-bottom-left-radius: 4px;
  box-shadow: none;
  border: none;
}
.ai-msg-bubble a      { color: var(--ai-accent); text-decoration: underline; }
.ai-msg-bubble code   { background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px; font-size: .88em; font-family: 'SFMono-Regular', Consolas, monospace; }
.ai-msg-bubble strong { font-weight: 600; }
.ai-msg-bubble em     { font-style: italic; }

/* Markdown block elements inside bot bubble */
.ai-msg-bubble p      { margin: 0 0 .5em; }
.ai-msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg-bubble ul,
.ai-msg-bubble ol     { margin: .3em 0 .5em; padding-left: 1.4em; }
.ai-msg-bubble li     { margin-bottom: .2em; }
.ai-msg-bubble pre    {
  background: rgba(0,0,0,.06);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  margin: .5em 0;
  font-size: .85em;
}
.ai-msg-bubble pre code { background: none; padding: 0; font-size: inherit; }

/* ── Timestamp ── */
.ai-msg-time {
  font-size: 10px;
  color: var(--ai-text-muted);
  margin-top: 4px;
  opacity: 0.75;
}
/* Bot: indent timestamp to align with bubble (28px avatar + 8px gap) */
.ai-msg--bot .ai-msg-time,
.ai-msg--refused .ai-msg-time { margin-left: 36px; }
.ai-msg--user .ai-msg-time    { text-align: right; }

/* ── Message actions (copy / feedback) ── */
.ai-msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  margin-left: 36px; /* align with bubble, same as timestamp */
  opacity: 0;
  transition: opacity .15s;
}
.ai-msg:hover .ai-msg-actions,
.ai-msg-actions:focus-within { opacity: 1; }
.ai-msg-action {
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--ai-border);
  border-radius: 20px;
  background: var(--ai-bg);
  color: var(--ai-text-muted);
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  transition: background .12s, color .12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--ai-font);
}
.ai-msg-action:hover  { background: var(--ai-surface); color: var(--ai-text); }
.ai-msg-action svg    { width: 12px; height: 12px; }
.ai-msg-action.active { color: var(--ai-accent); border-color: var(--ai-accent); }

/* Touch devices: actions always visible, targets larger */
@media (hover: none) {
  .ai-msg-actions { opacity: 1; }
  .ai-msg-action  { padding: 5px 10px; min-height: 32px; font-size: 12px; }
  .ai-msg-action svg { width: 13px; height: 13px; }
}

/* ── Refused / error bubble ── */
.ai-msg--refused .ai-msg-bubble,
.ai-msg--error   .ai-msg-bubble {
  background: var(--ai-error-bg);
  color: var(--ai-error-text);
  border: 1px solid var(--ai-error-border);
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ── */
.ai-typing {
  align-self: flex-start;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: ai-fade-up .18s ease both;
}
.ai-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: var(--ai-bot-bg);
  border-radius: var(--ai-radius);
  border-bottom-left-radius: 4px;
}
.ai-dot {
  width: 7px; height: 7px;
  background: var(--ai-text-muted);
  border-radius: 50%;
  animation: ai-bounce .9s ease-in-out infinite;
}
.ai-dot:nth-child(2) { animation-delay: .15s; }
.ai-dot:nth-child(3) { animation-delay: .3s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(.75); opacity: .5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ── Inline error banner ── */
.ai-error-banner {
  margin: 0 14px;
  padding: 10px 14px;
  background: var(--ai-error-bg);
  border: 1px solid var(--ai-error-border);
  border-radius: var(--ai-radius-sm);
  color: var(--ai-error-text);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ai-error-banner.hidden { display: none; }
.ai-error-msg  { flex: 1; }
.ai-retry-btn {
  padding: 4px 10px;
  border: 1px solid currentColor;
  border-radius: 20px;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--ai-font);
  white-space: nowrap;
  transition: background .12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ai-retry-btn:hover { background: rgba(185,28,28,.08); }

/* ── Input area ── */
.ai-input-area {
  border-top: 1px solid var(--ai-border);
  padding: 6px 10px 8px;
  background: var(--ai-bg);
  flex-shrink: 0;
}
.ai-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ai-bg);
  border: 1px solid var(--ai-input-outer-border);
  border-radius: 12px;
  padding: 4px 4px 4px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.ai-input-row:focus-within {
  border-color: var(--ai-accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}
.ai-textarea {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  font-family: var(--ai-font);
  font-size: 14px;
  color: var(--ai-text);
  outline: none;
  min-height: 22px;
  max-height: 120px;
  line-height: 1.5;
  padding: 4px 0;
  -webkit-appearance: none;
  appearance: none;
}
/* Remove ALL browser/host-page outlines and borders from the textarea —
   focus indicator lives on .ai-input-row:focus-within instead. */
.ai-input-row textarea,
.ai-input-row textarea:focus,
.ai-input-row textarea:focus-visible,
.ai-widget textarea.ai-textarea:focus,
.ai-widget textarea.ai-textarea:focus-visible,
.ai-widget textarea.ai-textarea:focus:not(:focus-visible) {
  outline: none !important;
  outline-offset: 0 !important;
  border: none !important;
  box-shadow: none !important;
}
.ai-textarea::placeholder { color: var(--ai-text-muted); }

.ai-send-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--ai-send-soft-bg);
  color: var(--ai-send-soft-fg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .12s, color .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
}
.ai-send-btn:hover:not(:disabled) { background: #bfdbfe; color: var(--ai-accent-hover); transform: scale(1.05); }
.ai-send-btn:disabled:not(.ai-send-btn--loading) {
  background: var(--ai-surface);
  color: var(--ai-text-muted);
  opacity: 1;
  cursor: not-allowed;
  transform: none;
}
.ai-send-btn.ai-send-btn--loading {
  background: var(--ai-send-soft-bg);
  color: var(--ai-send-soft-fg);
  cursor: wait;
}
.ai-send-btn svg { width: 15px; height: 15px; }

/* ── Character counter ── */
.ai-char-counter {
  font-size: 10px;
  color: var(--ai-text-muted);
  text-align: right;
  padding: 2px 2px 0;
  height: 14px;
  opacity: 0;
  transition: opacity .2s, color .2s;
}
.ai-char-counter.visible { opacity: 1; }
.ai-char-counter.warn    { color: #d97706; }
.ai-char-counter.danger  { color: #dc2626; }

/* ── Disclaimer ── */
.ai-disclaimer {
  padding: 6px 14px 10px;
  font-size: 11px;
  color: var(--ai-text-muted);
  text-align: center;
  line-height: 1.45;
  flex-shrink: 0;
}

/* ── Skip link (a11y) ── */
.ai-skip-link {
  position: absolute;
  top: -40px; left: 12px;
  background: var(--ai-accent);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--ai-radius-sm);
  font-size: 12px;
  z-index: 1;
  transition: top .15s;
  text-decoration: none;
}
.ai-skip-link:focus { top: 8px; }

/* ── Mobile: bottom sheet ── */
@media (max-width: 479px) {

  .ai-widget {
    bottom: 0; right: 0;
    width: 100%;
    height: calc(100dvh - env(safe-area-inset-top, 0px));
    border-radius: 20px 20px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform .35s cubic-bezier(.32, .72, 0, 1);
    transform: translateY(0);
  }
  .ai-widget.hidden {
    opacity: 1;
    transform: translateY(100%);
  }

  .ai-drag-handle { display: block; }

  .ai-icon-btn { width: 44px; height: 44px; }
  .ai-send-btn { width: 44px; height: 44px; }

  /* 16px prevents iOS Safari auto-zoom on input focus */
  .ai-textarea { font-size: 16px; }

  .ai-msg        { max-width: 90%; }
  .ai-msg--bot,
  .ai-msg--refused { max-width: 95%; }
  .ai-msg-bubble { font-size: 15px; }

  .ai-empty-icon      { width: 64px; height: 64px; }
  .ai-empty-icon svg  { width: 32px; height: 32px; }
  .ai-empty-title     { font-size: 17px; }
  .ai-empty-hint      { font-size: 14px; }

  .ai-prompt-chip { font-size: 13px; padding: 7px 14px; }

  .ai-input-area {
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .ai-toggle {
    width: 60px; height: 60px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 20px;
  }
  .ai-toggle svg { width: 28px; height: 28px; }
}

/* ── Safe area for desktop widget (iOS/Android WebView) ── */
@supports (bottom: env(safe-area-inset-bottom)) {
  @media (min-width: 480px) {
    .ai-toggle {
      bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }
    .ai-widget {
      bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    }
  }
}

/* ============================================================
   Kareta AI Dock — embed shell integration
   Overrides for .ai-widget mounted inside the dock panel.
   ============================================================ */
.kareta-ai-dock__body .kareta-public-ai-embed-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  position: relative;
  width: 100%;
  flex-basis: auto;
  overflow: hidden;
  border-radius: 20px;
}
.kareta-ai-dock__body .kareta-public-ai-chat-mount {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  width: 100%;
  padding: 0;
}
/* Dock: нет отдельной PHP-шапки — скрываем только FAB-переключатель; шапка и кнопки — из виджета (.ai-header). */
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-toggle      { display: none !important; }
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-drag-handle { display: none !important; }
/* Skip-link «Mesaj sahəsinə keç» уезжает за пределы панели (position:absolute;top:-40px) и мешает в доке. */
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-skip-link  { display: none !important; }
/* Cancel mobile bottom-sheet positioning so the widget fills the dock */
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-widget {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  bottom: auto !important;
  right: auto !important;
  left: 0 !important;
  top: 0 !important;
  border-radius: 16px;
  box-shadow: none;
  border: none;
  transform: none !important;
  transition: opacity 0.2s ease !important;
  min-height: 0 !important;
  background: var(--ai-bg, #fff) !important;
}
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-messages {
  min-height: 0 !important;
  flex: 1 1 auto !important;
}
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-input-area,
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-disclaimer {
  flex-shrink: 0 !important;
}
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-header {
  flex: 0 0 auto !important;
  flex-shrink: 0 !important;
}
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-widget:not(.hidden) {
  opacity: 1 !important;
  pointer-events: auto !important;
}
.kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-widget.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(6px) scale(0.99) !important;
}
@media (max-width: 479px) {
  .kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-widget,
  .kareta-ai-dock__body .kareta-public-ai-embed-shell .ai-widget.hidden {
    height: 100% !important;
    max-height: none !important;
  }
}

/* ============================================================
   Kareta AI Dock — panel, header, launcher button
   ============================================================ */
.kareta-ai-dock {
  position: fixed;
  inset: 0;
  z-index: 1040;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
.kareta-ai-dock.kareta-ai-dock--open {
  visibility: visible;
  opacity: 1;
}
.kareta-ai-dock:not(.kareta-ai-dock--open) .kareta-ai-dock__panel {
  pointer-events: none;
}
.kareta-ai-dock__panel {
  --kareta-ai-dock-top:    max(20px, env(safe-area-inset-top, 0px));
  --kareta-ai-dock-right:  max(20px, env(safe-area-inset-right, 0px));
  --kareta-ai-dock-bottom: max(96px, calc(20px + env(safe-area-inset-bottom, 0px)));
  pointer-events: auto;
  position: fixed;
  top:    var(--kareta-ai-dock-top);
  right:  var(--kareta-ai-dock-right);
  bottom: var(--kareta-ai-dock-bottom);
  width:  min(100vw - var(--kareta-ai-dock-right) - 16px, 440px);
  height: min(75vh, calc(100vh  - var(--kareta-ai-dock-top) - var(--kareta-ai-dock-bottom)));
  height: min(75vh, calc(100dvh - var(--kareta-ai-dock-top) - var(--kareta-ai-dock-bottom)));
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(255,255,255,.94) 0%, rgba(248,250,252,.92) 100%);
  border: 1px solid rgba(15,23,42,.08);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.6) inset,
    0 24px 48px -12px rgba(15,23,42,.18),
    0 12px 24px -8px rgba(15,23,42,.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transform: translate3d(calc(100% + 32px), 0, 0);
  opacity: 0;
  transition:
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease;
}
.kareta-ai-dock--open .kareta-ai-dock__panel {
  transform: translate3d(0, 0, 0);
  opacity: 1;
}
@media (prefers-color-scheme: dark) {
  .kareta-ai-dock__panel {
    background: linear-gradient(165deg, rgba(30,41,59,.96) 0%, rgba(15,23,42,.94) 100%);
    border-color: rgba(148,163,184,.15);
    box-shadow:
      0 0 0 1px rgba(255,255,255,.06) inset,
      0 24px 48px -12px rgba(0,0,0,.45);
  }
  .kareta-ai-dock__title         { color: #f1f5f9; }
  .kareta-ai-dock__close         { color: #94a3b8; }
  .kareta-ai-dock__close:hover   { background: rgba(255,255,255,.08); color: #f8fafc; }
  .kareta-ai-dock__header-avatar { box-shadow: 0 2px 8px rgba(37,99,235,.45); }
  .kareta-ai-dock__status-dot    { background: #4ade80; box-shadow: 0 0 0 2px rgba(74,222,128,.2); }
}

/* ── Header ── */
.kareta-ai-dock__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15,23,42,.06);
  background: linear-gradient(135deg, rgba(37,99,235,.1) 0%, rgba(248,250,252,.65) 42%, rgba(255,255,255,.35) 100%);
}
@media (prefers-color-scheme: dark) {
  .kareta-ai-dock__header {
    border-bottom-color: rgba(148,163,184,.12);
    background: linear-gradient(135deg, rgba(59,130,246,.18) 0%, rgba(30,41,59,.55) 45%, rgba(15,23,42,.25) 100%);
  }
}
.kareta-ai-dock__header-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.kareta-ai-dock__header-avatar svg { width: 20px; height: 20px; }
.kareta-ai-dock__header-text       { min-width: 0; flex: 1; }
.kareta-ai-dock__title-row         { display: flex; align-items: center; gap: 7px; margin: 0; }
.kareta-ai-dock__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -.02em;
  color: #0f172a;
  line-height: 1.28;
}
.kareta-ai-dock__status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(34,197,94,.2);
  animation: kareta-ai-status-pulse 2.5s ease-in-out infinite;
}
@keyframes kareta-ai-status-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(34,197,94,.15); }
  50%       { box-shadow: 0 0 0 5px rgba(34,197,94,.12); }
}
.kareta-ai-dock__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.kareta-ai-dock__close svg         { width: 18px; height: 18px; flex-shrink: 0; display: block; }
.kareta-ai-dock__close:hover       { background: rgba(15,23,42,.06); color: #0f172a; }
.kareta-ai-dock__close:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* ── Body ── */
.kareta-ai-dock__body {
  flex: 1 1 0;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.kareta-ai-dock__alert {
  margin: 10px 14px 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: .875rem;
  line-height: 1.4;
  background: rgba(254,226,226,.95);
  color: #991b1b;
  border: 1px solid rgba(248,113,113,.35);
}
.kareta-ai-dock__placeholder {
  padding: 20px 18px;
  font-size: .9rem;
  line-height: 1.5;
  color: #64748b;
}
@media (max-width: 480px) {
  .kareta-ai-dock__panel {
    width: calc(100vw - var(--kareta-ai-dock-right) - 12px);
    border-radius: 16px;
  }
}

/* Публичный лаунчер: форма/позиция — main.css; здесь только усиление active/expanded (подключается после main). */
.ai-assistant-btn-fixed:active {
  transform: translateY(0) scale(.97);
  box-shadow:
    0 2px 10px rgba(37,99,235,.3),
    0 1px 3px rgba(0,0,0,.08);
}
.ai-assistant-btn-fixed[aria-expanded="true"] {
  background: linear-gradient(135deg, #1e40af 0%, #3730a3 100%);
  color: #fff;
  box-shadow:
    0 2px 12px rgba(30,64,175,.38),
    0 0 0 3px rgba(37,99,235,.18);
}
@media (max-width: 480px) {
  .ai-assistant-btn-fixed {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
  }
  .ai-assistant-launcher-icon svg {
    width: 24px;
    height: 24px;
  }
}

/* Публичный лаунчер: не перекрывать «Техподдержку», пока открыт док */
#karetaPublicAiLauncherBtn[aria-expanded="true"] {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
