/* The Daily Token. Layout: masthead + tabs, then one page per tab. Reels fill one screen; Digest scrolls. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --ink: #151821; --muted: #5b6272; --faint: #a9afba; --rule: #dde1e8;
  --accent: #2b55c9; --tint: #e8eefc; --core: #9a5b00; --core-bg: #fff3dc;
  --good: #16824f; --bad: #c8312f; --secret: #b06a00;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #6250d6; --s0: #8c93a1; --track: #e6e9ef;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --f-mast: "UnifrakturMaguntia", "Old English Text MT", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #11141a; --surface: #191d25; --ink: #e9ebf0; --muted: #a3aab8; --faint: #565d6b; --rule: #2b313c;
  --accent: #8fb0ff; --tint: #1f2a44; --core: #f2b54a; --core-bg: #3a2b10;
  --good: #3cc58a; --bad: #f06b69; --secret: #f2b54a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #9085e9; --s0: #737b8a; --track: #2a303b; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #11141a; --surface: #191d25; --ink: #e9ebf0; --muted: #a3aab8; --faint: #565d6b; --rule: #2b313c;
  --accent: #8fb0ff; --tint: #1f2a44; --core: #f2b54a; --core-bg: #3a2b10;
  --good: #3cc58a; --bad: #f06b69; --secret: #f2b54a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #9085e9; --s0: #737b8a; --track: #2a303b; color-scheme: dark }

[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
/* The scrollbar's room is kept on every tab, so a long Digest doesn't shift the page sideways. */
html { scrollbar-gutter: stable; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); }
.app { height: 100%; max-width: 1200px; margin: 0 auto; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px; padding-block: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); box-sizing: border-box; }
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-size: .88em; }

.top { display: grid; gap: 10px; }
.issue { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; font: 500 12px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.issue b { color: var(--ink); font-weight: 500; }
/* The nameplate, in blackletter like a newspaper's. */
.issue .nameplate { font: 400 30px/1 var(--f-mast); letter-spacing: 0; text-transform: none; margin-right: 4px; }

.stage { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 28px; align-items: center; min-height: 0; }
.viz { min-height: 0; height: 100%; display: flex; align-items: center; justify-content: center; }
.scene { width: 100%; height: auto; max-height: 100%; background: var(--bg); border-radius: 6px; }
.book { position: relative; min-height: 0; overflow: hidden; border-radius: 10px; }
.page { position: relative; height: 100%; box-sizing: border-box; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; padding: 14px 24px 12px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
.copy { display: grid; gap: 10px; align-content: center; min-width: 0; }
.kicker { display: flex; align-items: center; gap: 8px; font: 500 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; display: inline-block; }
h1 { font: 700 clamp(24px, 3vw, 34px)/1.08 var(--f-display); letter-spacing: -.015em; margin: 0; text-wrap: balance; }
.copy p { margin: 0; max-width: 52ch; }
.copy p.why { color: var(--muted); font-size: 14px; }
.prs { display: flex; flex-wrap: wrap; gap: 6px; }
.pr { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 8px; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); text-decoration: none; color: var(--ink); font-size: 12.5px; }
.pr:hover { border-color: var(--accent); }
.pr .n { font-family: var(--f-mono); color: var(--accent); }
.core { font: 600 10px/1 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--core); background: var(--core-bg); border-radius: 3px; padding: 3px 5px; }
.todo { border: 1px solid var(--core); background: var(--core-bg); border-radius: 6px; padding: 9px 12px; font-size: 13.5px; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
button { font: 500 13px/1 var(--f-body); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 5px; padding: 8px 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
button svg { width: 12px; height: 12px; fill: currentColor; }
.hint { font-size: 12.5px; color: var(--muted); margin-left: auto; }

@media (max-width: 860px) {
  .app { height: auto; min-height: 100%; }
  .stage { grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
  .viz { height: auto; }
  .page { height: auto; padding: 12px 14px; }
  .hint { display: none; }
}

.topline { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.tabs { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; padding: 2px; background: var(--surface); }
.tabs button { border: 0; padding: 6px 14px; border-radius: 4px; background: transparent; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }

/* Pages 2 and 3: digest and blueprint */
.pagehead { display: grid; gap: 4px; padding-bottom: 12px; border-bottom: 1.5px solid var(--ink); }
.pagehead .ph-title { font: 700 clamp(20px, 2.4vw, 28px)/1.15 var(--f-display); letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.pagehead .ph-dek { margin: 0; font-size: 14px; color: var(--muted); }
/* A page shorter than the screen keeps its header at the top instead of stretching the rows. */
.app.on-page { height: auto; min-height: 100%; grid-template-rows: auto auto; align-content: start; }
.app.on-page .tray, .app.on-page .book, .app.on-page .controls { display: none; }
.label { font: 500 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.dgrid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; }
@media (max-width: 900px) { .dgrid { grid-template-columns: minmax(0, 1fr); gap: 28px; } }
.dgrid > * { min-width: 0; display: grid; gap: 22px; align-content: start; }
#sections { display: grid; gap: 40px; }
.section { display: grid; gap: 16px; scroll-margin-top: 16px; }
.section > header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; align-items: end; }
.section > header .kicker { grid-column: 1 / -1; }
.section h2 { font: 700 clamp(22px, 2.6vw, 28px)/1.12 var(--f-display); letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.section .dek { grid-column: 1; margin: 0; color: var(--muted); max-width: 60ch; font-size: 15px; }
.recap { padding: 18px 20px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); }
.weekbars { display: grid; gap: 6px; max-width: 520px; }
.wb { display: grid; grid-template-columns: 64px minmax(0, 1fr) 28px; align-items: center; gap: 10px; font: 500 12px/1 var(--f-mono); color: var(--muted); }
.wb .t { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.wb .t i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.wb.today { color: var(--ink); }
.wb.today .t i { background: var(--ink); }
.wb .n { text-align: right; color: var(--ink); }
.recap .points { margin: 0; padding-left: 18px; display: grid; gap: 6px; max-width: 64ch; }
.recap .wk-totals { margin: 0; font: 500 12px/1.4 var(--f-mono); color: var(--muted); }
.section .watch { grid-column: 2; grid-row: 2 / 4; align-self: center; font-size: 13px; padding: 7px 11px; border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; color: var(--ink); background: var(--surface); white-space: nowrap; }
.section .watch:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 640px) { .section > header { grid-template-columns: minmax(0, 1fr); } .section .watch { grid-column: 1; grid-row: auto; justify-self: start; } }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: grid; gap: 8px; align-content: start; padding: 16px 16px 12px; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; transition: border-color .15s; }
.card:hover { border-color: var(--faint); }
.card.lead { grid-column: 1 / -1; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); column-gap: 28px; padding: 20px; }
.card.lead > * { grid-column: 1; }
.card.lead .side { grid-column: 2; grid-row: 1 / 6; align-self: center; }
@media (max-width: 720px) { .card.lead { grid-template-columns: minmax(0, 1fr); } .card.lead .side { grid-column: 1; grid-row: auto; } }
.card .type { display: inline-flex; align-items: center; gap: 6px; font: 600 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; }
.card .type i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.card h3 { font: 600 17px/1.3 var(--f-body); margin: 0; text-wrap: balance; }
.card.lead h3 { font: 700 22px/1.2 var(--f-display); }
.card p { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--ink); max-width: 62ch; }
.card .side p { font-size: 14px; color: var(--muted); }
.card .side b { color: var(--ink); font-weight: 600; }
.card details { font-size: 13px; color: var(--muted); }
.card summary { cursor: pointer; font-weight: 500; color: var(--muted); list-style: none; display: inline-flex; gap: 6px; align-items: center; }
.card summary::before { content: "+"; font-family: var(--f-mono); }
.card details[open] summary::before { content: "−"; }
.card summary::-webkit-details-marker { display: none; }
.card details p { margin-top: 6px; font-size: 13px; color: var(--muted); }
.card details .mono { font-size: .92em; }
.card .foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding-top: 10px; margin-top: 2px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted); }
.card .foot a { font-family: var(--f-mono); }
.card .foot .by { margin-left: auto; }
.place { all: unset; cursor: pointer; font-size: 12px; color: var(--ink); padding: 3px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--rule); }
.place:hover, .place:focus-visible { border-color: var(--accent); color: var(--accent); }
.who { display: grid; gap: 8px; }
.row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.row span:last-child { font-family: var(--f-mono); color: var(--muted); }
.epics { display: grid; gap: 10px; }
.epic { display: grid; gap: 4px; font-size: 13px; }
.epic .top { display: flex; justify-content: space-between; gap: 10px; }
.epic .top a { color: var(--ink); text-decoration: none; }
.epic .top a:hover { color: var(--accent); }
.epic .top span { font-family: var(--f-mono); color: var(--muted); white-space: nowrap; }
.track { height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.queue { font-size: 13px; display: grid; gap: 4px; margin: 0; padding: 0; }
.queue li { list-style: none; display: flex; gap: 8px; }
.queue li a { font-family: var(--f-mono); flex: none; }
.src { font-size: 12.5px; color: var(--muted); margin: 0; }

/* Scene drawing */
.scene text { font-family: var(--f-mono); font-size: 12px; fill: var(--muted); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.scene .box text { stroke: none; }
.scene .tb { fill: var(--ink); font-family: var(--f-body); font-weight: 600; font-size: 14px; }
.scene .big { fill: var(--ink); font-family: var(--f-display); font-weight: 700; font-size: 38px; }
.scene .ink { fill: var(--ink); }
.scene .good { fill: var(--good); }
.scene .bad { fill: var(--bad); }
.scene .secret { fill: var(--secret); }
.scene .box rect { fill: var(--surface); stroke: var(--faint); stroke-width: 1.3; transition: stroke .25s, fill .25s; }
.scene .box.on rect { stroke: var(--accent); stroke-width: 2.5; fill: var(--tint); }
.scene .box.bad-on rect { stroke: var(--bad); stroke-width: 2.5; }
.scene .box.good-on rect { stroke: var(--good); stroke-width: 2.5; }
.scene .line { stroke: var(--muted); stroke-width: 1.4; fill: none; }
.scene .life { stroke: var(--rule); stroke-width: 1.5; stroke-dasharray: 4 4; }
.scene .msg { stroke-width: 1.6; fill: none; }
.scene .tok { stroke: var(--surface); stroke-width: 2; }
@media (prefers-reduced-motion: reduce) { .scene .box rect { transition: none; } }

.viz { touch-action: manipulation; user-select: none; }
@media (max-width: 700px) { .reel .stage { touch-action: manipulation; user-select: none; -webkit-user-select: none; } }

/* Phones: where to tap, once, and a chevron at the edge tapped. */
.tap-hint { position: absolute; inset: 56px 0 72px; display: grid; grid-template-columns: 1fr 2fr; pointer-events: none; z-index: 3; animation: tap-in 300ms ease-out; transition: opacity 400ms; }
.tap-hint span { display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.tap-hint b { padding: 8px 14px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); font: 600 15px var(--f-body); color: var(--ink); box-shadow: 0 2px 10px rgb(0 0 0 / 0.08); }
.tap-hint .back { border-right: 1px dashed var(--rule); }
.tap-hint.gone { opacity: 0; }
.tap-flash { position: absolute; top: 40%; z-index: 3; pointer-events: none; font: 700 40px/1 var(--f-body); color: var(--ink); opacity: 0; animation: tap-flash 450ms ease-out; }
.tap-flash.back { left: 10px; }
.tap-flash.next { right: 10px; }
@keyframes tap-in { from { opacity: 0; } }
@keyframes tap-flash { 30% { opacity: .55; } to { opacity: 0; } }

/* Phones: a vertical reel that fills the screen, picture on top, words below. */
@media (max-width: 700px) {
  .app:not(.on-page) { height: 100dvh; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
  .app:not(.on-page) .page { height: 100%; }
  .app:not(.on-page) .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-items: start; gap: 12px; }
  .app:not(.on-page) .copy { overflow: hidden; align-content: start; min-height: 0; font-size: calc(16px * var(--fit, 1)); }
  .copy h1 { font-size: calc(22px * var(--fit, 1)); }
  .copy p.why { font-size: calc(14px * var(--fit, 1)); }
  .copy.terse p.why { display: none; }
  .copy.lean .prs { display: none; }
  .copy.clipped { mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
  .pagehead .ph-title { font-size: 19px; }
}

/* Desktop reels: the page takes its content's height and sits in the middle, no tall empty frame. */
@media (min-width: 701px) {
  .app:not(.on-page) .book { align-self: center; }
  .app:not(.on-page) .page { height: auto; }
}

/* Editions: a drawer, and a rail on wide screens. */
.masthead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ed-open { padding: 6px 9px; font-size: 15px; line-height: 1; }
.topline .issue { align-items: center; }
.weekly { color: var(--core); }
.editions { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 280px; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px;
  padding: max(16px, env(safe-area-inset-top, 0px)) 14px 16px max(14px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-right: 1px solid var(--rule); overflow-y: auto; transform: translateX(-100%); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.editions.open { transform: none; }
.ed-scrim { position: fixed; inset: 0; z-index: 35; background: color-mix(in srgb, var(--ink) 30%, transparent); }
.ed-head { display: flex; justify-content: space-between; align-items: center; font: 700 18px/1 var(--f-display); }
/* The rail's heading in the nameplate's blackletter. */
.ed-head b { font: 400 26px/1 var(--f-mast); }
.ed-close { padding: 4px 8px; }
#ed-list { display: grid; gap: 4px; }
.ed-group { margin: 10px 0 2px; font: 500 10.5px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ed-item { display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.ed-item:hover { background: var(--bg); }
.ed-item[aria-current="page"] { background: var(--tint); border-color: var(--rule); }
.ed-date { font: 500 11px/1.2 var(--f-mono); color: var(--muted); }
.ed-title { font-size: 13.5px; line-height: 1.35; }
.ed-all { margin-top: auto; font-size: 13px; text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .editions { transition: none; } }
@media (min-width: 1500px) {
  .editions { transform: none; }
  .ed-open, .ed-close, .ed-scrim { display: none !important; }
  body { padding-left: 280px; }
}

/* Phones: give the reel the screen. The segment bar already says where you are. */
@media (max-width: 700px) {
  .app:not(.on-page) .copy { align-self: stretch; }
  .app:not(.on-page) .ph-dek { display: none; }
  .app:not(.on-page) .pagehead { padding-bottom: 8px; }
  .app:not(.on-page) .pagehead .ph-title { font-size: 16px; }
  .app:not(.on-page) .page { padding: 10px 12px; gap: 8px; }
  .topline .issue span:nth-child(n+4) { display: none; }
  .issue .nameplate { font-size: 24px; }
  /* Swipe, tap the sides and hold to pause stand in for the controls. */
  .app:not(.on-page) .controls { display: none; }
}

/* Threads: a tray of stories, one circle each; the story playing, its neighbours either side on a wide screen. */
.tray { display: flex; gap: 14px; margin: 0; padding: 2px 2px 4px; list-style: none; overflow-x: auto; scrollbar-width: none; }
.tray::-webkit-scrollbar { display: none; }
.circle { all: unset; cursor: pointer; display: grid; justify-items: center; gap: 5px; width: 64px; }
/* A story not yet watched wears a bright ring, its colour and the accent; a watched one goes grey, as stories do. */
.circle .ring { width: 52px; height: 52px; border-radius: 50%; padding: 3px; box-sizing: border-box; background: conic-gradient(var(--c), var(--accent), var(--c)); }
.circle .dot { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; box-sizing: border-box; border: 2.5px solid var(--bg); background: var(--surface); color: var(--c); font: 700 19px/1 var(--f-display); }
.circle .cname { max-width: 64px; font: 500 11px/1.2 var(--f-body); color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.circle.seen .ring { background: var(--rule); }
.circle.seen .dot { color: var(--muted); }
.circle.seen .cname { opacity: .7; }
.circle.cur .cname { color: var(--ink); font-weight: 600; }
.circle.cur .dot { background: var(--c); color: var(--surface); }
.circle:focus-visible .ring { outline: 2px solid var(--accent); outline-offset: 2px; }

.thread { position: relative; box-sizing: border-box; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 8px; min-height: 0;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; }
.thread .segs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.thread .seg .bar { display: block; height: 3px; border-radius: 2px; background: var(--track); overflow: hidden; }
.thread .seg .bar i { display: block; height: 100%; width: 0; background: var(--c); }
.thead { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.thead b { font-weight: 600; white-space: nowrap; }
.thead .ttitle { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* The way into the story: a bar along the card's foot, in the story's color, its chevron nudging up. */
.read-bar { display: flex; align-items: center; gap: 10px; width: 100%; box-sizing: border-box; padding: 12px 14px; border: 0; border-radius: 10px; cursor: pointer;
  background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--ink); font: 600 15px/1.2 var(--f-body); text-align: left; transition: background .2s; }
.read-bar:hover { background: color-mix(in srgb, var(--c) 20%, var(--surface)); }
.read-bar:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; }
.read-bar .chev { width: 9px; height: 9px; margin-top: 4px; border: solid var(--c); border-width: 2.5px 0 0 2.5px; transform: rotate(45deg); animation: nudge 1.8s ease-in-out infinite; }
.read-bar .more { margin-left: auto; font: 500 12px/1 var(--f-mono); color: var(--muted); }
@keyframes nudge { 0%, 60%, 100% { translate: 0 0; } 30% { translate: 0 -4px; } }
@media (prefers-reduced-motion: reduce) { .read-bar .chev { animation: none; } }
.thread .page { border: 0; padding: 0; background: transparent; border-radius: 0; }
.thread .stage { grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.thread h1 { font-size: clamp(20px, 2.2vw, 26px); }
.thread.peek { position: absolute; inset: 0; z-index: 5; pointer-events: none; }

/* The story under the reel: a sheet from the bottom on a phone, a panel from the right on a wide screen. */
.sheet { position: fixed; z-index: 30; overflow-y: auto; box-sizing: border-box; display: grid; gap: 12px; align-content: start;
  background: var(--surface); box-shadow: 0 -8px 40px color-mix(in srgb, var(--ink) 18%, transparent); }
.sheet h2 { font: 700 24px/1.15 var(--f-display); margin: 0; text-wrap: balance; }
.sheet .dek { margin: 0; color: var(--muted); }
.sheet .cards { grid-template-columns: minmax(0, 1fr); }
.sheet .card.lead { grid-template-columns: minmax(0, 1fr); }
.sheet .card.lead .side { grid-column: 1; grid-row: auto; }
.sheet .points { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.sheet-close { justify-self: start; }
.sheet-grab { display: none; }

@media (min-width: 701px) {
  /* A story's card takes its own height; a tall one makes the page scroll rather than ride over the tray. */
  .app:not(.on-page) { height: auto; min-height: 100%; }
  /* The stories as a stack of cards: the current one in front, its neighbours tucked behind it on either side,
     the next ones out further and unseen, so a move to the next story slides the whole stack. */
  /* As wide as the window's height lets the whole card show, between 500 and 680px. */
  .app:not(.on-page) .book { display: grid; grid-template-columns: minmax(0, clamp(500px, calc((100dvh - 440px) * 1.15), 680px)); justify-content: center; overflow: clip visible; padding: 6px 0 10px; }
  .thread { grid-row: 1; grid-column: 1; transition: transform .5s cubic-bezier(.2,.8,.2,1), opacity .5s, box-shadow .5s; }
  .thread.cur { z-index: 3; box-shadow: 0 12px 40px color-mix(in srgb, var(--ink) 12%, transparent); }
  /* A card behind is solid, dimmed by a veil, so cards in motion never show through each other. */
  .thread::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; background: var(--bg); opacity: 0; pointer-events: none; transition: opacity .5s; }
  .thread.side-prev, .thread.side-next { z-index: 2; cursor: pointer; }
  .thread.side-prev::after, .thread.side-next::after { opacity: .55; }
  .thread.side-prev:hover::after, .thread.side-next:hover::after { opacity: .3; }
  .thread.side-prev { transform: translateX(-21%) scale(.86); }
  .thread.side-next { transform: translateX(21%) scale(.86); }
  .thread.far-prev, .thread.far-next { z-index: 1; opacity: 0; pointer-events: none; }
  .thread.far-prev { transform: translateX(-32%) scale(.72); }
  .thread.far-next { transform: translateX(32%) scale(.72); }
  @starting-style {
    .thread.cur { transform: scale(.96); }
    .thread.side-prev { opacity: 0; transform: translateX(-32%) scale(.72); }
    .thread.side-next { opacity: 0; transform: translateX(32%) scale(.72); }
  }
  .thread.side-prev *, .thread.side-next * { pointer-events: none; }
  /* The current card steps through its shorts; the cards behind it and the space beside move between stories. */
  .thread.cur .stage { cursor: pointer; }
  .app:not(.on-page) .book { cursor: pointer; }
  .app:not(.on-page) .book .thread.cur { cursor: auto; }
  .sheet { inset: 0 0 0 auto; width: min(560px, 100%); padding: 20px 24px 28px; border-left: 1px solid var(--rule); }
}

@media (max-width: 700px) {
  .tray { gap: 10px; }
  .circle { width: 54px; }
  .circle .ring { width: 46px; height: 46px; }
  .circle .dot { font-size: 16px; }
  .app:not(.on-page) .book { display: block; height: 100%; }
  /* The card reaches a little into the page's margin, and the picture a little into the card's, for a bigger reel. */
  .app:not(.on-page) .book { margin-inline: -8px; }
  .app:not(.on-page) .thread { height: 100%; padding: 10px 8px; }
  .thread.side-prev:not(.peek, .leaving), .thread.side-next:not(.peek, .leaving), .thread.far-prev, .thread.far-next { display: none; }
  /* A story left by a tap or at its end stays under the arriving one while it slides away. */
  .thread.leaving { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
  .thread.cur { z-index: 1; }
  .sheet { inset: 10dvh 0 0 0; padding: 8px 16px 28px; border-radius: 16px 16px 0 0; overscroll-behavior-y: contain; }
  /* The handle says the sheet drags down to close. */
  .sheet-grab { display: block; justify-self: center; width: 40px; height: 5px; margin-bottom: -2px; border-radius: 3px; background: var(--faint); }
}
@media (prefers-reduced-motion: reduce) { .thread { transition: none; } }

/* The Cutaway: the motion beside its words on a wide screen, above them on a phone. */
.mgrid { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 36px; align-items: start; }
.mvideo { margin: 0; position: sticky; top: 16px; }
.mvideo video { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; }
.mnone { aspect-ratio: 4 / 5; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--rule); border-radius: 12px; }
.mcopy { display: grid; gap: 14px; align-content: start; max-width: 64ch; }
.mcopy h2 { font: 700 clamp(24px, 3vw, 34px)/1.1 var(--f-display); letter-spacing: -.015em; margin: 0; text-wrap: balance; }
.mcopy .dek { margin: 0; color: var(--muted); font-size: 16px; }
.mcopy .label { margin: 10px 0 0; }
.mcopy .prs { align-items: center; }
.mcopy .prs .label { margin: 0 6px 0 0; }
.mparts { margin: 0; font: 500 13px/1.6 var(--f-mono); color: var(--muted); }
.narration { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.narration li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 8px 10px; border-radius: 8px; font-size: 16px; }
.narration li[data-now] { background: var(--tint); }
.narration .at { font: 500 12.5px/1 var(--f-mono); color: var(--accent); padding: 5px 7px; justify-content: center; }
.narration span.at { color: var(--muted); }
@media (max-width: 760px) {
  .mgrid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .mvideo { position: static; justify-self: center; width: min(100%, 62dvh * 4 / 5); }
}

/* Short phone screens give the reel the room: no issue headline over the reels (the Digest has it), smaller
   circles, a tighter card. */
@media (max-width: 700px) and (max-height: 760px) {
  .app:not(.on-page) .pagehead { display: none; }
  .app:not(.on-page) .page { padding: 10px 14px 8px; gap: 8px; }
  .tray { gap: 8px; }
  .circle { width: 50px; gap: 3px; }
  .circle .ring { width: 40px; height: 40px; }
  .circle .dot { font-size: 14px; }
  .circle .cname { max-width: 50px; font-size: 10px; }
}

/* The masthead's text, and the phone's section menu in place of the tabs. On a wide screen the tabs stay. */
.mast-text { display: contents; }
.issue-line, .section-pill, .dateline { display: none; }
.ph-dek:empty { display: none; }
.sections[hidden] { display: none; }
@media (max-width: 700px) {
  .topline { position: relative; flex-wrap: nowrap; gap: 8px; }
  .masthead { flex: 1; min-width: 0; }
  .mast-text { display: grid; gap: 3px; min-width: 0; }
  /* The issue's dateline under the nameplate, as a newspaper's: its number, its day, and the weekly edition. */
  .dateline { display: block; font: 500 10px/1 var(--f-mono); letter-spacing: .03em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topline .issue span { display: none; }
  .issue .nameplate { font-size: 21px; white-space: nowrap; }
  /* The issue's headline, whole, under the masthead on every tab; the page head's own title isn't repeated. */
  .issue-line { display: block; margin: 0; font: 700 15.5px/1.25 var(--f-display); color: var(--ink); text-wrap: balance; }
  .app.on-page .issue-line { padding-bottom: 10px; border-bottom: 1.5px solid var(--ink); }
  .pagehead { display: none; }
  .tabs { display: none; }
  .section-pill { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 6px 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 600; }
  .section-pill .caret { color: var(--muted); font-size: 12px; transition: transform .2s cubic-bezier(.2,.8,.2,1); }
  .section-pill[aria-expanded="true"] .caret { transform: rotate(180deg); }
  .section-pill:active { transform: scale(.97); }
  .sections { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; transform-origin: top right; width: min(290px, calc(100vw - 32px)); display: grid; gap: 2px; padding: 6px;
    background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; box-shadow: 0 12px 32px rgb(0 0 0 / .16); }
  .sections button { display: grid; grid-template-columns: 26px 1fr; gap: 1px 10px; align-items: center; padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: var(--ink); text-align: left; }
  .sections button:active { background: color-mix(in srgb, var(--ink) 6%, transparent); }
  .sections button[aria-current="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .sections svg { grid-row: span 2; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .sections svg .fill { fill: currentColor; stroke: none; }
  .sections b { font: 600 14.5px/1.2 var(--f-body); }
  .sections small { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
  /* The reel's picture reaches toward the card's edges. */
  .app:not(.on-page) .page.reel .viz { margin-inline: -12px; }
}
@media (prefers-reduced-motion: reduce) { .section-pill .caret { transition: none; } }

/* Phones set to reduce motion: a paused reel's play button, over the middle of its picture. Others hold to pause. */
.resume { display: none; }
@media (max-width: 700px) {
  .reel .viz { position: relative; }
  .app.reduced.paused:not(.on-page) .thread.cur .resume { display: grid; place-items: center; position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; padding: 0; z-index: 2;
    border: 0; border-radius: 50%; background: color-mix(in srgb, var(--ink) 72%, transparent); color: var(--bg); box-shadow: 0 4px 16px rgb(0 0 0 / .2); animation: tap-in 200ms ease-out; }
  .resume svg { width: 26px; height: 26px; margin-left: 3px; fill: currentColor; }
}

/* The end of the issue's last story. */
.end-card { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 24px; text-align: center;
  border-radius: inherit; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(3px); animation: tap-in 260ms ease-out; }
.end-card[hidden] { display: none; }
.end-card b { font: 700 24px/1.15 var(--f-display); }
.end-card span { color: var(--muted); }
.end-card div { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.end-card button { padding: 9px 16px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 600; }
.end-card button[data-end="replay"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* A newer issue than the one open: a pill under the masthead. */
.new-issue { justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--accent); color: var(--bg); text-decoration: none; font-size: 13.5px; animation: tap-in 300ms ease-out; }
.new-issue span { opacity: .9; }

/* The week in review: its themes, each with the week's PRs it covers. */
.themes { display: grid; gap: 14px; margin: 14px 0; }
.theme { padding: 12px 14px; border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: 10px; background: var(--surface); }
.theme h3 { margin: 0 0 4px; font: 700 17px/1.25 var(--f-display); }
.theme p { margin: 0 0 8px; font-size: 14.5px; line-height: 1.45; }
.theme ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13.5px; color: var(--muted); }
.theme li a { font-family: var(--f-mono); margin-right: 6px; }
.theme details { margin-top: 6px; }
.theme summary { cursor: pointer; font-size: 13px; color: var(--accent); }
.theme details ul { margin-top: 6px; }
