/* DharmaTube AI: the composed answer (/ask and the search page), the AI panel on the watch page, the limit card and
   subtitle-translation status. Loaded by ai.js (the search and watch pages) or linked in the head (/ask).
   Solid surfaces only (no glass), every value from the app.css tokens, light and dark. */
/* ------------------------------------------------------------------ watch page panel (below the about box) */

.ai-panel {
  display: grid;
  gap: 16px;
  margin-top: 12px;
  padding: 14px 16px 16px;
  border-radius: var(--radius-m, 12px);
  corner-shape: squircle;
  background: var(--bg-2, #f2f2f2);
  color: var(--text, #0f0f0f);
}
.ai-panel[hidden] {
  display: none;
}

.ai-summary__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.ai-summary__title {
  margin: 0;
  color: var(--text-3, #5f5f66);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ai-summary__text {
  margin: 0;
  color: var(--text, #0f0f0f);
  line-height: 1.55;
}
.ai-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--fill-2, rgb(0 0 0 / 0.09));
  color: var(--text-2, #3f3f46);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.ai-ask {
  display: grid;
  gap: 8px;
}
.ai-ask__label {
  font-size: 15px;
  font-weight: 600;
}
.ai-ask__row {
  display: flex;
  gap: 8px;
  min-width: 0;
}
.ai-ask__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--bg, #fff);
  box-shadow: inset 0 0 0 1px var(--separator, rgb(0 0 0 / 0.1));
  color: inherit;
  font: inherit;
  font-size: 16px; /* no iOS zoom on focus */
  text-overflow: ellipsis; /* a long example question ends in "…" on a phone, not cut mid-word */
  outline: none;
}
.ai-ask__input::placeholder {
  color: var(--text-3, #5f5f66);
  text-overflow: ellipsis;
}
.ai-ask__input:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus, #0a66ff);
}

.ai-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent, #0f0f0f);
  color: var(--accent-contrast, #fff);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--dur-press, 120ms), transform var(--dur-press, 120ms) var(--ease-out, ease-out);
}
.ai-btn:hover {
  opacity: 0.88;
}
.ai-btn:disabled {
  opacity: 0.5;
  cursor: progress;
}
.ai-btn:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 2px;
}
.ai-btn--small {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.ai-out:empty {
  display: none;
}
.ai-out__title {
  margin: 20px 0 10px;
  font-size: 17px;
  font-weight: 700;
}
.ai-answer {
  display: grid;
  gap: 10px;
}
.ai-answer__p {
  margin: 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.ai-note {
  margin: 0;
  color: var(--text-2, #3f3f46);
  font-size: 13px;
}
.ai-note--soft {
  padding: 10px 14px;
  border-radius: calc(12px * var(--sq, 1));
  corner-shape: squircle;
  background: var(--bg, #fff);
  color: var(--text, #0f0f0f);
  font-size: 14px;
}

/* the browser check did not pass: the line and its "Try again" button (ai.js retryNote) */

.ai-retry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.ai-retry__btn {
  flex: none;
}

/* timestamp citations: pills that seek the player */

.ai-cite {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 1px;
  padding: 1px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--bg, #fff);
  box-shadow: inset 0 0 0 1px var(--separator, rgb(0 0 0 / 0.1));
  color: var(--link, #065fd4);
  font: inherit;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  vertical-align: baseline;
}
.ai-cite:hover {
  background: var(--fill, rgb(0 0 0 / 0.05));
}
.ai-cite:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 1px;
}
.ai-cites {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ai-cite--chip {
  max-width: 100%;
  min-height: 36px;
  align-items: center;
  padding: 4px 12px;
  text-align: start;
}
.ai-cite__text {
  max-width: 34ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2, #3f3f46);
  font-family: var(--font-sans, system-ui, sans-serif);
}

.ai-vref {
  display: inline-block;
  min-width: 1.5em;
  margin: 0 2px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--fill, rgb(0 0 0 / 0.05));
  color: var(--link, #065fd4);
  font-size: 0.75em;
  font-weight: 600;
  line-height: 1.6;
  text-align: center;
  text-decoration: none;
  vertical-align: super;
}

.ai-turnstile:empty {
  display: none;
}
/* after a failed check the widget is drawn visibly in the answer, for the person to complete */
.ai-turnstile--visible {
  margin: 12px 0;
  min-height: 65px;
}

/* subtitle-translation status: inserted by ai.js after the #sub-lang label inside the strip (see app.css .sub-strip) */

.ai-sub-status {
  color: var(--glass-text-2, #3a3a40);
  font-size: 12px;
  line-height: 1.3;
}
.ai-sub-status:empty {
  display: none;
}

/* ------------------------------------------------------------------ /ask chat (the curator) */

.ai-chat {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 760px;
  margin: 12px auto 0;
}

/* "New chat" beside the title while both fit; when they do not (fr at 390 px, pt and ja at 344 px) it goes under the
   title instead of past the screen's edge */

.ai-chat__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ai-chat__head > .ai-chat__title {
  flex: 1 1 10ch; /* the title may take two lines beside the button; its longest word decides when the button wraps */
  overflow-wrap: break-word;
}
.ai-chat__title {
  margin: 0;
  font-size: 32px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.022em;
}
.ai-chat__reset {
  flex: none;
  max-width: 100%;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--fill, rgb(0 0 0 / 0.05));
  color: var(--text, #0f0f0f);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ai-chat__reset:hover {
  background: var(--fill-2, rgb(0 0 0 / 0.09));
}
.ai-chat__reset[hidden],
.ai-chat__intro[hidden] {
  display: none;
}
.ai-chat__intro {
  display: grid;
  gap: 14px;
}
.ai-chat__lead {
  margin: 0;
  color: var(--text-2, #3f3f46);
  line-height: 1.55;
}
.ai-chat__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ai-chip {
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--fill, rgb(0 0 0 / 0.05));
  color: var(--text, #0f0f0f);
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  text-align: start;
  cursor: pointer;
  transition: background var(--dur-press, 120ms);
}
.ai-chip:hover {
  background: var(--fill-2, rgb(0 0 0 / 0.09));
}
.ai-chip:active {
  background: var(--fill-3, rgb(0 0 0 / 0.14));
}
.ai-chip:focus-visible,
.ai-chat__reset:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 2px;
}

.ai-chat__log {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ai-chat__log:empty {
  display: none;
}
.ai-msg {
  display: grid;
  gap: 10px;
  min-width: 0;
  scroll-margin-top: calc(var(--appbar-h, 56px) + var(--safe-top, 0px) + 16px); /* a question brought to the top lands below the sticky header */
}
.ai-msg--user {
  justify-items: end;
}
.ai-msg--assistant + .ai-msg--user {
  margin-top: 26px;
  padding-top: 26px;
  border-top: 1px solid var(--separator, rgb(0 0 0 / 0.1));
}
.ai-msg__bubble {
  max-width: min(85%, 560px);
  padding: 10px 15px;
  border-radius: 20px;
  border-end-end-radius: 6px; /* the tail on the viewer's side */
  background: var(--bg-2, #f2f2f2);
  color: var(--text, #0f0f0f);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ the answer: a composed result
   steps · headline · body (marks) · the talks in the library (rail) · follow-ups.
   Solid surfaces, app.css tokens; the video numbers are ink. */

.ai-chat {
  --wref-fg: rgb(84 46 206);
  --wref-bg: rgb(var(--ai-cool, 118 70 255) / 0.1);
  --wref-ring: rgb(var(--ai-cool, 118 70 255) / 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ai-chat {
    --wref-fg: rgb(196 178 255);
    --wref-bg: rgb(var(--ai-cool, 156 122 255) / 0.2);
  }
}
:root[data-theme="dark"] .ai-chat {
  --wref-fg: rgb(196 178 255);
  --wref-bg: rgb(var(--ai-cool, 156 122 255) / 0.2);
}

.ai-res {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}

/* progress: a short list while it runs, one quiet line when done */

.ai-res__steps {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.ai-res__steps[hidden] {
  display: none;
}
.ai-res[data-state="done"] .ai-res__steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 12px;
}
.ai-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-3, #5f5f66);
  font-size: 13px;
  line-height: 18px;
}
.ai-step[data-state="active"] {
  color: var(--text-2, #3f3f46);
}
.ai-step__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-step__n {
  flex: none;
  color: var(--text-3, #5f5f66);
}
.ai-step__n::before {
  content: "·";
  margin-inline-end: 6px;
}
.ai-step__dot {
  position: relative;
  flex: none;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--separator, rgb(0 0 0 / 0.1));
  border-radius: 50%;
}
.ai-step[data-state="active"] .ai-step__dot {
  border-color: var(--text-2, #3f3f46);
  border-top-color: transparent;
  animation: ai-spin 0.8s linear infinite;
}
.ai-step[data-state="done"] .ai-step__dot {
  border-color: var(--text-3, #5f5f66);
  background: var(--text-3, #5f5f66);
}
.ai-step[data-state="done"] .ai-step__dot::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 3px;
  height: 6px;
  border: solid var(--bg, #fff);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.ai-res[data-state="done"] .ai-step {
  font-size: 12px;
}
.ai-res[data-state="done"] .ai-step__dot {
  width: 10px;
  height: 10px;
}
.ai-res[data-state="done"] .ai-step__dot::after {
  left: 2.5px;
  top: 0.5px;
  height: 5px;
}
@keyframes ai-spin {
  to {
    transform: rotate(360deg);
  }
}

/* the direct answer, then the body */

.ai-res__headline {
  display: grid;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--text, #0f0f0f);
  font-size: 22px;
  font-weight: 650;
  line-height: 1.32;
  letter-spacing: -0.012em;
  overflow-wrap: anywhere;
}
.ai-res__headline[hidden],
.ai-res__body[hidden],
.ai-res__sec[hidden],
.ai-res__next[hidden],
.ai-res__foot[hidden] {
  display: none;
}
.ai-res__hl {
  display: block;
}
.ai-res__body {
  display: grid;
  gap: 10px;
  color: var(--text, #0f0f0f);
  font-size: 16px;
  line-height: 1.62;
}
.ai-res__p {
  margin: 0;
  overflow-wrap: anywhere;
}
.ai-res__sec {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  margin-top: 28px;
}
.ai-res__kicker {
  margin: 0;
  color: var(--text-3, #5f5f66);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 16px;
  text-transform: uppercase;
}
:lang(zh) .ai-res__kicker,
:lang(ja) .ai-res__kicker,
:lang(ko) .ai-res__kicker,
:lang(ar) .ai-res__kicker {
  letter-spacing: 0.02em;
}
.ai-res__foot {
  margin-top: 16px;
}
.ai-res > .ai-note--soft {
  margin-top: 14px;
}

/* marks: video numbers (ink) */

.ai-vref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 18px;
  height: 18px;
  margin: 0 2px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 650;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  vertical-align: 2px;
  transition: background var(--dur-press, 120ms);
}
.ai-vref {
  background: var(--fill-2, rgb(0 0 0 / 0.09));
  color: var(--text, #0f0f0f);
}
.ai-vref:hover {
  background: var(--fill-3, rgb(0 0 0 / 0.14));
}
.ai-vref:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 1px;
}
.ai-res__headline .ai-vref {
  vertical-align: 3px;
}

/* a fact from the web: its chip says so (dashed edge, the word "web"), and the cards below list the pages */
.ai-wref {
  display: inline-flex;
  align-items: center;
  height: 18px;
  margin: 0 2px;
  padding: 0 6px;
  border: 1px dashed var(--separator, rgb(0 0 0 / 0.28));
  border-radius: 6px;
  color: var(--text-2, #3f3f46);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: 1px;
}
.ai-wref:hover {
  background: var(--fill-2, rgb(0 0 0 / 0.06));
}
.ai-wref:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 1px;
}
.ai-res__headline .ai-wref {
  vertical-align: 3px;
}
.ai-res__web {
  margin-top: 22px;
}
/* "More in the library": compact lines, then the link to the whole search */
.ai-res__more {
  margin-top: 18px;
}
.ai-mlist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2px 16px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.ai-mitem__link {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 0;
  border-bottom: 1px solid var(--separator, rgb(0 0 0 / 0.1));
  color: inherit;
  text-decoration: none;
}
.ai-mitem__link:hover .ai-mitem__title {
  text-decoration: underline;
}
.ai-mitem__link:focus-visible,
.ai-res__all:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 2px;
}
.ai-mitem__title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 520;
  line-height: 19px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-mitem__meta {
  overflow: hidden;
  color: var(--text-3, #5f5f66);
  font-size: 12px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-res__all {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-top: 10px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--fill, rgb(0 0 0 / 0.05));
  color: inherit;
  font-size: 14px;
  font-weight: 560;
  text-decoration: none;
}
.ai-res__more[hidden],
.ai-mlist[hidden],
.ai-res__all[hidden],
.ai-res__more .ai-res__kicker[hidden] {
  display: none;
}
.ai-res__all:hover {
  background: var(--fill-2, rgb(0 0 0 / 0.09));
}
.ai-res__webnote {
  margin: 4px 0 10px;
  color: var(--text-3, #5f5f66);
  font-size: 13px;
  line-height: 18px;
}
.ai-wlist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ai-wcard__link {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px dashed var(--separator, rgb(0 0 0 / 0.22));
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.ai-wcard__link:hover {
  background: var(--fill, rgb(0 0 0 / 0.04));
}
.ai-wcard__link:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 2px;
}
.ai-wcard__letter {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--fill-2, rgb(0 0 0 / 0.09));
  font-size: 11px;
  font-weight: 650;
}
.ai-wcard__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ai-wcard__title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14px;
  font-weight: 550;
  line-height: 19px;
}
.ai-wcard__meta {
  overflow: hidden;
  color: var(--text-3, #5f5f66);
  font-size: 12px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* video cards: a grid on wide screens, a rail on phones */

.ai-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 16px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ai-vcard {
  min-width: 0;
}
.ai-vcard__link {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  border-radius: var(--radius-m, 12px);
  corner-shape: squircle;
  color: inherit;
  text-decoration: none;
}
.ai-vcard__link:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 3px;
}
.ai-vcard__media {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-m, 12px);
  corner-shape: squircle;
  --cc-r: 12px; /* Safari's continuous corner (app.css, end) */
  background: var(--thumb-bg, #ececec);
  aspect-ratio: 16 / 9;
}
.ai-vcard__thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-fade, 200ms) var(--ease-out, ease-out);
}
.ai-vcard__thumb.is-broken {
  visibility: hidden;
}
@media (hover: hover) {
  .ai-vcard__link:hover .ai-vcard__thumb {
    transform: scale(1.02);
  }
}
.ai-vcard__num,
.ai-vcard__dur {
  position: absolute;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--overlay, rgb(0 0 0 / 0.8));
  color: var(--overlay-text, #fff);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}
.ai-vcard__num {
  top: 6px;
  inset-inline-start: 6px;
  min-width: 20px;
  text-align: center;
}
.ai-vcard__dur,
.ai-vcard__parts {
  inset-inline-end: 6px;
  bottom: 6px;
}
/* a whole series as one card: its parts where a talk has its length, "Play all" under the title */
.ai-vcard__parts {
  position: absolute;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--overlay, rgb(0 0 0 / 0.8));
  color: var(--overlay-text, #fff);
  font-size: 12px;
  font-weight: 650;
  line-height: 18px;
}
.ai-vcard--series .ai-vcard__media {
  box-shadow: 6px -6px 0 -2px var(--fill-2, rgb(0 0 0 / 0.12));
}
.ai-vcard__play {
  display: block;
  margin-top: 2px;
  color: var(--wref-fg, #0a66ff);
  font-size: 12px;
  font-weight: 620;
}
.ai-vcard__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.ai-vcard__kicker {
  overflow: hidden;
  color: var(--wref-fg);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-vcard__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}
.ai-vcard__meta {
  overflow: hidden;
  color: var(--text-3, #5f5f66);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* follow-ups: ask with one tap */

.ai-res__next {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}
.ai-chip--next {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.ai-chip__arrow {
  flex: none;
  color: var(--text-3, #5f5f66);
}
[dir="rtl"] .ai-chip__arrow {
  display: inline-block;
  transform: scaleX(-1);
}

/* placeholders while a section is on its way (same footprint as what replaces them) */

.ai-skel {
  display: block;
  border-radius: 6px;
  background: var(--fill, rgb(0 0 0 / 0.05));
}
.ai-skel--h {
  width: 92%;
  height: 22px;
  border-radius: 7px;
}
.ai-skel--line {
  width: 100%;
  height: 12px;
  margin: 4px 0;
}
.ai-skel--short {
  width: 58%;
}
.ai-skel--media {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-m, 12px);
  corner-shape: squircle;
}
.ai-skel-card {
  display: grid;
  align-content: start;
  gap: 6px;
}
@media (prefers-reduced-motion: no-preference) {
  .ai-skel {
    background: linear-gradient(90deg, var(--fill, rgb(0 0 0 / 0.05)) 30%, var(--fill-2, rgb(0 0 0 / 0.09)) 50%, var(--fill, rgb(0 0 0 / 0.05)) 70%) 0 0 / 300% 100%;
    animation: ai-shimmer 1.4s ease-in-out infinite;
  }
}
@keyframes ai-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}
@keyframes ai-flash {
  0%,
  60% {
    box-shadow: inset 0 0 0 2px var(--wref-ring);
  }
  100% {
    box-shadow: inset 0 0 0 1px var(--separator, rgb(0 0 0 / 0.1));
  }
}

/* ------------------------------------------------------------------ the answer's parts: numbered lines, chips
   Same language as the cards: solid surfaces, hairline insets, app.css tokens; logical properties (RTL-safe). */
/* numbered lines in the body (a path, a brief): the number in its own column, like the video numbers */

.ai-res__ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ai-res__li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}
.ai-res__n {
  color: var(--text-3, #5f5f66);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: end;
}
.ai-res__lt {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* blocks */

.ai-res__blocks {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.ai-res__blocks[hidden] {
  display: none;
}
.ai-res[data-kind="brief"] .ai-res__blocks {
  margin: 4px 0 18px;
}

/* watch: the videos come right under the headline */

.ai-res[data-kind="watch"] .ai-res__lib {
  margin: 6px 0 22px;
}

/* compact (the search page's panel): denser, one row of cards */

.ai-res--compact .ai-res__headline {
  font-size: 18px;
}
.ai-res--compact .ai-res__body {
  font-size: 15px;
}
.ai-res--compact .ai-res__sec {
  margin-top: 18px;
}
.ai-res--compact .ai-res__blocks {
  margin-top: 14px;
}
.ai-more {
  display: none;
}

/* the clamp: about five lines of the body, faded at the edge; "Read more" opens it in place */

.ai-res--compact:not(.is-open) .ai-res__body {
  max-height: calc(1.62em * 5 + 10px);
  overflow: hidden;
}
.ai-res--compact:not(.is-open) .ai-res__body.has-more {
  -webkit-mask-image: linear-gradient(#000 62%, transparent);
  mask-image: linear-gradient(#000 62%, transparent);
}
.ai-res--compact .ai-more:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  min-height: 36px;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2, #3f3f46);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ai-res--compact .ai-more::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  transition: transform var(--dur-fade, 200ms) var(--ease-out, ease-out);
}
.ai-res--compact.is-open .ai-more::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}
.ai-res--compact .ai-more:hover {
  color: var(--text, #0f0f0f);
}
.ai-res--compact .ai-more:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (min-width: 768px) {
  .ai-res--compact .ai-rail {
    grid-template-rows: auto;
    grid-auto-rows: 0;
    row-gap: 0;
    overflow: hidden;
  }
}

/* composer: solid, sticks to the bottom of the viewport while the conversation scrolls */

.ai-composer {
  position: sticky;
  bottom: calc(16px + var(--safe-bottom, 0px));
  z-index: 5;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding: 6px;
  padding-inline-start: 18px;
  border-radius: 26px;
  --ai-r: 26px; /* the ring's lights follow this corner (app.css .ai-ring) */
  background: var(--bg, #fff);
  /* the outline is the .ai-ring inside (app.css): a closed line with two lights travelling along it; nothing is drawn
     outside the box (no drop shadow: the header's ask box has none either) */
}
.ai-composer::before {
  /* fade the conversation out above the composer (same-color stops: no dark band in WebKit) */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 20px;
  background: linear-gradient(rgb(var(--bg-rgb, 255 255 255) / 0), rgb(var(--bg-rgb, 255 255 255) / 1));
  pointer-events: none;
}
.ai-composer__field {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}
.ai-composer__field .ask-hint {
  inset: 11px 0 auto;
  height: 22px; /* the hint is size-contained: it needs its own height */
  color: var(--text-3, #5f5f66);
  font-size: 16px;
  line-height: 22px;
  --hint-o: 1;
}

/* "Tab" takes the example shown (app.js), only while the field is focused and empty, on mouse/keyboard devices */

.ai-composer__tab {
  position: absolute;
  inset-inline-end: 0;
  top: 11px;
  display: none;
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .ai-composer.has-example:focus-within:has(.ai-composer__input:placeholder-shown) .ai-composer__tab {
    display: inline-block;
  }
  .ai-composer.has-example:focus-within:has(.ai-composer__input:placeholder-shown) .ask-hint {
    inset-inline-end: 46px;
  }
}
.ai-composer__input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 168px;
  padding: 11px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 16px; /* no iOS zoom on focus */
  line-height: 22px;
  resize: none;
  outline: none;
}
.ai-composer__input::placeholder {
  color: var(--text-3, #5f5f66);
}
.ai-composer__send {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0; /* a plain ink circle: a gradient rim of its own would read as a second outline inside the box's */
  border-radius: 50%;
  background: var(--accent, #0f0f0f);
  color: var(--accent-contrast, #fff);
  /* the light sweep (.ask-btn__sheen): white on the dark button, warm on the light one (dark theme) */
  --sheen: 255 255 255;
  --sheen-a: 0.34;
  cursor: pointer;
  transition: opacity var(--dur-press, 120ms), transform var(--dur-press, 120ms) var(--ease-out, ease-out);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ai-composer__send {
    --sheen: var(--ai-hot, 255 170 92);
    --sheen-a: 0.55;
  }
}
:root[data-theme="dark"] .ai-composer__send {
  --sheen: var(--ai-hot, 255 170 92);
  --sheen-a: 0.55;
}
.ai-composer__send:active {
  transform: scale(var(--press-scale, 0.97));
}
.ai-composer__send:disabled {
  opacity: 0.45;
  cursor: progress;
}
.ai-composer__send:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 2px;
}
.ai-chat__fine {
  margin: -6px 0 0;
  color: var(--text-3, #5f5f66);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 767.98px) {
  .ai-chat {
    margin-top: 4px;
  }
  .ai-chat__title {
    font-size: 34px;
    line-height: 41px;
    letter-spacing: -0.012em;
  }
  .ai-chip {
    min-height: 44px;
  }
  .ai-chat__reset {
    min-height: 44px;
  }
  .ai-msg {
    scroll-margin-top: calc(var(--appbar-h, 44px) + 52px + var(--safe-top, 0px) + 12px); /* the bar's two rows: logo, then the field */
  }

/* the answer: rails that run edge to edge (the page gutter becomes their padding), the next card peeking */
  
  .ai-res__headline {
    font-size: 20px;
    line-height: 1.34;
  }
  .ai-rail {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 64%;
    gap: 12px;
    margin-inline: calc(-1 * var(--gutter, 16px));
    padding: 2px var(--gutter, 16px) 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter, 16px);
    scrollbar-width: none;
  }
  .ai-rail::-webkit-scrollbar {
    display: none;
  }
  .ai-rail > li {
    scroll-snap-align: start;
  }
  .ai-rail.ai-rail--few {
    grid-auto-columns: calc(50% - 6px);
  }
  .ai-chip--next {
    min-height: 44px;
    align-items: center;
  }

/* v5 parts on a phone: 44 px targets, compare stacked per aspect, rails edge to edge */
  
  .ai-res--compact .ai-more:not([hidden]) {
    min-height: 44px;
  }
  .ai-composer {
    --composer-rows-min: 1;
    --composer-rows-max: 4;
    /* clear the floating tab bar */
    bottom: calc(var(--tabbar-h, 62px) + max(10px, var(--safe-bottom, 0px)) + 10px);
    padding: 8px 6px 6px 16px;
  }

/* software keyboard up (ui-core.js watchKeyboard): sit right above it; the tab bar is under the keyboard anyway */
  
  html.kb-open .ai-composer {
    bottom: calc(var(--kb-inset, 0px) + 8px);
  }
  .ai-composer__send {
    width: 44px;
    height: 44px;
  }
}

/* wide phones (app.css): logo and field share one 52 px row */

@media (min-width: 560px) and (max-width: 767.98px), (min-width: 440px) and (max-width: 767.98px) and (min-aspect-ratio: 3/5) {
  .ai-msg {
    scroll-margin-top: calc(52px + var(--safe-top, 0px) + 12px);
  }
}

/* a touch screen with the tablet layout (a phone on its side, an unfolded folding phone, a tablet): 44 px touch sizes */

@media (pointer: coarse) {
  .ai-chip,
.ai-chat__reset {
    min-height: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ai-step[data-state="active"] .ai-step__dot {
    animation: none;
    border-top-color: var(--text-2, #3f3f46);
    border-style: dotted;
  }
  .ai-vref,
.ai-vcard__thumb,
.ai-chip,
.ai-composer__send {
    transition: none;
  }
  .ai-vcard__link:hover .ai-vcard__thumb {
    transform: none;
  }
  .ai-res--compact .ai-more::after {
    transition: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ai-btn {
    transition: none;
  }
}

/* ------------------------------------------------------------------ the AI answers used up (public/ai-limit.js)
   A solid card in place of the answer (/ask, the search page's answer), value first: when more answers come (a closed
   ring), the library's closest videos for the question with "See all results" beside them. Light and dark from the
   tokens, right-to-left safe, 44 px targets. The ask box says the same in its placeholder. */

.ai-limit {
  --lim-pad: 20px;
  --lim-ink: #5b38e0; /* violet text: 6.2:1 on white */
  --lim-wash: linear-gradient(120deg, rgb(var(--ai-cool) / 0.08), rgb(var(--ai-mid) / 0.05) 55%, rgb(var(--ai-hot) / 0.06));
  --lim-shadow: inset 0 0 0 1px var(--separator, rgb(0 0 0 / 0.1)), 0 10px 30px -18px rgb(0 0 0 / 0.18);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
  padding: var(--lim-pad);
  border-radius: calc(20px * var(--sq, 1));
  corner-shape: squircle;
  background: var(--bg, #fff);
  box-shadow: var(--lim-shadow);
  color: var(--text, #0f0f0f);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ai-limit {
    --lim-ink: #c9b8ff;
    --lim-wash: linear-gradient(120deg, rgb(var(--ai-cool) / 0.16), rgb(var(--ai-mid) / 0.09) 55%, rgb(var(--ai-hot) / 0.08));
    --lim-shadow: inset 0 0 0 1px var(--separator), 0 12px 32px -18px rgb(0 0 0 / 0.6);
  }
}
:root[data-theme="dark"] .ai-limit {
  --lim-ink: #c9b8ff;
  --lim-wash: linear-gradient(120deg, rgb(var(--ai-cool) / 0.16), rgb(var(--ai-mid) / 0.09) 55%, rgb(var(--ai-hot) / 0.08));
  --lim-shadow: inset 0 0 0 1px var(--separator), 0 12px 32px -18px rgb(0 0 0 / 0.6);
}
.ai-limit__head {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

/* a closed ring in the AI line's colours: today's answers are used; the clock says they come back */

.ai-limit__badge {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  border-radius: 50%;
  color: var(--text, #0f0f0f);
}
.ai-limit__badge::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(from 200deg, rgb(var(--ai-cool)), rgb(var(--ai-mid)), rgb(var(--ai-hot)), rgb(var(--ai-cool)));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.ai-limit[data-scope="site"] .ai-limit__badge::before {
  background: var(--fill-3, rgb(0 0 0 / 0.14));
}
.ai-limit__icon {
  position: relative;
  inline-size: 20px;
  block-size: 20px;
}
.ai-limit__text {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  text-wrap-style: pretty;
}
.ai-limit__extra {
  margin: -8px 0 0;
  padding-inline-start: 58px;
  color: var(--text-2, #3f3f46);
  font-size: 14px;
  line-height: 1.45;
}
.ai-limit__lib {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}
.ai-limit__lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.ai-limit__kicker {
  margin: 0;
  color: var(--text-2, #3f3f46);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

/* "See all results": a quiet link beside the videos (alone, as a pill, when nothing in the library is close) */

.ai-limit__all {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-block: -8px;
  margin-inline-end: -4px;
  padding-inline: 10px 4px;
  border-radius: 999px;
  color: var(--text, #0f0f0f);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--dur-press, 120ms);
}
.ai-limit__all .ai-limit__chev {
  inline-size: 18px;
  block-size: 18px;
}
@media (hover: hover) {
  .ai-limit__all:hover {
    background: var(--fill, rgb(0 0 0 / 0.05));
  }
}
.ai-limit__all:active {
  background: var(--fill-2, rgb(0 0 0 / 0.09));
}
.ai-limit__all:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 0;
}
.ai-limit__lib.is-empty .ai-limit__lib-head {
  justify-content: flex-start;
}
.ai-limit__lib.is-empty .ai-limit__all {
  margin: 0;
  padding-inline: 14px 10px;
  background: var(--fill, rgb(0 0 0 / 0.05));
}
.ai-limit__rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ai-limit__rail .ai-vcard__title {
  font-size: 13px;
}
.ai-limit__rail .ai-vcard__meta {
  font-size: 12px;
}
.ai-limit__row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px;
  border-radius: calc(20px * var(--sq, 1) - 14px);
  corner-shape: squircle;
  color: inherit;
  text-decoration: none;
  transition: background-color var(--dur-press, 120ms);
}
@media (hover: hover) {
  .ai-limit__row:hover {
    background: var(--fill, rgb(0 0 0 / 0.05));
  }
}
.ai-limit__row:active {
  background: var(--fill-2, rgb(0 0 0 / 0.09));
}
.ai-limit__row:focus-visible {
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 0;
}
.ai-limit__chev {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--text-3, #5f5f66);
}
[dir="rtl"] .ai-limit__chev {
  transform: scaleX(-1);
}
.ai-out > .ai-limit {
  margin-top: 4px;
}

/* the ask box while the limit holds: its placeholder says until when (ai.js), so the typed examples step aside */

.ai-chat[data-ai-limit] .ai-composer__field .ask-hint,
.ai-chat[data-ai-limit] .ai-composer__tab {
  display: none;
}
.ai-chat[data-ai-limit] .has-hint .ai-composer__input::placeholder {
  color: var(--text-3, #5f5f66);
}
@media (max-width: 767.98px) {
  .ai-limit {
    --lim-pad: 16px;
  }
  .ai-limit__text {
    font-size: 15px;
  }

/* a rail that runs to the card's edges, the next card peeking */
  
  .ai-limit__rail {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 46%;
    margin-inline: calc(1px - var(--lim-pad));
    padding: 2px calc(var(--lim-pad) - 1px) 4px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: calc(var(--lim-pad) - 1px);
    scrollbar-width: none;
  }
  .ai-limit__rail::-webkit-scrollbar {
    display: none;
  }
  .ai-limit__rail > li {
    scroll-snap-align: start;
  }

}

/* the notice near the end of the day's answers: a small ring, four fifths closed, before the line */

.ai-nearly {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-nearly[hidden] {
  display: none;
}
.ai-nearly__ring {
  flex: none;
  inline-size: 14px;
  block-size: 14px;
  border-radius: 50%;
  background: conic-gradient(rgb(var(--ai-mid)) 0 80%, var(--fill-3, rgb(0 0 0 / 0.14)) 80% 100%);
  -webkit-mask: radial-gradient(farthest-side, rgb(0 0 0 / 0) calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, rgb(0 0 0 / 0) calc(100% - 3px), #000 calc(100% - 2.5px));
}
.ai-nearly__text {
  min-width: 0;
}
@media (prefers-reduced-motion: reduce) {
  .ai-limit__row,
  .ai-limit__all {
    transition: none;
  }
}

/* ---------------------------------------------------------------- DharmaTube: what its answers add */
/* skeletons while a summary or an answer about this video is on its way (shapes in app.css .skeleton) */

.ai-out[aria-busy="true"] .skeleton-lines,
.ai-summary[aria-busy="true"] .skeleton-lines {
  max-width: 60ch;
}

/* help lines lead the answer, apart from the rest */

.ai-res--safety .ai-res__body {
  padding: 14px 16px;
  border-radius: var(--radius-m, 12px);
  background: var(--bg-2, #f2f2f2);
  box-shadow: inset 3px 0 0 var(--text, #0f0f0f);
}
.ai-res__safety {
  margin: 0 0 8px;
  font-weight: 600;
}

/* traditions side by side: equal columns, no order of merit */

.ai-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 16px;
  margin-top: 12px;
}
.ai-compare__col {
  min-width: 0;
}
.ai-compare__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--separator, rgb(0 0 0 / 0.1));
  font-size: 14px;
  font-weight: 600;
}
.ai-compare__count {
  color: var(--text-3, #5f5f66);
  font-size: 12px;
  font-weight: 400;
}
.ai-rail--col {
  grid-auto-flow: row;
  grid-auto-columns: auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: visible;
}

/* cards: the gentle marker on a restricted video */

.ai-vcard__flag {
  display: block;
  margin-top: 2px;
  color: var(--text-3, #5f5f66);
  font-size: 12px;
}

/* 系统学: "make it a course" under a study request's answer (public/ai.js learnLink) */
.ai-res__learn {
  width: fit-content;
  margin-top: 10px;
}
.ai-res__learn[hidden] {
  display: none;
}
