.case-gallery {
  --case-ink: var(--fg, #16212b);
  --case-selection: var(--accent, #3f67e6);
  --case-muted: var(--muted, #5a6b79);
  --case-rule: var(--border, #e3e8ef);
  --case-matte: var(--bg-soft, #f5f7fb);
  --case-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --case-control: 15px;
  margin: clamp(20px, 2vw, 28px) 0 0;
  color: var(--case-ink);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.case-gallery button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}
.case-gallery :focus-visible { outline: 2px solid var(--case-selection); outline-offset: 2px; }
.case-nav {
  text-align: left;
  border-bottom: 1px solid var(--case-rule);
}
.case-nav h3 {
  margin: 0 0 8px;
  font-size: clamp(28px, 2.25vw, 30px);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.2;
}
.case-scenes {
  display: flex;
  flex-wrap: wrap;
  gap: 2px clamp(16px, 1.8vw, 26px);
}
.case-scenes button {
  flex: none;
  min-height: 35px;
  padding: 5px 0 8px;
  color: var(--case-muted);
  border-bottom: 1px solid transparent;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}
.case-scenes button[aria-selected="true"] { border-color: var(--case-selection); color: var(--case-ink); }
.case-scenes button:hover, .case-archive-links a:hover { color: var(--case-selection); }
.case-scenes button:focus-visible, .case-thumb:focus-visible { outline-offset: -2px; }
.case-line, .case-time {
  font-size: 12px; font-weight: 400; line-height: 1.3; color: var(--case-muted);
  font-variant-numeric: tabular-nums;
}
.case-triptych {
  --case-ratio: 1.5;
  --pane-height: clamp(184px, 22vw, 280px);
  margin: 8px 0 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) clamp(174px, 22%, 244px);
  gap: clamp(12px, 1.15vw, 17px);
}
.case-pane { margin: 0; min-width: 0; }
.case-pane figcaption, #case-play {
  font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1.35;
}
.case-pane figcaption {
  display: flex; align-items: baseline; justify-content: space-between; padding: 5px 0 7px;
  color: var(--case-ink);
}
.case-enlarge {
  position: absolute; inset: 0; display: block;
  background: none; color: var(--case-ink); cursor: zoom-in;
}
.case-enlarge svg {
  position: absolute; right: 8px; top: 8px; width: 27px; height: 27px; padding: 5px;
  fill: none; stroke: currentColor; stroke-width: 1.5; background: rgb(255 255 255 / .9);
  opacity: 0; transition: opacity .16s;
}
.case-enlarge:focus-visible { outline-offset: -2px; }
.case-enlarge:focus-visible svg { opacity: 1; }
@media (hover: hover) {
  .case-enlarge:hover svg { opacity: 1; }
}
.case-surface {
  position: relative; display: grid; place-items: center; height: var(--pane-height);
  background: var(--case-matte); overflow: hidden; container-type: size;
}
.case-paper {
  position: relative; width: min(100%, calc(100cqh * var(--case-ratio)));
  aspect-ratio: var(--case-ratio); max-height: 100%; background: white;
}
.case-paper img, .case-paper iframe {
  display: block; width: 100%; height: 100%; border: 0; object-fit: contain;
}
.case-paper iframe, .case-pen { pointer-events: none; }
.case-pen {
  position: absolute; left: var(--pen-x); top: var(--pen-y);
  width: 9px; height: 9px; transform: translate(-50%, -50%);
  border: 1.5px solid white; border-radius: 50%;
  background: rgba(63, 103, 230, .82); box-shadow: 0 0 0 1px #1e3a8a;
}
#case-code {
  height: var(--pane-height); margin: 0; padding: 11px 12px;
  overflow: auto; overscroll-behavior: contain; tab-size: 2;
  scrollbar-width: thin; scrollbar-color: #c7d3df transparent;
  background: var(--case-matte); color: #455565; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 400 12px/1.45 var(--case-mono); text-align: left; contain: layout paint;
}
#case-code code { font: inherit; }
.case-writing { color: #344454; }
.case-code-punctuation { color: var(--case-muted); }
.case-writing:not(:empty)::after { content: ""; border-right: 1px solid var(--case-muted); }

.case-toolbar {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 6px; padding-top: 4px;
}
#case-play {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
  color: var(--case-muted);
}
#case-play:is(:hover, :focus-visible) { color: var(--case-selection); }
#case-play svg { width: 13px; height: 13px; flex: none; }
#case-play .pause-symbol, #case-play[data-playing="true"] .play-symbol { display: none; }
#case-play[data-playing="true"] .pause-symbol { display: initial; }
.case-time { margin-inline-start: auto; text-align: right; white-space: nowrap; }
#case-seek {
  --track: linear-gradient(to right, var(--case-selection) var(--played, 0%), #c4d1df var(--played, 0%));
  position: absolute; inset-inline: 0; top: 0; z-index: 1; transform: translateY(-50%);
  appearance: none; -webkit-appearance: none; width: 100%; height: 24px;
  margin: 0; background: transparent; cursor: pointer;
}
#case-seek::-webkit-slider-runnable-track { height: 1.5px; background: var(--track); }
#case-seek::-moz-range-track { height: 1.5px; background: var(--track); }
#case-seek::-webkit-slider-thumb {
  appearance: none; width: 8px; height: 8px; margin-top: -3.25px;
  background: var(--case-selection); border: 0; border-radius: 50%;
}
#case-seek::-moz-range-thumb { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--case-selection); }
.case-filmstrip {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  column-gap: clamp(10px, 1.6vw, 22px);
}
.case-strip {
  --film-gap: clamp(16px, 1.4vw, 20px);
  --film-visible: 5.5;
  --film-gaps: 5;
  display: grid; grid-auto-flow: column; align-items: start;
  grid-auto-columns: calc((100% - var(--film-gaps) * var(--film-gap)) / var(--film-visible));
  gap: var(--film-gap); min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
}
.case-strip::-webkit-scrollbar { display: none; }
.case-film-nav {
  display: grid; grid-template-columns: repeat(2, 30px); align-items: center; padding-bottom: 7px;
}
#case-position {
  grid-column: 1 / -1; text-align: center; white-space: nowrap;
  font-size: 13px; line-height: 1.4; font-variant-numeric: tabular-nums; color: var(--case-muted);
}
.case-filmstrip .case-film-arrow { display: grid; place-items: center; height: 32px; color: var(--case-ink); }
.case-film-arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.case-film-arrow:disabled { opacity: .25; cursor: default; }
.case-strip .case-thumb { display: grid; gap: 5px; min-width: 0; }
.case-thumb::after {
  content: ""; display: block; height: 2px;
  background: var(--case-selection); opacity: 0;
}
.case-thumb[aria-current="true"]::after { opacity: 1; }
.case-thumb-image {
  display: block; aspect-ratio: 4 / 3; overflow: hidden; background-color: var(--case-matte);
  background-image: var(--film); background-size: var(--film-width) 100%;
  background-position: var(--thumb-position) center; background-repeat: no-repeat;
  opacity: .58; filter: saturate(.82); transition: opacity .18s, filter .18s;
}
.case-thumb-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.case-thumb:is([aria-current="true"], :focus-visible) .case-thumb-image { opacity: 1; filter: none; }
@media (hover: hover) {
  .case-thumb:hover .case-thumb-image { opacity: .9; filter: none; }
  .case-thumb[aria-current="true"]:hover .case-thumb-image { opacity: 1; }
}

.case-zoom:not([open]) { display: none; }
.case-zoom {
  padding: 0; margin: auto; border: 0; max-width: 92vw; max-height: 92vh;
  overscroll-behavior: contain; background: #fff; color: var(--case-ink);
}
.case-zoom::backdrop { background: rgb(22 33 43 / .58); }
.case-zoom-inner { width: fit-content; min-width: min(240px, 88vw); }
.case-zoom-header {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding-left: 12px; font-size: var(--case-control); line-height: 1.4;
}
.case-zoom-header button { display: grid; place-items: center; flex: 0 0 40px; height: 40px; }
.case-zoom-header svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.4; fill: none; }
.case-zoom img {
  display: block; width: min(88vw, calc(78vh * var(--case-ratio))); height: auto;
  max-height: 78vh; margin-inline: auto; aspect-ratio: var(--case-ratio); object-fit: contain;
}
.case-archive-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 17px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--case-rule);
  color: var(--case-muted);
  font-size: var(--case-control);
  line-height: 1.5;
}
.case-archive-links a { color: var(--case-muted); }
/* Cached articles can still contain the former collection totals. */
.case-gallery #case-counts { display: none; }
.case-message { font-size: var(--case-control); padding: 6px 0; }
.case-message button { text-decoration: underline; }
@media (max-width: 900px) {
  .case-strip { --film-visible: 4.5; --film-gaps: 4; }
}
@media (max-width: 680px) {
  .case-scenes { gap: 0 17px; }
  .case-scenes button { min-height: 36px; }
  .case-triptych {
    --pane-height: clamp(104px, 30vw, 175px);
    margin: 4px 0 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px;
  }
  .case-pane figcaption { padding: 5px 0; }
  .case-source-pane { grid-column: 1 / -1; }
  #case-code { height: 93px; padding: 6px 9px; }
  .case-pen { width: 7px; height: 7px; }
  #case-play { min-height: 36px; }
  .case-strip { --film-visible: 3.5; --film-gaps: 3; }
}
@media (max-width: 500px) {
  .case-strip { --film-visible: 2.35; --film-gaps: 2; --film-gap: 12px; }
  .case-film-nav { grid-template-columns: repeat(2, 26px); }
}
@media (max-width: 370px) {
  .case-toolbar { gap: 2px; }
  #case-play { gap: 4px; }
}
