/* =========================================================
   Pioneer Python — Interactive Python environment.
   Loaded on programming-playground.html and quiz.html (linked there
   directly, after styles.css; quiz.html adds quiz.css after this file
   for its two-column variant). All colors come from the shared theme
   tokens, so the panes follow light and dark mode automatically.
   ========================================================= */

.pyenv {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr; /* stacked by default (narrow / iframe) */
  align-items: start;
}

/* Wide screens: VS Code-style three columns — activity rail | coding
   window | activity + tests — in a roughly 1 : 4 : 2 ratio. minmax(0, …)
   on the center track lets the editor shrink inside a constrained iframe
   instead of forcing the page wider; the side tracks keep usable minimums. */
@media (min-width: 1024px) {
  .pyenv {
    grid-template-columns: minmax(150px, 1fr) minmax(0, 4fr) minmax(240px, 2fr);
  }
}

/* --- Left rail: activity picker ------------------------- */
.pyenv__rail {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.pyenv__rail-title {
  font: 600 0.78rem/1 var(--font-sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
}
.pyenv__pick-list { list-style: none; margin: 0; padding: 0.35rem; }
.pyenv__pick {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  color: var(--color-ink);
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.pyenv__pick:hover { background: var(--color-tab-bg-hover); }
.pyenv__pick.is-active {
  background: var(--color-accent-soft);
  border-left-color: var(--color-accent);
}
.pyenv__pick:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.pyenv__pick-name { display: block; font-weight: 600; font-size: 0.92rem; }
.pyenv__pick-blurb { display: block; font-size: 0.78rem; color: var(--color-ink-muted); }

/* --- Right panel: instructions + tester ------------------- */
/* Shares the card aesthetic with the rail. */
.pyenv__panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: clamp(1.25rem, 3vw, 1.75rem);
  box-shadow: var(--shadow-sm);
}

.pyenv__heading {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.pyenv__prose {
  color: var(--color-ink);
  font-size: 0.95rem;
}
.pyenv__prose p { margin: 0 0 0.75rem; }
.pyenv__prose ol { margin: 0 0 0.75rem; padding-left: 1.25rem; }
.pyenv__prose li { margin-bottom: 0.35rem; }
.pyenv__prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}
.pyenv__prose pre {
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.85rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
/* Tabs four columns wide, as in IDLE and VS Code, rather than the browser's
   eight: Star Trek vs. Star Wars prints tab-separated columns, and its example
   in the directions has to fit the panel and line up with the output pane and
   the tester's Expected / Your output boxes. */
.pyenv__prose pre,
.pyenv__output,
.pyenv__test-detail pre {
  tab-size: 4;
}
.pyenv__prose pre code {
  background: none;
  color: var(--color-ink);
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.pyenv__note {
  color: var(--color-ink-muted);
  font-size: 0.85rem;
}
/* "Type exactly" box: text a student must copy character for character, such
   as an input() prompt or a function name, set apart from the directions. The
   shading hugs the text so a trailing space shows as a visible gap. */
.pyenv__exact {
  margin: 0.5rem 0 0.75rem;
  padding: 0.45rem 0.7rem 0.55rem;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
}
.pyenv__exact-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
}
.pyenv__prose .pyenv__exact pre {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}
.pyenv__prose .pyenv__exact pre code {
  display: inline-block;
  padding: 0.15em 0.3em;
  background: var(--color-accent-soft);
  font-size: 0.95rem;
}
.pyenv__exact-hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--color-ink-muted);
}

/* --- Tester (inside the right panel) ---------------------- */
.pyenv__tests {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--color-border);
}

/* "Test Code" button — a ghost variant of the Run button so it reads as
   a secondary action sitting next to the primary green/red feedback. */
.pyenv__test-btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  min-height: 44px; /* touch target minimum (WCAG / Apple HIG) */
  transition: filter 150ms var(--ease), opacity 150ms var(--ease);
}
.pyenv__test-btn:hover:not(:disabled) { filter: brightness(1.06); }
.pyenv__test-btn:disabled { opacity: 0.55; cursor: default; }
.pyenv__test-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.pyenv__test-status {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--color-ink-muted);
}

.pyenv__test-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.pyenv__test {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.5rem;
  align-items: start;
  padding: 0.4rem 0;
  border-top: 1px solid var(--color-border);
}
.pyenv__test:first-child { border-top: 0; }
.pyenv__test-icon {
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  color: var(--color-ink-muted); /* pending */
}
.pyenv__test--pass .pyenv__test-icon { color: var(--color-pass); }
.pyenv__test--fail .pyenv__test-icon { color: var(--color-fail); }
.pyenv__test-name { font-size: 0.9rem; line-height: 1.4; }
.pyenv__test--pass .pyenv__test-name { color: var(--color-ink); }
.pyenv__test--fail .pyenv__test-name { color: var(--color-ink); }

/* Optional expected-vs-actual detail shown under a failed output test. */
.pyenv__test-detail {
  grid-column: 2;
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--color-ink-muted);
}
.pyenv__test-detail pre {
  margin: 0.2rem 0 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--color-fail-soft);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.pyenv__test-detail .is-expected { background: var(--color-pass-soft); }

/* Primary column: toolbar, editor, then output stacked vertically. */
.pyenv__main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0; /* allow the editor to shrink within the grid track */
}

/* Three parts: Run + status on the left, the Full Coding Screen toggle in
   the true center, Submit on the right. Equal 1fr side tracks keep the
   toggle centered however long the status text runs. */
.pyenv__toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.85rem;
}
.pyenv__toolbar-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}
.pyenv__toolbar .pyenv__submit { justify-self: end; }

/* Phone width: no room for three parts on one row, so the toggle drops to
   its own full-width row under Run and Submit. */
@media (max-width: 639px) {
  .pyenv__toolbar { grid-template-columns: 1fr auto; }
  .pyenv__focus-toggle { grid-column: 1 / -1; grid-row: 2; }
}

/* Run button. Text uses --color-surface as an "on-accent" color: the
   surface always contrasts with the accent in both themes (white text
   on dark-blue in light mode, dark text on light-blue in dark mode). */
.pyenv__run {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-surface);
  background: var(--color-accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  min-height: 44px; /* touch target minimum (WCAG / Apple HIG) */
  transition: filter 150ms var(--ease), opacity 150ms var(--ease);
}
.pyenv__run:hover:not(:disabled) { filter: brightness(1.08); }
.pyenv__run:disabled { opacity: 0.55; cursor: default; }
.pyenv__run:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.pyenv__status {
  color: var(--color-ink-muted);
  font-size: 0.9rem;
}

/* Editor pane. CodeMirror mounts inside and fills this box; it scrolls
   internally rather than growing the page. Height clamps so it stays
   usable inside a short iframe. */
.pyenv__editor {
  height: clamp(260px, 45vh, 520px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}
.pyenv__editor .cm-editor { height: 100%; }
.pyenv__editor .cm-editor.cm-focused { outline: none; }

/* Shown for ~3s when a paste into the editor is refused (the pasteBlocker
   extension in playground.js). Accent, not a red error color: the student
   did nothing wrong, the editor simply does not take pasted code. */
.pyenv__paste-note {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--color-accent);
  opacity: 0;
  transition: opacity 140ms var(--ease);
}
.pyenv__paste-note:empty { display: none; }
.pyenv__paste-note.is-visible { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .pyenv__paste-note { transition: none; }
}

/* Output pane. */
.pyenv__output-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.pyenv__output-bar {
  background: var(--color-tab-bg);
  color: var(--color-ink-muted);
  font: 600 0.78rem/1 var(--font-sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
}
.pyenv__output {
  margin: 0;
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-ink);
  background: var(--color-surface);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 96px;
  max-height: 320px;
  overflow: auto;
}
/* Hint shown before the first run (and whenever output is empty). */
/* The quiz page's note to AI assistants, just under the output box (see
   quiz.html). Quiet but readable: muted ink is 5.6:1 on the light page and
   6.5:1 on the dark one. */
.pyenv__ai-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--color-ink-muted);
}
.pyenv__output:empty::before {
  content: "Output will appear here after you press Run.";
  color: var(--color-ink-muted);
}

/* Error block. Flagged with the theme accent rather than a hardcoded
   red, so it themes correctly and adds no new palette. */
.pyenv__output-line--error {
  display: block;
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  background: var(--color-accent-soft);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
}

/* --- Full Coding Screen ----------------------------------- */
/* The toolbar's center button. Pressed, the rail slides off to the left and
   the activity panel off to the right; then .pyenv--focus drops them from
   the layout so the coding window gets the whole width, a taller editor,
   and a short output strip. Pressed again ("Details and Code"), they slide
   back in. The sequencing lives in setFocusMode() in playground.js. */

/* Filled accent, like Run, but with rounder corners so it reads as a view
   switch rather than another action on the code. */
.pyenv__focus-toggle {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-surface);
  background: var(--color-accent);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.5rem 1.25rem;
  min-height: 44px; /* touch target minimum (WCAG / Apple HIG) */
  transition: filter 150ms var(--ease);
}
.pyenv__focus-toggle:hover { filter: brightness(1.08); }
.pyenv__focus-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* The toolbar's Test Code copy and its pass count exist only in Full
   Coding Screen, and only for an activity that has tests (the open
   playground has none). playground.js sets .pyenv--has-tests. */
.pyenv__quick-test,
.pyenv__quick-score { display: none; }
.pyenv--focus.pyenv--has-tests .pyenv__quick-test { display: inline-block; }
.pyenv--focus.pyenv--has-tests .pyenv__quick-score { display: inline; }
.pyenv__quick-score {
  color: var(--color-ink-muted);
  font-size: 0.9rem;
}

/* The slide. Always armed on the rail and panel; .pyenv--offstage is the
   off-stage position. For the whole slide (.pyenv--sliding) .pyenv clips
   them at its own edges, so the panel never pokes past the page and adds a
   sideways scrollbar. */
.pyenv__rail,
.pyenv__panel {
  transition: transform 250ms var(--ease), opacity 250ms var(--ease);
}
.pyenv--sliding { overflow-x: clip; }
/* A slight shrink as they go reads as stepping back, not just moving. */
.pyenv--offstage .pyenv__rail { transform: translateX(-110%) scale(0.94); opacity: 0; }
.pyenv--offstage .pyenv__panel { transform: translateX(110%) scale(0.94); opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .pyenv__rail,
  .pyenv__panel { transition: none; }
}

/* The morph (second beat). While html.pyenv-morphing is set, these boxes
   are named for a view transition, so the browser animates each one from
   its old size and place to its new one: the coding window stretches
   wide, the title card shrinks to its slim line, and the output glides
   from under the editor to beside it. Names exist only during the morph
   (morphLayout in playground.js) so they never affect the page otherwise. */
.pyenv-morphing .page__hero { view-transition-name: pp-hero; }
.pyenv-morphing .pyenv__editor { view-transition-name: pp-editor; }
.pyenv-morphing .pyenv__output-wrap { view-transition-name: pp-output; }
/* The toolbar's three parts glide separately: as one box, its narrow
   snapshot would be stretched across the wide one. */
.pyenv-morphing .pyenv__toolbar-start { view-transition-name: pp-tools; }
.pyenv-morphing .pyenv__focus-toggle { view-transition-name: pp-toggle; }
.pyenv-morphing .pyenv__submit { view-transition-name: pp-submit; }

::view-transition-group(pp-hero),
::view-transition-group(pp-editor),
::view-transition-group(pp-output),
::view-transition-group(pp-tools),
::view-transition-group(pp-toggle),
::view-transition-group(pp-submit) {
  animation-duration: 420ms;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1); /* fast, soft landing */
}
::view-transition-old(pp-tools),
::view-transition-new(pp-tools),
::view-transition-old(pp-toggle),
::view-transition-new(pp-toggle) {
  height: 100%;
  object-fit: none;
  object-position: left center;
}
/* The output lands a beat after the code, with a small springy settle. */
::view-transition-group(pp-output) {
  animation-delay: 50ms;
  animation-timing-function: cubic-bezier(0.34, 1.3, 0.64, 1);
}
/* Don't stretch the code or the title text while their boxes resize:
   pin each snapshot at its natural size inside a clipping box, and let
   the old one fade into the new. */
::view-transition-group(pp-hero),
::view-transition-group(pp-editor),
::view-transition-group(pp-output) {
  overflow: clip;
  border-radius: var(--radius-md);
}
::view-transition-old(pp-editor),
::view-transition-new(pp-editor),
::view-transition-old(pp-output),
::view-transition-new(pp-output) {
  width: 100%;
  height: 100%;
  object-fit: none;
  object-position: left top;
}
::view-transition-old(pp-hero),
::view-transition-new(pp-hero) {
  width: 100%;
  height: 100%;
  object-fit: none;
  object-position: left center;
}
/* No double-exposure: the new snapshot is solid from the first frame and
   sits on top, and the old one only shows where the box is still bigger
   than the new content, fading out quickly. (The browser default fades
   both and adds them together, which ghosts two sets of edges.) */
::view-transition-old(pp-editor),
::view-transition-old(pp-output),
::view-transition-old(pp-hero),
::view-transition-old(pp-tools),
::view-transition-old(pp-toggle) {
  animation-duration: 160ms;
  mix-blend-mode: normal;
}
::view-transition-new(pp-editor),
::view-transition-new(pp-output),
::view-transition-new(pp-hero),
::view-transition-new(pp-tools),
::view-transition-new(pp-toggle) {
  animation: none;
  mix-blend-mode: normal;
}

/* Settled full-screen layout: one column. Two classes, so it outranks both
   the wide-screen three-column rule above and quiz.css's two-column one.
   The editor height is measured by playground.js to reach the bottom of
   the window under the header and title, but never less than the normal
   editor's height: on a short laptop screen the header and title leave
   less room than that, and full screen should never mean a shorter
   editor. On a narrow screen the output is a fixed five-ish-line strip
   under the editor; from 768px up it moves beside the editor (below). */
.pyenv.pyenv--focus {
  grid-template-columns: minmax(0, 1fr);
  --pyenv-focus-code-h: max(clamp(260px, 45vh, 520px), var(--pyenv-focus-editor-h, 0px));
}
.pyenv--focus .pyenv__rail,
.pyenv--focus .pyenv__panel { display: none; }
.pyenv--focus .pyenv__editor { height: var(--pyenv-focus-code-h); }
.pyenv--focus .pyenv__output {
  height: 8.5rem;
  min-height: 0;
  max-height: none;
}

/* Output beside the editor: code on the left two-thirds, output on the
   right third, both the full code height, so the strip under the editor
   gives its height back to the code. Still wider than the normal view's
   editor. Below 768px the third would be too narrow to read, so phones
   keep the strip. */
@media (min-width: 768px) {
  .pyenv--focus .pyenv__main {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    column-gap: 1rem;
    row-gap: 0.75rem;
    align-items: start;
  }
  .pyenv--focus .pyenv__toolbar { grid-column: 1 / -1; }
  .pyenv--focus .pyenv__editor { grid-column: 1; grid-row: 2; }
  .pyenv--focus .pyenv__paste-note { grid-column: 1; grid-row: 3; }
  .pyenv--focus .pyenv__output-wrap {
    grid-column: 2;
    grid-row: 2;
    height: var(--pyenv-focus-code-h);
    display: flex;
    flex-direction: column;
  }
  .pyenv--focus .pyenv__output { flex: 1 1 0; height: auto; }
  .pyenv--focus .pyenv__ai-note { grid-column: 1 / -1; }
}

/* The page's title card shrinks to a slim one-line heading in full mode
   (the site menu above it stays as it is). The class sits on <body>
   because the card is outside .pyenv; setFocusMode() sets it. */
.is-full-coding .page__hero {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
}
.is-full-coding .page__hero h1 {
  font-size: 1.15rem;
  line-height: 1.3;
}

/* --- Submit: capture the activity as a submission PNG ------ */
/* The Submit button (toolbar, right edge) re-runs the tests, then captures
   the whole activity — code, output, instructions, test results — as a PNG
   the student uploads to Canvas. Flow lives in submitLab() in playground.js
   and mirrors the problem sets' Submit. */

.pyenv { position: relative; } /* anchors the .pyenv-watermark overlay */

/* Outlined accent, so Run (filled) stays the primary action. */
.pyenv__submit {
  margin-left: auto; /* push to the toolbar's right edge */
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-accent);
  background: transparent;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  min-height: 44px; /* touch target minimum (WCAG / Apple HIG) */
  transition: background 150ms var(--ease), opacity 150ms var(--ease);
}
.pyenv__submit:hover:not(:disabled) { background: var(--color-accent-soft); }
.pyenv__submit:disabled { opacity: 0.55; cursor: default; }
.pyenv__submit:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Stamp line (name · activity · date). Filled and un-hidden by
   submitLab() only while the PNG renders; spans the full grid width so it
   reads as a header on the captured image. */
.pyenv__stamp {
  grid-column: 1 / -1;
  margin: 0;
  font: 600 0.95rem/1.3 var(--font-sans);
  color: var(--color-ink);
}

/* Automated-browser banner (.pyenv-automation). Injected by
   buildAutomationBanner() in playground.js only while a QUIZ PNG renders,
   and only when the browser reported navigator.webdriver. Mirrors
   .ps-automation in problem-sets.css: large, solid red, across the top of
   the image. #B91C1C is 5.8:1 on the light page, #FF6B6B 6.4:1 on the dark
   one. */
.pyenv-automation {
  grid-column: 1 / -1;
  padding: 0.6rem 0.5rem;
  border-block: 4px solid currentColor;
  color: #B91C1C;
  text-align: center;
  font-family: var(--font-sans);
}
[data-theme="dark"] .pyenv-automation { color: #FF6B6B; }
.pyenv-automation__title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pyenv-automation__note { margin-top: 0.3rem; font-size: 1rem; font-weight: 600; }

/* Capture mode, applied to .pyenv only while the PNG renders.

   Two jobs:
   1. Hide the activity rail — the picker is navigation, not evidence,
      and dropping it gives the code and tests the full image width.
   2. Un-clip the editor and output so the WHOLE program and its full
      output are in the image. This is not just about scrollbars: with a
      fixed height, CodeMirror renders only the lines near the viewport,
      so a long program would be silently truncated mid-file in the PNG.
      height:auto makes the scroller as tall as its content, which makes
      CodeMirror's viewport cover every line (playground.js waits for a
      re-measure before rendering the image). */
.pyenv--capture .pyenv__rail { display: none; }
/* A Full Coding Screen slide cut short by Submit snaps the panel home
   rather than being captured mid-flight. */
.pyenv--capture .pyenv__panel { transition: none; transform: none; opacity: 1; }
.pyenv--capture .pyenv__editor { height: auto; }
.pyenv--capture .pyenv__editor .cm-editor { height: auto; }
.pyenv--capture .pyenv__output { max-height: none; overflow: visible; }

/* The wide-screen grid reserves a track for the rail; with the rail hidden
   the capture collapses to coding window | activity panel. Must live in
   the same media query that sets the three-column layout, or the first
   track's 150px minimum would squeeze the code column. */
@media (min-width: 1024px) {
  .pyenv--capture {
    grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  }
}

/* Red diagonal watermark burned into the submission PNG: student name plus
   tests passed. Injected by buildWatermark() in playground.js just before
   the capture and removed right after, so it only ever exists in the image.
   Mirrors .ps-watermark in problem-sets.css; the hardcoded red is shared
   with it deliberately — the stamp must look the same on every submission
   in both themes, so it does not use theme tokens. This page loads no web
   fonts, so the stack resolves to the system sans. */
.pyenv-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* clip the rotated text at the capture edges */
  pointer-events: none;
}
.pyenv-watermark__stamp {
  transform: rotate(-45deg);
  text-align: center;
  color: #dc2626;
  opacity: 0.38;
  font-family: var(--font-sans);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.15;
  white-space: nowrap;
}

/* "Leave this activity?" — put up by confirmLeaveActivity() in playground.js
   when a student who has written code taps another rail entry. Sized for a
   thumb: the two buttons are full width and stacked, Stay on top and filled
   so it is the one a hurried tap lands on, Switch below and outlined.
   Same scrim and card as the submission save panel (submission.css). */
.leave-guard {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  /* Not a token, for the same reason as .submit-save: it sits over the
     page in both themes. */
  background: rgba(0, 0, 0, 0.65);
}
.leave-guard__card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(26rem, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(1rem, 4vw, 1.5rem);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.leave-guard__title {
  margin: 0;
  font-size: 1.25rem;
}
.leave-guard__target,
.leave-guard__note {
  margin: 0;
}
.leave-guard__note {
  color: var(--color-ink-muted);
}
.leave-guard__stay,
.leave-guard__go {
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.leave-guard__stay {
  margin-top: 0.25rem;
  background: var(--color-accent);
  border: 1px solid transparent;
  color: var(--color-surface);
  font-size: 1.05rem;
}
.leave-guard__stay:hover,
.leave-guard__stay:focus-visible {
  filter: brightness(1.08);
}
.leave-guard__go {
  background: transparent;
  border: 1px solid var(--color-ink-muted);
  color: var(--color-ink);
}
.leave-guard__go:hover,
.leave-guard__go:focus-visible {
  background: var(--color-accent-soft);
}
.leave-guard__stay:focus-visible,
.leave-guard__go:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Marks on what differs between Expected and Your output (see "Highlighting
   what differs" in js/playground.js). Fixed colors so the mark reads the
   same in light and dark mode: #1F1F1F on #FFE066 is 12.6:1. Bold and the
   outline carry the meaning too, so it never rests on color alone, and a
   screen reader hears "(missing: ...)" / "(extra: ...)" from hidden text. */
.pyenv__diff {
  background: #FFE066;
  color: #1F1F1F;
  font-weight: 700;
  border-radius: 2px;
  box-shadow: 0 0 0 1px #8A6D00;
}
.pyenv__diff-key {
  margin: 0.3rem 0 0.1rem;
  font-size: 0.78rem;
}
.pyenv__diff-key .pyenv__diff { padding: 0 0.2em; }
