/* "Ask AI" on the docs pages (src/ask-ai/ask-ai.js): a large centred dialog over the dimmed page, like "Ask Aside" on
   docs.aside.com; a full-screen sheet on a phone. scripts/docs-ask-ai.mjs copies this file to public/docs/assets/.
   Uses the docs' own colour tokens (public/docs/assets/site.css), so light and dark follow the page. */
.askai-launch {
  position: fixed; right: 20px; bottom: 20px; z-index: 70;
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px 10px 13px;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff;
  font: 600 14px/1 var(--sans); cursor: pointer;
  box-shadow: 0 6px 24px rgb(20 17 15 / 0.18), 0 1px 3px rgb(20 17 15 / 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.askai-launch:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgb(20 17 15 / 0.24), 0 1px 3px rgb(20 17 15 / 0.1); }
.askai-launch svg { width: 17px; height: 17px; fill: currentColor; }
.askai-open .askai-launch { display: none; }
.askai-open, .askai-open body { overflow: hidden; }

.askai-backdrop { position: fixed; inset: 0; z-index: 79; background: rgb(10 8 6 / 0.55); backdrop-filter: blur(2px); }
.askai-backdrop[hidden] { display: none; }

.askai-panel {
  position: fixed; z-index: 80; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(680px, calc(100vw - 48px)); height: min(720px, calc(100vh - 96px)); height: min(720px, calc(100dvh - 96px));
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.35), 0 2px 8px rgb(0 0 0 / 0.12);
  font: 15px/1.6 var(--sans); overflow: hidden;
}
.askai-panel[hidden] { display: none; }

.askai-head { display: flex; align-items: flex-start; gap: 8px; padding: 22px 18px 6px 24px; }
.askai-titles { flex: 1; min-width: 0; }
.askai-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; }
.askai-head h2 svg { width: 17px; height: 17px; fill: var(--accent); }
.askai-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.askai-reset {
  min-height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--muted);
  font: 500 13px/1 var(--sans); cursor: pointer;
}
.askai-reset:hover { background: var(--hover); color: var(--ink); }
.askai-reset[hidden] { display: none; }
.askai-close {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 999px; background: var(--subtle); color: var(--muted); cursor: pointer;
}
.askai-close:hover { background: var(--hover); color: var(--ink); }
.askai-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.askai-log { flex: 1; overflow-y: auto; padding: 14px 24px 18px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.askai-intro { margin: auto; width: 100%; max-width: 400px; padding: 8px 0 16px; text-align: center; }
.askai-intro-icon svg { width: 26px; height: 26px; fill: var(--accent); }
.askai-intro-title { margin: 8px 0 4px; font-size: 22px; font-weight: 600; line-height: 1.3; }
.askai-intro-sub { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; }
.askai-examples { display: flex; flex-direction: column; }
.askai-example {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px;
  border: 0; border-radius: 10px; background: none; color: var(--ink); font: 15px/1.4 var(--sans); text-align: left; cursor: pointer;
}
.askai-example:hover { background: var(--hover); }
.askai-example svg { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.askai-example:hover svg { stroke: var(--accent); }

.askai-q {
  align-self: flex-end; max-width: 85%; padding: 9px 14px; border-radius: 16px 16px 4px 16px;
  background: var(--accent-soft); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere;
}
.askai-a { align-self: stretch; overflow-wrap: anywhere; }
.askai-status { margin: 0; color: var(--muted); font-size: 14px; animation: askai-pulse 1.2s ease-in-out infinite; }
@keyframes askai-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .askai-status { animation: none; } .askai-launch { transition: none; } }
.askai-md p { margin: 0 0 10px; }
.askai-md .askai-h { font-weight: 650; margin-top: 4px; }
.askai-md ul, .askai-md ol { margin: 0 0 10px; padding-left: 22px; }
.askai-md li { margin: 4px 0; }
.askai-md code { padding: 1px 5px; border-radius: 5px; background: var(--code-bg); font: 0.88em/1.4 var(--mono); }
.askai-md pre { margin: 0 0 10px; padding: 10px 12px; border-radius: 8px; background: var(--code-bg); overflow-x: auto; }
.askai-md pre code { padding: 0; background: none; font-size: 13px; white-space: pre; }
.askai-md a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.askai-cite {
  display: inline-block; min-width: 17px; margin: 0 1px; padding: 0 4px; border-radius: 5px;
  background: var(--subtle); color: var(--muted) !important; font-size: 11px; line-height: 17px; text-align: center;
  text-decoration: none !important; vertical-align: 2px;
}
.askai-cite:hover { background: var(--accent-soft); color: var(--accent-text) !important; }
.askai-sources { margin-top: 2px; }
.askai-sources-title { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.askai-sources ul { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.askai-sources a {
  display: inline-block; max-width: 100%; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 12.5px; line-height: 1.5; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.askai-sources a:hover { border-color: var(--accent); color: var(--accent-text); }
.askai-error { margin: 0; padding: 9px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }

.askai-form { padding: 0 16px 12px; }
.askai-box { border: 1px solid var(--line-strong); border-radius: 14px; background: var(--bg); padding: 10px 10px 8px 14px; }
.askai-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.askai-input {
  display: block; width: 100%; min-height: 48px; max-height: 140px; padding: 2px 0; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--ink); font: 15px/1.5 var(--sans);
}
.askai-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.askai-fresh { margin: 0; color: var(--muted); font-size: 12.5px; }
.askai-send {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff; cursor: pointer;
}
.askai-send svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.askai-send.is-busy svg { fill: currentColor; stroke: none; }
.askai-foot { margin: 8px 4px 0; color: var(--muted); font-size: 12px; line-height: 1.4; text-align: center; }

@media (max-width: 640px) {
  .askai-launch { right: 14px; bottom: 14px; }
  .askai-panel { inset: 0; left: 0; top: 0; transform: none; width: auto; height: auto; border: 0; border-radius: 0; }
  .askai-head { padding: 16px 14px 4px 18px; }
  .askai-log { padding: 12px 18px 14px; }
  .askai-form { padding: 0 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .askai-input { font-size: 16px; }
  .askai-intro-title { font-size: 20px; }
}
@media print { .askai-launch, .askai-panel, .askai-backdrop { display: none !important; } }
