.chat-assistant {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 100;
  font-family: var(--font-body);
}

.chat-assistant-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 48px;
  padding: 0 1rem;
  color: #04111f;
  border: 1px solid rgba(234, 242, 255, 0.18);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 38px rgba(56, 189, 248, 0.32);
  font: inherit;
  font-size: 14px;
  font-weight: 720;
  cursor: pointer;
  transition: transform 0.16s, box-shadow 0.16s;
}

.chat-assistant-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 48px rgba(56, 189, 248, 0.42);
}

.chat-assistant-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.85rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(360px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 7rem));
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--surface-strong), rgba(5, 11, 24, 0.94));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42), 0 0 34px rgba(56, 189, 248, 0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.chat-assistant-panel[hidden] {
  display: none;
}

.chat-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(80, 160, 255, 0.2);
}

.chat-assistant-title {
  display: grid;
  gap: 0.1rem;
}

.chat-assistant-title strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.3;
}

.chat-assistant-title span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.chat-assistant-close {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(15, 35, 65, 0.42);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.chat-assistant-close:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.chat-assistant-messages {
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
  min-height: 0;
  padding: 1rem;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-assistant-message {
  max-width: 84%;
  padding: 0.68rem 0.82rem;
  border: 1px solid rgba(80, 160, 255, 0.18);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-assistant-message.is-assistant {
  align-self: flex-start;
  background: rgba(15, 35, 65, 0.58);
}

.chat-assistant-message.is-user {
  align-self: flex-end;
  color: #04111f;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.chat-assistant-message.is-error {
  color: var(--text);
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.3);
}

.chat-assistant-message.is-navigation {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.34);
  background: rgba(56, 189, 248, 0.1);
}

.chat-assistant-cursor::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 0.15em;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: chat-caret 0.9s steps(2, start) infinite;
}

@keyframes chat-caret {
  50% {
    opacity: 0;
  }
}

.chat-assistant-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  padding: 0.85rem;
  border-top: 1px solid rgba(80, 160, 255, 0.2);
}

.chat-assistant-input {
  width: 100%;
  min-height: 42px;
  max-height: 108px;
  resize: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(5, 11, 24, 0.42);
  padding: 0.65rem 0.72rem;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
}

.chat-assistant-input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.chat-assistant-submit {
  min-width: 58px;
  min-height: 42px;
  color: #04111f;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font: inherit;
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
}

.chat-assistant-submit:disabled,
.chat-assistant-input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

@media (max-width: 560px) {
  .chat-assistant {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .chat-assistant-panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    height: min(78vh, 560px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }
}
