.kuma-ai-chat,
.kuma-ai-chat * {
  box-sizing: border-box;
}

.kuma-ai-chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2200;
  --ai-chat-text: #eef3ff;
  --ai-chat-title: #fff;
  --ai-chat-muted: #aebbd2;
  --ai-chat-note: #7f8ca5;
  --ai-chat-panel: #111827;
  --ai-chat-header: radial-gradient(circle at 88% 10%, rgba(255, 159, 67, .24), transparent 48%), #172033;
  --ai-chat-surface: #202c42;
  --ai-chat-input-area: #151e31;
  --ai-chat-input: #0e1627;
  --ai-chat-border: rgba(255, 255, 255, .07);
  --ai-chat-input-border: rgba(174, 187, 210, .28);
  --ai-chat-close: #b8c3d7;
  --ai-chat-close-bg: rgba(255, 255, 255, .08);
  --ai-chat-close-hover: rgba(255, 255, 255, .15);
  --ai-chat-scrollbar: #40516f;
  --ai-chat-quick-text: #ffd98a;
  --ai-chat-quick-border: rgba(255, 209, 102, .32);
  --ai-chat-quick-bg: rgba(255, 209, 102, .06);
  color: var(--ai-chat-text);
  color-scheme: dark;
  font-family: inherit;
  transition: transform .32s cubic-bezier(.22, 1, .36, 1), opacity .24s ease;
  will-change: transform, opacity;
}

/* Shared visibility controls for the floating AI and Theme utilities. */
.lang-switch {
  transition: transform .32s cubic-bezier(.22, 1, .36, 1), opacity .24s ease;
  will-change: transform, opacity;
}

.utility-controls-hide {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 2px;
  padding: 0;
  border: 1px solid rgba(255, 189, 63, .32);
  border-radius: 9px;
  color: #dbe7f6;
  background: rgba(7, 17, 31, .72);
  cursor: pointer;
  font-size: 12px;
  transition: color .18s ease, background-color .18s ease, transform .18s ease;
}

.utility-controls-hide:hover,
.utility-controls-hide:focus-visible {
  color: #1a130b;
  background: #ffd166;
  outline: none;
  transform: translateY(-1px);
}

.utility-controls-restore {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2305;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 189, 63, .52);
  border-radius: 12px;
  color: #1a130b;
  background: linear-gradient(135deg, #ffd166 0%, #ff9f43 100%);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .32), 0 0 0 1px rgba(255, 255, 255, .18) inset;
  cursor: pointer;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(18px) scale(.86);
  transition: transform .32s cubic-bezier(.22, 1, .36, 1), opacity .24s ease;
}

.utility-controls-restore.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.utility-controls-restore:focus-visible {
  outline: 2px solid #fff1bf;
  outline-offset: 3px;
}

body.utility-controls-hidden .kuma-ai-chat,
body.utility-controls-hidden .lang-switch {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 28px));
}

@media (prefers-reduced-motion: reduce) {
  .kuma-ai-chat,
  .lang-switch,
  .utility-controls-hide,
  .utility-controls-restore {
    transition: none !important;
  }
}

/* The dashboard layouts reserve the bottom-right corner for the Theme switcher. */
body.kuma-ui-gaming .kuma-ai-chat,
body.kuma-ui-classic .kuma-ai-chat {
  bottom: 88px;
}

.kuma-ai-chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px 12px 13px;
  color: #17100a;
  background: linear-gradient(135deg, #ffd166 0%, #ff9f43 100%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .32), 0 0 0 1px rgba(255, 255, 255, .18) inset;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease;
}

.kuma-ai-chat-launcher:hover,
.kuma-ai-chat-launcher:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, .38), 0 0 0 2px rgba(255, 209, 102, .35);
  outline: none;
}

.kuma-ai-chat-launcher-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff8ec;
  background: #20150d;
  font-size: 17px;
}

.kuma-ai-chat-panel {
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 110px));
  min-height: 400px;
  overflow: hidden;
  border: 1px solid rgba(255, 209, 102, .2);
  border-radius: 22px;
  background: var(--ai-chat-panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .46), 0 0 0 1px rgba(255, 255, 255, .04) inset;
  animation: kuma-ai-chat-in .2s ease-out;
}

.kuma-ai-chat-panel[hidden] {
  display: none;
}

.kuma-ai-chat-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 16px;
  background: var(--ai-chat-header);
}

.kuma-ai-chat-kicker {
  color: #ffc566;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}

.kuma-ai-chat-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 50%;
  background: #8ee28e;
  box-shadow: 0 0 0 4px rgba(142, 226, 142, .1);
}

.kuma-ai-chat-header h2 {
  margin: 6px 0 2px;
  color: var(--ai-chat-title);
  font-size: 22px;
  line-height: 1.1;
}

.kuma-ai-chat-header p {
  margin: 0;
  color: var(--ai-chat-muted);
  font-size: 12px;
}

.kuma-ai-chat-close {
  align-self: flex-start;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  color: var(--ai-chat-close);
  background: var(--ai-chat-close-bg);
  cursor: pointer;
  font: inherit;
  font-size: 22px;
  line-height: 1;
}

.kuma-ai-chat-close:hover,
.kuma-ai-chat-close:focus-visible {
  color: var(--ai-chat-title);
  background: var(--ai-chat-close-hover);
  outline: none;
}

.kuma-ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  scrollbar-color: var(--ai-chat-scrollbar) transparent;
}

.kuma-ai-chat-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}

.kuma-ai-chat-message.is-user {
  justify-content: flex-end;
}

.kuma-ai-chat-avatar {
  display: grid;
  flex: 0 0 26px;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  color: #17100a;
  background: #ffd166;
  font-size: 12px;
  font-weight: 900;
}

.kuma-ai-chat-bubble {
  max-width: 82%;
  padding: 10px 12px;
  border: 1px solid var(--ai-chat-border);
  border-radius: 14px 14px 14px 4px;
  color: var(--ai-chat-text);
  background: var(--ai-chat-surface);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.kuma-ai-chat-message.is-user .kuma-ai-chat-bubble {
  border-radius: 14px 14px 4px 14px;
  color: #1a130b;
  background: #ffd166;
}

.kuma-ai-chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 18px 34px;
}

.kuma-ai-chat-quick-actions button {
  border: 1px solid var(--ai-chat-quick-border);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--ai-chat-quick-text);
  background: var(--ai-chat-quick-bg);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}

.kuma-ai-chat-quick-actions button:hover,
.kuma-ai-chat-quick-actions button:focus-visible {
  color: #1a130b;
  background: #ffd166;
  outline: none;
}

.kuma-ai-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 52px;
}

.kuma-ai-chat-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ai-chat-muted);
  animation: kuma-ai-chat-bounce 1s infinite ease-in-out;
}

.kuma-ai-chat-typing span:nth-child(2) { animation-delay: .12s; }
.kuma-ai-chat-typing span:nth-child(3) { animation-delay: .24s; }

.kuma-ai-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 8px;
  border-top: 1px solid var(--ai-chat-border);
  background: var(--ai-chat-input-area);
}

.kuma-ai-chat-form textarea {
  flex: 1;
  min-height: 40px;
  max-height: 100px;
  resize: none;
  border: 1px solid var(--ai-chat-input-border);
  border-radius: 12px;
  padding: 10px 11px;
  color: var(--ai-chat-text);
  background: var(--ai-chat-input);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.kuma-ai-chat-form textarea:focus {
  border-color: #ffd166;
  outline: 2px solid rgba(255, 209, 102, .12);
}

.kuma-ai-chat-form > button {
  display: grid;
  flex: 0 0 40px;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  color: #1a130b;
  background: #ffd166;
  cursor: pointer;
  font-size: 18px;
}

.kuma-ai-chat-form > button:disabled {
  cursor: wait;
  opacity: .5;
}

.kuma-ai-chat-note {
  padding: 0 14px 12px;
  color: var(--ai-chat-note);
  background: var(--ai-chat-input-area);
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

/* Follow the existing Light Theme controls on both landing and client pages. */
html[data-color-mode="light"] .kuma-ai-chat,
body[data-color-mode="light"] .kuma-ai-chat,
body.kuma-ui-gaming:not(.dark-page) .kuma-ai-chat,
body.kuma-ui-classic:not(.dark-page) .kuma-ai-chat {
  --ai-chat-text: #24364a;
  --ai-chat-title: #1d2a3a;
  --ai-chat-muted: #607387;
  --ai-chat-note: #73879a;
  --ai-chat-panel: #fff;
  --ai-chat-header: radial-gradient(circle at 88% 10%, rgba(255, 178, 77, .2), transparent 48%), #f4f8fb;
  --ai-chat-surface: #eef3f7;
  --ai-chat-input-area: #f3f7fa;
  --ai-chat-input: #fff;
  --ai-chat-border: rgba(45, 69, 94, .14);
  --ai-chat-input-border: rgba(82, 101, 119, .3);
  --ai-chat-close: #526577;
  --ai-chat-close-bg: rgba(18, 34, 54, .07);
  --ai-chat-close-hover: rgba(18, 34, 54, .13);
  --ai-chat-scrollbar: #b7c5d1;
  --ai-chat-quick-text: #9b5f00;
  --ai-chat-quick-border: rgba(198, 132, 16, .34);
  --ai-chat-quick-bg: rgba(255, 209, 102, .12);
  color-scheme: light;
}

html[data-color-mode="light"] .kuma-ai-chat-panel,
body[data-color-mode="light"] .kuma-ai-chat-panel,
body.kuma-ui-gaming:not(.dark-page) .kuma-ai-chat-panel,
body.kuma-ui-classic:not(.dark-page) .kuma-ai-chat-panel {
  box-shadow: 0 24px 70px rgba(38, 57, 76, .2), 0 0 0 1px rgba(38, 57, 76, .04) inset;
}

.kuma-ai-chat-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes kuma-ai-chat-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes kuma-ai-chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .55; }
  40% { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 540px) {
  .utility-controls-restore {
    right: 12px;
    bottom: 12px;
    width: 36px;
    height: 36px;
  }

  .kuma-ai-chat {
    right: 12px;
    bottom: 12px;
  }

  body.kuma-ui-gaming .kuma-ai-chat,
  body.kuma-ui-classic .kuma-ai-chat {
    bottom: 78px;
  }

  .kuma-ai-chat-panel {
    height: min(640px, calc(100vh - 86px));
    min-height: 360px;
  }

  .kuma-ai-chat-launcher {
    padding-right: 14px;
  }
}
