.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.ai-fullscreen-open {
  overflow: hidden;
}

.ai-assistant {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 640px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 80% 0%, rgba(215, 181, 109, 0.16), transparent 20rem),
    linear-gradient(145deg, rgba(16, 31, 53, 0.92), rgba(7, 17, 31, 0.94));
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.ai-assistant.ai-fullscreen {
  position: fixed;
  inset: 18px;
  z-index: 120;
  min-height: auto;
  width: auto;
  max-width: none;
}

.ai-glow {
  position: absolute;
  inset: -20% -10% auto auto;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 207, 122, 0.16), transparent 68%);
  pointer-events: none;
  animation: aiGlow 7s ease-in-out infinite;
}

.ai-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid rgba(246, 241, 232, 0.11);
  background: rgba(246, 241, 232, 0.035);
  backdrop-filter: blur(16px);
}

.ai-header h3 {
  margin-bottom: 0;
}

.ai-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--color-soft);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ai-status span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #58d68d;
  box-shadow: 0 0 18px rgba(88, 214, 141, 0.72);
}

.ai-header-actions,
.ai-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-icon-button,
.ai-toolbar button,
.ai-upload {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(246, 241, 232, 0.14);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  background: rgba(246, 241, 232, 0.06);
  color: var(--color-soft);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.ai-icon-button:hover,
.ai-toolbar button:hover,
.ai-upload:hover,
.ai-icon-button:focus-visible,
.ai-toolbar button:focus-visible,
.ai-upload:focus-within {
  border-color: rgba(240, 207, 122, 0.48);
  background: rgba(215, 181, 109, 0.1);
  transform: translateY(-1px);
}

.ai-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ai-video {
  position: absolute;
  right: 18px;
  top: 88px;
  z-index: 3;
  width: min(42%, 210px);
  border: 1px solid rgba(246, 241, 232, 0.16);
  border-radius: var(--radius-md);
  padding: 8px;
  background: rgba(7, 17, 31, 0.72);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
}

.ai-video video {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #030911;
}

.ai-video span {
  display: block;
  margin-top: 6px;
  color: var(--color-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.ai-messages {
  position: relative;
  z-index: 1;
  min-height: 300px;
  max-height: 440px;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px 20px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.ai-fullscreen .ai-messages {
  max-height: none;
}

.ai-message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  animation: aiMessage 260ms ease both;
}

.ai-message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
}

.ai-message.user .ai-avatar {
  grid-column: 2;
}

.ai-message.user .ai-bubble {
  grid-column: 1;
  grid-row: 1;
  margin-left: auto;
  background: rgba(215, 181, 109, 0.1);
}

.ai-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(215, 181, 109, 0.34);
  border-radius: 50%;
  background: rgba(215, 181, 109, 0.12);
  color: var(--color-gold-strong);
  font-size: 0.72rem;
  font-weight: 900;
}

.ai-bubble {
  width: fit-content;
  max-width: min(100%, 620px);
  border: 1px solid rgba(246, 241, 232, 0.13);
  border-radius: var(--radius-md);
  padding: 14px 15px;
  background: rgba(246, 241, 232, 0.06);
  color: var(--color-muted);
}

.ai-bubble strong {
  display: block;
  margin-bottom: 5px;
  color: var(--color-gold-strong);
  font-size: 0.82rem;
}

.ai-bubble p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.ai-typing .ai-bubble p {
  display: inline-flex;
  gap: 5px;
}

.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-gold-strong);
  animation: aiTyping 900ms ease-in-out infinite;
}

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

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

.ai-suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 20px 14px;
  max-width: 100%;
  overflow: hidden;
}

.ai-suggestions button {
  min-width: 0;
  border: 1px solid rgba(246, 241, 232, 0.12);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(246, 241, 232, 0.05);
  color: var(--color-soft);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.ai-file-preview {
  padding: 0 20px 12px;
}

.ai-file-card {
  border: 1px solid rgba(240, 207, 122, 0.24);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(215, 181, 109, 0.08);
}

.ai-file-card span,
.ai-file-card strong,
.ai-file-card small {
  display: block;
}

.ai-file-card span {
  color: var(--color-gold-strong);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ai-file-card strong {
  color: var(--color-ink);
}

.ai-file-card small {
  color: var(--color-muted);
}

.ai-composer {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  margin: 0 20px 14px;
  border: 1px solid rgba(246, 241, 232, 0.14);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(3, 9, 17, 0.58);
}

.ai-composer textarea {
  min-height: 44px;
  max-height: 140px;
  border: 0;
  padding: 4px;
  background: transparent;
  resize: none;
}

.ai-toolbar {
  justify-content: space-between;
}

.ai-toolbar button,
.ai-upload {
  height: 48px;
  min-width: 86px;
  margin: 0;
  box-sizing: border-box;
  align-self: center;
}

.ai-upload {
  position: relative;
  line-height: 1;
  text-align: center;
  vertical-align: top;
}

.ai-send {
  margin-left: auto;
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-strong)) !important;
  color: #101015 !important;
}

.ai-assistant.is-thinking .ai-status span {
  animation: aiPulse 900ms ease-in-out infinite;
}

.ai-assistant.is-listening {
  box-shadow: 0 0 0 1px rgba(240, 207, 122, 0.2), 0 34px 90px rgba(0, 0, 0, 0.3);
}

@keyframes aiGlow {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(0.96);
  }

  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

@keyframes aiMessage {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes aiTyping {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes aiPulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.35);
  }
}

@media (max-width: 980px) {
  .ai-assistant {
    min-height: 620px;
  }
}

@media (max-width: 640px) {
  .ai-assistant {
    min-height: 680px;
    border-radius: var(--radius-md);
  }

  .ai-assistant.ai-fullscreen {
    inset: 8px;
  }

  .ai-header {
    flex-direction: column;
  }

  .ai-header-actions,
  .ai-toolbar {
    width: 100%;
  }

  .ai-suggestions {
    grid-template-columns: 1fr;
    padding-inline: 14px;
  }

  .ai-icon-button,
  .ai-toolbar button,
  .ai-upload {
    flex: 1;
  }

  .ai-video {
    position: relative;
    top: auto;
    right: auto;
    width: auto;
    margin: 14px 20px 0;
  }

  .ai-messages {
    padding-inline: 14px;
  }

  .ai-composer {
    margin-inline: 14px;
  }
}
