#leo-ai {
  --leo-gold: #d4af37;
  --leo-text: #f8f4e8;
  --leo-muted: #bfb8ab;
  --leo-line: #d4af3752;
  --leo-edge: max(17px, env(safe-area-inset-right));
  --leo-base: max(16px, env(safe-area-inset-bottom));
  font-family: Manrope, system-ui, sans-serif;
  color: var(--leo-text);
}

#leo-ai [hidden] { display: none; }
:where(#leo-ai) button { font: inherit; cursor: pointer; }
#leo-ai :focus-visible { outline: 2px solid #ffe188; outline-offset: 3px; }

.leo-ai-launcher {
  position: fixed;
  z-index: 30;
  right: var(--leo-edge);
  bottom: var(--leo-base);
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 53px;
  padding: 0 18px 0 13px;
  border-radius: 32px;
  border: 1px solid #f3cd58;
  color: #ffe08a;
  background: linear-gradient(140deg, #302715, #0a0a0c 72%);
  box-shadow: 0 0 18px #d4af3735, 0 8px 22px #0009, inset 0 1px #ffdc7024;
  transition: transform 160ms ease, box-shadow 160ms ease;
  touch-action: manipulation;
}

.leo-ai-launcher span { font-size: 14px; font-weight: 800; letter-spacing: -.02em; }
.leo-ai-launcher:hover { transform: translateY(-2px); box-shadow: 0 0 24px #d4af376b, 0 8px 24px #0009; }
.leo-ai-launcher[aria-expanded="true"] { background: linear-gradient(140deg, #423416, #171309); }

.leo-ai-panel {
  position: fixed;
  z-index: 30;
  right: var(--leo-edge);
  bottom: calc(var(--leo-base) + 64px);
  display: flex;
  flex-direction: column;
  width: min(398px, calc(100vw - var(--leo-edge) - 14px));
  height: min(514px, calc(100vh - var(--leo-base) - 82px));
  height: min(514px, calc(100dvh - var(--leo-base) - 82px));
  overflow: hidden;
  border: 1px solid var(--leo-line);
  border-radius: 19px;
  background: radial-gradient(ellipse at 94% 3%, #20402d50, transparent 38%), #0a0a0cf5;
  box-shadow: 0 16px 60px #000a, inset 0 1px #ffe08a23;
  backdrop-filter: blur(12px);
  transform-origin: right bottom;
  animation: leo-ai-enter 175ms ease-out both;
}

.leo-ai-panel.leo-ai-closing { animation: leo-ai-leave 145ms ease-in both; pointer-events: none; }
@keyframes leo-ai-enter { from { opacity: 0; transform: translateY(9px) scale(.98); } }
@keyframes leo-ai-leave { to { opacity: 0; transform: translateY(9px) scale(.98); } }

.leo-ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 15px;
  border-bottom: 1px solid var(--leo-line);
}

.leo-ai-mark {
  flex: 0 0 36px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--leo-line);
  border-radius: 11px;
  background: linear-gradient(135deg, #e8874b3b, #d4af371c);
  color: #ffdf83;
  font-size: 19px;
}

.leo-ai-identity { min-width: 0; flex: 1; }
.leo-ai-identity h2 { color: #ffe295; font: 750 17px/1.15 Manrope, system-ui, sans-serif; margin: 0 0 4px; }
.leo-ai-identity p { color: var(--leo-muted); font-size: 10px; line-height: 1.15; margin: 0; }
.leo-ai-identity p span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #73df9a; margin-right: 3px; }

.leo-ai-header .leo-ai-quiet, .leo-ai-header .leo-ai-close, .leo-ai-starters button {
  color: #eadab3;
  background: #d4af370d;
  border: 1px solid var(--leo-line);
}

.leo-ai-header .leo-ai-quiet { font-size: 11px; white-space: nowrap; padding: 6px; border-radius: 6px; min-height: 34px; }
.leo-ai-header .leo-ai-close { display: grid; place-items: center; font-size: 22px; line-height: 1; width: 36px; height: 36px; padding: 0; border-radius: 8px; }
.leo-ai-header button:hover, .leo-ai-starters button:hover { color: #ffe393; background: #d4af3726; }

.leo-ai-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 6px;
  scrollbar-color: #67572d transparent;
}

.leo-ai-message {
  width: fit-content;
  max-width: 92%;
  margin: 0 0 8px;
  padding: 9px 11px;
  border: 1px solid #ffffff1f;
  border-radius: 4px 11px 11px;
  background: #ffffff0a;
  font-size: 13px;
  line-height: 1.52;
  overflow-wrap: anywhere;
}

.leo-ai-message > span { color: #e9c967; font-size: 10px; font-weight: 800; letter-spacing: .05em; }
.leo-ai-message > div { white-space: pre-wrap; }
.leo-ai-message--user { margin-left: auto; border-color: #75c89645; border-radius: 11px 4px 11px 11px; background: #1f4b343f; }
.leo-ai-message--user > span { color: #a2e9ba; }
.leo-ai-message p { margin: 0 0 6px; }
.leo-ai-message p:last-child { margin-bottom: 0; }
.leo-ai-message p:not(:first-child) { margin-top: 5px; }
.leo-ai-message :is(ol, ul) { margin: 0 0 6px; padding-inline-start: 19px; }
.leo-ai-message a { color: #ffe188; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.leo-ai-message code { padding-inline: 3px; border-radius: 4px; background: #0008; }
.leo-ai-preview { font-size: 12px; color: var(--leo-muted); margin: 3px 0; }
.leo-ai-thinking { color: var(--leo-muted); }
.leo-ai-thinking::after { content: ''; display: inline-block; margin-left: 6px; width: 6px; height: 6px; border-radius: 50%; background: #e8ad51; animation: leo-ai-pulse 900ms ease-in-out alternate infinite; }
@keyframes leo-ai-pulse { to { opacity: .25; } }

.leo-ai-starters { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 13px 7px; }
.leo-ai-starters button { border-radius: 22px; padding: 5px 7px; min-height: 33px; font-size: 11px; }
.leo-ai-form { display: flex; gap: 7px; padding: 9px 12px 0; border-top: 1px solid #ffffff15; }
.leo-ai-form input {
  min-width: 0;
  flex: 1;
  border-radius: 9px;
  border: 1px solid var(--leo-line);
  padding: 7px 9px;
  font: 16px Manrope, system-ui, sans-serif;
  color: var(--leo-text);
  background: #050506;
}

.leo-ai-form input::placeholder { color: #b6ad9d; font-size: 13px; }
.leo-ai-form button { min-width: 43px; min-height: 43px; border: 1px solid #ffd96d; border-radius: 9px; font-size: 21px; font-weight: 800; color: #161104; background: #eac562; }
.leo-ai-form button:disabled { opacity: .65; cursor: wait; }
.leo-ai-privacy { color: var(--leo-muted); margin: 6px 13px 10px; font-size: 10px; line-height: 1.4; }
.leo-ai-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-height: 420px) {
  .leo-ai-panel { bottom: var(--leo-base); height: min(370px, calc(100dvh - var(--leo-base) - 12px)); }
  .leo-ai-panel:not([hidden]) + .leo-ai-launcher[aria-expanded="true"] { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  #leo-ai *, #leo-ai *::after { animation: none; transition: none; }
  .leo-ai-panel.leo-ai-closing { opacity: 0; }
}
