.duvi-assistant {
  --duvi-accent: #087d6d;
  --duvi-gold: #f3b72f;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(92px, calc(env(safe-area-inset-bottom) + 18px));
  z-index: 120;
  display: grid;
  justify-items: end;
  gap: 10px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.duvi-assistant[dir="rtl"] {
  right: auto;
  left: max(18px, env(safe-area-inset-left));
  justify-items: start;
}

.duvi-launcher {
  position: relative;
  width: 66px;
  height: 66px;
  padding: 3px;
  border: 1px solid rgba(243, 183, 47, .9);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 12px 34px rgba(15, 25, 34, .28);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.duvi-launcher:hover,
.duvi-launcher:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(15, 25, 34, .34);
  outline: 3px solid rgba(8, 125, 109, .25);
  outline-offset: 2px;
}

.duvi-launcher img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.duvi-launcher::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 3px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #24b47e;
}

.duvi-panel {
  display: flex;
  flex-direction: column;
  /* Reset host-page styles: the panel is a <section>, and host pages style
     `section` (e.g. the landing gives sections padding-top ~90px). */
  margin: 0;
  padding: 0;
  width: min(370px, calc(100vw - 28px));
  max-height: min(560px, calc(100vh - 140px));
  overflow: hidden;
  border: 1px solid rgba(30, 92, 82, .2);
  border-radius: 8px;
  background: #fff;
  color: #172321;
  box-shadow: 0 22px 60px rgba(10, 26, 31, .3);
}

.duvi-panel[hidden] {
  display: none;
}

.duvi-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid #e1ece9;
  background: #f5fbf9;
}

.duvi-panel-head strong {
  min-width: 0;
  flex: 1;
  font-size: 15px;
  letter-spacing: 0;
}

.duvi-head-btns {
  display: flex;
  align-items: center;
  gap: 2px;
}

.duvi-voice {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.duvi-voice:hover,
.duvi-voice:focus-visible {
  background: #e6f1ee;
  outline: 2px solid rgba(8, 125, 109, .25);
}

.duvi-voice[aria-pressed="true"] {
  background: #d8efe8;
}

.duvi-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #52615e;
  font: 700 22px/1 system-ui, sans-serif;
  cursor: pointer;
}

.duvi-close:hover,
.duvi-close:focus-visible {
  background: #e6f1ee;
  color: #172321;
  outline: 2px solid rgba(8, 125, 109, .25);
}

.duvi-thread {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #fbfdfc;
}

.duvi-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.duvi-msg-user {
  flex-direction: row-reverse;
}

.duvi-msg-avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 50%;
  background: #eef6f3;
}

.duvi-bubble {
  margin: 0;
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.46;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.duvi-msg-bot .duvi-bubble {
  border-bottom-left-radius: 4px;
  background: #eef4f2;
  color: #26332f;
}

.duvi-msg-user .duvi-bubble {
  border-bottom-right-radius: 4px;
  background: var(--duvi-accent);
  color: #fff;
}

.duvi-bubble.duvi-typing::after {
  content: "•••";
  letter-spacing: 2px;
  animation: duviDots 1.1s steps(4, end) infinite;
}

@keyframes duviDots {
  0% { opacity: .35; }
  50% { opacity: 1; }
  100% { opacity: .35; }
}

.duvi-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 14px 10px;
}

.duvi-actions:empty {
  display: none;
}

.duvi-input {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid #e1ece9;
  background: #fff;
}

.duvi-text {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #cdddd8;
  border-radius: 20px;
  background: #fff;
  color: #172321;
  font: 400 14px/1.2 inherit;
}

.duvi-text:focus-visible {
  border-color: var(--duvi-accent);
  outline: 2px solid rgba(8, 125, 109, .18);
}

.duvi-mic,
.duvi-send {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #cdddd8;
  border-radius: 50%;
  background: #fff;
  color: #174c43;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.duvi-send {
  border-color: var(--duvi-accent);
  background: var(--duvi-accent);
  color: #fff;
}

.duvi-mic:hover,
.duvi-mic:focus-visible,
.duvi-send:hover,
.duvi-send:focus-visible {
  outline: 2px solid rgba(8, 125, 109, .25);
}

.duvi-send:disabled {
  opacity: .55;
  cursor: default;
}

.duvi-mic.duvi-listening {
  border-color: #d8443b;
  background: #fde8e6;
  animation: duviPulse 1s ease-in-out infinite;
}

@keyframes duviPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(216, 68, 59, .4); }
  50% { box-shadow: 0 0 0 6px rgba(216, 68, 59, 0); }
}

.duvi-actions button {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid #bfd5cf;
  border-radius: 7px;
  background: #fff;
  color: #174c43;
  font: 700 12px/1.2 inherit;
  cursor: pointer;
}

.duvi-actions button:hover,
.duvi-actions button:focus-visible {
  border-color: var(--duvi-accent);
  background: #eaf7f3;
  outline: 2px solid rgba(8, 125, 109, .18);
}

.duvi-actions button[data-duvi-action="dismiss"] {
  margin-inline-start: auto;
  border-color: var(--duvi-accent);
  background: var(--duvi-accent);
  color: #fff;
}

.duvi-assistant.duvi-attention .duvi-launcher {
  animation: duviAttention .55s ease-out 2;
}

@keyframes duviAttention {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .duvi-launcher,
  .duvi-assistant.duvi-attention .duvi-launcher,
  .duvi-mic.duvi-listening,
  .duvi-bubble.duvi-typing::after {
    transition: none;
    animation: none;
  }
}

@media (max-width: 700px) {
  .duvi-assistant {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 76px));
  }

  .duvi-assistant[dir="rtl"] {
    right: auto;
    left: max(10px, env(safe-area-inset-left));
  }

  .duvi-launcher {
    width: 58px;
    height: 58px;
  }

  .duvi-panel {
    max-height: min(70vh, calc(100vh - 120px));
  }
}
