/* Guides (/guides, /guides/play; formerly /lab): the ask box (ai.css .ai-composer + app.css .ai-ring), and the playable
   answer around one player.
   Solid content only (no new glass): the page's glass stays the header and the tab bar (docs/DESIGN.md §5).
   Every colour is a site variable, so light and dark follow app.css. */

/* ------------------------------------------------------------------ /guides */
.lab {
  display: grid;
  gap: 16px;
  max-width: 780px;
  margin: 8px auto 0;
}
.lab-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lab-hero__title {
  margin: 6px 0 0;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.022em;
}
.lab-hero__lead {
  max-width: 62ch;
  margin: 10px 0 0;
  color: var(--text-2);
  line-height: 1.55;
}
/* the /ask composer, inline here (not stuck to the bottom) */
.lab-composer.ai-composer {
  position: relative;
  bottom: auto;
  margin-top: 6px;
}
.lab-composer.ai-composer::before {
  display: none;
}
.lab-h2 {
  margin: 14px 0 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lab-examples {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lab-example {
  display: grid;
  align-content: start;
  gap: 8px;
  height: 100%;
  padding: 16px;
  border-radius: var(--radius-l);
  background: var(--bg-2);
  color: inherit;
  text-decoration: none;
  transition: transform var(--dur-press) var(--ease-out), box-shadow var(--dur-fade);
}
.lab-example:hover {
  box-shadow: inset 0 0 0 1px var(--separator);
}
.lab-example:active {
  transform: scale(0.98);
}
.lab-example:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.lab-example__shape {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}
.lab-example__q {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.006em;
}
.lab-example__d {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}
.lab-ico {
  flex: none;
}
.lab-saved__list {
  display: grid;
  gap: 2px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.lab-saved__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
}
.lab-saved__link {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 6px;
  border-radius: var(--radius-m);
  color: inherit;
  text-decoration: none;
}
.lab-saved__link:hover {
  background: var(--fill);
}
.lab-saved__media {
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: var(--thumb-bg);
}
.lab-saved__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lab-saved__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.lab-saved__kind {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
}
.lab-saved__q {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lab-saved__meta {
  color: var(--text-3);
  font-size: 12.5px;
}
.lab-saved__rm {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.lab-saved__rm:hover {
  background: var(--fill);
  color: var(--text);
}
.lab-note {
  margin: 0;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.45;
}
.lab-fine {
  margin: 8px 0 0;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
}

/* how guides work: three short steps */
.lab-about__steps {
  display: grid;
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.lab-about__steps li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  color: var(--text-2);
  line-height: 1.5;
}
.lab-about__n {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--fill-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ /guides/play: player + sequence are the page */
.lab-play {
  display: grid;
  gap: 24px;
  max-width: 1500px;
  margin: 4px auto 0;
}
.lab-play__main {
  min-width: 0;
}
.lab-play__side {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}
.lab-player > iframe,
.lab-player > #lab-yt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
/* waiting for the first videos: a slow light across the empty player (one colour at two alphas: no WebKit band) */
.lab-play[data-state="loading"] .lab-player::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgb(255 255 255 / 0) 30%, rgb(255 255 255 / 0.08) 50%, rgb(255 255 255 / 0) 70%);
  background-size: 220% 100%;
  animation: lab-sheen 1.6s ease-in-out infinite;
}
@keyframes lab-sheen {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}
.lab-now {
  display: flex;
  gap: 8px;
  min-width: 0;
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 20px;
}
.lab-now__k {
  flex: none;
  color: var(--text-3);
  font-weight: 500;
}
.lab-now__t {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lab-head {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.lab-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: fit-content;
  min-height: 32px;
  margin-inline-start: -4px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}
.lab-back:hover {
  color: var(--text);
}
[dir="rtl"] .lab-back svg {
  transform: scaleX(-1);
}
.lab-head .lab-kicker:empty {
  display: none;
}
.lab-head__q {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.016em;
  overflow-wrap: anywhere;
}
.lab-head__meta {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
}
.lab-head__meta:empty {
  display: none;
}
.lab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.lab-actions .btn {
  min-height: 40px;
}
.lab-actions .btn svg {
  flex: none;
}
.lab-actions [data-lab-save].is-on svg path {
  fill: currentColor;
}
.lab-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 12.5px;
}
.lab-progress__track {
  flex: 1;
  max-width: 220px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--fill-2);
}
.lab-progress__bar {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--text);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 320ms var(--ease-out);
}
[dir="rtl"] .lab-progress__bar {
  transform-origin: right center;
}

/* generation steps (real: each one turns on when the server starts it) */
.lab-gen {
  display: grid;
  gap: 10px;
}
.lab-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius-l);
  background: var(--bg-2);
  list-style: none;
}
.lab-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 14px;
  line-height: 1.35;
}
.lab-step[data-state="active"] {
  color: var(--text);
  font-weight: 600;
}
.lab-step[data-state="done"] {
  color: var(--text-2);
}
.lab-step[data-state="skip"] {
  opacity: 0.45;
}
.lab-step__text {
  min-width: 0;
}
.lab-step__note {
  color: var(--text-2);
  font-weight: 400;
}
/* the Turnstile widget: invisible while it runs; when Cloudflare needs a click it draws its box here */
.lab-ts {
  min-height: 0;
}
.lab-ts.is-open {
  display: flex;
  justify-content: center;
  padding: 6px 0;
}
.lab-msg--thin {
  color: var(--text);
}
/* "From the web": a short live-search note when the library is thin, apart from the videos */
.lab-web {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-l);
  box-shadow: inset 0 0 0 1px var(--separator);
}
.lab-web__title {
  margin: 0;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.lab-web__text {
  margin: 0;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.lab-web__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lab-web__link {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 4px 0;
  color: inherit;
  text-decoration: none;
}
.lab-web__site {
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lab-web__t {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.lab-web__link:hover .lab-web__t {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lab-web__link:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--focus, #0a66ff);
  outline-offset: 2px;
}
.lab-step__dot {
  position: relative;
  flex: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--separator);
  border-radius: 50%;
}
.lab-step[data-state="active"] .lab-step__dot {
  border-color: var(--text);
  border-top-color: transparent;
  animation: lab-spin 0.8s linear infinite;
}
.lab-step[data-state="done"] .lab-step__dot {
  border-color: var(--text);
  background: var(--text);
}
.lab-step[data-state="done"] .lab-step__dot::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
@keyframes lab-spin {
  to {
    transform: rotate(360deg);
  }
}
.lab-msg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius-l);
  background: var(--bg-2);
  line-height: 1.45;
}
.lab-skel {
  display: grid;
  gap: 14px;
}
.lab-skel__row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 12px;
}
.lab-skel__row span {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: var(--fill);
}
.lab-skel__row i {
  display: block;
  height: 12px;
  margin-top: 6px;
  border-radius: 6px;
  background: var(--fill);
}

/* ------------------------------------------------------------------ path / syllabus rows */
.lab-seq {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lab-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  border-radius: var(--radius-m);
  transition: background-color var(--dur-fade);
}
.lab-item:hover {
  background: var(--fill);
}
.lab-item.is-current {
  background: var(--select-bg);
  box-shadow: inset 3px 0 0 var(--select);
}
[dir="rtl"] .lab-item.is-current {
  box-shadow: inset -3px 0 0 var(--select);
}
.lab-item__btn {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-m);
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.lab-item__btn:focus-visible,
.lab-cell__btn:focus-visible,
.lab-tick:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.lab-item__media,
.lab-cell__media {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: var(--thumb-bg);
}
.lab-item__media img,
.lab-cell__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lab-item__num,
.lab-item__dur {
  position: absolute;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--overlay);
  color: var(--overlay-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}
.lab-item__num {
  top: 5px;
  inset-inline-start: 5px;
  min-width: 20px;
  text-align: center;
}
.lab-item__dur {
  bottom: 5px;
  inset-inline-end: 5px;
}
.lab-item.is-current .lab-item__num {
  background: var(--select);
}
.lab-item__text {
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 0;
}
.lab-item__title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.lab-item.is-watched .lab-item__title {
  color: var(--text-2);
}
.lab-item__meta {
  overflow: hidden;
  color: var(--text-3);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lab-item__why {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
}
.lab-item__why:empty {
  display: none;
}
.lab-item__why.is-pending {
  color: var(--text-3);
  animation: lab-pulse 1.4s ease-in-out infinite;
}
@keyframes lab-pulse {
  50% {
    opacity: 0.45;
  }
}
.lab-tick {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 4px 2px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: transparent;
  cursor: pointer;
}
.lab-tick::before {
  content: "";
  grid-area: 1 / 1;
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--text-3);
  border-radius: 50%;
  opacity: 0.6;
}
.lab-tick .lab-ico {
  grid-area: 1 / 1;
  width: 14px;
  height: 14px;
}
.lab-tick:hover {
  color: var(--text-3);
}
.lab-tick[aria-pressed="true"] {
  color: var(--bg);
}
.lab-tick[aria-pressed="true"]::before {
  border-color: var(--text);
  background: var(--text);
  opacity: 1;
}

/* ------------------------------------------------------------------ syllabus */
.lab-week {
  display: grid;
  gap: 8px;
}
.lab-week__title {
  margin: 4px 0 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lab-days {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lab-day {
  padding: 4px;
  border-radius: var(--radius-l);
  background: var(--bg-2);
}
.lab-day__head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 2px;
  font-size: 13px;
  font-weight: 600;
}
.lab-day__min {
  color: var(--text-3);
  font-weight: 500;
}
.lab-day .lab-item:hover {
  background: var(--fill);
}

/* ------------------------------------------------------------------ board */
.lab-board__sum {
  margin: 0;
  color: var(--text-2);
  font-size: 13.5px;
}
.lab-board {
  display: grid;
  gap: 10px;
}
.lab-board__row {
  display: grid;
  grid-template-columns: 52px repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
}
.lab-board__row--head {
  padding-bottom: 2px;
  border-bottom: 1px solid var(--separator);
}
.lab-board__colhead {
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lab-board__label {
  padding-top: 4px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lab-cell {
  min-width: 0;
}
.lab-cell__btn {
  display: grid;
  gap: 5px;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.lab-cell__btn:hover .lab-cell__title {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lab-cell.is-current .lab-cell__media {
  outline: 2px solid var(--select);
  outline-offset: 2px;
}
.lab-cell__check {
  position: absolute;
  top: 5px;
  inset-inline-start: 5px;
  display: none;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--overlay);
  color: var(--overlay-text);
}
.lab-cell__check .lab-ico {
  width: 12px;
  height: 12px;
}
.lab-cell.is-watched .lab-cell__check {
  display: grid;
}
.lab-cell__title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.32;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.lab-cell__meta {
  overflow: hidden;
  color: var(--text-3);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lab-cell__note {
  color: var(--text-3);
  font-size: 11px;
  font-style: italic;
  line-height: 1.3;
}
.lab-cell--empty {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  padding: 6px;
  border: 1px dashed var(--separator);
  border-radius: 8px;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.3;
  text-align: center;
}

/* ------------------------------------------------------------------ toast */
.lab-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 60;
  max-width: min(92vw, 520px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-pop);
  transform: translateX(-50%);
}

/* ------------------------------------------------------------------ desktop: player column (sticky) + sequence column */
@media (min-width: 1100px) {
  .lab-play {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 460px);
    align-items: start;
    gap: 28px;
  }
  .lab-play[data-shape="board"] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  }
  .lab-play__main {
    position: sticky;
    top: calc(var(--appbar-h) + 16px);
  }
}

/* ------------------------------------------------------------------ phones: pinned player like the watch page */
@media (max-width: 767.98px) {
  .lab-hero__title {
    font-size: 30px;
    line-height: 1.18;
  }
  .lab-examples {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .lab-example {
    padding: 14px 16px;
  }
  .lab-saved__link {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  body[data-page="lab-play"] .appbar {
    display: none;
  }
  body[data-page="lab-play"] .main {
    padding-top: 0;
  }
  .lab-play {
    display: block;
    margin-top: 0;
  }
  /* the player's sticky parent must be the whole page (as .watch__main / .watch__stage do) */
  .lab-play__main,
  .lab-play__stage {
    display: contents;
  }
  .lab-now {
    margin-top: 10px;
  }
  .lab-head {
    margin-top: 6px;
  }
  .lab-head__q {
    font-size: 20px;
    line-height: 1.3;
  }
  .lab-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }
  .lab-play__side {
    margin-top: 18px;
  }
  .lab-item__btn {
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0 8px 2px;
  }
  .lab-item__title {
    font-size: 14px;
  }
  .lab-item__why {
    font-size: 12.5px;
  }
  .lab-tick {
    margin: 2px -6px 0 0;
  }
  .lab-skel__row {
    grid-template-columns: 132px minmax(0, 1fr);
  }
  .lab-board {
    gap: 12px;
  }
  .lab-board__row {
    grid-template-columns: 38px repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .lab-board__label {
    font-size: 12px;
    padding-top: 2px;
  }
  .lab-board__colhead {
    font-size: 10.5px;
    letter-spacing: 0.04em;
  }
  /* the row labels (SS14, 2014) say what the first column is; its heading does not fit 38 px: kept for screen readers */
  .lab-board__row--head > .lab-board__colhead:first-child {
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .lab-cell__title {
    font-size: 11.5px;
  }
  .lab-cell__meta {
    font-size: 10.5px;
  }
  .lab-cell__note {
    font-size: 10px;
  }
  .lab-item__dur {
    font-size: 11px;
  }
  .lab-cell .lab-item__dur {
    padding: 0 4px;
    font-size: 10px;
    line-height: 15px;
  }
  .lab-cell--empty {
    font-size: 10.5px;
  }
  .lab-toast {
    bottom: calc(var(--tabbar-h) + max(10px, var(--safe-bottom)) + 18px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab-play[data-state="loading"] .lab-player::after,
  .lab-step[data-state="active"] .lab-step__dot,
  .lab-item__why.is-pending {
    animation: none;
  }
  .lab-progress__bar,
  .lab-item,
  .lab-example {
    transition: none;
  }
}
