/* Study room v3 (?study=v3; owner, 2026-10-10: "too many buttons", "ChatGPT
   like quality"). The V2 study room as one conversation beside the board:
   the header keeps only the title, steps stay in the thread with "Siguiente
   paso" under the latest one, and the board's tools are one menu. Every rule
   is scoped to html.study-v3; the V2 room is unchanged. */

/* ── Shell: a title bar and the workspace ─────────────────────────────── */
html.study-v2-enabled.study-v3 #view-chat.active {
  grid-template-rows: 56px minmax(0, 1fr) !important;
}

html.study-v2-enabled.study-v3 #studyV2LessonHeader,
html.study-v2-enabled.study-v3 #studyV2StepNavigation,
html.study-v2-enabled.study-v3 #studyV2ModeMarker,
html.study-v2-enabled.study-v3 #studyV2Conversation,
html.study-v2-enabled.study-v3 .topbar-actions .status-badge,
html.study-v2-enabled.study-v3 .board-footer,
html.study-v2-enabled.study-v3 #studyV2FigureKicker,
html.study-v2-enabled.study-v3 #boardTitle,
html.study-v2-enabled.study-v3 .board-toolbar,
html.study-v2-enabled.study-v3 .study-v2-notebook blockquote,
html.study-v2-enabled.study-v3 #studyV2BoardHint {
  display: none !important;
}

/* The board comes back from the header after it is closed. */
html.study-v2-enabled.study-v3 body:not(.study-v2-board-hidden) #studyV2BoardVisibility {
  display: none;
}

html.study-v2-enabled.study-v3 .chat-topbar {
  height: 56px;
  min-height: 56px;
  padding: 0 20px;
  border-bottom: 0;
  background: var(--study-paper);
}

html.study-v2-enabled.study-v3 .chat-topbar-brand {
  gap: 12px;
  min-width: 0;
}

/* One row: with the board closed, "Mostrar pizarra" sits beside the title,
   which shortens, instead of wrapping under it, where the fixed-height bar
   cut the title at the top and hid half the button (phone, night hunt,
   21 Oct). */
html.study-v2-enabled.study-v3 .chat-topbar {
  flex-wrap: nowrap;
}

html.study-v2-enabled.study-v3 .chat-topbar-brand {
  flex: 1 1 auto;
}

html.study-v2-enabled.study-v3 #studyV2BoardVisibility {
  flex: 0 0 auto;
}

html.study-v2-enabled.study-v3 .chat-topbar-brand #studyV2LessonTitle {
  display: block;
  margin: 0;
  overflow: hidden;
  font: 600 15px/1.3 var(--study-body);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--study-ink);
}

/* ── Messages: no avatars; a step's number small beside its title ─────── */
html.study-v2-enabled.study-v3 #chatThread .message > .avatar {
  display: none;
}

/* The lesson's intro holds the whole answer: it stays out of the
   conversation, and the conclusion joins it once the last step is reached. */
html.study-v2-enabled.study-v3 #chatThread .lesson-intro-message,
html.study-v2-enabled.study-v3 body:not(.study-v3-lesson-done) #chatThread .lesson-conclusion-message {
  display: none !important;
}

/* The answer keeps the thread's centred column: without a board beside it
   (an answer alone, or the board closed) it hugged the left of the wide
   column, off the question and the box under it (UAH C7, 15 Oct). */
html.study-v2-enabled.study-v3 #chatThread .message.assistant {
  margin-inline: auto;
  padding-inline: 0;
  border: 0;
}

html.study-v2-enabled.study-v3 #chatThread .message.assistant > .bubble {
  margin-inline: 0;
  padding-inline: 0;
  border: 0;
}

html.study-v2-enabled.study-v3 #chatThread .message {
  border-bottom: 0;
}

html.study-v2-enabled.study-v3 .lesson-step-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: baseline;
  gap: 4px 10px;
  margin-bottom: 10px;
}

html.study-v2-enabled.study-v3 .lesson-step-header::after {
  display: none;
}

html.study-v2-enabled.study-v3 .lesson-step-badge {
  color: var(--study-muted) !important;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

html.study-v2-enabled.study-v3 .lesson-step-caption,
html.study-v2-enabled.study-v3 body.study-v2-conversation .lesson-step-caption {
  margin-top: 0;
  font: 700 19px/1.35 var(--study-body);
  letter-spacing: 0;
  color: var(--study-ink);
}

html.study-v2-enabled.study-v3 .lesson-step-body {
  font-size: 15.5px;
  line-height: 1.65;
}

/* The student's message: a bubble on the right. */
html.study-v2-enabled.study-v3 #chatThread .message.user .bubble {
  max-width: 82%;
  padding: 12px 18px;
  border: 0;
  border-radius: 20px;
  background: var(--study-user-bubble);
}

/* No line between the conversation and the board. */
html.study-v2-enabled.study-v3 .chat-container {
  border-right: 0 !important;
}

html.study-v2-enabled.study-v3 .whiteboard-container {
  border-left: 0 !important;
  box-shadow: none;
}

/* ── Sidebar: a new question and the recent ones ──────────────────────── */
html.study-v2-enabled.study-v3 .study-v2-new {
  border: 1px solid var(--study-line);
  border-radius: 999px;
  background: var(--study-paper);
  color: var(--study-ink);
}

html.study-v2-enabled.study-v3 .study-v2-notebook-heading {
  font: 600 12px var(--study-body);
  letter-spacing: 0;
  text-transform: none;
  color: var(--study-muted);
}

html.study-v2-enabled.study-v3 .study-v2-notebook-heading > span:last-child,
html.study-v2-enabled.study-v3 .study-v2-entry-symbol,
html.study-v2-enabled.study-v3 .study-v2-notebook-entry small {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v2-notebook-entry {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

html.study-v2-enabled.study-v3 .study-v2-notebook-entry b {
  display: block;
  overflow: hidden;
  font: 500 14px/1.35 var(--study-body);
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--study-ink);
}

html.study-v2-enabled.study-v3 .study-v2-notebook-entry[aria-current="page"] {
  background: var(--study-line);
}

/* ── Workspace: the conversation and the board ────────────────────────── */
/* Only while the board shows: a closed board kept its column, and the
   conversation stayed in the left half of an empty page (owner, 21 Oct). */
html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-board-hidden) .workspace {
  grid-template-columns: minmax(420px, 1fr) minmax(0, 1.25fr);
}

html.study-v2-enabled.study-v3 .chat-container {
  border-right: 0;
}

html.study-v2-enabled.study-v3 .whiteboard-container {
  margin: 4px 20px 16px 4px;
  border: 0;
  border-radius: 20px;
  overflow: hidden;
  background: var(--study-board-bg, var(--study-tool-bg));
}

/* The thread: a reading column. */
html.study-v2-enabled.study-v3 #chatThread {
  padding: 8px 28px 24px;
}

html.study-v2-enabled.study-v3 #chatThread > * {
  max-width: 640px;
  margin-inline: auto;
}

/* Steps not reached yet stay out of the conversation. */
html.study-v2-enabled.study-v3 #chatThread .lesson-step-message.study-v3-step-ahead {
  display: none !important;
}

html.study-v2-enabled.study-v3 body.study-v2-conversation .lesson-step-message {
  border-bottom: 0;
  padding-block: 10px;
}

html.study-v2-enabled.study-v3 body.study-v2-conversation .lesson-step-caption {
  font: 700 19px/1.35 var(--study-body);
}

/* "Anterior" and "Siguiente paso" under the latest step. */
html.study-v2-enabled.study-v3 .study-v3-step-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 6px 0 18px;
}

html.study-v2-enabled.study-v3 .study-v3-step-actions[hidden] {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-step-actions #btnNextStep {
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--study-ink);
  color: var(--study-paper);
  font: 600 14px var(--study-body);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

html.study-v2-enabled.study-v3 .study-v3-step-actions #btnNextStep:disabled {
  opacity: 0.55;
}

html.study-v2-enabled.study-v3 .study-v3-step-actions #btnPrevStep {
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--study-ink);
  font: 600 14px var(--study-body);
}

html.study-v2-enabled.study-v3 .study-v3-step-actions #btnPrevStep:disabled {
  display: none;
}

/* The end: "Lección completada", then review or ask; while reviewing an
   earlier step, the step buttons again (study-experience-v2.js, atEnd). */
html.study-v2-enabled.study-v3 body.study-v3-at-end .study-v3-step-actions #btnPrevStep,
html.study-v2-enabled.study-v3 body.study-v3-at-end .study-v3-step-actions #btnNextStep,
html.study-v2-enabled.study-v3 body:not(.study-v3-at-end) .study-v3-complete {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-complete {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font: 600 14px var(--study-body);
  color: var(--study-ink);
}

html.study-v2-enabled.study-v3 .study-v3-complete svg {
  width: 18px;
  height: 18px;
  color: var(--study-accent);
  stroke-width: 2.2;
}

html.study-v2-enabled.study-v3 .study-v3-step-actions .study-v2-lesson-complete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

html.study-v2-enabled.study-v3 .study-v3-step-actions .study-v2-lesson-complete[hidden] {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-step-actions .study-v2-lesson-complete button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--study-line);
  border-radius: 999px;
  background: transparent;
  color: var(--study-ink);
  font: 600 14px var(--study-body);
}

html.study-v2-enabled.study-v3 .study-v3-step-actions .study-v2-lesson-complete button[hidden] {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-step-actions .study-v2-lesson-complete svg {
  width: 16px;
  height: 16px;
}

/* The student's feedback on the lesson (chat_premium.js): its own line
   under "Repasar desde el principio" and "Hacer una pregunta", only while
   they show. After an answer it keeps the reading column, no avatar gap. */
html.study-v2-enabled.study-v3 .study-v3-lesson-feedback {
  flex: 1 0 100%;
}

html.study-v2-enabled.study-v3 .study-v3-lesson-feedback:empty,
html.study-v2-enabled.study-v3 body:not(.study-v3-at-end) .study-v3-lesson-feedback,
html.study-v2-enabled.study-v3 .study-v2-lesson-complete[hidden] ~ .study-v3-lesson-feedback {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-lesson-feedback .prisma-feedback {
  margin: 6px 0 0;
}

html.study-v2-enabled.study-v3 #chatThread > .prisma-answer-feedback {
  padding-left: 0;
}

/* ── Composer: one box ─────────────────────────────────────────────────── */
html.study-v2-enabled.study-v3 #studyV2ComposerContext {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

html.study-v2-enabled.study-v3 .composer-panel {
  padding: 0 28px 14px;
  border-top: 0;
  background: transparent;
}

html.study-v2-enabled.study-v3 .input-wrapper {
  max-width: 640px;
  margin-inline: auto;
  border: 1px solid var(--study-line-strong, var(--study-line));
  border-radius: 24px;
  background: var(--study-card, var(--study-paper));
  box-shadow: 0 2px 10px rgba(28, 59, 67, 0.06);
}

/* The focus ring (U12) shows only while the student moves with Tab (owner,
   15 Oct): typing in the box or clicking leaves no dark frame. The box and
   the conversation column never draw their own; with Tab, the box's rounded
   border takes the ring. */
html.study-v2-enabled.study-v3:not(.study-v3-keyboard)
  :is(button, input, textarea, select, a[href], [tabindex]):focus-visible,
html.study-v2-enabled.study-v3 :is(#chatInput, #chatThread):focus-visible {
  outline: none !important;
}

html.study-v2-enabled.study-v3.study-v3-keyboard .input-wrapper:focus-within {
  outline: var(--study-focus-width) solid var(--study-focus-ring);
  outline-offset: var(--study-focus-offset);
}

/* With Tab the conversation column shows its focus too, inside its edges
   (WCAG 2.4.7; night hunt, 21 Oct: nothing showed where the focus was). */
html.study-v2-enabled.study-v3.study-v3-keyboard #chatThread:focus-visible {
  outline: var(--study-focus-width) solid var(--study-focus-ring) !important;
  outline-offset: calc(-1 * var(--study-focus-width));
}

html.study-v2-enabled.study-v3 .study-v3-footnote {
  max-width: 640px;
  margin: 8px auto 0;
  text-align: center;
  font: 12px/1.4 var(--study-body);
  color: var(--study-muted);
}

/* ── Board: a card with three controls ────────────────────────────────── */
html.study-v2-enabled.study-v3 .board-header {
  position: relative;
  min-height: 52px;
  padding: 0 10px 0 20px;
  border-bottom: 0;
  background: transparent;
}

html.study-v2-enabled.study-v3 .study-v2-board-tools {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-board-step {
  overflow: hidden;
  font: 600 13px/1.3 var(--study-body);
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--study-muted);
}

html.study-v2-enabled.study-v3 .study-v3-board-bar {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

html.study-v2-enabled.study-v3 .study-v3-icon-button,
html.study-v2-enabled.study-v3 .study-v3-board-bar #studyV2Expand {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--study-ink);
  cursor: pointer;
}

html.study-v2-enabled.study-v3 .study-v3-icon-button svg,
html.study-v2-enabled.study-v3 .study-v3-board-bar #studyV2Expand svg {
  width: 18px;
  height: 18px;
}

html.study-v2-enabled.study-v3 #studyV3BoardMenu svg {
  stroke-width: 3;
}

html.study-v2-enabled.study-v3 .study-v3-icon-button:hover,
html.study-v2-enabled.study-v3 .study-v3-board-bar #studyV2Expand:hover {
  background: var(--study-line);
}

/* The menu: the board's tools, each with its name. */
html.study-v2-enabled.study-v3 .study-v3-board-menu {
  position: absolute;
  top: 48px;
  right: 10px;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--study-line);
  border-radius: 14px;
  background: var(--study-card, var(--study-paper));
  box-shadow: 0 10px 30px rgba(19, 38, 74, 0.14);
}

html.study-v2-enabled.study-v3 .study-v3-board-menu[hidden] {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-board-menu .toolbar-btn {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--study-ink);
}

html.study-v2-enabled.study-v3 .study-v3-board-menu .toolbar-btn:hover {
  background: var(--study-line);
}

html.study-v2-enabled.study-v3 .study-v3-board-menu .toolbar-btn[hidden] {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-tool-label {
  font: 500 14px var(--study-body);
}

/* A legend entry isolates its object while pointed at or focused. The
   legend lets the board's drags through; only its entries take the pointer. */
html.study-v2-enabled.study-v3 #studyV2Legend > span[tabindex] {
  border-radius: 6px;
  cursor: default;
  pointer-events: auto;
}

html.study-v2-enabled.study-v3 #studyV2Legend > span[tabindex]:hover,
html.study-v2-enabled.study-v3 #studyV2Legend > span[tabindex]:focus-visible {
  background: var(--study-line);
}

/* An object the step being read does not use is muted on the board
   (chat_premium.js applyStepMuting); its swatch fades with it. The text keeps
   its contrast. */
html.study-v2-enabled.study-v3 #studyV2Legend > span.is-step-muted > i {
  opacity: 0.35;
}

/* A curve's name on the board stays on one line (UAH B5: "p(x) = x² − 4x +"
   above a lone "3"); the label's own inline width is a card's. */
html.study-v2-enabled.study-v3 .pizarra-label.pizarra-curve-tag {
  white-space: nowrap !important;
  max-width: none !important;
  /* The scheme's ink on the scheme's label card: in dark mode the card is
     dark, and the ink written inline was dark too (names unreadable). */
  color: var(--study-ink) !important;
}

/* A curve's or a surface's name on the board (chat_premium.js
   refreshCurveTags) fades with it; the legend keeps the name at full
   contrast. The card stays solid, so the axis numbers it covers do not show
   through (UAH A8 step 2); its text and border go to the scheme's muted
   colours. */
html.study-v2-enabled.study-v3 .pizarra-label.pizarra-curve-tag.is-step-muted {
  color: var(--study-muted) !important;
  border-color: var(--study-line) !important;
}

html.study-v2-enabled.study-v3 .pizarra-label-leader.pizarra-curve-tag.is-step-muted {
  opacity: 0.5 !important;
}

/* A 3D board's axis compass (chat_premium.js syncAxisGizmo): x, y and z as
   the camera sees them, in the board's top right corner; a click is "Ver
   todo". */
html.study-v2-enabled.study-v3 .study-v3-axis-gizmo {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid var(--study-line);
  border-radius: 50%;
  background: var(--study-paper);
  color: var(--study-ink);
  font: inherit;
  cursor: pointer;
}

html.study-v2-enabled.study-v3 .study-v3-axis-gizmo[hidden] {
  display: none;
}

html.study-v2-enabled.study-v3 .study-v3-axis-gizmo:hover {
  border-color: var(--study-accent);
}

html.study-v2-enabled.study-v3 .study-v3-axis-gizmo:focus-visible {
  outline: 2px solid var(--study-accent);
  outline-offset: 2px;
}

html.study-v2-enabled.study-v3 .study-v3-axis-gizmo svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

html.study-v2-enabled.study-v3 .study-v3-axis-gizmo line {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

html.study-v2-enabled.study-v3 .study-v3-axis-gizmo text {
  fill: currentColor;
  font-size: 12.5px;
  font-weight: 700;
}

/* A reached step's header shows that step on the board (study-experience-v2.js
   markStepShowable); the hint appears while pointed at or focused. */
html.study-v2-enabled.study-v3 .lesson-step-header[data-study-v3-show] {
  margin-inline: -8px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
}

html.study-v2-enabled.study-v3 .lesson-step-header[data-study-v3-show]:hover,
html.study-v2-enabled.study-v3 .lesson-step-header[data-study-v3-show]:focus-visible {
  background: var(--study-line);
}

html.study-v2-enabled.study-v3 .lesson-step-header[data-study-v3-show]:hover .lesson-step-badge::after,
html.study-v2-enabled.study-v3 .lesson-step-header[data-study-v3-show]:focus-visible .lesson-step-badge::after {
  content: " · " attr(data-study-v3-hint);
}

/* A step read earlier folds to one line, a tick and its title, outlined
   like a button (study-experience-v2.js markStepFolded); showing it on the
   board unfolds it. */
html.study-v2-enabled.study-v3 .lesson-step-message[data-study-v3-folded] .lesson-step-body {
  display: none;
}

html.study-v2-enabled.study-v3 .lesson-step-message[data-study-v3-folded] .lesson-step-header {
  border: 1px solid var(--study-line);
  margin-inline: 0;
  padding: 8px 14px;
  border-radius: 12px;
}

html.study-v2-enabled.study-v3 .lesson-step-message[data-study-v3-folded] .lesson-step-header::before {
  content: "✓";
  margin-right: 8px;
  color: var(--study-teal-ink, #077487);
  font-weight: 700;
}

/* ── Narrow screens and phones: the board is a card pinned under the title
   bar, a little over a third of the height, with no empty rows (v3 hides
   the tool row and the footer V2 keeps under the drawing). The
   conversation scrolls beneath it, so the drawing stays in view while the
   step is read; a new step brings its heading to just under the card
   (study-experience-v2.js revealStepUnderBoard). ── */
@media (max-width: 980px) {
  html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-board-hidden) {
    --study-figure-height: max(190px, 36dvh);
  }

  /* One column: the desktop rule above (a conversation of at least 420 px)
     made both the board and the conversation wider than a phone. */
  html.study-v2-enabled.study-v3 body.board-mode .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The page scrolls as one (title bar, card, conversation, composer): the
     desktop rows above gave the workspace exactly the screen's height, which
     clipped the conversation and let the card slide away with it. */
  html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-board-hidden) #view-chat.active {
    grid-template-rows: 56px max-content !important;
  }

  /* A column at natural heights, the board first (its DOM comes after the
     conversation): as a grid the conversation's row stayed the screen's
     height less the board, however long the text. */
  html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-board-hidden) .workspace {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 56px);
    reading-flow: flex-visual;
  }

  html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-board-hidden) .whiteboard-container {
    order: -1;
    flex: none;
  }

  html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-board-hidden) .chat-container {
    flex: 1 0 auto;
    overflow: visible;
  }

  /* The pinned card sits on a strip of page colour, so the text scrolling
     beneath it never shows beside it; the card itself is the header and the
     drawing, with the board's own background and rounded corners. */
  html.study-v2-enabled.study-v3
    body.board-mode:not(.study-v2-board-hidden):not(.study-v2-expanded)
    .whiteboard-container {
    position: sticky;
    top: 56px;
    z-index: 60;
    grid-template-rows: auto var(--study-figure-height) 0 !important;
    min-height: 0;
    margin: 0;
    padding: 0 12px 10px;
    border-radius: 0;
    overflow: visible;
    background: var(--study-paper);
  }

  html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-expanded) .board-header {
    flex-wrap: nowrap;
    height: 52px;
    min-height: 52px;
    padding: 0 6px 0 16px;
    border-radius: 16px 16px 0 0;
    background: var(--study-board-bg, var(--study-tool-bg));
  }

  html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-expanded) .board-meta {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
  }

  html.study-v2-enabled.study-v3 body.board-mode:not(.study-v2-expanded) .board-canvas-area {
    border-radius: 0 0 16px 16px;
    overflow: hidden;
    background: var(--study-board-bg, var(--study-tool-bg));
  }

  /* No tool row under the drawing in v3: the drawing and what floats on it
     go down to the card's edge. */
  html.study-v2-enabled.study-v3 #pizarraApp {
    bottom: 0;
  }

  /* On the pinned card the legend is one row, scrolled sideways when it is
     longer than the card: three rows covered the bottom of a phone's board
     (UAH C2 at 390 px, 14 Oct). */
  html.study-v2-enabled.study-v3 #studyV2Legend {
    bottom: calc(10px + var(--ix-deck, 0px));
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    pointer-events: auto;
  }

  html.study-v2-enabled.study-v3 #studyV2Legend::-webkit-scrollbar {
    display: none;
  }

  /* More entries past the right edge: the row fades out there
     (study-experience-v2.js syncLegendFade). */
  html.study-v2-enabled.study-v3 #studyV2Legend.study-v3-legend-more {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
  }

  html.study-v2-enabled.study-v3 #studyV2Legend > span {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  html.study-v2-enabled.study-v3 .viewport-panel,
  html.study-v2-enabled.study-v3 .study-v2-board-hint {
    bottom: calc(12px + var(--ix-deck, 0px));
  }

  /* No step bar is pinned at the bottom in v3 (the step buttons sit under
     the latest step), so U7's fade stays at the screen's bottom edge. Lifted
     72 px for V2's bar, it washed out a line and a half of the lesson in
     mid-screen (bug hunt, 19 Oct, 390 px). */
  html.study-v2-enabled.study-v3
    body.study-v2-has-lesson.board-mode:not(.study-v2-board-hidden)
    .thread-area::after {
    bottom: 0;
  }
}

/* Lesson sweep, 21 Oct (390x844): the legend, laid over the bottom of the
   drawing, covered the x axis's numbers there in 6 lessons ("Área bajo
   y=x² entre 0 y 2": 0, 0.5, 1, 1.5 and 2 under it). On the pinned card the
   legend is the card's last row, under the drawing: the drawing gives up
   the row's height, so the card keeps its own, and the drawing's rounded
   corners move to the canvas, which the legend now hangs below. A board
   with controls (their deck under the drawing) and the full-screen board
   keep the legend on the drawing. */
@media (max-width: 980px) {
  html.study-v2-enabled.study-v3
    body.board-mode:not(.study-v2-board-hidden):not(.study-v2-expanded):not(.prisma-ix-board)
    .whiteboard-container:has(#studyV2Legend > span) {
    --study-legend-row: 34px;
    grid-template-rows: auto calc(var(--study-figure-height) - var(--study-legend-row)) 0 !important;
    padding-bottom: calc(10px + var(--study-legend-row));
  }

  html.study-v2-enabled.study-v3
    body.board-mode:not(.study-v2-board-hidden):not(.study-v2-expanded):not(.prisma-ix-board)
    .whiteboard-container:has(#studyV2Legend > span)
    .board-canvas-area {
    overflow: visible;
  }

  html.study-v2-enabled.study-v3
    body.board-mode:not(.study-v2-board-hidden):not(.study-v2-expanded):not(.prisma-ix-board)
    .whiteboard-container:has(#studyV2Legend > span)
    #pizarraApp {
    overflow: hidden;
    border-radius: 0 0 16px 16px;
  }

  html.study-v2-enabled.study-v3
    body.board-mode:not(.study-v2-board-hidden):not(.study-v2-expanded):not(.prisma-ix-board)
    .whiteboard-container:has(#studyV2Legend > span)
    #studyV2Legend {
    top: calc(100% + 6px);
    bottom: auto;
  }
}

/* A phone held sideways is too short to keep the card pinned: it scrolls
   with the page there. */
@media (max-width: 980px) and (max-height: 500px) {
  html.study-v2-enabled.study-v3
    body.board-mode:not(.study-v2-board-hidden):not(.study-v2-expanded)
    .whiteboard-container {
    position: relative;
    top: auto;
  }
}

/* Lesson sweep, 21 Oct (390x844): a display formula wider than the column
   scrolled sideways with nothing to say so, and lost its end ("... + C = (",
   22 formulas in 139 saved lessons). A shade marks each edge where more of
   the formula follows; covers that scroll with it hide the shade at either
   end, so a formula that fits shows none. */
html.study-v2-enabled.study-v3 #chatThread .katex-display {
  --study-math-shade: color-mix(in srgb, var(--study-ink) 24%, transparent);
  background:
    linear-gradient(to right, var(--study-paper) 40%, transparent) left
      center / 28px 100% no-repeat local,
    linear-gradient(to left, var(--study-paper) 40%, transparent) right
      center / 28px 100% no-repeat local,
    radial-gradient(
        farthest-side at 0 50%,
        var(--study-math-shade),
        transparent
      )
      left center / 12px 100% no-repeat scroll,
    radial-gradient(
        farthest-side at 100% 50%,
        var(--study-math-shade),
        transparent
      )
      right center / 12px 100% no-repeat scroll;
}
