#maika {
  --maika-bg: rgba(8, 15, 31, .98);
  --maika-panel: rgba(15, 27, 51, .96);
  --maika-line: rgba(148, 163, 184, .20);
  --maika-text: #f8fbff;
  --maika-muted: #a9b8d2;
  --maika-accent: #22d3ee;
  --maika-accent-2: #3b82f6;

  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100000;
  font-family: "DM Sans", system-ui, sans-serif;
}

#maika *,
#maika *::before,
#maika *::after {
  box-sizing: border-box;
}


/* ═══════════════════════════════════════
   LAUNCHER MAIKA
   ═══════════════════════════════════════ */

.maika-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 132px;
  height: 54px;
  padding: 0 16px 0 11px;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(103, 232, 249, .5);
  border-radius: 999px;
  color: #eef2ff;
  background: linear-gradient(115deg, #12324b 0%, #18285a 52%, #253778 100%);
  box-shadow: 0 9px 28px rgba(2, 8, 23, .42), inset 0 1px 0 rgba(255,255,255,.16);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font: 800 14px/1 "DM Sans", system-ui, sans-serif;
  letter-spacing: .15px;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease,
    min-width .24s ease, padding .24s ease;
}

.maika-toggle:hover {
  border-color: rgba(165, 243, 252, .9);
  box-shadow: 0 13px 34px rgba(8, 145, 178, .25), 0 10px 30px rgba(2, 8, 23, .4),
    inset 0 1px 0 rgba(255,255,255,.2);
  transform: translateY(-3px);
}

.maika-toggle:active {
  transform: translateY(-1px) scale(.97);
}

.maika-toggle:focus {
  outline: 0;
}

.maika-toggle:focus-visible {
  outline: 2px solid var(--maika-accent);
  outline-offset: 3px;
}

#maika {
  isolation: isolate;
}

.maika-launcher-actions {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: calc(100% + 8px);
  display: flex;
  gap: 7px;
  padding: 4px;
  border: 1px solid rgba(103, 232, 249, .22);
  border-radius: 999px;
  background: rgba(8, 15, 31, .78);
  box-shadow: 0 8px 24px rgba(2, 8, 23, .28), 0 0 22px rgba(34, 211, 238, .10);
  backdrop-filter: blur(12px);
  transition: opacity .2s ease, transform .2s ease;
}

.maika-launcher-actions button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(165, 243, 252, .24);
  border-radius: 50%;
  background: rgba(15, 27, 51, .94);
  color: #e0f2fe;
  font: 600 19px/1 "DM Sans", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(2, 8, 23, .25);
  animation: maika-control-enter .35s cubic-bezier(.2,.8,.2,1) both;
  transition: color .18s ease, background .18s ease, border-color .18s ease,
    transform .18s ease, box-shadow .18s ease;
}

.maika-launcher-minimize {
  animation-delay: .08s !important;
}

.maika-launcher-close {
  animation-delay: .14s !important;
}

.maika-launcher-minimize:hover {
  transform: translateY(-2px) rotate(-8deg) scale(1.08);
}

.maika-launcher-close:hover {
  border-color: rgba(251, 113, 133, .8);
  background: linear-gradient(145deg, #7f1d35, #3f1028);
  box-shadow: 0 0 18px rgba(251, 113, 133, .32);
  transform: translateY(-2px) rotate(8deg) scale(1.08);
}

.maika-launcher-actions button:active {
  transform: scale(.92);
}

.maika-launcher-actions button:focus-visible {
  outline: 2px solid var(--maika-accent);
  outline-offset: 3px;
}

.maika-toggle-icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 50%;
  color: #a5f3fc;
  background: rgba(103, 232, 249, .14);
  filter: drop-shadow(0 0 7px rgba(103, 232, 249, .48));
  font-size: 19px;
  transition: transform .25s ease, background .25s ease;
}

.maika-toggle:hover .maika-toggle-icon {
  background: rgba(103, 232, 249, .24);
  transform: rotate(35deg) scale(1.08);
}

.maika-toggle-label {
  max-width: 80px;
  overflow: hidden;
  opacity: 1;
  white-space: nowrap;
  transition: max-width .24s ease, opacity .18s ease;
}

#maika.is-minimized .maika-toggle {
  min-width: 50px;
  padding: 0 10px;
}

#maika.is-minimized .maika-toggle-label {
  max-width: 0;
  opacity: 0;
}

#maika.is-controls-dismissed .maika-launcher-actions {
  display: none;
}

#maika.is-minimizing .maika-toggle {
  animation: maika-minimize .28s ease-out;
}

@keyframes maika-control-enter {
  from { opacity: 0; transform: translateY(8px) scale(.7); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes maika-minimize {
  45% { transform: scale(.84); filter: brightness(1.25); }
  100% { transform: scale(1); }
}


/* ═══════════════════════════════════════
   PANEL CHAT MAIKA
   ═══════════════════════════════════════ */

.maika-panel {
  position: absolute;
  right: 0;
  bottom: 82px;

  display: flex;
  flex-direction: column;

  width: min(390px, calc(100vw - 32px));
  max-height: min(650px, calc(100vh - 100px));

  overflow: hidden;

  border: 1px solid var(--maika-line);
  border-radius: 22px;

  color: var(--maika-text);

  background:
    linear-gradient(
      rgba(8, 15, 31, .72),
      rgba(8, 15, 31, .90)
    ),
    url('/assets/img/mascot-cloud.webp') center / cover no-repeat;

  box-shadow:
    0 28px 80px rgba(2, 6, 23, .58),
    0 0 38px rgba(34, 211, 238, .11);

  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);

  transform-origin: bottom right;

  animation: maika-pop .22s ease both;
}

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

@keyframes maika-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */

.maika-head {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 15px 16px;

  border-bottom: 1px solid var(--maika-line);

  background:
    linear-gradient(
      135deg,
      rgba(14, 165, 233, .16),
      rgba(15, 23, 42, .15)
    );
}


/* Avatar GIF di dalam header */

.maika-head-avatar {
  position: relative;

  width: 40px;
  height: 40px;

  padding: 2px;

  overflow: hidden;

  border-radius: 13px;

  background:
    linear-gradient(
      135deg,
      #22d3ee,
      #2563eb
    );

  box-shadow:
    0 0 12px rgba(34, 211, 238, .35),
    0 0 28px rgba(37, 99, 235, .18);
}

.maika-head-avatar img,
.maika-head-avatar video {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: cover;

  border-radius: 10px;
}


/* Judul header */

.maika-head-copy {
  min-width: 0;
  flex: 1;
}

.maika-head-copy strong {
  display: block;
  font-size: 14px;
}

.maika-status {
  display: block;

  margin-top: 2px;

  color: var(--maika-muted);

  font-size: 11px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* Tombol tutup */

.maika-close,
.maika-clear {
  border: 0;

  color: var(--maika-muted);

  background: transparent;

  cursor: pointer;
}

.maika-close {
  width: 34px;
  height: 34px;

  border-radius: 10px;

  font-size: 19px;
}

.maika-close:hover,
.maika-clear:hover {
  color: var(--maika-text);
  background: rgba(255, 255, 255, .08);
}


/* ═══════════════════════════════════════
   PESAN
   ═══════════════════════════════════════ */

.maika-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;

  min-height: 190px;
  max-height: 390px;

  padding: 16px;

  overflow-y: auto;

  overscroll-behavior: contain;
}

.maika-message {
  max-width: 88%;

  padding: 10px 12px;

  border: 1px solid var(--maika-line);

  border-radius: 14px 14px 14px 4px;

  color: #e8f0ff;

  background: rgba(255, 255, 255, .065);

  font-size: 13px;
  line-height: 1.55;

  overflow-wrap: anywhere;
}

.maika-message.user {
  align-self: flex-end;

  border-color: rgba(34, 211, 238, .26);

  border-radius: 14px 14px 4px 14px;

  background: rgba(14, 165, 233, .16);
}

.maika-message p {
  margin: 0 0 7px;
}

.maika-message p:last-child {
  margin-bottom: 0;
}

.maika-message a {
  color: #8be9ff;
  font-weight: 700;
}

.maika-message ul {
  margin: 7px 0 0 18px;
  padding: 0;
}


/* ═══════════════════════════════════════
   SARAN PERTANYAAN
   ═══════════════════════════════════════ */

.maika-suggestions {
  display: flex;
  gap: 7px;

  padding: 0 16px 12px;

  overflow-x: auto;

  scrollbar-width: thin;
}

.maika-suggestion {
  flex: 0 0 auto;

  padding: 7px 10px;

  border: 1px solid rgba(34, 211, 238, .25);
  border-radius: 999px;

  color: #b9f5ff;

  background: rgba(34, 211, 238, .07);

  cursor: pointer;

  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.maika-suggestion:hover {
  background: rgba(34, 211, 238, .15);
}


/* ═══════════════════════════════════════
   FORM CHAT
   ═══════════════════════════════════════ */

.maika-form {
  display: flex;
  gap: 8px;

  padding: 12px;

  border-top: 1px solid var(--maika-line);

  background: rgba(2, 6, 23, .24);
}

.maika-input {
  min-width: 0;
  flex: 1;

  height: 42px;

  padding: 0 12px;

  border: 1px solid var(--maika-line);
  border-radius: 12px;

  color: var(--maika-text);

  background: rgba(255, 255, 255, .07);

  font-family: inherit;
  font-size: 13px;
}

.maika-input::placeholder {
  color: #8291ab;
}

.maika-input:focus {
  border-color: var(--maika-accent);

  outline: 0;

  box-shadow:
    0 0 0 3px rgba(34, 211, 238, .12);
}

.maika-send {
  flex: 0 0 auto;

  min-width: 64px;

  border: 0;
  border-radius: 12px;

  color: #06111f;

  background:
    linear-gradient(
      135deg,
      #67e8f9,
      #38bdf8
    );

  cursor: pointer;

  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
}


/* ═══════════════════════════════════════
   BERSIHKAN CHAT
   ═══════════════════════════════════════ */

.maika-clear {
  align-self: flex-end;

  margin: 0 14px 9px;

  padding: 3px 6px;

  border-radius: 6px;

  font-family: inherit;
  font-size: 11px;
}

.maika-typing {
  color: var(--maika-muted);

  font-size: 11px;
  font-style: italic;
}


/* ═══════════════════════════════════════
   FOCUS
   ═══════════════════════════════════════ */

.maika-close:focus-visible,
.maika-suggestion:focus-visible,
.maika-send:focus-visible,
.maika-clear:focus-visible {
  outline: 2px solid var(--maika-accent);
  outline-offset: 3px;
}


/* ═══════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════ */

@media (max-width: 640px) {

  #maika {
    right: 14px;
    bottom: 14px;
  }

  .maika-toggle {
    min-width: 124px;
    height: 52px;
    padding: 0 14px 0 10px;
  }

  #maika.is-minimized .maika-toggle {
    min-width: 48px;
    padding: 0 9px;
  }

  .maika-launcher-actions {
    right: 0;
  }

  .maika-panel {
    right: -2px;
    bottom: 68px;

    width: min(
      390px,
      calc(100vw - 28px)
    );

    max-height: calc(100vh - 82px);

    border-radius: 18px;
  }

  .maika-messages {
    max-height: min(52vh, 360px);
  }
}


/* ═══════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {

  .maika-panel,
  .maika-toggle,
  .maika-launcher-actions,
  .maika-launcher-actions button,
  #maika.is-minimizing .maika-toggle {
    animation: none;
    transition: none;
  }
}

/* EduGame Copilot visual language, adapted for Maika's existing chat controls. */
#maika {
  --maika-bg: rgba(8, 13, 29, .97);
  --maika-line: rgba(255, 255, 255, .14);
  --maika-text: #eef2ff;
  --maika-muted: #a6b0d6;
  --maika-accent: #00d4ff;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  font-family: "DM Sans", system-ui, sans-serif;
}

.maika-toggle {
  min-width: 0;
  height: 54px;
  gap: 10px;
  padding: 0 17px 0 10px;
  border-color: rgba(255, 255, 255, .2);
  background: linear-gradient(130deg, rgba(18, 28, 54, .97), rgba(20, 37, 67, .97));
  box-shadow: 0 10px 34px rgba(0, 0, 0, .38);
  font-size: 14px;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease,
    min-width .24s ease, padding .24s ease;
}

.maika-toggle:hover {
  border-color: rgba(0, 212, 255, .6);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .42);
  transform: translateY(-2px);
}

.maika-toggle-icon {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  color: #07101d;
  background: linear-gradient(135deg, #00d4ff, #8b5cf6);
  box-shadow: 0 6px 22px rgba(0, 212, 255, .24);
  font-size: 21px;
  transition: transform .2s ease;
}

.maika-toggle:hover .maika-toggle-icon {
  background: linear-gradient(135deg, #00d4ff, #8b5cf6);
}

.maika-toggle[aria-expanded="true"] .maika-toggle-icon {
  transform: rotate(45deg);
}

#maika.is-minimized .maika-toggle {
  min-width: 48px;
  padding: 0 9px;
}

.maika-launcher-actions {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(8, 13, 29, .88);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}

.maika-launcher-actions button {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
}

.maika-panel {
  bottom: 68px;
  width: min(390px, calc(100vw - 28px));
  max-height: min(590px, calc(100dvh - 110px));
  border-color: rgba(255, 255, 255, .16);
  border-radius: 20px;
  background: rgba(8, 13, 29, .97);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .48);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.maika-head {
  gap: 12px;
  padding: 16px;
  border-bottom-color: rgba(255, 255, 255, .09);
  background: transparent;
}

.maika-head-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #00d4ff, #8b5cf6);
  box-shadow: 0 6px 22px rgba(0, 212, 255, .24);
}

.maika-head-avatar img,
.maika-head-avatar video {
  border-radius: 11px;
}

.maika-head-copy strong {
  font-size: 1rem;
  line-height: 1.3;
}

.maika-status {
  color: #8894bb;
  font-size: .72rem;
}

.maika-close {
  width: 38px;
  height: 38px;
  margin-left: auto;
  border-radius: 10px;
  font-size: 25px;
}

.maika-messages {
  gap: 10px;
  min-height: 116px;
  max-height: 280px;
  padding: 16px;
}

.maika-message {
  max-width: 92%;
  padding: 10px 13px;
  border-color: rgba(255, 255, 255, .09);
  border-radius: 14px;
  background: rgba(255, 255, 255, .06);
  color: #e8edff;
  font-size: .88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.maika-message.user {
  border-color: rgba(0, 212, 255, .24);
  border-radius: 14px;
  background: rgba(0, 212, 255, .12);
}

.maika-message a {
  color: #7ce8ff;
}

.maika-message ul {
  padding-left: 18px;
}

.maika-suggestions {
  gap: 7px;
  padding: 0 14px 12px;
  scrollbar-width: thin;
}

.maika-suggestion {
  min-height: 34px;
  padding: 0 11px;
  border-color: rgba(255, 255, 255, .13);
  color: #c9d2f2;
  background: rgba(255, 255, 255, .03);
  font-size: .76rem;
}

.maika-suggestion:hover {
  border-color: #00d4ff;
  color: #fff;
  background: rgba(255, 255, 255, .06);
}

.maika-clear {
  margin: 0 14px 8px;
  padding: 4px 7px;
  color: #a6b0d6;
}

.maika-form {
  align-items: center;
  gap: 8px;
  margin: 0 14px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  background: rgba(255, 255, 255, .045);
}

.maika-form:focus-within {
  border-color: #00d4ff;
}

.maika-input {
  height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  outline: 0;
  background: transparent;
  color: #eef2ff;
  font: inherit;
  font-size: .9rem;
  box-shadow: none;
}

.maika-input::placeholder {
  color: #7f8ab1;
}

.maika-input:focus {
  border-color: transparent;
  outline: 0;
  box-shadow: none;
}

.maika-send {
  display: grid;
  width: 40px;
  min-width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(120deg, #6366f1, #00d4ff);
  color: #07101d;
  font-size: 19px;
}

.maika-assistant-note {
  margin: 0;
  padding: 10px 16px 13px;
  color: #8894bb;
  font-size: .72rem;
  line-height: 1.4;
}

#maika :focus-visible {
  outline: 2px solid #00d4ff;
  outline-offset: 3px;
}

@media (max-width: 640px) {
  #maika {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .maika-toggle {
    height: 54px;
    padding: 0 17px 0 10px;
  }

  #maika.is-minimized .maika-toggle {
    min-width: 48px;
    padding: 0 9px;
  }

  .maika-panel {
    right: 0;
    bottom: 64px;
    width: min(390px, calc(100vw - 28px));
    max-height: min(570px, calc(100dvh - 96px));
  }

  .maika-messages {
    max-height: min(36vh, 250px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .maika-toggle,
  .maika-toggle-icon {
    transition: none !important;
  }
}
