/* Alex AI follows the portfolio typography, slate buttons, and neutral canvas. */
.alex-ai-widget {
  --chat-ink: #212121;
  --chat-muted: #62606c;
  --chat-accent: #474559;
  --chat-accent-ink: #fff;
  --chat-line: #e4e3e8;
  --chat-surface: #fff;
  --chat-soft: #f3f2f5;
  position: fixed;
  z-index: 1000000;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  color: var(--chat-ink);
  font-family: inherit;
}
.dark-mode .alex-ai-widget {
  --chat-ink: #f1eff5;
  --chat-muted: #bdb9c5;
  --chat-accent: #e6e3ec;
  --chat-accent-ink: #28252f;
  --chat-line: #403b49;
  --chat-surface: #24212b;
  --chat-soft: #302c38;
}
.alex-ai-launcher { display: flex; align-items: center; gap: 9px; min-height: 48px; padding: 12px 18px; border: 0; border-radius: 50px; color: var(--chat-accent-ink); background: var(--chat-accent); box-shadow: 0 4px 16px #0002; cursor: pointer; font: inherit; font-size: 14px; font-weight: 700; transition: background .15s, color .15s; }
.alex-ai-launcher[hidden] { display: none; }
.alex-ai-launcher:hover { background: #ffc200; color: #212121; }
.alex-ai-launcher__icon { display: flex; }
.alex-ai-launcher__icon svg { width: 20px; height: 20px; }
.alex-ai-widget :is(button, a, textarea):focus-visible { outline: 2px solid #a17c00; outline-offset: 3px; }
.alex-ai-panel { position: absolute; right: 0; bottom: 64px; display: flex; flex-direction: column; width: min(390px, calc(100vw - 32px)); height: min(550px, calc(100dvh - 170px)); min-height: 280px; overflow: hidden; border: 1px solid var(--chat-line); border-radius: 14px; background: var(--chat-surface); box-shadow: 0 12px 36px #0002; animation: chat-enter .16s ease-out; }
.alex-ai-panel[hidden], .alex-ai-message[hidden], .alex-ai-status-card[hidden] { display: none; }
.alex-ai-panel__header { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--chat-line); }
.alex-ai-panel__identity h2 { margin: 0; padding: 0; color: var(--chat-ink); font-size: 18px; line-height: 1.4; letter-spacing: -.02em; }
.alex-ai-close { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--chat-muted); cursor: pointer; }
.alex-ai-close:hover { background: var(--chat-soft); }
.alex-ai-close svg { width: 20px; height: 20px; }
.alex-ai-panel__body { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 18px 20px 0; }
.alex-ai-status-card { margin-bottom: 16px; padding: 12px; border-radius: 8px; background: var(--chat-soft); }
.alex-ai-status-card p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--chat-muted); }
.alex-ai-messages { display: flex; flex: 1; flex-direction: column; gap: 16px; min-height: 0; overflow-y: auto; padding: 2px 2px 18px 0; overscroll-behavior: contain; overflow-anchor: none; scroll-behavior: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--chat-line) transparent; }
.alex-ai-message { flex-shrink: 0; align-self: flex-start; max-width: 92%; min-width: 0; animation: chat-enter .16s ease-out; }
.alex-ai-message--user { align-self: flex-end; max-width: 88%; }
.alex-ai-message__content { min-width: 0; }
.alex-ai-message__content p { margin: 0; padding: 11px 14px; border-radius: 10px 10px 10px 2px; color: var(--chat-ink); background: var(--chat-soft); font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.alex-ai-message--user .alex-ai-message__content p { border-radius: 10px 10px 2px 10px; background: var(--chat-accent); color: var(--chat-accent-ink); }
.alex-ai-message__content a { color: var(--chat-accent); text-decoration: underline; text-underline-offset: 3px; }
.alex-ai-message--error .alex-ai-message__content p { border: 1px solid var(--chat-line); }
.alex-ai-topics { flex-shrink: 0; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; border-top: 1px solid var(--chat-line); }
.alex-ai-topics a { display: inline-flex; align-items: center; min-height: 44px; color: var(--chat-muted); font-size: 12px; font-weight: 500; text-decoration: none; }
.alex-ai-topics a:hover { text-decoration: underline; text-underline-offset: 3px; }
.alex-ai-composer { flex-shrink: 0; display: grid; grid-template-columns: minmax(0,1fr) 44px; align-items: end; gap: 8px; padding: 14px 16px 12px; border-top: 1px solid var(--chat-line); background: var(--chat-surface); }
.alex-ai-composer textarea { width: 100%; min-width: 0; min-height: 44px; max-height: 112px; resize: none; padding: 11px 12px; border: 1px solid var(--chat-line); border-radius: 8px; background: var(--chat-surface); color: var(--chat-ink); font: inherit; font-size: 14px; line-height: 1.5; }
.alex-ai-composer textarea::placeholder { color: var(--chat-muted); opacity: 1; }
.alex-ai-composer textarea:disabled { background: var(--chat-soft); cursor: not-allowed; }
.alex-ai-send { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 8px; background: var(--chat-accent); color: var(--chat-accent-ink); cursor: pointer; }
.alex-ai-send:hover:not(:disabled) { background: #ffc200; color: #212121; }
.alex-ai-send:disabled { background: var(--chat-soft); color: var(--chat-muted); cursor: not-allowed; }
.alex-ai-send svg { width: 19px; height: 19px; }
.alex-ai-composer .alex-ai-composer__hint { grid-column: 1 / -1; margin: 0; font-size: 10px; line-height: 1.5; color: var(--chat-muted); }
.alex-ai-typing { display: flex; align-items: center; gap: 5px; min-height: 44px; }
.alex-ai-typing__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--chat-muted); animation: chat-dot 1.2s ease-in-out infinite; }
.alex-ai-typing__dot:nth-of-type(3) { animation-delay: .15s; }
.alex-ai-typing__dot:nth-of-type(4) { animation-delay: .3s; }
html.alex-ai-open { overflow: hidden; scroll-behavior: auto; }
body.alex-ai-open { overflow: hidden; overscroll-behavior: none; }
.alex-ai-backdrop { display: none; }
@keyframes chat-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes chat-dot { 0%,70%,100% { opacity: .35; } 35% { opacity: 1; } }
@media (max-width: 600px) {
  body.alex-ai-open { position: fixed; top: var(--chat-page-y); left: var(--chat-page-x); width: 100%; }
  .alex-ai-widget { right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); }
  .alex-ai-message { animation: none; }
  .alex-ai-panel { animation: none; position: fixed; z-index: 1; inset: 0; width: 100%; height: 100dvh; min-height: 0; border: 0; border-radius: 0; padding-top: env(safe-area-inset-top); }
  .alex-ai-panel__header { flex-shrink: 0; padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .alex-ai-panel__body { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .alex-ai-composer { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .alex-ai-composer textarea { font-size: 16px; }
  .alex-ai-launcher[aria-expanded="true"] { visibility: hidden; }
}
@media (max-height: 500px) and (min-width: 601px) { .alex-ai-panel { min-height: 0; height: calc(100dvh - 160px); } }
@media (prefers-reduced-motion: reduce) { .alex-ai-widget *, .alex-ai-widget *::before, .alex-ai-widget *::after { animation: none !important; transition: none !important; } }
