.fkf-ai-assistant {
  --fkf-ai-primary: var(--fkf-primary, #0a6464);
  --fkf-ai-surface: var(--fkf-surface, #fff);
  --fkf-ai-surface-muted: var(--fkf-surface-muted, #f0f4f8);
  --fkf-ai-text: var(--fkf-text, #17212f);
  --fkf-ai-muted: var(--fkf-text-muted, #5b6b82);
  --fkf-ai-border: var(--fkf-border, #d5dfeb);
  --fkf-ai-radius: var(--fkf-radius-md, 8px);
  color: var(--fkf-ai-text);
  font-size: var(--fkf-density-font-size, 14px);
  position: relative;
  z-index: 1045;
}

.fkf-ai-launcher {
  align-items: center;
  background: var(--fkf-ai-primary);
  border: 1px solid color-mix(in srgb, var(--fkf-ai-primary) 82%, #000);
  border-radius: 50%;
  bottom: 18px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--fkf-ai-primary) 28%, transparent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 1.3rem;
  height: 54px;
  justify-content: center;
  padding: 0;
  position: fixed;
  right: 18px;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  width: 54px;
  z-index: 1052;
}

.fkf-ai-launcher:hover,
.fkf-ai-launcher:focus-visible {
  box-shadow: 0 10px 26px color-mix(in srgb, var(--fkf-ai-primary) 38%, transparent);
  color: #fff;
  transform: translateY(-2px);
}

.fkf-ai-assistant.is-open .fkf-ai-launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.fkf-ai-panel {
  background: var(--fkf-ai-surface);
  border: 1px solid var(--fkf-ai-border);
  border-radius: var(--fkf-ai-radius);
  bottom: 12px;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  height: min(620px, calc(100vh - 24px));
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  right: 12px;
  transform: translateY(12px) scale(0.985);
  transform-origin: bottom right;
  transition: opacity 170ms ease, transform 170ms ease, width 170ms ease, height 170ms ease;
  visibility: hidden;
  width: min(400px, calc(100vw - 24px));
  z-index: 1051;
}

.fkf-ai-assistant.is-open .fkf-ai-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.fkf-ai-assistant.is-expanded .fkf-ai-panel {
  height: calc(100vh - 24px);
  width: min(680px, calc(100vw - 24px));
}

.fkf-ai-header {
  align-items: center;
  border-bottom: 1px solid var(--fkf-ai-border);
  display: flex;
  flex: 0 0 auto;
  gap: 0.65rem;
  min-height: 62px;
  padding: 0.65rem 0.8rem;
}

.fkf-ai-brand-icon {
  align-items: center;
  background: var(--fkf-ai-primary);
  border-radius: var(--fkf-radius-sm, 6px);
  color: #fff;
  display: inline-flex;
  flex: 0 0 38px;
  font-size: 1.1rem;
  height: 38px;
  justify-content: center;
}

.fkf-ai-heading {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.fkf-ai-heading strong,
.fkf-ai-heading span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fkf-ai-heading strong {
  font-size: 0.96rem;
}

.fkf-ai-heading span {
  color: var(--fkf-ai-muted);
  font-size: 0.78rem;
  margin-top: 0.12rem;
}

.fkf-ai-header-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.2rem;
}

.fkf-ai-icon-btn,
.fkf-ai-toolbar-btn {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--fkf-radius-sm, 6px);
  color: var(--fkf-ai-muted);
  display: inline-flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  width: 32px;
}

.fkf-ai-icon-btn:hover,
.fkf-ai-icon-btn:focus-visible,
.fkf-ai-toolbar-btn:hover,
.fkf-ai-toolbar-btn:focus-visible {
  background: var(--fkf-ai-surface-muted);
  border-color: var(--fkf-ai-border);
  color: var(--fkf-ai-primary);
}

.fkf-ai-toolbar-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.fkf-ai-conversation-bar {
  align-items: center;
  background: var(--fkf-ai-surface-muted);
  border-bottom: 1px solid var(--fkf-ai-border);
  display: flex;
  flex: 0 0 auto;
  gap: 0.4rem;
  padding: 0.48rem 0.7rem;
}

.fkf-ai-conversation-label {
  align-items: center;
  background: var(--fkf-ai-surface);
  border: 1px solid var(--fkf-ai-border);
  border-radius: var(--fkf-radius-sm, 6px);
  color: var(--fkf-ai-text);
  display: flex;
  flex: 1 1 auto;
  gap: 0.45rem;
  height: 34px;
  min-width: 0;
  padding: 0 0.65rem;
}

.fkf-ai-conversation-label i {
  color: var(--fkf-ai-primary);
  flex: 0 0 auto;
}

.fkf-ai-conversation-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fkf-ai-toolbar-btn {
  background: var(--fkf-ai-surface);
  border-color: var(--fkf-ai-border);
  flex: 0 0 34px;
  height: 34px;
  width: 34px;
}

.fkf-ai-body {
  background: color-mix(in srgb, var(--fkf-ai-surface) 88%, var(--fkf-ai-surface-muted));
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.fkf-ai-empty {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto;
  padding: clamp(2rem, 9vh, 4.2rem) 1.2rem 1.2rem;
  text-align: center;
}

.fkf-ai-empty[hidden],
.fkf-ai-messages[hidden] {
  display: none !important;
}

.fkf-ai-empty-icon {
  align-items: center;
  background: color-mix(in srgb, var(--fkf-ai-primary) 11%, var(--fkf-ai-surface));
  border-radius: 50%;
  color: var(--fkf-ai-primary);
  display: inline-flex;
  font-size: 1.15rem;
  height: 48px;
  justify-content: center;
  margin-bottom: 0.65rem;
  width: 48px;
}

.fkf-ai-empty > strong {
  font-size: 1rem;
}

.fkf-ai-empty > p {
  color: var(--fkf-ai-muted);
  line-height: 1.45;
  margin: 0.45rem auto 0.9rem;
  max-width: 290px;
}

.fkf-ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.fkf-ai-suggestions button {
  background: var(--fkf-ai-surface);
  border: 1px solid var(--fkf-ai-border);
  border-radius: 999px;
  color: var(--fkf-ai-text);
  font-size: 0.78rem;
  padding: 0.32rem 0.58rem;
}

.fkf-ai-suggestions button:hover,
.fkf-ai-suggestions button:focus-visible {
  border-color: var(--fkf-ai-primary);
  color: var(--fkf-ai-primary);
}

.fkf-ai-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
  padding: 0.8rem;
  scroll-behavior: smooth;
}

.fkf-ai-message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.fkf-ai-message.is-user {
  align-self: flex-end;
  align-items: flex-end;
}

.fkf-ai-message.is-assistant,
.fkf-ai-message.is-error {
  align-self: flex-start;
  align-items: flex-start;
}

.fkf-ai-message-label {
  color: var(--fkf-ai-muted);
  font-size: 0.7rem;
  margin: 0 0.25rem 0.2rem;
}

.fkf-ai-bubble {
  background: var(--fkf-ai-surface);
  border: 1px solid var(--fkf-ai-border);
  border-radius: 12px 12px 12px 3px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
  color: var(--fkf-ai-text);
  line-height: 1.45;
  overflow-wrap: anywhere;
  padding: 0.58rem 0.7rem;
  white-space: pre-wrap;
}

.fkf-ai-message.is-user .fkf-ai-bubble {
  background: color-mix(in srgb, var(--fkf-ai-primary) 10%, var(--fkf-ai-surface));
  border-color: color-mix(in srgb, var(--fkf-ai-primary) 34%, var(--fkf-ai-border));
  border-radius: 12px 12px 3px 12px;
}

.fkf-ai-message.is-error .fkf-ai-bubble {
  background: color-mix(in srgb, var(--fkf-danger, #dc3545) 9%, var(--fkf-ai-surface));
  border-color: color-mix(in srgb, var(--fkf-danger, #dc3545) 38%, var(--fkf-ai-border));
}

.fkf-ai-typing {
  align-items: center;
  display: inline-flex;
  gap: 0.28rem;
  min-height: 0.9rem;
}

.fkf-ai-typing span {
  animation: fkf-ai-pulse 1.1s infinite ease-in-out;
  background: var(--fkf-ai-muted);
  border-radius: 50%;
  height: 5px;
  width: 5px;
}

.fkf-ai-typing span:nth-child(2) {
  animation-delay: 120ms;
}

.fkf-ai-typing span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes fkf-ai-pulse {
  0%, 70%, 100% { opacity: 0.3; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

.fkf-ai-footer {
  background: var(--fkf-ai-surface);
  border-top: 1px solid var(--fkf-ai-border);
  flex: 0 0 auto;
  padding: 0.65rem 0.7rem 0.5rem;
}

.fkf-ai-composer {
  align-items: flex-end;
  display: flex;
  gap: 0.45rem;
}

.fkf-ai-composer textarea {
  background: var(--fkf-ai-surface);
  border: 1px solid var(--fkf-ai-border);
  border-radius: var(--fkf-radius-sm, 6px);
  color: var(--fkf-ai-text);
  flex: 1 1 auto;
  font: inherit;
  line-height: 1.4;
  max-height: 96px;
  min-height: 54px;
  outline: 0;
  padding: 0.55rem 0.62rem;
  resize: none;
}

.fkf-ai-composer textarea:focus {
  border-color: var(--fkf-ai-primary);
  box-shadow: 0 0 0 0.15rem color-mix(in srgb, var(--fkf-ai-primary) 16%, transparent);
}

.fkf-ai-composer textarea::placeholder {
  color: var(--fkf-ai-muted);
}

.fkf-ai-send {
  align-items: center;
  align-self: stretch;
  background: var(--fkf-ai-primary);
  border: 1px solid var(--fkf-ai-primary);
  border-radius: var(--fkf-radius-sm, 6px);
  color: #fff;
  display: inline-flex;
  flex: 0 0 46px;
  font-size: 1rem;
  justify-content: center;
  min-height: 54px;
  padding: 0;
  width: 46px;
}

.fkf-ai-send:hover,
.fkf-ai-send:focus-visible {
  background: color-mix(in srgb, var(--fkf-ai-primary) 86%, #000);
  color: #fff;
}

.fkf-ai-send:disabled {
  cursor: wait;
  opacity: 0.65;
}

.fkf-ai-footer small {
  color: var(--fkf-ai-muted);
  display: block;
  font-size: 0.69rem;
  line-height: 1.3;
  margin-top: 0.42rem;
}

html[data-theme="dark"] .fkf-ai-panel,
body.fkf-modern[data-theme="dark"] .fkf-ai-panel {
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

html[data-theme="dark"] .fkf-ai-bubble,
body.fkf-modern[data-theme="dark"] .fkf-ai-bubble {
  box-shadow: none;
}

@media (max-width: 575.98px) {
  .fkf-ai-launcher {
    bottom: 12px;
    height: 50px;
    right: 12px;
    width: 50px;
  }

  .fkf-ai-panel,
  .fkf-ai-assistant.is-expanded .fkf-ai-panel {
    bottom: 6px;
    height: min(620px, calc(100dvh - 12px));
    right: 6px;
    width: calc(100vw - 12px);
  }

  .fkf-ai-header {
    min-height: 56px;
    padding: 0.55rem 0.62rem;
  }

  .fkf-ai-brand-icon {
    flex-basis: 34px;
    height: 34px;
  }

  .fkf-ai-header-actions [data-ai-action="expand"] {
    display: none;
  }

  .fkf-ai-conversation-bar {
    padding: 0.4rem 0.55rem;
  }

  .fkf-ai-empty {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .fkf-ai-messages {
    padding: 0.62rem;
  }

  .fkf-ai-message {
    max-width: 92%;
  }

  .fkf-ai-footer {
    padding: 0.55rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fkf-ai-launcher,
  .fkf-ai-panel,
  .fkf-ai-typing span {
    animation: none;
    transition: none;
  }
}
