:root {
  --elenya-ai-bg: #FFFAF6;
  --elenya-ai-surface: #FFFFFF;
  --elenya-ai-ink: #191919;
  --elenya-ai-accent: #7A3E13;
  --elenya-ai-support: #F1DED2;
  --elenya-ai-border: rgba(122, 62, 19, 0.16);
  --elenya-ai-shadow: 0 18px 50px rgba(62, 31, 10, 0.16);
}

.elenya-ai {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99998;
  font-family: Inter, sans-serif;
  color: var(--elenya-ai-ink);
}

.elenya-ai *,
.elenya-ai *::before,
.elenya-ai *::after {
  box-sizing: border-box;
}

.elenya-ai__launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 14px 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: var(--elenya-ai-accent);
  color: #fff;
  box-shadow: 0 10px 28px rgba(74, 35, 9, 0.2);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.elenya-ai__launcher:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(74, 35, 9, 0.24);
}

.elenya-ai__launcher:focus-visible,
.elenya-ai button:focus-visible,
.elenya-ai a:focus-visible,
.elenya-ai textarea:focus-visible {
  outline: 2px solid var(--elenya-ai-accent);
  outline-offset: 2px;
}

.elenya-ai__launcher-icon,
.elenya-ai__mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
}

.elenya-ai__launcher-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.13);
  font-size: 17px;
}

.elenya-ai__launcher-copy {
  display: grid;
  gap: 1px;
  text-align: left;
}

.elenya-ai__launcher-copy strong {
  font-size: 13px;
  line-height: 1.25;
  font-weight: 700;
}

.elenya-ai__launcher-copy small {
  font-size: 10.5px;
  line-height: 1.25;
  opacity: .78;
}

.elenya-ai__panel {
  position: fixed;
  right: 24px;
  bottom: 90px;
  left: auto;
  top: auto;
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(390px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 112px));
  overflow: hidden;
  border: 1px solid var(--elenya-ai-border);
  border-radius: 10px;
  background: var(--elenya-ai-surface);
  box-shadow: var(--elenya-ai-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(.985);
  transform-origin: right bottom;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.elenya-ai__panel.is-open,
.elenya-ai__panel:popover-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

@supports selector(:popover-open) {
  .elenya-ai__panel[popover]:not(:popover-open):not(.is-open) {
    display: none;
  }

  .elenya-ai__panel:popover-open {
    display: grid;
  }
}

.elenya-ai__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--elenya-ai-border);
  background: var(--elenya-ai-bg);
}

.elenya-ai__identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.elenya-ai__mark {
  width: 38px;
  height: 38px;
  background: var(--elenya-ai-accent);
  color: #fff;
  font-size: 17px;
}

.elenya-ai__identity > div {
  display: grid;
  gap: 2px;
}

.elenya-ai__identity strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.15;
  font-weight: 500;
}

.elenya-ai__identity small {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  opacity: .72;
}

.elenya-ai__identity small i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--elenya-ai-accent);
}

.elenya-ai__close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--elenya-ai-ink);
  font: 400 25px/1 Arial, sans-serif;
  cursor: pointer;
}

.elenya-ai__close:hover {
  background: var(--elenya-ai-support);
}

.elenya-ai__messages {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 18px;
  background:
    linear-gradient(180deg, rgba(255,250,246,.76) 0, rgba(255,255,255,1) 22%);
  scrollbar-width: thin;
  scrollbar-color: rgba(122,62,19,.25) transparent;
}

.elenya-ai__message {
  display: flex;
  margin: 0 0 10px;
}

.elenya-ai__message.is-user {
  justify-content: flex-end;
}

.elenya-ai__bubble {
  display: grid;
  gap: 5px;
  max-width: 86%;
  padding: 10px 12px;
  border: 1px solid var(--elenya-ai-border);
  border-radius: 10px;
  background: var(--elenya-ai-bg);
  font-size: 13px;
  line-height: 1.52;
}

.elenya-ai__message.is-user .elenya-ai__bubble {
  border-color: var(--elenya-ai-accent);
  border-bottom-right-radius: 5px;
  background: var(--elenya-ai-accent);
  color: #fff;
}

.elenya-ai__message.is-assistant .elenya-ai__bubble {
  border-top-left-radius: 5px;
}

.elenya-ai__bubble strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 500;
}

.elenya-ai__bubble span {
  white-space: pre-wrap;
}

.elenya-ai__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 4px 0 14px;
}

.elenya-ai__quick button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--elenya-ai-border);
  border-radius: 5px;
  background: var(--elenya-ai-surface);
  color: var(--elenya-ai-accent);
  font: 600 11.5px/1.25 Inter, sans-serif;
  cursor: pointer;
}

.elenya-ai__quick button:hover {
  background: var(--elenya-ai-support);
}

.elenya-ai__quick.is-followup {
  margin-top: 6px;
}

.elenya-ai__actions {
  display: grid;
  gap: 7px;
  margin: 2px 0 14px 28px;
}

.elenya-ai__action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 49px;
  padding: 9px 10px;
  border: 1px solid var(--elenya-ai-border);
  border-radius: 10px;
  background: #fff;
  color: var(--elenya-ai-ink);
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease;
}

.elenya-ai__action:hover {
  border-color: rgba(122,62,19,.38);
  background: var(--elenya-ai-bg);
}

.elenya-ai__action > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.elenya-ai__action strong {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elenya-ai__action small {
  overflow: hidden;
  color: rgba(25,25,25,.64);
  font-size: 10.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elenya-ai__action b {
  display: grid;
  place-items: center;
  flex: 0 0 29px;
  width: 29px;
  height: 29px;
  border-radius: 5px;
  background: var(--elenya-ai-support);
  color: var(--elenya-ai-accent);
  font-size: 14px;
}

.elenya-ai__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: end;
  padding: 10px 12px 8px;
  border-top: 1px solid var(--elenya-ai-border);
  background: #fff;
}

.elenya-ai__composer textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 104px;
  resize: none;
  padding: 10px 11px;
  border: 1px solid var(--elenya-ai-border);
  border-radius: 5px;
  background: var(--elenya-ai-bg);
  color: var(--elenya-ai-ink);
  font: 400 12.5px/1.45 Inter, sans-serif;
}

.elenya-ai__composer textarea::placeholder {
  color: rgba(25,25,25,.48);
}

.elenya-ai__composer button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--elenya-ai-accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.elenya-ai__composer button:disabled {
  cursor: wait;
  opacity: .55;
}

.elenya-ai__legal {
  padding: 0 12px 10px;
  background: #fff;
  color: rgba(25,25,25,.5);
  font-size: 9.5px;
  line-height: 1.35;
}

.elenya-ai__dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 15px;
}

.elenya-ai__dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--elenya-ai-accent);
  opacity: .35;
  animation: elenya-ai-dot 900ms infinite ease-in-out;
}

.elenya-ai__dots i:nth-child(2) { animation-delay: 120ms; }
.elenya-ai__dots i:nth-child(3) { animation-delay: 240ms; }

@keyframes elenya-ai-dot {
  0%, 70%, 100% { transform: translateY(0); opacity: .3; }
  35% { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 640px) {
  .elenya-ai {
    right: 12px;
    bottom: 12px;
  }

  .elenya-ai__launcher-copy {
    display: none;
  }

  .elenya-ai__launcher {
    min-height: 50px;
    width: 50px;
    padding: 6px;
    border-radius: 50%;
  }

  .elenya-ai__launcher-icon {
    width: 36px;
    height: 36px;
  }

  .elenya-ai__panel {
    position: fixed;
    right: 8px;
    bottom: 8px;
    left: 8px;
    top: auto;
    margin: 0;
    width: auto;
    height: min(680px, calc(100dvh - 16px));
    max-height: calc(100dvh - 16px);
    border-radius: 10px;
    transform-origin: center bottom;
  }

  .elenya-ai__panel.is-open + .elenya-ai__launcher,
  .elenya-ai:has(.elenya-ai__panel.is-open) .elenya-ai__launcher {
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .elenya-ai__panel,
  .elenya-ai__launcher,
  .elenya-ai__action {
    transition: none;
  }

  .elenya-ai__dots i {
    animation: none;
    opacity: .65;
  }
}