.app-ai-chat {
  position: fixed !important;
  inset: auto 1.25rem 1.25rem auto !important;
  right: 1.25rem;
  bottom: 1.25rem;
  left: auto;
  top: auto;
  transform: none !important;
  translate: none !important;
  margin: 0 !important;
  z-index: 1085;
  display: grid;
  justify-items: end;
  gap: 0.85rem;
  pointer-events: none;
}

.app-ai-chat-launcher,
.app-ai-chat-panel {
  pointer-events: auto;
}

.app-ai-chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  max-width: min(24rem, calc(100vw - 2.5rem));
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 149, 60, 0.28);
  border-radius: 1.2rem;
  color: #fff8ee;
  background:
    linear-gradient(135deg, rgba(17, 17, 20, 0.92) 0%, rgba(26, 16, 11, 0.94) 100%),
    linear-gradient(135deg, rgba(255, 122, 0, 0.28) 0%, rgba(255, 154, 31, 0.14) 100%);
  box-shadow:
    0 1.2rem 2.8rem rgba(9, 11, 16, 0.34),
    0 0 0 0 rgba(255, 122, 0, 0.28);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, opacity 180ms ease;
  backdrop-filter: blur(16px);
}

.app-ai-chat-launcher:hover,
.app-ai-chat-launcher:focus {
  transform: translateY(-2px);
  border-color: rgba(255, 154, 31, 0.46);
  box-shadow:
    0 1.6rem 3rem rgba(9, 11, 16, 0.38),
    0 0 0 0.55rem rgba(255, 122, 0, 0.08);
}

.app-ai-chat-launcher:focus-visible,
.app-ai-chat-close:focus-visible,
.app-ai-chat-send:focus-visible,
.app-ai-chat-upload:focus-within {
  outline: 2px solid rgba(255, 181, 106, 0.95);
  outline-offset: 2px;
}

.app-ai-chat-launcher-orb {
  width: 2.85rem;
  height: 2.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), transparent 35%),
    linear-gradient(145deg, rgba(255, 154, 31, 0.95) 0%, rgba(255, 122, 0, 0.95) 100%);
  color: #111318;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  animation: darkflame-ai-orb-pulse 4.2s ease-in-out infinite;
}

.app-ai-chat-launcher-copy {
  display: grid;
  gap: 0.15rem;
  text-align: left;
}

.app-ai-chat-launcher-label {
  font-size: 0.93rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.app-ai-chat-launcher-subtitle {
  font-size: 0.79rem;
  color: rgba(255, 244, 232, 0.76);
  line-height: 1.2;
}

.app-ai-chat-panel {
  width: min(27rem, calc(100vw - 2.5rem));
  max-height: min(42rem, calc(100vh - 7rem));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 160, 74, 0.18);
  background:
    radial-gradient(circle at top left, rgba(255, 122, 0, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(61, 143, 184, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(14, 16, 20, 0.98) 0%, rgba(12, 13, 16, 0.98) 100%);
  box-shadow: 0 1.6rem 3.8rem rgba(7, 8, 12, 0.48);
  overflow: hidden;
  backdrop-filter: blur(22px);
  transform-origin: bottom right;
  transform: translateY(1rem) scale(0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

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

.app-ai-chat-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.app-ai-chat-kicker {
  color: rgba(255, 181, 106, 0.82);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

.app-ai-chat-title {
  margin: 0.2rem 0 0;
  color: #fff8ee;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-ai-chat-close {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff8ee;
}

.app-ai-chat-body {
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.app-ai-chat-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.85rem;
  padding: 0.95rem;
  border-radius: 1.1rem;
  background:
    linear-gradient(135deg, rgba(255, 122, 0, 0.14) 0%, rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid rgba(255, 181, 106, 0.12);
}

.app-ai-chat-hero-icon {
  width: 3rem;
  height: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), transparent 36%),
    linear-gradient(145deg, rgba(255, 154, 31, 0.95) 0%, rgba(255, 122, 0, 0.95) 100%);
  color: #111318;
  font-size: 1.2rem;
}

.app-ai-chat-hero-copy {
  margin: 0;
  color: rgba(255, 246, 238, 0.9);
  line-height: 1.55;
}

.app-ai-chat-hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.app-ai-chat-hero-pills span,
.app-ai-chat-suggestion {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #fef4e8;
  border: 1px solid rgba(255, 181, 106, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

.app-ai-chat-hero-pills span {
  padding: 0.3rem 0.55rem;
}

.app-ai-chat-resources-wrap {
  display: grid;
  gap: 0.65rem;
}

.app-ai-chat-section-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 181, 106, 0.8);
  font-weight: 700;
}

.app-ai-chat-resources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.app-ai-chat-resource {
  display: grid;
  gap: 0.35rem;
  min-height: 6.4rem;
  padding: 0.85rem;
  border-radius: 1rem;
  color: #fffaf5;
  text-decoration: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.app-ai-chat-resource:hover,
.app-ai-chat-resource:focus {
  transform: translateY(-2px);
  border-color: rgba(255, 181, 106, 0.22);
  color: #fffaf5;
}

.app-ai-chat-resource-icon {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.7rem;
  color: #111318;
  background: linear-gradient(145deg, rgba(255, 154, 31, 0.95) 0%, rgba(255, 122, 0, 0.95) 100%);
}

.app-ai-chat-resource-title {
  font-size: 0.92rem;
  font-weight: 800;
}

.app-ai-chat-resource-description {
  font-size: 0.82rem;
  color: rgba(255, 246, 238, 0.72);
  line-height: 1.45;
}

.app-ai-chat-thread {
  display: grid;
  gap: 0.7rem;
  align-content: start;
}

.app-ai-chat-empty {
  padding: 0.9rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  color: rgba(255, 246, 238, 0.82);
  line-height: 1.55;
}

.app-ai-chat-message {
  display: grid;
  gap: 0.4rem;
}

.app-ai-chat-message.mine {
  justify-items: end;
}

.app-ai-chat-bubble {
  max-width: 100%;
  padding: 0.85rem 0.95rem;
  border-radius: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-ai-chat-message.assistant .app-ai-chat-bubble {
  color: #fffaf5;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.app-ai-chat-message.mine .app-ai-chat-bubble {
  color: #111318;
  background: linear-gradient(135deg, rgba(255, 181, 106, 0.98) 0%, rgba(255, 149, 60, 0.98) 100%);
  box-shadow: 0 0.8rem 1.6rem rgba(255, 122, 0, 0.16);
}

.app-ai-chat-message-meta {
  font-size: 0.72rem;
  color: rgba(255, 246, 238, 0.52);
}

.app-ai-chat-footer {
  padding: 0 1rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(12, 13, 16, 0.2) 0%, rgba(12, 13, 16, 0.9) 24%);
}

.app-ai-chat-attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0 0.5rem;
}

.app-ai-chat-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 246, 238, 0.8);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.app-ai-chat-upload input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.app-ai-chat-clear-attachment {
  color: rgba(255, 181, 106, 0.88);
  text-decoration: none;
  padding: 0;
}

.app-ai-chat-composer {
  display: grid;
  gap: 0.65rem;
}

.app-ai-chat-input {
  min-height: 5.5rem;
  resize: none;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.04);
  color: #fffaf5;
  border-color: rgba(255, 255, 255, 0.08);
}

.app-ai-chat-input::placeholder {
  color: rgba(255, 246, 238, 0.38);
}

.app-ai-chat-input:focus {
  color: #fffaf5;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 181, 106, 0.32);
  box-shadow: 0 0 0 0.2rem rgba(255, 122, 0, 0.14);
}

.app-ai-chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-ai-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.app-ai-chat-suggestion {
  padding: 0.42rem 0.65rem;
  cursor: pointer;
}

.app-ai-chat-suggestion:hover,
.app-ai-chat-suggestion:focus {
  color: #fffaf5;
  border-color: rgba(255, 181, 106, 0.34);
  background: rgba(255, 255, 255, 0.08);
}

.app-ai-chat-send {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 999px;
}

.app-ai-chat.is-busy .app-ai-chat-send {
  opacity: 0.84;
}

@keyframes darkflame-ai-orb-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 0 0 rgba(255, 122, 0, 0.28);
  }

  50% {
    transform: scale(1.04);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24), 0 0 0 0.6rem rgba(255, 122, 0, 0.06);
  }
}

@media (max-width: 767.98px) {
  .app-ai-chat {
    inset: auto 0.75rem 0.75rem 0.75rem !important;
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
    justify-items: stretch;
  }

  .app-ai-chat-launcher {
    max-width: none;
    width: 100%;
  }

  .app-ai-chat-panel {
    width: 100%;
    max-height: min(70vh, 42rem);
  }

  .app-ai-chat-resources {
    grid-template-columns: 1fr;
  }

  .app-ai-chat-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .app-ai-chat-send {
    justify-content: center;
  }
}
