:root {
  --assistant-ink: #102d20;
  --assistant-green: #08d772;
  --assistant-mint: #a8f2c8;
  --assistant-deep: #06261a;
  --assistant-paper: #f7fbf8;
  --assistant-line: rgba(21, 66, 44, .15);
}

.matrix-assistant-launcher {
  position: fixed;
  z-index: 9996;
  inset-inline-end: clamp(16px, 2.2vw, 32px);
  bottom: clamp(16px, 2.2vw, 30px);
  display: grid;
  grid-template-columns: auto 64px;
  align-items: center;
  gap: 0;
  border: 0;
  padding: 0;
  color: #fff;
  background: transparent;
  font: inherit;
  cursor: pointer;
  filter: drop-shadow(0 18px 34px rgba(4, 35, 23, .3));
  animation: assistant-launcher-arrive .72s .45s cubic-bezier(.16,1,.3,1) both,
             assistant-invite-nudge 9s 3s ease-in-out infinite;
}

.matrix-assistant-launcher__label {
  display: block;
  margin-inline-end: -15px;
  padding: 12px 27px 12px 17px;
  border: 1px solid rgba(129, 240, 175, .24);
  border-radius: 999px 0 0 999px;
  background: linear-gradient(110deg, rgba(6, 34, 23, .96), rgba(9, 66, 41, .95));
  backdrop-filter: blur(14px);
  font-size: .8rem;
  font-weight: 650;
  letter-spacing: .01em;
  transition: transform .25s ease, background .25s ease;
}

[dir="rtl"] .matrix-assistant-launcher__label { border-radius: 0 999px 999px 0; }

.matrix-assistant-launcher__icon {
  position: relative;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  overflow: visible;
  border: 1px solid rgba(111, 239, 165, .5);
  border-radius: 22px;
  background:
    radial-gradient(circle at 28% 16%, rgba(90,236,151,.18), transparent 32%),
    linear-gradient(145deg, #103e2c, #06261a 76%);
  box-shadow: inset 0 1px rgba(255, 255, 255, .13), 0 0 0 7px rgba(13, 218, 111, .09);
}

.matrix-assistant-launcher__icon::before {
  position: absolute;
  inset: -8px;
  content: "";
  border: 1px solid rgba(37, 231, 131, .42);
  border-radius: 28px;
  animation: assistant-beacon 2.8s ease-out infinite;
}

.assistant-brand-mark {
  position: relative;
  display: block;
  width: 25px;
  height: 21px;
}

.assistant-brand-mark::before,
.assistant-brand-mark::after {
  position: absolute;
  inset-block: 0;
  width: 7px;
  content: "";
  border-block: 4px solid currentColor;
}

.assistant-brand-mark::before { inset-inline-start: 1px; border-inline-start: 4px solid currentColor; }
.assistant-brand-mark::after { inset-inline-end: 1px; border-inline-end: 4px solid currentColor; }

.matrix-assistant-launcher__halo {
  position: absolute;
  inset: -15px;
  border: 1px solid rgba(47, 238, 139, .18);
  border-radius: 32px;
  animation: assistant-halo 4.2s ease-in-out infinite;
}

.matrix-assistant-launcher__logo {
  position: relative;
  z-index: 2;
  width: 43px;
  height: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgba(3, 53, 29, .18));
}
.matrix-assistant-launcher__status {
  position: absolute;
  z-index: 3;
  inset-inline-end: -2px;
  inset-block-start: -2px;
  width: 14px;
  height: 14px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #13df78;
  box-shadow: 0 0 0 3px rgba(19,223,120,.18);
}

.matrix-assistant-launcher:hover .matrix-assistant-launcher__label,
.matrix-assistant-launcher:focus-visible .matrix-assistant-launcher__label {
  transform: translateX(-3px);
  background: #092f21;
}

[dir="rtl"] .matrix-assistant-launcher:hover .matrix-assistant-launcher__label,
[dir="rtl"] .matrix-assistant-launcher:focus-visible .matrix-assistant-launcher__label { transform: translateX(3px); }

.matrix-assistant-shell {
  position: fixed;
  z-index: 9998;
  inset-inline-end: clamp(16px, 2.2vw, 32px);
  bottom: clamp(82px, 7vw, 104px);
  display: grid;
  width: min(430px, calc(100vw - 32px));
  height: min(680px, calc(100dvh - 112px));
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(157, 211, 180, .38);
  border-radius: 28px;
  color: var(--assistant-ink);
  background: rgba(249, 252, 250, .98);
  box-shadow: 0 32px 90px rgba(2, 31, 20, .26), 0 2px 12px rgba(2, 31, 20, .08);
  transform: translateY(18px) scale(.98);
  opacity: 0;
  pointer-events: none;
  transform-origin: bottom right;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
  backdrop-filter: blur(22px);
}

[dir="rtl"] .matrix-assistant-shell { transform-origin: bottom left; }
.matrix-assistant-shell[data-open="true"] { transform: none; opacity: 1; pointer-events: auto; }

.matrix-assistant-header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 13px;
  align-items: center;
  padding: 17px 18px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 84% -20%, rgba(55, 239, 142, .32), transparent 46%),
    linear-gradient(135deg, #061e15, #0b3a28);
}

.matrix-assistant-header::after {
  position: absolute;
  inset: auto -8% -28px 36%;
  height: 58px;
  content: "";
  border: 1px solid rgba(118, 235, 168, .24);
  border-radius: 50%;
  transform: rotate(-7deg);
}

.assistant-brand-orb {
  position: relative;
  z-index: 1;
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 14px;
  color: #0b3525;
  background: var(--assistant-green);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
}

.matrix-assistant-title { position: relative; z-index: 1; min-width: 0; }
.matrix-assistant-title strong { display: block; font-size: .95rem; font-weight: 680; letter-spacing: -.01em; }
.matrix-assistant-title span { display: flex; gap: 6px; align-items: center; margin-top: 3px; color: rgba(255,255,255,.72); font-size: .7rem; }
.matrix-assistant-title span::before { width: 6px; height: 6px; content: ""; border-radius: 50%; background: #49ef9b; box-shadow: 0 0 0 4px rgba(73,239,155,.11); }

.matrix-assistant-close {
  position: relative;
  z-index: 2;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  color: #fff;
  background: rgba(255,255,255,.08);
  cursor: pointer;
}
.matrix-assistant-close:hover { background: rgba(255,255,255,.16); }

.matrix-assistant-messages {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 18px 12px;
  scroll-behavior: smooth;
  background:
    linear-gradient(rgba(247,251,248,.93), rgba(247,251,248,.98)),
    radial-gradient(circle at 1px 1px, rgba(30,90,58,.16) 1px, transparent 1.2px);
  background-size: auto, 18px 18px;
}

.assistant-message { display: flex; margin: 0 0 12px; animation: assistant-enter .3s ease both; }
.assistant-message--user { justify-content: flex-end; }
.assistant-message__bubble {
  max-width: 84%;
  padding: 11px 13px;
  border: 1px solid var(--assistant-line);
  border-radius: 6px 18px 18px 18px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(9, 52, 34, .05);
  font-size: .86rem;
  line-height: 1.55;
  white-space: pre-line;
}
.assistant-message--user .assistant-message__bubble {
  border-color: transparent;
  border-radius: 18px 6px 18px 18px;
  color: #fff;
  background: #0a5c39;
}
[dir="rtl"] .assistant-message__bubble { border-radius: 18px 6px 18px 18px; }
[dir="rtl"] .assistant-message--user .assistant-message__bubble { border-radius: 6px 18px 18px 18px; }
.assistant-message__bubble a { color: #087544; font-weight: 650; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.assistant-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; animation: assistant-enter .32s .05s ease both; }
.assistant-suggestion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 37px;
  padding: 8px 12px;
  border: 1px solid rgba(12, 111, 65, .24);
  border-radius: 999px;
  color: #075e38;
  background: rgba(255,255,255,.9);
  font: 600 .75rem/1.2 inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.assistant-suggestion:hover,
.assistant-suggestion:focus-visible { color: #fff; background: #08673e; transform: translateY(-1px); }

.assistant-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 3px 0 14px;
  padding: 11px 13px;
  border: 1px solid var(--assistant-line);
  border-radius: 14px;
  color: var(--assistant-ink);
  background: rgba(230, 246, 236, .76);
  font-size: .77rem;
  font-weight: 650;
  text-decoration: none;
}
.assistant-link-card span:last-child { color: #08844d; }

.matrix-assistant-composer {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--assistant-line);
  background: #fff;
}
.matrix-assistant-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.matrix-assistant-input {
  width: 100%;
  min-height: 45px;
  max-height: 110px;
  resize: none;
  padding: 12px 14px;
  border: 1px solid rgba(18, 70, 45, .2);
  border-radius: 15px;
  outline: none;
  color: var(--assistant-ink);
  background: #f7faf8;
  font: 400 .86rem/1.45 inherit;
}
.matrix-assistant-input:focus { border-color: #0a9c59; box-shadow: 0 0 0 3px rgba(8, 196, 104, .1); }
.matrix-assistant-send {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border: 0;
  border-radius: 14px;
  color: #052719;
  background: var(--assistant-green);
  cursor: pointer;
}
.matrix-assistant-send:disabled { opacity: .45; cursor: wait; }
.matrix-assistant-disclaimer { margin: 8px 3px 0; color: #60736a; font-size: .62rem; line-height: 1.35; }

.assistant-typing { display: inline-flex; gap: 4px; align-items: center; min-width: 48px; }
.assistant-typing i { width: 5px; height: 5px; border-radius: 50%; background: #5d7769; animation: assistant-dot 1.1s infinite ease-in-out; }
.assistant-typing i:nth-child(2) { animation-delay: .14s; }
.assistant-typing i:nth-child(3) { animation-delay: .28s; }

.assistant-invitation {
  position: relative;
  overflow: hidden;
  padding: clamp(30px, 5vw, 58px);
  border: 1px solid rgba(94, 188, 132, .24);
  border-radius: clamp(24px, 3vw, 38px);
  color: #fff;
  background:
    radial-gradient(circle at 84% 12%, rgba(33, 229, 125, .24), transparent 34%),
    linear-gradient(145deg, #061f15, #0a3a27 72%, #0a4a2f);
  box-shadow: 0 30px 80px rgba(7, 45, 29, .16);
}
.assistant-invitation::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: .32;
  background-image: radial-gradient(circle at 1px 1px, rgba(159, 242, 193, .35) 1px, transparent 1.2px);
  background-size: 22px 22px;
  mask-image: linear-gradient(100deg, transparent 20%, #000);
}
.assistant-invitation > * { position: relative; z-index: 1; }
.assistant-invitation .eyebrow { color: #79e9a8; }
.assistant-invitation h2 { max-width: 680px; margin: 10px 0 18px; color: #fff; font-size: clamp(2rem, 4.2vw, 4.25rem); line-height: .98; letter-spacing: -.055em; }
.assistant-invitation > p:not(.eyebrow):not(.assistant-privacy-note) { max-width: 620px; color: rgba(255,255,255,.72); font-size: 1rem; line-height: 1.7; }
.assistant-invitation-points { display: grid; gap: 10px; margin: 25px 0 28px; padding: 0; list-style: none; }
.assistant-invitation-points li { display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.86); font-size: .82rem; }
.assistant-invitation-points li::before { width: 7px; height: 7px; flex: 0 0 auto; content: ""; border-radius: 50%; background: #28e786; box-shadow: 0 0 0 5px rgba(40,231,134,.1); }
.assistant-invitation .button { margin-top: 2px; }
.assistant-direct-contact { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 20px; }
.assistant-direct-contact a { color: #a9f4c8; font-size: .82rem; font-weight: 650; text-decoration-color: rgba(169,244,200,.42); text-underline-offset: 4px; }
.assistant-privacy-note { margin: 15px 0 0; color: rgba(255,255,255,.48); font-size: .68rem; }
.assistant-invitation-mark { position: absolute; z-index: 0; inset: -28px -20px auto auto; width: 250px; height: 250px; opacity: .18; transform: rotate(12deg); }
.assistant-invitation-mark span { position: absolute; inset: 0; border: 1px solid #7ff2ad; border-radius: 38% 62% 52% 48%; animation: assistant-orbit 18s linear infinite; }
.assistant-invitation-mark span:nth-child(2) { inset: 28px; animation-duration: 14s; animation-direction: reverse; }
.assistant-invitation-mark span:nth-child(3) { inset: 58px; animation-duration: 11s; }

html[data-theme="dark"] .matrix-assistant-shell { color: #e9f8ef; border-color: rgba(90,210,141,.22); background: rgba(7, 28, 20, .98); }
html[data-theme="dark"] .matrix-assistant-messages { background: linear-gradient(rgba(7,28,20,.95),rgba(7,28,20,.98)), radial-gradient(circle at 1px 1px, rgba(115,219,157,.16) 1px, transparent 1.2px); background-size: auto,18px 18px; }
html[data-theme="dark"] .assistant-message__bubble { color: #e9f8ef; border-color: rgba(139,216,170,.16); background: #102f23; }
html[data-theme="dark"] .assistant-suggestion { color: #aaf0c7; border-color: rgba(126,227,166,.24); background: #0c2b1f; }
html[data-theme="dark"] .assistant-link-card { color: #e7f8ed; border-color: rgba(126,227,166,.18); background: #0d3223; }
html[data-theme="dark"] .matrix-assistant-composer { border-color: rgba(126,227,166,.17); background: #0a241a; }
html[data-theme="dark"] .matrix-assistant-input { color: #eefaf2; border-color: rgba(126,227,166,.18); background: #102f23; }
html[data-theme="dark"] .matrix-assistant-disclaimer { color: #8faa9a; }

@keyframes assistant-enter { from { transform: translateY(7px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes assistant-dot { 0%,60%,100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes assistant-orbit { to { transform: rotate(360deg); } }
@keyframes assistant-launcher-arrive { from { transform: translateY(28px) scale(.78); opacity: 0; } 68% { transform: translateY(-4px) scale(1.03); opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes assistant-invite-nudge { 0%,82%,100% { transform: translateY(0); } 86% { transform: translateY(-5px); } 90% { transform: translateY(0); } 94% { transform: translateY(-2px); } }
@keyframes assistant-beacon { 0% { transform: scale(.88); opacity: .7; } 70%,100% { transform: scale(1.35); opacity: 0; } }
@keyframes assistant-halo { 0%,100% { transform: scale(.95) rotate(-2deg); opacity: .32; } 50% { transform: scale(1.04) rotate(2deg); opacity: .75; } }

@media (max-width: 640px) {
  .matrix-assistant-launcher { grid-template-columns: auto 56px; inset-inline-end: 14px; bottom: 14px; }
  .matrix-assistant-launcher__icon { width: 56px; height: 56px; border-radius: 19px; }
  .matrix-assistant-launcher__logo { width: 38px; }
  .matrix-assistant-launcher__label { display: none; }
  .matrix-assistant-shell { inset: 0; width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .matrix-assistant-header { padding: max(14px, env(safe-area-inset-top)) 15px 14px; }
  .matrix-assistant-messages { padding: 18px 14px 10px; }
  .matrix-assistant-composer { padding: 10px 12px max(12px, env(safe-area-inset-bottom)); }
  .assistant-message__bubble { max-width: 90%; }
  .assistant-invitation { padding: 30px 22px; }
  .assistant-invitation h2 { font-size: clamp(2.1rem, 10vw, 3.2rem); }
}

@media (prefers-reduced-motion: reduce) {
  .matrix-assistant-launcher,
  .matrix-assistant-launcher__icon::before,
  .matrix-assistant-launcher__halo,
  .assistant-invitation-mark span,
  .assistant-typing i { animation: none !important; }
  .matrix-assistant-shell,
  .assistant-message,
  .assistant-suggestions { transition: none; animation: none; }
}
