:root {
  --assistant-panel-width: min(420px, calc(100vw - 24px));
}

.ai-assistant-shell {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.ai-assistant-toggle {
  min-width: 64px;
  min-height: 64px;
  border: 1px solid rgba(0, 242, 255, 0.28);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(0, 242, 255, 0.95), rgba(92, 248, 255, 0.88));
  color: #031014;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  box-shadow: 0 18px 40px rgba(0, 242, 255, 0.25);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.ai-assistant-toggle:hover {
  transform: translateY(-2px);
}

.ai-assistant-toggle-badge {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #031014;
  box-shadow: 0 0 0 6px rgba(3, 16, 20, 0.12);
}

.ai-assistant-panel {
  width: var(--assistant-panel-width);
  height: min(86vh, 820px);
  min-height: 620px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 8, 8, 0.96);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 40px rgba(0, 242, 255, 0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.ai-assistant-panel.is-open {
  display: flex;
}

.ai-assistant-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(0, 242, 255, 0.08), transparent);
}

.ai-assistant-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-assistant-title {
  margin: 0;
  font-size: 1.05rem;
}

.ai-assistant-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.ai-assistant-close {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
}

.ai-assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.ai-assistant-suggestions.is-hidden {
  display: none;
}

.ai-assistant-suggestion {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 242, 255, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
}

.ai-assistant-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.ai-message {
  max-width: 100%;
  width: 100%;
  padding: 14px 14px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-message p {
  margin: 0;
  white-space: pre-line;
}

.ai-message-user {
  align-self: flex-end;
  margin-left: auto;
  max-width: 88%;
  background: rgba(0, 242, 255, 0.12);
  border-color: rgba(0, 242, 255, 0.24);
}

.ai-message-assistant {
  align-self: flex-start;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.03);
}

.ai-message-meta {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.ai-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ai-meta-card {
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-meta-card span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.ai-meta-card strong {
  display: block;
  font-size: 0.92rem;
}

.ai-part-group {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-part-group h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.ai-tier-list {
  display: grid;
  gap: 8px;
}

.ai-tier-card {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.ai-tier-card.is-recommended {
  border-color: rgba(0, 242, 255, 0.24);
  box-shadow: 0 0 0 1px rgba(0, 242, 255, 0.08) inset;
}

.ai-tier-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.ai-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(0, 242, 255, 0.12);
  color: var(--accent-2);
}

.ai-pill-muted {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.ai-tier-brands,
.ai-tier-shipping {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.ai-tier-link {
  display: inline-flex;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--accent-2);
}

.ai-assistant-footer {
  flex: 0 0 auto;
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.ai-assistant-form {
  display: grid;
  gap: 10px;
}

.ai-assistant-textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 14px;
}

.ai-assistant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-assistant-send,
.ai-assistant-secondary {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.ai-assistant-send {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #031014;
}

.ai-assistant-secondary {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.08);
}

.ai-assistant-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.ai-assistant-status {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.ai-assistant-status.is-error {
  color: #ff7d7d;
}

.ai-assistant-status.is-success {
  color: #76ffc3;
}

.ai-message-typing::after {
  content: '...';
  animation: aiDots 1.2s infinite steps(4, end);
}

@keyframes aiDots {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
  100% { content: '.'; }
}

@media (max-width: 639px) {
  .ai-assistant-shell {
    left: 12px;
    right: 12px;
    bottom: 12px;
    align-items: stretch;
  }

  .ai-assistant-toggle {
    width: 100%;
    justify-content: center;
  }

  .ai-assistant-panel {
    width: 100%;
    height: min(88vh, 880px);
    min-height: 560px;
  }

  .ai-meta-grid {
    grid-template-columns: 1fr;
  }

  .ai-assistant-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ai-assistant-send,
  .ai-assistant-secondary {
    width: 100%;
  }
}

.ai-assistant-toggle,
.ai-assistant-panel,
.ai-assistant-header,
.ai-assistant-footer,
.ai-message,
.ai-meta-card,
.ai-part-group,
.ai-tier-card,
.ai-assistant-textarea,
.ai-assistant-secondary,
.ai-assistant-close,
.ai-assistant-suggestion {
  transition: background-color var(--transition, 0.35s ease), border-color var(--transition, 0.35s ease), color var(--transition, 0.35s ease), box-shadow var(--transition, 0.35s ease);
}

body[data-theme="light"] .ai-assistant-toggle {
  border-color: rgba(10, 168, 178, 0.26);
  background: linear-gradient(135deg, rgba(10, 168, 178, 0.96), rgba(89, 220, 228, 0.9));
  color: #ffffff;
  box-shadow: 0 18px 40px rgba(10, 168, 178, 0.18);
}

body[data-theme="light"] .ai-assistant-toggle-badge {
  background: #ffffff;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.28);
}

body[data-theme="light"] .ai-assistant-panel {
  border-color: rgba(16, 32, 45, 0.08);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 26px 70px rgba(30, 57, 82, 0.14);
}

body[data-theme="light"] .ai-assistant-header {
  border-bottom-color: rgba(16, 32, 45, 0.08);
  background: linear-gradient(180deg, rgba(10, 168, 178, 0.08), rgba(255, 255, 255, 0.86));
}

body[data-theme="light"] .ai-assistant-footer {
  border-top-color: rgba(16, 32, 45, 0.08);
  background: rgba(244, 248, 252, 0.92);
}

body[data-theme="light"] .ai-assistant-close,
body[data-theme="light"] .ai-assistant-secondary,
body[data-theme="light"] .ai-assistant-suggestion,
body[data-theme="light"] .ai-message-assistant,
body[data-theme="light"] .ai-meta-card,
body[data-theme="light"] .ai-part-group,
body[data-theme="light"] .ai-tier-card,
body[data-theme="light"] .ai-assistant-textarea {
  background: rgba(245, 249, 252, 0.96);
  border-color: rgba(16, 32, 45, 0.08);
}

body[data-theme="light"] .ai-message-user {
  background: rgba(10, 168, 178, 0.12);
  border-color: rgba(10, 168, 178, 0.22);
}

body[data-theme="light"] .ai-pill {
  background: rgba(10, 168, 178, 0.12);
  color: var(--accent);
}

body[data-theme="light"] .ai-pill-muted {
  background: rgba(16, 32, 45, 0.06);
  color: var(--muted);
}

body[data-theme="light"] .ai-assistant-status.is-error {
  color: #c24a4a;
}

body[data-theme="light"] .ai-assistant-status.is-success {
  color: #0d8f55;
}

