.apex-chat-open { overflow: hidden; }

.apex-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent, #e6b800);
  color: #080808;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3), 0 18px 48px rgba(0, 0, 0, .38);
  font: 700 14px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: transform 150ms cubic-bezier(0, 0, .2, 1), box-shadow 150ms cubic-bezier(0, 0, .2, 1);
}

.apex-chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .34), 0 22px 56px rgba(0, 0, 0, .44); }
.apex-chat-launcher:active { transform: scale(.97); }
.apex-chat-launcher:focus-visible,
.apex-chat button:focus-visible,
.apex-chat textarea:focus-visible,
.apex-chat a:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.apex-chat-launcher svg { width: 22px; height: 22px; }

.apex-chat {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 1001;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(390px, calc(100vw - 32px));
  height: min(620px, calc(100dvh - 120px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius, 18px);
  background: #111;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .34), 0 32px 90px rgba(0, 0, 0, .62);
  font-family: Inter, system-ui, sans-serif;
  opacity: 0;
  transform: translateY(12px) scale(.98);
  pointer-events: none;
  transition: opacity 200ms cubic-bezier(0, 0, .2, 1), transform 200ms cubic-bezier(0, 0, .2, 1);
}

.apex-chat[data-open="true"] { opacity: 1; transform: none; pointer-events: auto; }
.apex-chat__header { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: linear-gradient(135deg, #080808 0%, #121109 100%); border-bottom: 1px solid rgba(255, 255, 255, .1); }
.apex-chat__header::after { content: ''; position: absolute; right: 0; bottom: -1px; left: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(230, 184, 0, .6), transparent); }
.apex-chat__mark { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 50%; background: linear-gradient(145deg, #f3ca21, var(--accent, #e6b800)); color: #080808; box-shadow: 0 0 0 4px rgba(230, 184, 0, .08); font-weight: 800; }
.apex-chat__title { flex: 1; }
.apex-chat__eyebrow { display: block; margin-bottom: 2px; color: rgba(255, 255, 255, .46); font-size: 9px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.apex-chat__title strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.apex-chat__status { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: rgba(255, 255, 255, .62); font-size: 11px; }
.apex-chat__status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #64d98b; box-shadow: 0 0 0 3px rgba(100, 217, 139, .1); }
.apex-chat__close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 25px; cursor: pointer; }
.apex-chat__close:hover { background: rgba(255, 255, 255, .08); }
.apex-chat__close:active, .apex-chat__send:active, .apex-chat__quick button:active { transform: scale(.97); }

.apex-chat__messages { overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 20px 18px; background: radial-gradient(circle at 50% 0, rgba(230, 184, 0, .09), transparent 34%), #111; scroll-behavior: smooth; touch-action: pan-y; }
.apex-chat__messages::-webkit-scrollbar { width: 8px; }
.apex-chat__messages::-webkit-scrollbar-track { background: transparent; }
.apex-chat__messages::-webkit-scrollbar-thumb { border: 2px solid #111; border-radius: 999px; background: rgba(255, 255, 255, .2); }
.apex-chat__message { max-width: 86%; margin: 0 0 12px; padding: 12px 14px; border-radius: 16px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.apex-chat__message--assistant { border: 1px solid rgba(255, 255, 255, .08); border-bottom-left-radius: 4px; background: #202020; color: rgba(255, 255, 255, .92); box-shadow: 0 6px 18px rgba(0, 0, 0, .16); }
.apex-chat__message--user { margin-left: auto; border-bottom-right-radius: 4px; background: linear-gradient(145deg, #f0c91f, var(--accent, #e6b800)); color: #080808; box-shadow: 0 6px 18px rgba(230, 184, 0, .12); }
.apex-chat__message--error { border: 1px solid rgba(255, 145, 145, .35); background: rgba(130, 20, 20, .25); }
.apex-chat__message a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.apex-chat__typing { color: rgba(255, 255, 255, .58); }
.apex-chat__quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 16px; }
.apex-chat__quick button { min-height: 44px; padding: 9px 13px; border: 1px solid rgba(230, 184, 0, .36); border-radius: 999px; background: rgba(230, 184, 0, .03); color: #f1d45a; font: 600 12px/1.3 inherit; cursor: pointer; transition: background 150ms cubic-bezier(0, 0, .2, 1), border-color 150ms cubic-bezier(0, 0, .2, 1), transform 150ms cubic-bezier(0, 0, .2, 1); }
.apex-chat__quick button:hover { border-color: rgba(230, 184, 0, .7); background: rgba(230, 184, 0, .1); }

.apex-chat__composer { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .1); background: linear-gradient(180deg, #0d0d0d, #080808); }
.apex-chat__privacy { margin: 0 2px 9px; color: rgba(255, 255, 255, .48); font-size: 10px; line-height: 1.4; }
.apex-chat__form { display: flex; align-items: end; gap: 8px; }
.apex-chat textarea { flex: 1; min-height: 44px; max-height: 110px; resize: none; padding: 11px 13px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 14px; background: #181818; color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); font: 14px/1.45 inherit; transition: border-color 150ms cubic-bezier(0, 0, .2, 1), background 150ms cubic-bezier(0, 0, .2, 1); }
.apex-chat textarea:hover { border-color: rgba(255, 255, 255, .26); }
.apex-chat textarea:focus { border-color: rgba(230, 184, 0, .7); background: #1b1b1b; }
.apex-chat textarea::placeholder { color: rgba(255, 255, 255, .38); }
.apex-chat__send { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border: 0; border-radius: 50%; background: linear-gradient(145deg, #f0c91f, var(--accent, #e6b800)); color: #080808; box-shadow: 0 6px 16px rgba(230, 184, 0, .16); cursor: pointer; transition: transform 150ms cubic-bezier(0, 0, .2, 1), opacity 150ms cubic-bezier(0, 0, .2, 1); }
.apex-chat__send:disabled { opacity: .45; cursor: wait; }
.apex-chat__send svg { width: 19px; height: 19px; }

@media (max-width: 560px) {
  .apex-chat-launcher { right: 16px; bottom: 16px; padding: 0; width: 56px; justify-content: center; }
  .apex-chat-launcher span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .apex-chat { inset: 12px; width: auto; height: auto; border-radius: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .apex-chat, .apex-chat-launcher { transition: none; }
}
