/* The AI coach (4 Dec 2026): "Ask AI" in the top bar, the chat (full screen on phones, a panel on the
   right on computers) and the one-tap questions on lessons and Unlock my course. Nothing shows until the
   server says the coach can answer (body.coach-on). */

.ask-ai, .ask-row { display: none !important; }
body.coach-on .ask-ai { display: inline-flex !important; }
body.coach-on .ask-row { display: flex !important; }

.ask-ai { align-items: center; gap: 7px; height: 36px; padding: 0 14px 0 12px; border-radius: 999px; border: 1px solid rgba(139, 92, 246, 0.6); background: linear-gradient(180deg, rgba(139, 92, 246, 0.28), rgba(139, 92, 246, 0.12)); color: #fff; font: inherit; font-size: 14px; font-weight: 650; cursor: pointer; white-space: nowrap; box-shadow: 0 6px 22px -10px rgba(139, 92, 246, 0.9); transition: background 0.15s ease, transform 0.1s ease; }
.ask-ai svg { color: var(--purple-ink); flex: none; }
.ask-ai:hover { background: linear-gradient(180deg, rgba(139, 92, 246, 0.4), rgba(139, 92, 246, 0.2)); }
.ask-ai:active { transform: translateY(1px); }

/* One-tap questions on a page */
.ask-row { margin-top: 14px; align-items: center; gap: 12px 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--panel); }
.ask-row > svg { flex: none; width: 36px; height: 36px; padding: 8px; border-radius: 11px; background: rgba(139, 92, 246, 0.16); color: var(--purple-ink); }
.ask-t { flex: 1; min-width: 160px; display: grid; gap: 1px; }
.ask-t b { font-size: 15px; color: #fff; }
.ask-t span { font-size: 13.5px; color: var(--muted); }
.ask-b { display: flex; gap: 8px; flex-wrap: wrap; }
.ask-chip { height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(139, 92, 246, 0.55); background: rgba(139, 92, 246, 0.12); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.ask-chip:hover { background: rgba(139, 92, 246, 0.24); }
.unlock-page .ask-row { margin: 18px 0 4px; text-align: left; }

/* The chat */
.coach { position: fixed; z-index: 90; top: calc(var(--top) + 12px); right: 16px; bottom: 16px; width: 420px; display: flex; flex-direction: column; border-radius: 22px; border: 1px solid var(--line-2); background: #0b0a0f; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(139, 92, 246, 0.08); overflow: hidden; animation: coachIn 0.22s ease; }
.coach.hidden { display: none; }
@keyframes coachIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.coach-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(139, 92, 246, 0.12), transparent); }
.coach-av { flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #8b5cf6, #6d3fe6); color: #fff; box-shadow: 0 8px 22px -10px rgba(139, 92, 246, 0.9); }
.coach-av.big { width: 46px; height: 46px; border-radius: 15px; margin: 0 auto 10px; }
.coach-av.big svg { width: 22px; height: 22px; }
.coach-ttl { flex: 1; min-width: 0; display: grid; }
.coach-ttl b { font-size: 15.5px; color: #fff; }
.coach-ttl small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coach-ic { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.coach-ic:hover { color: #fff; background: var(--panel-2); border-color: var(--line-2); }

.coach-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 14px 10px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }
.coach-hello { text-align: center; padding: 6px 10px 10px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.coach-hello b { color: #fff; font-size: 16px; }
.coach-hello p + p { margin-top: 4px; }

.cm { display: flex; flex-direction: column; }
.cm.me { align-items: flex-end; }
.cm.ai { align-items: flex-start; }
.cb { max-width: 88%; padding: 11px 14px; border-radius: 18px; font-size: 15px; line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere; }
.cm.me .cb { background: var(--purple); color: #fff; border-bottom-right-radius: 6px; }
.cm.ai .cb { background: var(--panel-2); border: 1px solid var(--line); color: #e8e6ef; border-bottom-left-radius: 6px; }
.cm.ai.err .cb { border-color: rgba(248, 113, 113, 0.45); color: #fde2e2; }
.cb p + p, .cb p + ul, .cb ul + p, .cb p + ol, .cb ol + p { margin-top: 9px; }
.cb ul, .cb ol { margin: 0; padding-left: 20px; }
.cb li { margin: 3px 0; }
.cb li::marker { color: var(--purple-ink); }
.cb strong { color: #fff; }

.coach-ctas { display: grid; gap: 8px; margin-top: 8px; width: min(88%, 320px); }
.coach-cta { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; padding: 0 14px 0 16px; border-radius: 14px; border: 0; background: var(--purple); color: #fff; font: inherit; font-size: 14.5px; font-weight: 650; text-decoration: none; cursor: pointer; text-align: left; box-shadow: 0 10px 26px -14px rgba(139, 92, 246, 0.95); }
.coach-cta:hover { background: var(--purple-deep); }
.coach-cta.quiet { background: var(--panel); border: 1px solid var(--line-2); color: var(--text); box-shadow: none; }
.coach-cta.quiet:hover { border-color: var(--purple); }
.coach-cta svg { flex: none; }
.coach-sent { font-size: 13.5px; color: var(--good); padding: 4px 2px; }
.coach-sent a { color: var(--purple-ink); }

.coach-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 6px 0 2px; }
.coach-chip { padding: 10px 14px; border-radius: 999px; border: 1px solid rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.1); color: #fff; font: inherit; font-size: 14px; line-height: 1.3; cursor: pointer; text-align: center; }
.coach-chip:hover { background: rgba(139, 92, 246, 0.22); }

.typing { display: inline-flex; gap: 5px; align-items: center; min-height: 22px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--purple-ink); opacity: 0.35; animation: coachDot 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes coachDot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.coach-in { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: #0b0a0f; }
.coach-in textarea { flex: 1; min-height: 46px; max-height: 120px; resize: none; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line-2); background: #131118; color: var(--text); font: inherit; font-size: 16px; line-height: 1.35; outline: none; }
.coach-in textarea:focus { border-color: var(--purple); }
.coach-send { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--purple); color: #fff; cursor: pointer; }
.coach-send:hover { background: var(--purple-deep); }

/* Phones: the chat takes the whole screen, with room for the home bar. */
@media (max-width: 720px) {
  .ask-ai { height: 34px; padding: 0 12px 0 10px; font-size: 13.5px; }
  .coach { inset: 0; top: 0; width: auto; border-radius: 0; border: 0; height: 100%; height: 100dvh; padding-top: env(safe-area-inset-top); }
  .coach-in { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  body.coach-open { overflow: hidden; }
  body.coach-open .appbar, body.coach-open .lessonbar, body.coach-open .bbar { visibility: hidden; }
  .cb { max-width: 90%; }
  .coach-ctas { width: min(90%, 340px); }
  .ask-row { flex-direction: column; text-align: center; }
  .ask-t { min-width: 0; }
  .ask-b { justify-content: center; }
  .unlock-page .ask-row { text-align: center; }
}
@media (max-width: 440px) {
  body.coach-on .top .pill .bar { display: none; }
  .outline-toggle { white-space: nowrap; }
}
@media (max-width: 380px) {
  .ask-ai span { display: none; }
  .ask-ai { padding: 0 10px; }
}
