:root {
  --magi-orange: #ff6a00;
  --magi-surface: #111111;
  --magi-surface-soft: #191919;
  --magi-text: #ffffff;
  --magi-muted: rgba(255, 255, 255, 0.58);
}

#magi-assistant-root,
#magi-assistant-root * {
  box-sizing: border-box;
}

#magi-assistant-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--magi-text);
}

.magi-launcher {
  position: relative;
  display: grid;
  width: 76px;
  height: 76px;
  padding: 4px;
  place-items: center;
  border: 1px solid rgba(255, 106, 0, 0.55);
  border-radius: 26px;
  background: #111111;
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), border-color 160ms ease, box-shadow 160ms ease;
}

.magi-launcher::before {
  content: "";
  position: absolute;
  inset: -5px;
  z-index: -1;
  border-radius: 30px;
  background: rgba(255, 106, 0, 0.22);
  filter: blur(13px);
  opacity: 0.72;
}

.magi-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  border-color: rgba(255, 106, 0, 0.85);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.52);
}

.magi-launcher:active {
  transform: scale(0.97);
}

.magi-launcher:focus-visible,
.magi-close:focus-visible,
.magi-chip:focus-visible,
.magi-action:focus-visible,
.magi-send:focus-visible,
.magi-teaser:focus-visible,
.magi-input:focus-visible {
  outline: 2px solid var(--magi-orange);
  outline-offset: 3px;
}

.magi-launcher-image {
  width: 68px;
  height: 68px;
  border-radius: 22px;
  object-fit: cover;
  object-position: top;
  animation: magi-alive 4.4s ease-in-out infinite;
}

.magi-status-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  border: 2px solid #111111;
  border-radius: 999px;
  background: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.85);
  animation: magi-pulse 2.2s ease-in-out infinite;
}

.magi-message-icon {
  position: absolute;
  left: -3px;
  bottom: -3px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 999px;
  background: var(--magi-orange);
  color: #ffffff;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.35);
  font-size: 13px;
}

.magi-teaser {
  max-width: 278px;
  padding: 12px 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px 18px 4px 18px;
  background: rgba(21, 21, 21, 0.97);
  color: #ffffff;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

.magi-teaser[data-visible="true"] {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.magi-teaser-label {
  display: block;
  margin-bottom: 4px;
  color: var(--magi-orange);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.magi-teaser-text {
  display: block;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
}

.magi-panel {
  display: flex;
  width: min(390px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 110px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 28px;
  background: rgba(17, 17, 17, 0.985);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(22px);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 240ms ease, transform 240ms cubic-bezier(0.23, 1, 0.32, 1);
}

.magi-panel[data-open="true"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.magi-panel[hidden],
.magi-teaser[hidden] {
  display: none;
}

.magi-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 13px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(120deg, #1b1b1b, #0f0f0f);
}

.magi-header-avatar {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255, 106, 0, 0.5);
  border-radius: 18px;
  background: #000000;
  box-shadow: 0 8px 24px rgba(255, 106, 0, 0.13);
}

.magi-header-avatar::after {
  content: "";
  position: absolute;
  inset: -35% 55% -35% -30%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: translateX(-140%);
  animation: magi-scan 6.5s ease-in-out infinite;
}

.magi-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  animation: magi-alive 4.8s ease-in-out infinite;
}

.magi-header-copy {
  min-width: 0;
  flex: 1;
}

.magi-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.magi-name {
  margin: 0;
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.magi-spark {
  color: var(--magi-orange);
  font-size: 15px;
}

.magi-role {
  margin: 3px 0 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.magi-online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  color: rgba(110, 231, 183, 0.92);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.magi-online::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #34d399;
}

.magi-close {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.magi-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.magi-messages {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(255, 106, 0, 0.5) transparent;
  scrollbar-width: thin;
}

.magi-message-row {
  display: flex;
  margin-bottom: 11px;
}

.magi-message-row[data-role="user"] {
  justify-content: flex-end;
}

.magi-message {
  max-width: 86%;
  padding: 11px 13px;
  border-radius: 17px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.magi-message-row[data-role="assistant"] .magi-message {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 5px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.84);
}

.magi-message-row[data-role="user"] .magi-message {
  border-bottom-right-radius: 5px;
  background: var(--magi-orange);
  color: #ffffff;
}

.magi-quick-title {
  margin: 7px 0 8px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.magi-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.magi-chip {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.74);
  font-size: 11px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.magi-chip:hover {
  border-color: rgba(255, 106, 0, 0.5);
  background: rgba(255, 106, 0, 0.1);
  color: #ffffff;
}

.magi-thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 17px 17px 17px 5px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
}

.magi-thinking::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 106, 0, 0.25);
  border-top-color: var(--magi-orange);
  border-radius: 999px;
  animation: magi-spin 700ms linear infinite;
}

.magi-footer {
  padding: 12px 13px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  background: #151515;
}

.magi-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.magi-action {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.magi-action:hover {
  background: rgba(255, 255, 255, 0.08);
}

.magi-action:active {
  transform: scale(0.97);
}

.magi-action[data-primary="true"] {
  border-color: var(--magi-orange);
  background: var(--magi-orange);
}

.magi-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.magi-input {
  width: 100%;
  min-height: 44px;
  max-height: 96px;
  flex: 1;
  resize: none;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
}

.magi-input::placeholder {
  color: rgba(255, 255, 255, 0.33);
}

.magi-input:focus {
  border-color: rgba(255, 106, 0, 0.68);
  box-shadow: 0 0 0 2px rgba(255, 106, 0, 0.18);
}

.magi-input:disabled,
.magi-send:disabled,
.magi-chip:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.magi-send {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--magi-orange);
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.magi-send:hover {
  filter: brightness(1.1);
}

.magi-send:active {
  transform: scale(0.96);
}

.magi-privacy {
  margin: 7px 5px 0;
  color: rgba(255, 255, 255, 0.32);
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
}

@keyframes magi-alive {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  35% { transform: translateY(-2px) rotate(0.5deg) scale(1.008); }
  70% { transform: translateY(0) rotate(-0.4deg) scale(1); }
}

@keyframes magi-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.76); opacity: 0.72; }
}

@keyframes magi-scan {
  0%, 68% { transform: translateX(-160%); opacity: 0; }
  76% { opacity: 1; }
  90%, 100% { transform: translateX(340%); opacity: 0; }
}

@keyframes magi-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 560px) {
  #magi-assistant-root {
    right: 12px;
    bottom: 14px;
  }

  .magi-panel {
    width: calc(100vw - 24px);
    height: min(670px, calc(100dvh - 98px));
    border-radius: 24px;
  }

  .magi-launcher {
    width: 68px;
    height: 68px;
    border-radius: 23px;
  }

  .magi-launcher-image {
    width: 60px;
    height: 60px;
    border-radius: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #magi-assistant-root *,
  #magi-assistant-root *::before,
  #magi-assistant-root *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Full-body guided navigation mode */
#magi-assistant-root {
  right: auto;
  bottom: 0;
  left: 0;
  display: block;
  width: 100vw;
  height: 0;
  pointer-events: none;
}

.magi-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.magi-launcher {
  position: fixed;
  right: auto;
  bottom: 12px;
  left: calc(100vw - 192px);
  display: block;
  width: 170px;
  height: 280px;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  transform-origin: center bottom;
  transition: left 950ms cubic-bezier(0.22, 1, 0.36, 1), transform 180ms ease;
}

.magi-launcher::before {
  display: none;
}

.magi-launcher:hover {
  border-color: transparent;
  box-shadow: none;
  transform: translateY(-3px) scale(1.012);
}

.magi-launcher:active {
  transform: translateY(0) scale(0.99);
}

.magi-guide-character {
  position: absolute;
  inset: 0;
  display: block;
  transform-origin: center bottom;
  transition: transform 260ms ease;
}

.magi-launcher[data-direction="left"] .magi-guide-character {
  transform: scaleX(-1);
}

.magi-guide-image {
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.42));
  animation: magi-guide-idle 4.8s ease-in-out infinite;
}

.magi-launcher[data-walking="true"] .magi-guide-image {
  animation: magi-guide-walk 260ms ease-in-out infinite alternate;
}

.magi-guide-shadow {
  position: absolute;
  right: 24%;
  bottom: 1px;
  left: 24%;
  z-index: -1;
  height: 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.36);
  filter: blur(7px);
  animation: magi-shadow-breathe 4.8s ease-in-out infinite;
}

.magi-status-dot {
  top: 25px;
  right: 28px;
  width: 12px;
  height: 12px;
}

.magi-message-icon {
  right: 16px;
  bottom: 29px;
  left: auto;
  width: 28px;
  height: 28px;
  border: 2px solid #111111;
}

.magi-teaser {
  position: fixed;
  right: 188px;
  bottom: 165px;
  width: min(280px, calc(100vw - 390px));
  max-width: 280px;
  pointer-events: auto;
  text-align: left;
}

#magi-assistant-root[data-guide-side="left"] .magi-teaser {
  right: auto;
  left: 292px;
  border-radius: 18px 18px 18px 4px;
}

.magi-teaser-cta {
  display: block;
  margin-top: 8px;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.magi-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 4;
  pointer-events: none;
}

.magi-panel[data-open="true"] {
  pointer-events: auto;
}

@keyframes magi-guide-idle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  38% { transform: translateY(-4px) rotate(0.5deg); }
  72% { transform: translateY(-1px) rotate(-0.35deg); }
}

@keyframes magi-guide-walk {
  from { transform: translateY(0) rotate(-1.4deg); }
  to { transform: translateY(-7px) rotate(1.4deg); }
}

@keyframes magi-shadow-breathe {
  0%, 100% { transform: scaleX(1); opacity: 0.8; }
  50% { transform: scaleX(0.84); opacity: 0.55; }
}

@media (max-width: 1180px) and (min-width: 721px) {
  .magi-launcher {
    width: 145px;
    height: 238px;
  }

  .magi-teaser {
    right: 158px;
    bottom: 145px;
    width: 250px;
  }

  #magi-assistant-root[data-guide-side="left"] .magi-teaser {
    left: 268px;
  }
}

@media (max-width: 720px) {
  #magi-assistant-root {
    right: auto;
    bottom: 0;
    left: 0;
    width: 100vw;
  }

  .magi-launcher {
    bottom: 52px;
    width: 78px;
    height: 132px;
    border-radius: 0;
    transition: transform 160ms ease;
  }

  .magi-guide-image {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .magi-status-dot {
    top: 8px;
    right: 6px;
    width: 10px;
    height: 10px;
  }

  .magi-message-icon {
    display: none;
  }

  .magi-teaser,
  #magi-assistant-root[data-guide-side="left"] .magi-teaser {
    right: 86px;
    bottom: 126px;
    left: auto;
    width: min(238px, calc(100vw - 104px));
    max-width: 238px;
    border-radius: 17px 17px 4px 17px;
  }

  .magi-panel {
    right: 12px;
    bottom: 12px;
  }
}

/* Keep the full-body guide clear of the first-visit consent banner. */
body:has(#maginf-cookie-banner:not([hidden])) .magi-launcher {
  bottom: 148px;
}

body:has(#maginf-cookie-banner:not([hidden])) .magi-teaser,
body:has(#maginf-cookie-banner:not([hidden])) #magi-assistant-root[data-guide-side="left"] .magi-teaser {
  bottom: 300px;
}

#magi-assistant-root[data-chat-open="true"] .magi-launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.92);
}

@media (max-width: 720px) {
  body:has(#maginf-cookie-banner:not([hidden])) .magi-launcher {
    bottom: 190px;
  }

  body:has(#maginf-cookie-banner:not([hidden])) .magi-teaser,
  body:has(#maginf-cookie-banner:not([hidden])) #magi-assistant-root[data-guide-side="left"] .magi-teaser {
    bottom: 325px;
  }
}
