.at-ai-widget {
  --at-ai-widget-width: 380px;
  --at-ai-widget-top: 50%;
  --at-ai-panel-top: 50%;
  --at-ai-dock-width: 54px;
  --at-ai-bg: #15191e;
  --at-ai-panel: #1d232a;
  --at-ai-control: #252d35;
  --at-ai-border: #343e48;
  --at-ai-text: #e6edf3;
  --at-ai-muted: #9aa8b5;
  --at-ai-accent: #7bcfe0;
  color: var(--at-ai-text);
  color-scheme: dark;
  font: 14px/1.5 system-ui, sans-serif;
}

.at-ai-widget *,
.at-ai-widget *::before,
.at-ai-widget *::after {
  box-sizing: border-box;
}

.at-ai-widget button,
.at-ai-widget textarea,
.at-ai-widget select {
  color: inherit;
  font: inherit;
}

.at-ai-widget button {
  border: 1px solid var(--at-ai-border);
  border-radius: 7px;
  padding: 6px 9px;
  background: var(--at-ai-control);
  cursor: pointer;
}

.at-ai-widget button:hover:not(:disabled) {
  border-color: var(--at-ai-accent);
  background: #303b44;
}

.at-ai-widget button:disabled {
  opacity: .55;
  cursor: wait;
}

.at-ai-widget [hidden] {
  display: none !important;
}

.at-ai-widget__launcher {
  position: fixed;
  top: var(--at-ai-widget-top);
  left: -30px;
  z-index: 12000;
  display: grid;
  place-items: center;
  width: var(--at-ai-dock-width);
  height: 88px;
  transform: translateY(-50%);
  transition: left .24s ease, box-shadow .24s ease, background .24s ease;
  border: 1px solid #6fbdc7 !important;
  border-left: 0 !important;
  border-radius: 0 48px 48px 0 !important;
  padding: 0 0 0 20px !important;
  color: #effffb !important;
  background: linear-gradient(155deg, #245c53 0%, #245c53 54%, #754634 100%) !important;
  box-shadow: 0 8px 26px #0008;
  cursor: grab !important;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.at-ai-widget__launcher:hover,
.at-ai-widget__launcher:focus-visible {
  left: 0;
  background: linear-gradient(155deg, #2d7267 0%, #245c53 54%, #94563d 100%) !important;
}

.at-ai-widget__launcher:active {
  cursor: grabbing !important;
}

.at-ai-widget__launcher > span:first-child {
  position: absolute;
  left: 34px;
  color: #b6f0df;
  font-size: 24px;
  text-shadow: 0 0 12px #9de0ce99;
}

.at-ai-widget__launcher-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 10px);
  width: max-content;
  max-width: min(230px, calc(100vw - 80px));
  transform: translate(-8px, -50%);
  border: 1px solid #70bcca;
  border-radius: 16px;
  padding: 7px 12px;
  color: #e8fff8;
  background: linear-gradient(110deg, #203e3a 0%, #283b3c 62%, #57362f 100%);
  box-shadow: 0 5px 18px #0008;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  animation: at-ai-teaser 7s ease-in-out infinite;
}

.at-ai-widget__launcher:hover .at-ai-widget__launcher-label,
.at-ai-widget__launcher:focus-visible .at-ai-widget__launcher-label {
  animation: none;
  opacity: 0;
}

@keyframes at-ai-teaser {
  0%, 62%, 100% {
    transform: translate(-8px, -50%);
    opacity: 0;
  }

  68%, 88% {
    transform: translate(0, -50%);
    opacity: 1;
  }
}

.at-ai-widget__panel {
  position: fixed;
  z-index: 12001;
  top: var(--at-ai-panel-top);
  left: calc(var(--at-ai-dock-width) - 5px);
  display: flex;
  flex-direction: column;
  width: min(var(--at-ai-widget-width), calc(100vw - var(--at-ai-dock-width) - 12px));
  height: min(680px, calc(100vh - 32px));
  min-height: min(320px, calc(100vh - 32px));
  transform: translateY(-50%);
  overflow: visible;
  border: 1px solid var(--at-ai-border);
  border-radius: 12px;
  background: var(--at-ai-bg);
  box-shadow: 0 16px 52px #000a;
}

.at-ai-widget__resize {
  position: absolute;
  top: 0;
  right: -6px;
  bottom: 0;
  z-index: 2;
  width: 12px;
  cursor: ew-resize;
  touch-action: none;
}

.at-ai-widget__resize::after {
  position: absolute;
  top: 45%;
  right: 5px;
  width: 2px;
  height: 34px;
  border-radius: 3px;
  background: var(--at-ai-muted);
  content: "";
  opacity: .55;
}

.at-ai-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--at-ai-border);
  background: linear-gradient(100deg, #1d3033, var(--at-ai-panel) 65%, #382a25);
  border-radius: 12px 12px 0 0;
}

.at-ai-widget__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.at-ai-widget__close {
  width: 34px;
  padding: 2px !important;
  font-size: 20px !important;
}

.at-ai-widget__messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  overscroll-behavior: contain;
}

.at-ai-widget__message {
  max-width: 92%;
  margin: 0 0 12px;
  padding: 9px 12px;
  border: 1px solid var(--at-ai-border);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.at-ai-widget__message p {
  margin: 0;
  white-space: pre-wrap;
}

.at-ai-widget__message a {
  display: block;
  margin-top: 7px;
  color: #8dd5c4;
  overflow-wrap: anywhere;
}

.at-ai-widget__message--user {
  margin-left: auto;
  background: linear-gradient(120deg, #243d38, #3e302b);
}

.at-ai-widget__message--assistant {
  margin-right: auto;
  background: var(--at-ai-panel);
}

.at-ai-widget__composer {
  padding: 9px;
  border-top: 1px solid var(--at-ai-border);
  border-radius: 0 0 12px 12px;
  background: var(--at-ai-panel);
}

.at-ai-widget__composer textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid var(--at-ai-border);
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
  background: var(--at-ai-bg);
}

.at-ai-widget__composer textarea:focus,
.at-ai-widget__conversations:focus-visible,
.at-ai-widget button:focus-visible {
  outline: 2px solid var(--at-ai-accent);
  outline-offset: 1px;
}

.at-ai-widget__feedback {
  margin: 7px 2px 0;
  border-left: 2px solid #c4775b;
  padding: 3px 8px;
  color: #e9b29d;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.at-ai-widget__feedback:not([hidden]) + .at-ai-widget__toolbar {
  margin-top: 4px;
}

.at-ai-widget__toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
}

.at-ai-widget__conversations {
  min-width: 0;
  max-width: 125px;
  border: 1px solid var(--at-ai-border);
  border-radius: 7px;
  padding: 6px;
  background: var(--at-ai-control);
}

.at-ai-widget__toolbar button {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-color: #3d665d;
  background: linear-gradient(140deg, #243c38, #312b29);
}

.at-ai-widget__new {
  white-space: nowrap;
}

.at-ai-widget__mode[aria-pressed="true"] {
  border-color: var(--at-ai-accent);
  color: #a7e4d6;
}

.at-ai-widget__hint {
  padding: 6px 2px 0;
  color: var(--at-ai-muted);
  font-size: 12px;
}

.at-ai-widget__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .at-ai-widget__panel {
    left: 8px;
    width: calc(100vw - 16px);
    height: min(78vh, 700px);
  }

  .at-ai-widget__resize {
    display: none;
  }

  .at-ai-widget__conversations {
    max-width: 95px;
  }

  .at-ai-widget__toolbar {
    gap: 4px;
  }

  .at-ai-widget__toolbar button {
    padding: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .at-ai-widget__launcher,
  .at-ai-widget__launcher-label {
    animation: none;
    transition: none;
  }

  .at-ai-widget__launcher-label {
    opacity: 1;
    transform: translate(0, -50%);
  }
}
