/* ═══════════════════════════════════════════════════════════════════
   Video lessons (AITOOLS Academy) — shared by the Learning page, the
   dashboard card, the sign-up / setup prompts and the AI Helper chat.
   Rendering lives in js/tutorials/tutorials.js.

   Dark first, light through :where(html[data-theme="light"]), like
   theme.css. The accent is the indigo → violet of the lesson covers;
   emerald always means "watched".
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --ac-1: #6366f1;
  --ac-2: #8b5cf6;
  --ac-grad: linear-gradient(135deg, #4f46e5, #7c3aed);
  --ac-text: #c7d2fe;
  --ac-soft: rgba(99, 102, 241, 0.14);
  --ac-soft-border: rgba(129, 140, 248, 0.32);
  --ac-done: #34d399;
  --ac-done-strong: #10b981;
  --ac-done-soft: rgba(16, 185, 129, 0.14);
  --ac-track: rgba(148, 163, 184, 0.16);
  --ac-surface: rgba(15, 23, 42, 0.6);
  --ac-surface-2: rgba(30, 41, 59, 0.55);
  --ac-border: rgba(148, 163, 184, 0.12);
  --ac-border-strong: rgba(148, 163, 184, 0.24);
  --ac-strong: #f8fafc;
  --ac-body: #cbd5e1;
  --ac-muted: #94a3b8;
  --ac-faint: #64748b;
  --ac-thumb-bg: #1e1b4b;
}
:root[data-theme="light"] {
  --ac-text: #4338ca;
  --ac-soft: rgba(79, 70, 229, 0.08);
  --ac-soft-border: rgba(79, 70, 229, 0.24);
  --ac-done: #059669;
  --ac-done-soft: rgba(5, 150, 105, 0.09);
  --ac-track: #e2e8f0;
  --ac-surface: #ffffff;
  --ac-surface-2: #f8fafc;
  --ac-border: #e4e7ee;
  --ac-border-strong: #d3d8e2;
  --ac-strong: #0f172a;
  --ac-body: #334155;
  --ac-muted: #64748b;
  --ac-faint: #94a3b8;
  --ac-thumb-bg: #e0e7ff;
}

/* ── Segmented course bar: one segment per lesson ─────────────────── */
.ac-bar { display: flex; gap: 4px; height: 6px; }
.ac-bar > i {
  position: relative; flex: 1; min-width: 6px; border-radius: 99px;
  background: var(--ac-track); overflow: hidden;
}
.ac-bar > i::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: var(--ac-grad);
  transform-origin: left; transform: scaleX(var(--p, 0));
  transition: transform .6s cubic-bezier(.2, .7, .2, 1), background-color .3s;
}
.ac-bar > i.is-done::after { background: var(--ac-done-strong); }

/* ── Thumbnail ───────────────────────────────────────────────────── */
.ac-thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 12px; background: var(--ac-thumb-bg); flex-shrink: 0;
  border: 1px solid var(--ac-border);
}
.ac-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.ac-thumb .ac-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(180deg, transparent 40%, rgba(2, 6, 23, .35));
  opacity: 0; transition: opacity .2s ease;
}
.ac-play span {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .94); color: #4f46e5;
  box-shadow: 0 8px 24px rgba(2, 6, 23, .35);
}
.ac-play svg { width: 18px; height: 18px; margin-left: 3px; }
.ac-dur {
  position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; border-radius: 6px;
  font-size: 11px; font-weight: 600; line-height: 1.4; font-variant-numeric: tabular-nums;
  color: #fff; background: rgba(2, 6, 23, .78);
}
.ac-done-badge {
  position: absolute; left: 6px; top: 6px; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px 2px 5px; border-radius: 99px; font-size: 11px; font-weight: 600;
  color: #fff; background: var(--ac-done-strong);
}
.ac-done-badge svg { width: 12px; height: 12px; }
.ac-thumb-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(2, 6, 23, .4); }
.ac-thumb-progress i { display: block; height: 100%; background: #ef4444; }
button.ac-thumb, a.ac-thumb { cursor: pointer; padding: 0; }
.ac-thumb:hover img, .ac-lesson-open:hover .ac-thumb img { transform: scale(1.04); }
.ac-thumb:hover .ac-play, .ac-thumb:focus-visible .ac-play,
.ac-lesson-open:hover .ac-play, .ac-lesson-open:focus-visible .ac-play { opacity: 1; }
@media (hover: none) { .ac-thumb .ac-play { opacity: 1; background: transparent; } .ac-play span { width: 38px; height: 38px; } }

/* ── Buttons ─────────────────────────────────────────────────────── */
.ac-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 11px; border: 0; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none;
  color: #fff; background: var(--ac-grad);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 8px 20px -10px rgba(79, 70, 229, .8);
  transition: filter .15s ease, box-shadow .15s ease;
}
.ac-btn:hover { filter: brightness(1.08); }
.ac-btn svg { width: 16px; height: 16px; }
.ac-btn-ghost {
  color: var(--ac-strong); background: transparent; box-shadow: none;
  border: 1px solid var(--ac-border-strong);
}
.ac-btn-ghost:hover { filter: none; background: var(--ac-soft); border-color: var(--ac-soft-border); }
.ac-btn-sm { height: 32px; padding: 0 11px; border-radius: 9px; font-size: 12.5px; }
.ac-link { color: var(--ac-text); font-size: 13px; font-weight: 600; text-decoration: none; }
.ac-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ac-icon-btn {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--ac-muted); cursor: pointer;
}
.ac-icon-btn:hover { background: var(--ac-soft); color: var(--ac-strong); }
.ac-icon-btn svg { width: 16px; height: 16px; }

/* ── Player modal ────────────────────────────────────────────────── */
.ac-modal {
  position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(2, 6, 23, .82);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.ac-modal[hidden] { display: none; }
.ac-modal-panel {
  width: min(960px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  border-radius: 20px; background: #0b1020; border: 1px solid rgba(148, 163, 184, .16);
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, .7);
  animation: acPop .22s cubic-bezier(.2, .7, .2, 1) both;
}
:where(html[data-theme="light"]) .ac-modal-panel { background: #fff; border-color: #e4e7ee; }
@keyframes acPop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.ac-stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 20px 20px 0 0; overflow: hidden; }
.ac-stage > div, .ac-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ac-modal-body { display: flex; align-items: flex-start; gap: 16px; padding: 16px 20px 18px; }
.ac-modal-text { flex: 1; min-width: 0; }
.ac-kicker { font-size: 12.5px; font-weight: 600; color: var(--ac-text); font-variant-numeric: tabular-nums; }
.ac-modal-title { margin-top: 2px; font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--ac-strong); }
.ac-modal-desc { margin-top: 6px; font-size: 13.5px; line-height: 1.55; color: var(--ac-muted); max-width: 64ch; }
.ac-modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.ac-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ac-muted); margin-top: 8px; }
.ac-state.is-done { color: var(--ac-done); }
.ac-state svg { width: 14px; height: 14px; }
.ac-modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; border: 0; cursor: pointer; color: #fff; background: rgba(2, 6, 23, .6);
}
.ac-modal-close:hover { background: rgba(2, 6, 23, .85); }
.ac-modal-close svg { width: 18px; height: 18px; }
@media (max-width: 639px) {
  .ac-modal { padding: 0; align-items: flex-end; }
  .ac-modal-panel { border-radius: 18px 18px 0 0; max-height: 100dvh; }
  .ac-stage { border-radius: 18px 18px 0 0; }
  .ac-modal-body { flex-direction: column; padding: 14px 16px 18px; }
  .ac-modal-actions { width: 100%; justify-content: stretch; }
  .ac-modal-actions .ac-btn { flex: 1; }
}

/* ── Dashboard card: "Take the course" ───────────────────────────── */
.ac-card { border-radius: 18px; padding: 20px; }
.ac-card-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.ac-card-head h2 { font-size: 16px; font-weight: 650; color: var(--ac-strong); }
.ac-card-head p { margin-top: 3px; font-size: 13px; color: var(--ac-muted); }
.ac-card-meta { display: flex; align-items: center; gap: 14px; }
.ac-count { font-size: 13px; color: var(--ac-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ac-count b { color: var(--ac-strong); font-weight: 650; }
.ac-card .ac-bar { margin: 14px 0 16px; }
.ac-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ac-tile {
  display: flex; align-items: center; gap: 12px; min-width: 0; padding: 6px; margin: -6px; text-align: left;
  border: 0; border-radius: 14px; background: none; color: inherit; font: inherit; cursor: pointer;
  transition: background-color .15s ease;
}
.ac-tile:hover { background: var(--ac-soft); }
.ac-tile .ac-thumb { width: 46%; max-width: 168px; border-radius: 10px; }
.ac-tile:hover .ac-play, .ac-tile:focus-visible .ac-play { opacity: 1; }
.ac-tile:hover .ac-thumb img { transform: scale(1.04); }
.ac-tile-text { min-width: 0; flex: 1; }
.ac-tile-num { display: block; font-size: 12px; font-weight: 600; color: var(--ac-text); font-variant-numeric: tabular-nums; }
.ac-tile-title { display: block; margin-top: 2px; font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ac-strong); }
@media (max-width: 1023px) {
  .ac-tiles { grid-template-columns: 1fr; gap: 10px; }
  .ac-tile .ac-thumb { width: 128px; }
}

/* ── Learning page ───────────────────────────────────────────────── */
.ac-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 32px; margin-bottom: 28px; }
.ac-page-head h1 { font-size: clamp(26px, 3vw, 32px); font-weight: 750; letter-spacing: -.02em; color: var(--ac-strong); }
.ac-page-head p { margin-top: 6px; max-width: 58ch; font-size: 14.5px; line-height: 1.55; color: var(--ac-muted); }
.ac-course { width: min(340px, 100%); }
.ac-course .ac-count { display: block; margin-bottom: 8px; font-size: 13.5px; }
.ac-course .ac-bar { height: 8px; }

/* Up next */
.ac-next {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: center;
  padding: 18px; border-radius: 22px; margin-bottom: 36px;
}
.ac-next .ac-thumb { border-radius: 16px; }
.ac-next .ac-play span { width: 64px; height: 64px; }
.ac-next .ac-play svg { width: 24px; height: 24px; }
.ac-next .ac-play { opacity: 1; background: linear-gradient(180deg, transparent 50%, rgba(2, 6, 23, .3)); }
.ac-next-label { font-size: 13px; font-weight: 600; color: var(--ac-text); font-variant-numeric: tabular-nums; }
.ac-next h2 { margin-top: 6px; font-size: clamp(22px, 2.4vw, 28px); font-weight: 750; line-height: 1.2; letter-spacing: -.015em; color: var(--ac-strong); }
.ac-next-desc { margin-top: 10px; font-size: 14.5px; line-height: 1.6; color: var(--ac-body); max-width: 52ch; }
.ac-next-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 20px; }
.ac-next-foot .ac-btn { height: 44px; padding: 0 20px; }
.ac-meta-dur { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ac-muted); font-variant-numeric: tabular-nums; }
.ac-meta-dur svg { width: 14px; height: 14px; }
.ac-finished { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: 18px; margin-bottom: 36px; }
.ac-finished-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: var(--ac-done); background: var(--ac-done-soft); flex-shrink: 0; }
.ac-finished-ic svg { width: 22px; height: 22px; }
.ac-finished b { display: block; font-size: 15px; color: var(--ac-strong); }
.ac-finished span { font-size: 13.5px; color: var(--ac-muted); }
@media (max-width: 767px) {
  .ac-next { grid-template-columns: 1fr; gap: 16px; padding: 12px 12px 18px; }
  .ac-next > div:last-child { padding: 0 6px; }
}

/* Syllabus: numbered nodes on a track; each node is a progress ring. */
.ac-section-title { font-size: 15px; font-weight: 650; color: var(--ac-strong); margin-bottom: 10px; }
.ac-syllabus { list-style: none; margin: 0; padding: 0; }
.ac-lesson { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; }
.ac-lesson::before {
  content: ""; position: absolute; left: 19px; top: 0; bottom: 0; width: 2px; background: var(--ac-track);
}
.ac-lesson:first-child::before { top: 30px; }
.ac-lesson:last-child::before { bottom: calc(100% - 30px); }
.ac-lesson.is-done::before { background: linear-gradient(var(--ac-done-strong), var(--ac-done-strong)) top / 2px 100% no-repeat, var(--ac-track); }
.ac-node {
  position: relative; z-index: 1; margin-top: 12px; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--ac-1) calc(var(--p, 0) * 1%), var(--ac-track) 0);
}
.ac-node::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--ui-bg, #05070d); }
.ac-node b { position: relative; font-size: 13px; font-weight: 700; color: var(--ac-muted); font-variant-numeric: tabular-nums; }
.ac-lesson.is-started .ac-node b { color: var(--ac-text); }
.ac-lesson.is-done .ac-node { background: var(--ac-done-strong); }
.ac-lesson.is-done .ac-node::before { display: none; }
.ac-node svg { position: relative; width: 18px; height: 18px; color: #fff; }
.ac-lesson.is-next .ac-node { box-shadow: 0 0 0 4px var(--ac-soft); }

.ac-row {
  display: flex; align-items: center; gap: 16px; padding: 8px 10px 8px 8px; margin: 4px 0;
  border-radius: 16px; border: 1px solid transparent; transition: background-color .15s ease, border-color .15s ease;
}
.ac-row:hover { background: var(--ac-surface); border-color: var(--ac-border); }
.ac-lesson-open {
  display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; padding: 0; text-align: left;
  border: 0; background: none; color: inherit; font: inherit; cursor: pointer; border-radius: 12px;
}
.ac-row .ac-thumb { width: 168px; }
.ac-row-text { min-width: 0; flex: 1; }
.ac-row-title { font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--ac-strong); }
.ac-lesson-open:hover .ac-row-title { color: var(--ac-text); }
.ac-row-desc {
  margin-top: 4px; font-size: 13px; line-height: 1.5; color: var(--ac-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 70ch;
}
.ac-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; font-size: 12.5px; color: var(--ac-faint); font-variant-numeric: tabular-nums; }
.ac-row-meta .is-done { color: var(--ac-done); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.ac-row-meta .is-done svg { width: 13px; height: 13px; }
.ac-row-meta .is-started { color: var(--ac-text); font-weight: 600; }
.ac-row-side { flex-shrink: 0; }
@media (max-width: 639px) {
  .ac-lesson { grid-template-columns: 30px minmax(0, 1fr); gap: 8px; }
  .ac-lesson::before { left: 14px; }
  .ac-node { width: 30px; height: 30px; margin-top: 10px; }
  .ac-node b { font-size: 12px; }
  .ac-row { padding: 6px 4px; gap: 8px; align-items: flex-start; }
  .ac-lesson-open { flex-direction: column; align-items: stretch; gap: 10px; }
  .ac-row .ac-thumb { width: 100%; }
  .ac-row-desc { -webkit-line-clamp: 3; }
}

/* ── Prompt: sign-up and setup pages ─────────────────────────────── */
.ac-prompt {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 16px;
  background: var(--ac-soft); border: 1px solid var(--ac-soft-border);
  animation: acIn .35s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes acIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.ac-prompt .ac-thumb { width: 112px; border-radius: 10px; border-color: transparent; }
.ac-prompt .ac-play { opacity: 1; background: rgba(2, 6, 23, .18); }
.ac-prompt .ac-play span { width: 32px; height: 32px; }
.ac-prompt .ac-play svg { width: 13px; height: 13px; margin-left: 2px; }
.ac-prompt-text { flex: 1; min-width: 0; }
.ac-prompt > .ac-prompt-text { padding-right: 22px; }
.ac-prompt-text b { display: block; font-size: 14px; font-weight: 650; line-height: 1.35; color: var(--ac-strong); }
.ac-prompt-text span { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.45; color: var(--ac-muted); }
.ac-prompt-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.ac-prompt-x { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; }
.ac-prompt-x svg { width: 14px; height: 14px; }

/* Setup page: the prompt grows into an inline player with a playlist. */
.ac-setup { border-radius: 20px; overflow: hidden; background: var(--ac-surface); border: 1px solid var(--ac-border); }
.ac-setup-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; padding: 16px 18px; }
.ac-setup-ask .ac-stack { display: flex; flex-shrink: 0; }
.ac-setup-ask .ac-stack .ac-thumb { width: 64px; border-radius: 9px; border: 2px solid var(--ac-surface-2); }
.ac-setup-ask .ac-stack .ac-thumb + .ac-thumb { margin-left: -22px; }
.ac-setup-ask .ac-prompt-text b { font-size: 15px; }
.ac-setup-ask .ac-prompt-actions { margin-top: 0; }
.ac-setup-player { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.ac-setup-player[hidden] { display: none; }
.ac-setup-player .ac-stage { border-radius: 0; }
.ac-setup-now { padding: 14px 18px 16px; }
.ac-setup-list { border-left: 1px solid var(--ac-border); padding: 10px; display: flex; flex-direction: column; gap: 4px; max-height: 100%; overflow: auto; }
.ac-setup-list-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 8px; font-size: 13px; font-weight: 650; color: var(--ac-strong); }
.ac-pl {
  display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; text-align: left;
  border: 1px solid transparent; background: none; color: inherit; font: inherit; cursor: pointer;
}
.ac-pl:hover { background: var(--ac-soft); }
.ac-pl[aria-current="true"] { background: var(--ac-soft); border-color: var(--ac-soft-border); }
.ac-pl .ac-thumb { width: 96px; border-radius: 8px; }
.ac-pl b { display: block; font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--ac-strong); }
.ac-pl small { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; color: var(--ac-faint); font-variant-numeric: tabular-nums; }
.ac-pl small .is-done { color: var(--ac-done); font-weight: 600; }
@media (max-width: 899px) {
  .ac-setup-player { grid-template-columns: 1fr; }
  .ac-setup-list { border-left: 0; border-top: 1px solid var(--ac-border); }
}
@media (max-width: 639px) {
  .ac-setup-ask .ac-stack { display: none; }
  .ac-setup-ask .ac-prompt-actions { width: 100%; }
  .ac-setup-ask .ac-prompt-actions .ac-btn { flex: 1; }
}

/* ── AI Helper chat: lesson card under an answer ─────────────────── */
.ac-chat-video {
  display: flex; align-items: center; gap: 12px; width: 100%; max-width: 380px; margin-top: 10px; padding: 8px;
  border-radius: 14px; text-align: left; cursor: pointer; font: inherit; color: inherit;
  border: 1px solid var(--hai-accent-border, var(--ac-soft-border)); background: var(--hai-accent-soft, var(--ac-soft));
  transition: transform .15s ease, border-color .15s ease;
}
.ac-chat-video:hover { transform: translateY(-1px); }
.ac-chat-video .ac-thumb { width: 116px; border-radius: 9px; border-color: transparent; }
.ac-chat-video .ac-play { opacity: 1; background: rgba(2, 6, 23, .18); }
.ac-chat-video .ac-play span { width: 30px; height: 30px; }
.ac-chat-video .ac-play svg { width: 12px; height: 12px; margin-left: 2px; }
.ac-chat-video small { display: block; font-size: 11.5px; font-weight: 600; color: var(--hai-link, var(--ac-text)); }
.ac-chat-video b { display: block; margin-top: 2px; font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--hai-strong, var(--ac-strong)); }
.ac-chat-video em { display: block; margin-top: 3px; font-style: normal; font-size: 11.5px; color: var(--hai-muted, var(--ac-muted)); }

.ac-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .ac-bar > i::after, .ac-thumb img, .ac-chat-video { transition: none; }
  .ac-modal-panel, .ac-prompt { animation: none; }
}

/* Page slots */
.ac-signup { margin: 0 0 18px; }
.ac-setup-slot { scroll-margin-top: 88px; }
