.dl-chat {
  --dl-primary: #7c3aed;
  --dl-primary-deep: #5b21b6;
  --dl-black-purple: #160b24;
  --dl-text: #160f20;
  --dl-muted: #51445f;
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 999999;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.dl-chat *, .dl-chat *::before, .dl-chat *::after { box-sizing: border-box; }

.dl-chat button, .dl-chat textarea { font: inherit; }

.dl-chat__toggle {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-left: auto;
  padding: 0;
  color: #fff;
  background: linear-gradient(145deg, #8b5cf6, var(--dl-primary-deep));
  border: 0;
  border-radius: 50%;
  box-shadow: 0 10px 28px rgba(91, 33, 182, .38);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.dl-chat__toggle:hover { transform: translateY(-2px); box-shadow: 0 13px 34px rgba(91, 33, 182, .48); }
.dl-chat__toggle:focus-visible, .dl-chat button:focus-visible, .dl-chat textarea:focus-visible { outline: 3px solid rgba(124, 58, 237, .3); outline-offset: 3px; }
.dl-chat__toggle svg { width: 29px; height: 29px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dl-chat__x-icon { display: none; }
.dl-chat.is-open .dl-chat__bubble-icon { display: none; }
.dl-chat.is-open .dl-chat__x-icon { display: block; }
.dl-chat.is-open .dl-chat__toggle { opacity: 0; visibility: hidden; pointer-events: none; }

.dl-chat__panel {
  display: flex;
  position: absolute;
  right: 0;
  bottom: 0;
  flex-direction: column;
  width: min(410px, calc(100vw - 32px));
  height: min(590px, calc(100vh - 48px));
  overflow: hidden;
  color: var(--dl-text);
  background: #fff;
  border: 1px solid rgba(74, 38, 94, .16);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(28, 10, 42, .28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}

.dl-chat.is-open .dl-chat__panel { opacity: 1; visibility: visible; transform: none; }

.dl-chat__close-menu {
  position: absolute;
  top: 54px;
  right: 10px;
  z-index: 3;
  width: 168px;
  padding: 6px;
  background: #fff;
  border: 1px solid #e4dfe8;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(37, 19, 48, .16);
}
.dl-chat__close-menu[hidden] { display: none; }
.dl-chat__close-menu button {
  display: block;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  text-align: left;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  cursor: pointer;
}
.dl-chat__close-menu .dl-chat__end { color: #c23232; }
.dl-chat__close-menu .dl-chat__end:hover { background: #fff1f1; }
.dl-chat__close-menu .dl-chat__minimize { color: #302638; }
.dl-chat__close-menu .dl-chat__minimize:hover { background: #f6f3f8; }

.dl-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 10px 16px;
  color: #24143d;
  background: #fff;
  border-bottom: 1px solid #eeeaf5;
}

.dl-chat__body { position: relative; flex: 1; min-height: 0; overflow-y: auto; background: #f8f7fb; }
.dl-chat__home, .dl-chat__conversation { height: 100%; }
.dl-chat__home { display: block; overflow-y: auto; padding: 28px 18px 18px; }
.dl-chat__conversation { display: block; }
.dl-chat__home[hidden], .dl-chat__conversation[hidden] { display: none; }
.dl-chat__hero h2 { margin: 0; color: #190c27; font-size: 19px; font-weight: 700; line-height: 26px; }
.dl-chat__hero h2 span { color: var(--dl-primary); }
.dl-chat__hero .dl-chat__hero-subtitle { margin-top: 5px; color: #6d6177; font-size: 12px; font-weight: 600; line-height: 1.45; }
.dl-chat__topics { margin-top: 26px; }
.dl-chat__topics > p { margin: 0 0 10px; color: #382b43; font-size: 12px; font-weight: 600; letter-spacing: .01em; }
.dl-chat__topic-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.dl-chat__topic-grid button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 16px;
  align-items: center;
  column-gap: 6px;
  min-width: 0;
  min-height: 56px;
  padding: 10px 14px;
  color: var(--dl-text);
  background: #fff;
  border: 1px solid #e7e3eb;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.dl-chat__topic-grid button:hover { transform: translateY(-1px); background: #faf8ff; border-color: #a78bfa; box-shadow: none; }
.dl-chat__topic-grid button:active { transform: translateY(1px) scale(.995); }
.dl-chat__topic-icon { display: grid; place-items: center; width: 22px; height: 18px; color: #5e4d69; background: transparent; }
.dl-chat__topic-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dl-chat__topic-copy { display: flex; min-width: 0; flex-direction: column; text-align: left; }
.dl-chat__topic-grid strong { color: #2d2536; font-size: 13px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.dl-chat__topic-grid small { margin-top: 2px; color: #77717f; font-size: 10.5px; font-weight: 400; line-height: 14px; }
.dl-chat__topic-arrow { justify-self: end; color: var(--dl-primary); font-size: 19px; font-weight: 500; opacity: .52; transition: color .18s ease, opacity .18s ease, transform .18s ease; }
.dl-chat__topic-grid button:hover .dl-chat__topic-arrow { color: #7c3aed; opacity: 1; transform: translateX(3px); }

.dl-chat__identity { display: flex; min-width: 0; align-items: center; gap: 10px; }
.dl-chat__avatar {
  display: grid;
  flex: 0 0 36px;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  background: linear-gradient(145deg, rgba(167,139,250,.95), rgba(109,40,217,.9));
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 15px;
  box-shadow: 0 7px 20px rgba(8,3,14,.28), inset 0 1px 0 rgba(255,255,255,.25);
}
.dl-chat__avatar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.dl-chat__avatar svg circle { fill: currentColor; stroke: none; }
.dl-chat__copy { min-width: 0; }
.dl-chat__copy strong { display: block; color: #24143d; font-size: 14px; font-weight: 600; line-height: 1.3; }
.dl-chat__copy span { display: block; margin-top: 2px; color: #766a7d; font-size: 10px; font-weight: 500; line-height: 1.3; }
.dl-chat__header button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: #766a7d; background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.dl-chat__header button:hover { color: #4f246f; background: #f6f1fa; }
.dl-chat__header button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.dl-chat__close svg { width: 16px !important; height: 16px !important; stroke-width: 1.4 !important; }

.dl-chat__messages {
  height: 100%;
  overflow: auto;
  padding: 18px 16px;
  background: #f8f5fa;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.dl-chat__message { display: flex; margin: 0 0 12px; }
.dl-chat__message--user { justify-content: flex-end; }
.dl-chat__bubble {
  max-width: 86%;
  padding: 11px 13px;
  color: var(--dl-text);
  background: #fff;
  border: 1px solid #e8dfed;
  border-radius: 5px 15px 15px 15px;
  box-shadow: 0 2px 9px rgba(38, 15, 53, .06);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dl-chat__message--user .dl-chat__bubble { color: #fff; background: linear-gradient(135deg, var(--dl-primary), var(--dl-primary-deep)); border-color: var(--dl-primary-deep); border-radius: 15px 5px 15px 15px; }
.dl-chat__message--system { justify-content: center; }
.dl-chat__message--system .dl-chat__bubble { padding: 5px 9px; color: var(--dl-muted); background: transparent; border: 0; box-shadow: none; font-size: 12px; font-weight: 600; }
.dl-chat__bubble.is-error { color: #a22b2b; background: #fff5f5; border-color: #ffd4d4; }
.dl-chat__bubble.is-loading { display: flex; gap: 5px; align-items: center; min-height: 41px; }
.dl-chat__bubble.is-loading span { width: 6px; height: 6px; background: #536078; border-radius: 50%; animation: dl-chat-dot 1.15s infinite ease-in-out; }
.dl-chat__bubble.is-loading span:nth-child(2) { animation-delay: .14s; }
.dl-chat__bubble.is-loading span:nth-child(3) { animation-delay: .28s; }
@keyframes dl-chat-dot { 0%, 70%, 100% { transform: translateY(0); opacity: .45; } 35% { transform: translateY(-4px); opacity: 1; } }

.dl-chat__form { display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px 10px; background: #fff; border-top: 1px solid #e8dfed; }
.dl-chat__form textarea { flex: 1; min-width: 0; height: 44px; min-height: 44px; max-height: 100px; margin: 0; padding: 11px 12px; overflow-y: auto; resize: none; color: var(--dl-text) !important; background: #fff; border: 1px solid #d9d6dc; border-radius: 11px; box-shadow: none; font-size: 13px; font-weight: 500; line-height: 20px; transition: border-color .18s ease, box-shadow .18s ease; }
.dl-chat__form textarea:focus { outline: 0; border-color: #8b5cf6; box-shadow: 0 0 0 2px rgba(124,58,237,.10); }
.dl-chat__form textarea::placeholder { color: #51445f; opacity: 1; }
.dl-chat__send { display: grid; flex: 0 0 44px; place-items: center; width: 44px; height: 44px; margin: 0; padding: 0; color: #fff; background: var(--dl-primary); border: 0; border-radius: 8px; cursor: pointer; transition: background .18s ease, transform .18s ease; }
.dl-chat__send:hover { background: var(--dl-primary-deep); transform: translateY(-1px); }
.dl-chat__send:active { transform: translateY(1px); }
.dl-chat__send:disabled { cursor: wait; opacity: .55; }
.dl-chat__send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dl-chat__note { margin: 0; padding: 0 14px 12px; color: #8b858f; background: #fff; font-size: 10.5px; font-weight: 500; line-height: 1.4; text-align: center; }

@media (max-width: 768px) {
  .dl-chat { right: 10px; bottom: 10px; }
  .dl-chat__toggle { width: 54px; height: 54px; }
  .dl-chat__panel { right: 0; bottom: 0; width: calc(100vw - 20px); height: calc(100dvh - 20px); max-height: none; border-radius: 16px; }
  .dl-chat__header { min-height: 56px; padding: 10px 14px; }
  .dl-chat__avatar { flex-basis: 36px; width: 36px; height: 36px; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .dl-chat__panel, .dl-chat__toggle { transition: none; }
  .dl-chat__bubble.is-loading span { animation: none; }
}
