/* ============================================================
   Anything — AI chat view
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-head-actions { flex-wrap: wrap; justify-content: flex-end; }

.ai-model-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 75%, transparent);
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: .01em;
  white-space: nowrap;
}
.ai-model-badge b { color: var(--muted); font-weight: 600; }
.ai-model-badge.selecting { padding: 3px 6px 3px 11px; }
.ai-badge-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 15%, transparent);
}
.ai-badge-dot.off { background: var(--faint); box-shadow: none; }
.ai-badge-dot.demo { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 15%, transparent); }
.ai-model-select {
  width: auto;
  min-width: 150px;
  max-width: min(260px, 60vw);
  border: 0;
  background-color: transparent;
  padding: 4px 26px 4px 2px;
  font-size: 10.5px;
  color: var(--muted);
  text-overflow: ellipsis;
}
.ai-model-select:hover { border-color: transparent; }
.ai-model-select:focus { box-shadow: none; }

.ai-shell {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: clamp(480px, calc(100dvh - 300px), 820px);
  min-height: 460px;
  overflow: hidden;
  background:
    radial-gradient(760px 280px at 15% -15%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 65%),
    var(--panel);
}

.ai-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

/* ---------- welcome ---------- */

.ai-welcome {
  margin: auto;
  width: min(100%, 720px);
  text-align: center;
  padding: 10px 0 6px;
}
.ai-welcome-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(135deg, #9d6bff, #7b5cf6 52%, #22d3ee);
  box-shadow:
    0 18px 42px -18px color-mix(in srgb, var(--accent) 95%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .28);
}
.ai-welcome-icon .icon { width: 34px; height: 34px; }
.ai-welcome-eyebrow {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: var(--faint);
  font-weight: 600;
  margin-bottom: 9px;
}
.ai-welcome h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.68rem);
  font-weight: 660;
  letter-spacing: -.04em;
  line-height: 1.16;
}
.ai-welcome p {
  max-width: 52ch;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 12.8px;
  line-height: 1.65;
}
.ai-starters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 24px;
  text-align: left;
}
.ai-starter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-2) 78%, transparent);
  color: var(--text);
  text-align: left;
  transition: transform .2s var(--ease), border-color .2s, background .2s;
}
.ai-starter:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--panel-2));
}
.ai-starter:active { transform: translateY(0) scale(.99); }
.ai-starter-icon {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--accent);
}
.ai-starter-icon .icon { width: 15px; height: 15px; }
.ai-starter-copy { display: flex; flex-direction: column; min-width: 0; }
.ai-starter-copy b { font-size: 11.8px; font-weight: 650; letter-spacing: -.01em; }
.ai-starter-copy small { font-size: 9.8px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-starter-go { margin-left: auto; color: var(--accent); opacity: 0; transform: translate(-3px, 3px); transition: opacity .18s, transform .18s var(--ease); }
.ai-starter-go .icon { width: 13px; height: 13px; }
.ai-starter:hover .ai-starter-go { opacity: 1; transform: none; }
.ai-welcome-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: none !important;
  margin-top: 22px !important;
  font-size: 10px !important;
  color: var(--faint) !important;
}
.ai-welcome-note .icon { width: 12px; height: 12px; color: var(--good); }

/* ---------- messages ---------- */

.ai-msg {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  animation: answerIn .26s var(--ease) both;
}
.ai-msg.user { justify-content: flex-end; }
.ai-msg.user .ai-bubble {
  max-width: min(78%, 720px);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  border-bottom-right-radius: 5px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--panel-2)), color-mix(in srgb, var(--accent) 9%, var(--panel-2)));
  color: var(--text);
}
.ai-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  margin-top: 3px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, #9d6bff, #7b5cf6 52%, #22d3ee);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 8px 18px -12px color-mix(in srgb, var(--accent) 90%, transparent), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.ai-avatar .icon { width: 17px; height: 17px; }
.ai-msg-main { min-width: 0; max-width: min(84%, 760px); }
.ai-bubble {
  padding: 12px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13.3px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}
.ai-msg.assistant .ai-bubble { border-bottom-left-radius: 5px; }
.ai-user-bubble { white-space: normal; }

.ai-markdown > :first-child { margin-top: 0; }
.ai-markdown > :last-child { margin-bottom: 0; }
.ai-markdown p + p { margin-top: 10px; }
.ai-markdown h3,
.ai-markdown h4 {
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.3;
  margin: 16px 0 7px;
}
.ai-markdown h3 { font-size: 1.02rem; }
.ai-markdown h4 { font-size: .95rem; }
.ai-markdown strong { color: var(--text); font-weight: 650; }
.ai-markdown em { color: var(--muted); }
.ai-markdown ul,
.ai-markdown ol { margin: 8px 0; padding-left: 21px; }
.ai-markdown li + li { margin-top: 4px; }
.ai-markdown li > p { margin: 0; }
.ai-markdown blockquote {
  margin: 11px 0;
  padding: 2px 0 2px 12px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  color: var(--muted);
}
.ai-markdown hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.ai-markdown a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.ai-markdown a:hover { color: var(--accent); }
.ai-markdown code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--panel-3);
  color: var(--text);
  padding: 1px 5px;
  border-radius: 4px;
}

.ai-code {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--bg-soft);
}
.ai-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 7px 5px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .13em;
}
.ai-code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 6px;
}
.ai-code-copy:hover { color: var(--text); background: var(--panel-2); }
.ai-code-copy .icon { width: 11px; height: 11px; }
.ai-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.ai-code pre code {
  display: block;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.62;
  white-space: pre;
}

.ai-table-wrap { margin: 12px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.ai-table { width: 100%; border-collapse: collapse; font-size: 11.8px; }
.ai-table th,
.ai-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; vertical-align: top; }
.ai-table th { background: var(--panel-3); font-weight: 650; white-space: nowrap; }
.ai-table tr:last-child td { border-bottom: 0; }
.ai-table th:last-child,
.ai-table td:last-child { border-right: 0; }

.ai-msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 5px;
  padding-left: 2px;
}
.ai-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 10.2px;
  padding: 4px 6px;
  transition: color .15s, background .15s;
}
.ai-action:hover { color: var(--text); background: var(--panel-2); }
.ai-action .icon { width: 12px; height: 12px; }
.ai-stopped {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
}

/* ---------- streaming / errors ---------- */

.ai-typing { display: flex; align-items: center; gap: 5px; min-height: 20px; }
.ai-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: aiBlink 1.25s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: .16s; }
.ai-typing span:nth-child(3) { animation-delay: .32s; }
@keyframes aiBlink { 0%, 70%, 100% { opacity: .3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }

.ai-stream-status { margin-top: 6px; padding-left: 2px; font-size: 9.5px; color: var(--faint); letter-spacing: .06em; }
.ai-cursor {
  display: inline-block;
  width: 2px;
  height: 1.02em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  animation: aiCursor 0.9s steps(2, jump-none) infinite;
}
@keyframes aiCursor { 50% { opacity: 0; } }

.ai-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 2px 0;
  padding: 10px 13px;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 7%, transparent);
  color: var(--muted);
  font-size: 11.5px;
}
.ai-error-copy { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ai-error-copy .icon { width: 15px; height: 15px; flex: none; color: var(--warn); }

/* ---------- setup ---------- */

.ai-setup-card {
  width: min(100%, 640px);
  margin: auto;
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: 17px;
  background:
    radial-gradient(420px 180px at 10% -20%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--panel-2);
}
.ai-setup-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  margin-bottom: 13px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}
.ai-setup-icon .icon { width: 19px; height: 19px; }
.ai-setup-card h3 { margin-top: 5px; font-size: 1.06rem; font-weight: 640; letter-spacing: -.025em; }
.ai-setup-copy { margin-top: 8px; color: var(--muted); font-size: 12.2px; line-height: 1.68; }
.ai-setup-card ol { margin: 13px 0 0; padding-left: 19px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.ai-setup-card li + li { margin-top: 2px; }
.ai-setup-card code {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text);
  background: var(--panel-3);
  border-radius: 4px;
  padding: 1px 5px;
}
.ai-setup-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.ai-setup-note { display: flex; align-items: center; gap: 6px; margin-top: 14px; color: var(--faint); font-size: 10px; }
.ai-setup-note .icon { width: 12px; height: 12px; color: var(--good); flex: none; }

/* ---------- composer ---------- */

.ai-composer {
  flex: none;
  padding: 12px 14px 11px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 16%, var(--panel)), color-mix(in srgb, var(--bg) 36%, var(--panel)));
}
.ai-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: color-mix(in srgb, var(--bg) 42%, var(--panel-2));
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.ai-input-wrap:hover { border-color: color-mix(in srgb, var(--line-strong) 72%, var(--accent)); }
.ai-input-wrap:focus-within {
  border-color: color-mix(in srgb, var(--accent) 58%, transparent);
  background: color-mix(in srgb, var(--bg) 30%, var(--panel-2));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 11%, transparent), 0 12px 30px -24px rgba(0, 0, 0, .9);
}
.ai-input {
  flex: 1;
  min-width: 0;
  min-height: 25px;
  max-height: 160px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.3px;
  line-height: 1.55;
  padding: 4px 0;
}
.ai-input::placeholder { color: var(--faint); }
.ai-mic { flex: none; border-radius: 9px; }
.ai-mic.recording {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  animation: pulse 1.4s ease-in-out infinite;
}
.ai-send,
.ai-stop {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: #fff;
  transition: transform .15s var(--ease), filter .18s, box-shadow .18s;
}
.ai-send {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 52%, var(--accent-2)) 68%, var(--accent-2));
  box-shadow: 0 9px 22px -10px color-mix(in srgb, var(--accent) 90%, transparent), inset 0 1px 0 rgba(255, 255, 255, .24);
}
.ai-send:hover { filter: brightness(1.08); transform: translateX(1px); box-shadow: 0 11px 26px -10px color-mix(in srgb, var(--accent) 100%, transparent), inset 0 1px 0 rgba(255, 255, 255, .3); }
.ai-send:active { transform: scale(.96); }
.ai-send .icon { width: 16px; height: 16px; }
.ai-stop {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 32%, transparent);
  color: var(--bad);
}
.ai-stop:hover { background: color-mix(in srgb, var(--bad) 20%, transparent); }
.ai-stop .icon { width: 15px; height: 15px; }
.ai-composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 7px; padding: 0 2px; }
.ai-hint { font-size: 9.5px; color: var(--faint); }
.ai-privacy-note { display: inline-flex; align-items: center; gap: 4px; }
.ai-privacy-note .icon { width: 11px; height: 11px; color: var(--good); }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .ai-shell { height: calc(100dvh - 260px); min-height: 420px; border-radius: 15px; }
  .ai-thread { padding: 18px 14px; gap: 14px; }
  .ai-msg-main { max-width: calc(100% - 40px); }
  .ai-msg.user .ai-bubble { max-width: 90%; }
  .ai-bubble { font-size: 13px; padding: 11px 13px; }
  .ai-welcome { padding: 8px 0; }
  .ai-welcome h2 { font-size: 1.18rem; }
  .ai-starters { grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 20px; }
  .ai-setup-card { padding: 18px; }
  .ai-composer { padding: 10px; }
  .ai-composer-bar { justify-content: flex-end; }
  .ai-hint:first-child { display: none; }
  .ai-head-actions { width: 100%; justify-content: flex-start; }
}

@media (max-width: 520px) {
  .ai-head-actions { gap: 6px; }
  .ai-model-badge { font-size: 9.5px; padding: 5px 9px; }
  .ai-thread { padding: 15px 11px; }
  .ai-avatar { width: 26px; height: 26px; border-radius: 8px; }
  .ai-avatar .icon { width: 13px; height: 13px; }
  .ai-msg-main { max-width: calc(100% - 36px); }
  .ai-msg-actions { gap: 0; }
  .ai-action { font-size: 9.6px; padding: 4px 5px; }
  .ai-welcome-note { display: flex; justify-content: center; }
  .ai-starters { gap: 6px; }
  .ai-starter { padding: 9px; gap: 8px; }
  .ai-starter-icon { width: 27px; height: 27px; }
  .ai-starter-copy small { display: none; }
  .ai-starter-go { display: none; }
  .ai-setup-card { padding: 16px; }
  .ai-setup-actions .btn { flex: 1; }
}

/* short phones: keep the mark, headline, and all six starters in view */
@media (max-width: 760px) and (max-height: 720px) {
  .ai-shell { height: calc(100dvh - 262px); min-height: 300px; }
  .ai-welcome { padding: 2px 0; }
  .ai-welcome-icon { width: 54px; height: 54px; border-radius: 17px; margin-bottom: 12px; }
  .ai-welcome-icon .icon { width: 29px; height: 29px; }
  .ai-welcome-eyebrow { display: none; }
  .ai-welcome h2 { font-size: 1.12rem; }
  .ai-welcome p { margin-top: 8px; font-size: 12px; }
  .ai-starters { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
  .ai-starter { padding: 7px; gap: 6px; }
  .ai-starter-icon { width: 24px; height: 24px; border-radius: 7px; }
  .ai-starter-icon .icon { width: 13px; height: 13px; }
  .ai-starter-copy b { font-size: 10.8px; }
  .ai-welcome-note { display: none !important; }
}
