/*
 * Xaslarbet AI v2 — Chat widget styles
 * Scoped under .xasai-v2-chat to prevent leaking into the host theme.
 * Tokens mirror reference-design/style.css from the Xaslar mobile app.
 */

/* ============================================================
   1. DESIGN TOKENS (scoped — only resolved inside the widget)
   ============================================================ */
.xasai-v2-chat {
  --xv2-mint: #7FE9A5;
  --xv2-mint-bright: #8FF0B0;
  --xv2-mint-deep: #3BD17A;
  --xv2-mint-shadow: #1F8A4C;
  --xv2-black: #000000;
  --xv2-ink: #0A0A0A;
  --xv2-surface: #111214;
  --xv2-surface-2: #17181B;
  --xv2-line: #23252A;
  --xv2-line-soft: #1B1D21;
  --xv2-text: #FFFFFF;
  --xv2-muted: #8B8F97;
  --xv2-subtle: #5C6069;
  --xv2-red: #FF5A5F;
  --xv2-amber: #FFB547;

  --xv2-font-display: 'Space Grotesk', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --xv2-font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --xv2-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --xv2-radius-card: 14px;
  --xv2-radius-bubble: 14px;
  --xv2-radius-btn: 10px;
  --xv2-radius-chip: 999px;

  /* Container — boxed widget; sidebar | main grid layout. */
  position: relative;
  display: grid;
  grid-template-columns: 290px 1fr;
  grid-template-rows: 1fr;
  width: 100%;
  max-width: 1180px;
  height: 78vh;
  min-height: 560px;
  max-height: 880px;
  margin: 0 auto;
  background:
    radial-gradient(60% 40% at 50% 25%, rgba(127, 233, 165, 0.10), transparent 70%),
    var(--xv2-black);
  border: 1px solid var(--xv2-line);
  border-radius: 18px;
  overflow: hidden;
  color: var(--xv2-text);
  font-family: var(--xv2-font-body);
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
  isolation: isolate; /* tame z-indexes inside */
}
.xasai-v2-chat__main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  position: relative;
}
@media (max-width: 768px) {
  .xasai-v2-chat {
    grid-template-columns: 1fr;
    height: 75vh; min-height: 540px; max-height: none;
    border-radius: 14px;
  }
}

/* ============================================================
   2. SCOPED RESET — apply only to descendants
   ============================================================ */
.xasai-v2-chat *,
.xasai-v2-chat *::before,
.xasai-v2-chat *::after {
  box-sizing: border-box;
}

.xasai-v2-chat button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.xasai-v2-chat textarea,
.xasai-v2-chat input {
  font-family: inherit;
  color: inherit;
}

.xasai-v2-chat p { margin: 0; }
.xasai-v2-chat ul,
.xasai-v2-chat ol { margin: 6px 0 0; padding-left: 20px; }
.xasai-v2-chat li { margin: 2px 0; }
.xasai-v2-chat code {
  font-family: var(--xv2-font-mono);
  font-size: 0.9em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--xv2-surface-2);
  border: 1px solid var(--xv2-line);
}
.xasai-v2-chat a {
  color: var(--xv2-mint);
  text-decoration: none;
  border-bottom: 1px dotted rgba(127, 233, 165, 0.45);
}
.xasai-v2-chat a:hover { color: var(--xv2-mint-bright); }
.xasai-v2-chat strong { font-weight: 700; color: var(--xv2-text); }
.xasai-v2-chat em { font-style: italic; color: var(--xv2-text); }

/* ============================================================
   3. HEADER
   ============================================================ */
.xasai-v2-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--xv2-line);
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.xasai-v2-chat__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.xasai-v2-chat__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--xv2-surface-2);
  border: 1px solid var(--xv2-line);
  display: grid;
  place-items: center;
  color: var(--xv2-mint);
  font-family: var(--xv2-font-display);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  position: relative;
}
.xasai-v2-chat__avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--xv2-mint);
  border: 2px solid var(--xv2-ink);
  box-shadow: 0 0 8px rgba(127, 233, 165, 0.6);
}

.xasai-v2-chat__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.xasai-v2-chat__title-main {
  font-family: var(--xv2-font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xasai-v2-chat__title-sub {
  font-size: 11px;
  color: var(--xv2-muted);
  font-family: var(--xv2-font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Free counter / member badge top-right */
.xasai-v2-chat__counter {
  font-family: var(--xv2-font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--xv2-mint);
  background: rgba(127, 233, 165, 0.10);
  border: 1px solid rgba(127, 233, 165, 0.35);
  padding: 6px 10px;
  border-radius: var(--xv2-radius-chip);
  white-space: nowrap;
  flex-shrink: 0;
}
.xasai-v2-chat__counter--warn {
  color: var(--xv2-amber);
  background: rgba(255, 181, 71, 0.10);
  border-color: rgba(255, 181, 71, 0.35);
}
.xasai-v2-chat__counter--member {
  color: var(--xv2-text);
  background: var(--xv2-surface);
  border-color: var(--xv2-line);
}

/* ============================================================
   4. SUGGESTED PROMPTS ROW (chips)
   ============================================================ */
.xasai-v2-chat__suggest {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--xv2-line-soft);
  flex-shrink: 0;
}
.xasai-v2-chat__suggest::-webkit-scrollbar { display: none; }

.xasai-v2-chip {
  padding: 8px 14px;
  border-radius: var(--xv2-radius-chip);
  background: var(--xv2-surface);
  color: var(--xv2-text);
  border: 1px solid var(--xv2-line);
  font-family: var(--xv2-font-display);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 140ms ease, border-color 140ms ease, transform 80ms ease;
}
.xasai-v2-chip:hover {
  background: var(--xv2-surface-2);
  border-color: var(--xv2-mint);
}
.xasai-v2-chip:active { transform: scale(0.97); }
.xasai-v2-chip:disabled { opacity: 0.5; cursor: default; }

/* ============================================================
   5. MESSAGES AREA
   ============================================================ */
.xasai-v2-chat__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.xasai-v2-chat__messages::-webkit-scrollbar { width: 8px; }
.xasai-v2-chat__messages::-webkit-scrollbar-track { background: transparent; }
.xasai-v2-chat__messages::-webkit-scrollbar-thumb {
  background: var(--xv2-line);
  border-radius: 4px;
}
.xasai-v2-chat__messages::-webkit-scrollbar-thumb:hover {
  background: var(--xv2-subtle);
}

.xasai-v2-msg {
  display: flex;
  gap: 10px;
  animation: xv2-slide-up 220ms ease-out both;
  max-width: 100%;
}
.xasai-v2-msg--user {
  justify-content: flex-end;
}

.xasai-v2-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--xv2-surface-2);
  border: 1px solid var(--xv2-line);
  display: grid;
  place-items: center;
  color: var(--xv2-mint);
  font-family: var(--xv2-font-display);
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 2px;
}

.xasai-v2-msg__bubble {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: var(--xv2-radius-bubble);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.xasai-v2-msg--user .xasai-v2-msg__bubble {
  background: var(--xv2-mint);
  color: var(--xv2-black);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.xasai-v2-msg--user .xasai-v2-msg__bubble a { color: var(--xv2-black); }

.xasai-v2-msg--bot .xasai-v2-msg__bubble {
  background: var(--xv2-surface);
  color: var(--xv2-text);
  border: 1px solid var(--xv2-line);
  border-left: 2px solid var(--xv2-mint);
  border-bottom-left-radius: 4px;
}

.xasai-v2-msg--system .xasai-v2-msg__bubble {
  background: rgba(255, 90, 95, 0.10);
  border: 1px solid rgba(255, 90, 95, 0.30);
  color: var(--xv2-red);
  font-size: 13px;
}

/* Bot bubble can host markdown lists / code blocks */
.xasai-v2-msg--bot .xasai-v2-msg__bubble pre {
  background: var(--xv2-ink);
  border: 1px solid var(--xv2-line);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 0;
  overflow-x: auto;
  font-family: var(--xv2-font-mono);
  font-size: 12px;
}
.xasai-v2-msg--bot .xasai-v2-msg__bubble pre code {
  background: none;
  border: 0;
  padding: 0;
}

/* Numbers / odds rendered in mono-bold by markdown.js wrapping */
.xasai-v2-msg__bubble .xv2-mono {
  font-family: var(--xv2-font-mono);
  font-weight: 600;
}

/* ============================================================
   6. STREAMING DOT INDICATOR
   ============================================================ */
.xasai-v2-typing {
  display: inline-flex;
  gap: 4px;
  padding: 2px 0;
  align-items: center;
}
.xasai-v2-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--xv2-mint);
  opacity: 0.4;
  animation: xv2-pulse 1.1s ease-in-out infinite;
}
.xasai-v2-typing span:nth-child(2) { animation-delay: 0.18s; }
.xasai-v2-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes xv2-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* ============================================================
   7. TOOL CALL CHIPS
   ============================================================ */
.xasai-v2-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 8px;
}
.xasai-v2-tools:empty { display: none; }

.xasai-v2-tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 6px 11px;
  border-radius: var(--xv2-radius-chip);
  background: var(--xv2-surface-2);
  border: 1px solid var(--xv2-line);
  color: var(--xv2-muted);
  font-family: var(--xv2-font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  animation: xv2-slide-up 180ms ease-out both;
  max-width: 100%;
}

.xasai-v2-tool__spinner {
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--xv2-line);
  border-top-color: var(--xv2-mint);
  border-radius: 50%;
  animation: xv2-spin 700ms linear infinite;
  flex-shrink: 0;
}

.xasai-v2-tool--done {
  color: var(--xv2-mint);
  border-color: rgba(127, 233, 165, 0.35);
  background: rgba(127, 233, 165, 0.08);
}
.xasai-v2-tool--done .xasai-v2-tool__spinner { display: none; }
.xasai-v2-tool--done::before {
  content: "";
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237FE9A5' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='3 8.5 6.5 12 13 4.5'/></svg>");
  background-repeat: no-repeat;
  background-size: contain;
  flex-shrink: 0;
}

.xasai-v2-tool--error {
  color: var(--xv2-red);
  border-color: rgba(255, 90, 95, 0.35);
  background: rgba(255, 90, 95, 0.08);
}
.xasai-v2-tool--error .xasai-v2-tool__spinner { display: none; }

@keyframes xv2-spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   8. ARTIFACTS (slip / chart / player card)
   ============================================================ */
.xasai-v2-artifact {
  margin-top: 10px;
  border-radius: var(--xv2-radius-card);
  background: var(--xv2-surface-2);
  border: 1px solid var(--xv2-line);
  overflow: hidden;
  animation: xv2-fade-in 280ms ease-out both;
}

.xasai-v2-artifact--slip,
.xasai-v2-artifact--chart {
  width: 100%;
  display: block;
}

.xasai-v2-artifact--slip svg,
.xasai-v2-artifact--chart svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.xasai-v2-artifact--card {
  display: inline-block;
  width: auto;
  max-width: 100%;
  padding: 12px;
}

.xasai-v2-artifact__actions {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--xv2-line);
  background: var(--xv2-surface);
  flex-wrap: wrap;
}

.xasai-v2-artifact__btn {
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--xv2-surface-2);
  border: 1px solid var(--xv2-line);
  color: var(--xv2-text);
  font-family: var(--xv2-font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 140ms ease, border-color 140ms ease;
}
.xasai-v2-artifact__btn:hover {
  background: var(--xv2-ink);
  border-color: var(--xv2-mint);
}
.xasai-v2-artifact__btn--primary {
  background: var(--xv2-mint);
  color: var(--xv2-black);
  border-color: transparent;
}
.xasai-v2-artifact__btn--primary:hover { background: var(--xv2-mint-bright); }

@keyframes xv2-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   9. ERROR + RETRY CHIP
   ============================================================ */
.xasai-v2-retry {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--xv2-radius-chip);
  background: rgba(255, 90, 95, 0.10);
  border: 1px solid rgba(255, 90, 95, 0.35);
  color: var(--xv2-red);
  font-family: var(--xv2-font-mono);
  font-size: 11px;
  font-weight: 600;
}
.xasai-v2-retry__btn {
  margin-left: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--xv2-red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--xv2-font-display);
}
.xasai-v2-retry__btn:hover { background: #ff7075; }

/* ============================================================
   10. COMPOSER (input + send)
   ============================================================ */
.xasai-v2-chat__composer {
  border-top: 1px solid var(--xv2-line);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.xasai-v2-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--xv2-surface);
  border: 1px solid var(--xv2-line);
  border-radius: var(--xv2-radius-card);
  padding: 8px 10px 8px 12px;
  transition: border-color 140ms ease, background 140ms ease;
}
.xasai-v2-chat__form:focus-within {
  border-color: var(--xv2-mint);
  background: var(--xv2-surface-2);
}

.xasai-v2-chat__textarea {
  flex: 1;
  min-height: 24px;
  max-height: 140px;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--xv2-text);
  font-size: 14px;
  line-height: 1.5;
  font-family: var(--xv2-font-body);
  padding: 6px 0;
}
.xasai-v2-chat__textarea::placeholder { color: var(--xv2-subtle); }

.xasai-v2-chat__send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--xv2-mint);
  color: var(--xv2-black);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 140ms ease, opacity 140ms ease, transform 80ms ease;
}
.xasai-v2-chat__send:hover:not(:disabled) { background: var(--xv2-mint-bright); }
.xasai-v2-chat__send:active:not(:disabled) { transform: scale(0.96); }
.xasai-v2-chat__send:disabled {
  opacity: 0.45;
  cursor: default;
}
.xasai-v2-chat__send svg {
  width: 16px;
  height: 16px;
  display: block;
}

.xasai-v2-chat__hint {
  margin-top: 6px;
  text-align: center;
  font-size: 10.5px;
  color: var(--xv2-subtle);
  font-family: var(--xv2-font-mono);
  letter-spacing: 0.04em;
}

/* ============================================================
   11. PAYWALL CTA (replaces composer when wall hit)
   ============================================================ */
.xasai-v2-paywall {
  margin: 0;
  padding: 18px;
  background: linear-gradient(110deg, #0f2517 0%, #000 80%);
  border-top: 1px solid var(--xv2-line);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.xasai-v2-paywall__title {
  font-family: var(--xv2-font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--xv2-text);
  letter-spacing: -0.01em;
}
.xasai-v2-paywall__sub {
  font-size: 12.5px;
  color: var(--xv2-muted);
  line-height: 1.5;
  max-width: 420px;
}
.xasai-v2-paywall__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  background: var(--xv2-mint);
  color: var(--xv2-black);
  font-family: var(--xv2-font-display);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  border: 0;
  transition: background 140ms ease, transform 80ms ease;
}
.xasai-v2-paywall__btn:hover { background: var(--xv2-mint-bright); }
.xasai-v2-paywall__btn:active { transform: scale(0.98); }

/* ============================================================
   12. ANIMATIONS — message slide-up
   ============================================================ */
@keyframes xv2-slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   13. MOBILE — full-bleed chat
   ============================================================ */
@media (max-width: 640px) {
  .xasai-v2-chat {
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    max-width: 100%;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .xasai-v2-chat__header { padding: 12px 14px; }
  .xasai-v2-chat__suggest { padding: 10px 14px; }
  .xasai-v2-chat__messages { padding: 14px; gap: 12px; }
  .xasai-v2-msg__bubble { max-width: 85%; font-size: 14px; }
  .xasai-v2-chat__composer { padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .xasai-v2-chat__title-main { font-size: 14px; }
  .xasai-v2-chat__title-sub { font-size: 10px; }
  .xasai-v2-chat__counter { font-size: 10px; padding: 5px 9px; }
}

/* ============================================================
   14. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .xasai-v2-msg,
  .xasai-v2-tool,
  .xasai-v2-artifact { animation: none; }
  .xasai-v2-typing span { animation: none; opacity: 0.7; }
  .xasai-v2-tool__spinner { animation: none; }
  .xasai-v2-chat__messages { scroll-behavior: auto; }
}

/* ============================================================
   15. FULLSCREEN MODE — chat-fullscreen.php template
   ============================================================
   When the page uses our custom template, .xasai-fs-root wraps the
   chat and the body has data-xasai-fs="1". Force chat to viewport.
   ============================================================ */
html[data-xasai-fs="1"], html[data-xasai-fs="1"] body {
  background: #000 !important;
  color: #fff !important;
}
.xasai-fs-root .xasai-v2-chat {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background:
    radial-gradient(60% 40% at 50% 25%, rgba(127,233,165,0.10), transparent 70%),
    #000 !important;
}
.xasai-fs-root .xasai-v2-chat__messages {
  flex: 1 1 auto;
  min-height: 0;
}
.xasai-fs-root .xasai-v2-chat__composer {
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

/* Defensive overrides — Astra / parent theme often sets backgrounds on
   form elements; reassert ours. */
.xasai-v2-chat .xasai-v2-chat__textarea,
.xasai-v2-chat .xasai-v2-chat__form input,
.xasai-v2-chat .xasai-v2-chat__form textarea {
  background: transparent !important;
  color: #fff !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  font-family: 'Inter', system-ui, sans-serif !important;
}
.xasai-v2-chat .xasai-v2-chat__textarea:focus,
.xasai-v2-chat .xasai-v2-chat__form input:focus,
.xasai-v2-chat .xasai-v2-chat__form textarea:focus {
  background: transparent !important;
  outline: 0 !important;
  box-shadow: none !important;
}
.xasai-v2-chat .xasai-v2-chat__form {
  background: var(--xv2-surface-2) !important;
}
.xasai-v2-chat .xasai-v2-chat__send {
  background: var(--xv2-mint) !important;
  color: #0A0A0A !important;
}
.xasai-v2-chat .xasai-v2-chat__send:hover:not(:disabled) {
  background: var(--xv2-mint-bright) !important;
}

/* Mobile fullscreen tweaks */
@media (max-width: 640px) {
  .xasai-fs-root .xasai-v2-chat__header { padding: 14px 16px; }
  .xasai-fs-root .xasai-v2-chat__suggest { padding: 10px 14px; gap: 8px; }
  .xasai-fs-root .xasai-v2-chat__messages { padding: 16px 14px; }
  .xasai-fs-root .xasai-v2-chat__composer { padding: 12px 14px; }
  .xasai-fs-root .xasai-v2-chat__title-main { font-size: 17px; }
}

/* ============================================================
   16. SIDEBAR — Claude.ai-style chat history
   ============================================================ */
.xasai-v2-chat__sidebar {
  display: flex; flex-direction: column;
  background: var(--xv2-surface);
  border-right: 1px solid var(--xv2-line-soft);
  min-width: 0; min-height: 0;
}
.xasai-v2-chat__sidebar-head {
  padding: 16px 14px 12px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--xv2-line-soft);
}
.xasai-v2-chat__newchat {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--xv2-mint) !important;
  color: #0A0A0A !important;
  font-family: var(--xv2-font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.4px;
  padding: 13px 16px;
  min-height: 44px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.xasai-v2-chat__newchat:hover { background: var(--xv2-mint-bright) !important; transform: translateY(-1px); }
.xasai-v2-chat__newchat svg { width: 16px; height: 16px; }
.xasai-v2-chat__sidebar-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
/* Specificity bumped (0,2,0) so we beat the generic `.xasai-v2-chat button`
   reset (0,1,1) that zeroes out backgrounds. */
.xasai-v2-chat .xasai-v2-chat__session {
  position: relative;
  width: 100%;
  min-height: 44px;
  padding: 7px 38px 7px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 10px;
  background: #000;
  color: var(--xv2-text);
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
  text-align: center;
  border: 0;
  overflow: hidden;
}
.xasai-v2-chat .xasai-v2-chat__session:hover {
  background: #0A0B0E;
  transform: translateY(-1px);
}
.xasai-v2-chat .xasai-v2-chat__session--active {
  background: #0A0B0E;
  box-shadow: inset 3px 0 0 var(--xv2-mint);
}
.xasai-v2-chat__session-title {
  display: block;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
  color: var(--xv2-text);
}
.xasai-v2-chat__session-meta {
  display: block !important;
  font-size: 10px;
  line-height: 1;
  color: var(--xv2-subtle);
  font-family: var(--xv2-font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.xasai-v2-chat__session-del {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center; justify-content: center;
  color: #fff;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  flex-shrink: 0;
  z-index: 2;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.xasai-v2-chat__session-del:hover {
  color: #fff;
  background: var(--xv2-red);
  border-color: var(--xv2-red);
}
.xasai-v2-chat__session-del svg { width: 14px; height: 14px; }
.xasai-v2-chat__session:hover .xasai-v2-chat__session-del { display: inline-flex; }
.xasai-v2-chat__session-del:hover { color: var(--xv2-red); background: rgba(255,90,95,0.12); }
.xasai-v2-chat__sidebar-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: var(--xv2-muted);
  font-style: italic;
  text-align: center;
}

/* Mobile sidebar slide-over */
.xasai-v2-chat__sidebar-toggle {
  display: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--xv2-surface-2);
  border: 1px solid var(--xv2-line);
  align-items: center; justify-content: center;
  color: var(--xv2-text);
  cursor: pointer;
  flex-shrink: 0;
}
.xasai-v2-chat__sidebar-toggle:hover { background: var(--xv2-surface); border-color: var(--xv2-mint); }
.xasai-v2-chat__sidebar-toggle svg { width: 18px; height: 18px; }
.xasai-v2-chat__sidebar-overlay {
  display: none;
  position: absolute; inset: 0; z-index: 5;
  background: rgba(0,0,0,0.55);
  cursor: pointer;
}

@media (max-width: 768px) {
  .xasai-v2-chat__sidebar-toggle { display: inline-flex; }
  .xasai-v2-chat__sidebar {
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 280px; max-width: 84%;
    z-index: 10;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.55);
    border-right: 1px solid var(--xv2-line);
  }
  .xasai-v2-chat[data-sidebar-open="1"] .xasai-v2-chat__sidebar { transform: translateX(0); }
  .xasai-v2-chat[data-sidebar-open="1"] .xasai-v2-chat__sidebar-overlay { display: block; }
}

/* ============================================================
   17. ANTI-THEME OVERRIDES — beat Astra etc on form elements
   ============================================================ */
.xasai-v2-chat .xasai-v2-chat__form {
  background: var(--xv2-surface-2) !important;
  border: 1px solid var(--xv2-line) !important;
  border-radius: var(--xv2-radius-card) !important;
}
.xasai-v2-chat .xasai-v2-chat__form:focus-within {
  border-color: var(--xv2-mint) !important;
  box-shadow: 0 0 0 3px rgba(127, 233, 165, 0.12) !important;
}
.xasai-v2-chat .xasai-v2-chat__textarea,
.xasai-v2-chat textarea.xasai-v2-chat__textarea,
.xasai-v2-chat input.xasai-v2-chat__textarea {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: #fff !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  font-family: var(--xv2-font-body) !important;
  font-size: 15px !important;
  line-height: 1.5 !important;
}
.xasai-v2-chat .xasai-v2-chat__textarea:focus,
.xasai-v2-chat .xasai-v2-chat__textarea:focus-visible,
.xasai-v2-chat .xasai-v2-chat__textarea:active,
.xasai-v2-chat .xasai-v2-chat__textarea:hover {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: #fff !important;
  outline: 0 !important;
  box-shadow: none !important;
}
.xasai-v2-chat .xasai-v2-chat__textarea::-webkit-input-placeholder { color: var(--xv2-subtle) !important; }
.xasai-v2-chat .xasai-v2-chat__textarea::placeholder { color: var(--xv2-subtle) !important; }
.xasai-v2-chat .xasai-v2-chat__textarea:-webkit-autofill,
.xasai-v2-chat .xasai-v2-chat__textarea:-webkit-autofill:focus,
.xasai-v2-chat .xasai-v2-chat__textarea:-webkit-autofill:hover {
  -webkit-box-shadow: 0 0 0 1000px var(--xv2-surface-2) inset !important;
  -webkit-text-fill-color: #fff !important;
}
.xasai-v2-chat .xasai-v2-chat__send {
  background: var(--xv2-mint) !important;
  color: #0A0A0A !important;
}

/* ============================================================
   18. MOBILE COMPRESSION — chat header fits on narrow phones
   ============================================================ */
@media (max-width: 480px) {
  /* Hide the composer hint to free vertical room */
  .xasai-v2-chat__hint { display: none !important; }

  /* Compact header: smaller paddings, smaller fonts, allow truncation */
  .xasai-v2-chat__header {
    padding: 10px 12px !important;
    gap: 8px !important;
  }
  .xasai-v2-chat__brand {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }
  .xasai-v2-chat__avatar {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
  }
  .xasai-v2-chat__title { min-width: 0; }
  .xasai-v2-chat__title-main {
    font-size: 14px !important;
    max-width: 100%;
  }
  .xasai-v2-chat__title-sub {
    font-size: 9.5px !important;
    letter-spacing: 0.04em !important;
  }
  .xasai-v2-chat__counter {
    font-size: 9.5px !important;
    padding: 5px 8px !important;
    flex-shrink: 0;
  }
  .xasai-v2-chat__sidebar-toggle {
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0;
  }
  .xasai-v2-chat__sidebar-toggle svg { width: 16px !important; height: 16px !important; }

  /* Smaller suggested chips on phones */
  .xasai-v2-chat__suggest { padding: 8px 12px !important; gap: 6px !important; }
  .xasai-v2-chip { padding: 6px 12px !important; font-size: 11.5px !important; }

  /* Tighter messages padding */
  .xasai-v2-chat__messages { padding: 14px 12px !important; gap: 12px !important; }

  /* Composer compact */
  .xasai-v2-chat__composer { padding: 10px 12px !important; }
  .xasai-v2-chat__form { padding: 6px 8px 6px 12px !important; }
  .xasai-v2-chat__textarea { font-size: 14px !important; }
  .xasai-v2-chat__send {
    width: 38px !important; height: 38px !important;
    border-radius: 9px !important;
  }
  .xasai-v2-chat__send svg { width: 16px !important; height: 16px !important; }
}

/* On very narrow phones (<360px) drop the title-sub label entirely */
@media (max-width: 360px) {
  .xasai-v2-chat__title-sub { display: none !important; }
  .xasai-v2-chat__counter { font-size: 9px !important; padding: 4px 7px !important; }
}

/* ============================================================
   19. AUTH WALLS — login (anon) + subscribe (free user used up)
   ============================================================ */
.xasai-v2-chat .xasai-v2-wall {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
}
.xasai-v2-chat .xasai-v2-wall__box {
  max-width: 420px;
  width: 100%;
  text-align: center;
  background: var(--xv2-surface);
  border: 1px solid var(--xv2-line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(127, 233, 165, 0.08);
}
.xasai-v2-chat .xasai-v2-wall__title {
  font-family: var(--xv2-font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--xv2-text);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.xasai-v2-chat .xasai-v2-wall__sub {
  font-size: 14px;
  color: var(--xv2-muted);
  line-height: 1.45;
  margin-bottom: 22px;
}
.xasai-v2-chat .xasai-v2-wall__btn {
  display: inline-block;
  background: var(--xv2-mint);
  color: #0A0A0A !important;
  padding: 12px 28px;
  border-radius: 10px;
  font-family: var(--xv2-font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.4px;
  text-decoration: none !important;
  border-bottom: 0 !important;
  transition: background 0.15s, transform 0.1s;
}
.xasai-v2-chat .xasai-v2-wall__btn:hover {
  background: var(--xv2-mint-bright);
  transform: translateY(-1px);
}
@media (max-width: 480px) {
  .xasai-v2-chat .xasai-v2-wall__box { padding: 22px 18px; }
  .xasai-v2-chat .xasai-v2-wall__title { font-size: 18px; }
}

/* ============================================================
   Pick-detail card artifact (xv2-pdc — flagship visual)
   The card itself ships fully self-contained styles; these
   rules only handle the bubble-side wrapper margins so the
   artifact breathes inside the chat.
   ============================================================ */
.xasai-v2-chat .xasai-v2-artifact--pick-detail {
  width: 100%;
  margin: 10px 0 4px;
  background: transparent;
  padding: 0;
  border: 0;
}
.xasai-v2-chat .xasai-v2-artifact--pick-detail .xv2-pdc {
  margin: 0;
  width: 100%;
}
.xasai-v2-chat .xasai-v2-artifact--pick-detail img {
  max-width: 100%;
  height: auto;
}
