/* Tellavision. A dark studio around one lit picture; the picture is the only bright thing. */
:root {
  --studio: #101019;
  --raised: #191927;
  --line: #2e2e45;
  --paper: #fbf6ea;
  --ink: #23202e;
  --text: #eeeadf;
  --dim: #a3a0b4;
  --air: #ff4a38;
  --sun: #ffcb3d;
  --hand: 'Shantell Sans', 'Comic Sans MS', 'Chalkboard SE', cursive;
  --ui: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--studio) radial-gradient(1100px 520px at 50% 0%, #1d1d31 0%, rgba(29, 29, 49, 0) 62%) fixed;
  color: var(--text);
  font: 15px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) max(18px, env(safe-area-inset-right, 0)) env(safe-area-inset-bottom, 0) max(18px, env(safe-area-inset-left, 0));
}
.app[data-mode='viewer'] .studio-only { display: none !important; }
.app[data-mode='studio'] .viewer-only { display: none !important; }

/* top bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px 8px; flex: none; }
.brand { font: 700 23px/1 var(--hand); color: var(--text); text-decoration: none; letter-spacing: 0.01em; white-space: nowrap; }
.brand i { font-style: normal; padding-inline: 0.06em; color: var(--air); }
.brand i + i, .brand i:last-of-type { color: var(--sun); }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pens { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); }
.pens button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--dim); }
.pens button[aria-checked='true'] { background: var(--paper); color: var(--ink); font-weight: 600; }
.ghost { border: 1px solid var(--line); background: none; padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none; white-space: nowrap; }
.ghost:hover { border-color: var(--dim); }

/* the set */
.studio { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; }
.set { flex: 1 1 0; min-height: 0; container-type: size; display: grid; place-items: center; }
.tube {
  position: relative;
  width: min(100cqw, 100cqh * 1.6);
  aspect-ratio: 776 / 485;
  border-radius: 14px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 0 1px #05050a, 0 0 0 7px #0b0b13, 0 0 0 8px var(--line), 0 36px 80px -36px #000, 0 0 150px -60px rgba(255, 220, 140, 0.3);
}
/* each theme mounts its own picture (an svg, a canvas) inside the stage */
.stage { position: absolute; inset: 0; overflow: hidden; }
.stage > svg, .stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.osd { position: absolute; inset: 10px 12px auto 12px; display: flex; justify-content: space-between; pointer-events: none; font: 600 11px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; }
.osd span { background: rgba(16, 16, 25, 0.8); color: #fff; padding: 5px 8px; border-radius: 4px; }
.osd span:empty { visibility: hidden; }
.app[data-air='on'] #osdMode { background: var(--air); }

/* the words being spoken, over any theme (engines/type/captions.js draws them; this is only its place) */
.words { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* a stage nobody sees: the studio pen's work is measured there before it is shown */
.stage.shadow { visibility: hidden; pointer-events: none; }
/* how far along the studio pen is, while the picture stays as it was */
.prog { position: absolute; left: 12px; right: 12px; bottom: 13px; height: 5px; border-radius: 3px; background: rgba(16, 16, 25, 0.62); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); overflow: hidden; pointer-events: none; }
.prog i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); border-radius: 3px; background: var(--sun); transition: width 0.6s ease-out; }
.app:is([data-work='upgrade'], [data-work='film']) #osdMode { background: var(--sun); color: var(--ink); }
.app:is([data-work='upgrade'], [data-work='film']) .bars { display: none; }
/* a film takes minutes to make: the studio waits for it (the picture stays; nothing else can be started by accident) */
.app[data-work='film'] :is(.talk, .type, .themes, .under, .pens) { pointer-events: none; opacity: 0.38; transition: opacity 0.3s; }
.app[data-work='film'] #osdScene { font-variant-numeric: tabular-nums; }
/* a download is being recorded: nothing in the frame but the picture, the words and his face; nothing else on the page answers */
.app[data-rec='on'] .osd, .app[data-rec='on'] .bars, .app[data-rec='on'] .prog, .app[data-rec='on'] .chip, .app[data-rec='on'] .bigplay { display: none !important; }
.app[data-rec='on'] .bar, .app[data-rec='on'] .desk, .app[data-rec='on'] .picker, .app[data-rec='on'] .reel, .app[data-rec='on'] .caption { pointer-events: none; opacity: 0.32; transition: opacity 0.3s; }
.app[data-rec='on'] .notice::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--air); margin-right: 8px; animation: hear 0.7s ease-in-out infinite alternate; }

/* colour bars along the bottom edge shimmer while a beat is being drawn */
.bars { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; display: flex; opacity: 0; transition: opacity 0.3s; }
.bars i { flex: 1; }
.bars i:nth-child(1) { background: #cacdd3; } .bars i:nth-child(2) { background: #ffcb3d; } .bars i:nth-child(3) { background: #9bd2f1; }
.bars i:nth-child(4) { background: #5ea352; } .bars i:nth-child(5) { background: #8c4a80; } .bars i:nth-child(6) { background: #df4638; } .bars i:nth-child(7) { background: #3a6fd6; }
.bars.busy { opacity: 1; }
.bars.busy i { animation: bar 0.9s ease-in-out infinite; }
.bars.busy i:nth-child(2) { animation-delay: 0.08s; } .bars.busy i:nth-child(3) { animation-delay: 0.16s; } .bars.busy i:nth-child(4) { animation-delay: 0.24s; }
.bars.busy i:nth-child(5) { animation-delay: 0.32s; } .bars.busy i:nth-child(6) { animation-delay: 0.4s; } .bars.busy i:nth-child(7) { animation-delay: 0.48s; }
@keyframes bar { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.chip { position: absolute; right: 12px; bottom: 14px; border: 0; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px; box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.6); }
.bigplay { position: absolute; inset: 0; margin: auto; width: 96px; height: 96px; border-radius: 50%; border: 0; background: rgba(16, 16, 25, 0.86); color: #fff; display: grid; place-items: center; padding-left: 6px; box-shadow: 0 10px 40px -10px #000; }
.bigplay:hover { background: var(--air); }

/* the story sentence under the picture */
.caption { flex: none; margin: 0 auto; width: 100%; max-width: 64ch; height: calc(1.42em * 3); overflow: hidden; display: grid; place-content: start center; text-align: center; text-wrap: balance; font: 600 clamp(16px, 1.9vw, 22px)/1.42 var(--hand); color: var(--text); }
.caption .new { animation: cap 0.6s ease-out; display: inline-block; }
@keyframes cap { from { opacity: 0; transform: translateY(5px); } }
.caption:empty::before { content: attr(data-hint); color: var(--dim); font-weight: 500; }

/* the desk */
.desk { flex: none; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.mic { display: inline-flex; align-items: center; gap: 12px; height: 54px; padding: 0 26px 0 20px; border-radius: 999px; border: 1.5px solid var(--air); background: rgba(255, 74, 56, 0.08); font-weight: 600; font-size: 16px; letter-spacing: 0.01em; white-space: nowrap; transition: background 0.2s, box-shadow 0.2s; }
.mic:hover { background: rgba(255, 74, 56, 0.18); }
.lamp { width: 14px; height: 14px; border-radius: 50%; background: var(--air); box-shadow: 0 0 0 4px rgba(255, 74, 56, 0.2); flex: none; }
.app[data-air='on'] .mic { background: var(--air); color: #fff; text-transform: uppercase; letter-spacing: 0.16em; font-size: 15px; box-shadow: 0 0 0 0 rgba(255, 74, 56, 0.5); animation: onair 2s ease-out infinite; }
.app[data-air='on'] .lamp { background: #fff; box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.7); }
.app[data-air='on'][data-hearing='yes'] .lamp { animation: hear 0.5s ease-in-out infinite alternate; }
.app[data-air='asking'] .lamp { animation: hear 0.7s ease-in-out infinite alternate; }
.app[data-air='blocked'] .mic, .app[data-air='none'] .mic { border-color: var(--line); background: var(--raised); color: var(--dim); }
.app[data-air='blocked'] .lamp, .app[data-air='none'] .lamp { background: var(--dim); box-shadow: none; }
@keyframes onair { 0% { box-shadow: 0 0 0 0 rgba(255, 74, 56, 0.55); } 100% { box-shadow: 0 0 0 16px rgba(255, 74, 56, 0); } }
@keyframes hear { from { transform: scale(0.85); } to { transform: scale(1.25); } }
.talk { display: flex; align-items: center; gap: 8px; min-width: 0; }
/* the camera: his face in the corner of the picture, recorded with his voice */
.cam { flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; padding: 0; border: 1.5px solid var(--line); background: var(--raised); color: var(--dim); transition: background 0.2s, border-color 0.2s, color 0.2s; }
.cam svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cam .off { stroke: var(--dim); stroke-width: 1.9; }
.cam:hover { color: var(--text); border-color: var(--dim); }
.cam[aria-checked='true'] { color: #fff; border-color: var(--air); background: rgba(255, 74, 56, 0.16); }
.cam[aria-checked='true'] .body { fill: rgba(255, 74, 56, 0.55); }
.cam[aria-checked='true'] .off { display: none; }
.type { flex: 0 1 380px; min-width: 0; }
.type input { width: 100%; height: 54px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); padding: 0 20px; font-size: 15px; text-overflow: ellipsis; }
.type input::placeholder { color: var(--dim); }
.type input:focus { outline: none; border-color: var(--sun); }
.stat { font: 500 12px/1.2 var(--mono); color: var(--dim); min-width: 13ch; font-variant-numeric: tabular-nums; }

.notice { flex: none; margin: 0; min-height: 1.5em; text-align: center; font-size: 14px; color: var(--sun); }
.notice.bad { color: #ff8e80; }
.notice.quiet { color: var(--dim); }
.notice a { color: inherit; }
.notice button { margin-left: 8px; border: 1px solid currentColor; background: none; color: inherit; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.notice code { font: 500 13px var(--mono); color: var(--text); user-select: all; }

/* the theme picker: a bank of small monitors, one per way of turning words into a picture.
   However many there are: app.js sets --n (how many) and --per (how many to a row), choosing the
   fewest rows, up to --rows-max, on which every name can be read (see fitPicker). */
.picker { flex: none; display: grid; gap: 9px; justify-items: center; min-width: 0; }
.themes {
  --g: 6px; --rows-max: 2;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px var(--g); width: 100%; max-width: calc(var(--per, 7) * 72px);
}
.themes button {
  position: relative; flex: 0 0 calc((100% - (var(--per, 7) - 1) * var(--g)) / var(--per, 7)); min-width: 0; display: grid; justify-items: center; gap: 5px;
  padding: 4px 0 2px; border: 0; border-radius: 12px; background: none;
  color: var(--dim); font: 600 10.5px/1.15 var(--ui); letter-spacing: 0;
}
/* set a little tighter when that is what it takes for the names to fit */
.themes[data-fit='tight'] { --g: 4px; }
.themes[data-fit='tight'] button { font-size: 10px; letter-spacing: -0.015em; }
/* no room for every name: only the chosen theme, and the one pointed at, is named */
.themes[data-fit='compact'], .themes[data-fit='slide'] { --g: 4px; }
.themes:is([data-fit='compact'], [data-fit='slide']) button { padding-bottom: 17px; }
.themes:is([data-fit='compact'], [data-fit='slide']) .ico { width: min(44px, 100% - 5px); }
.themes:is([data-fit='compact'], [data-fit='slide']) .nm { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); visibility: hidden; max-width: none; overflow: visible; z-index: 1; }
.themes:is([data-fit='compact'], [data-fit='slide']) button[aria-checked='true'] .nm, .themes:is([data-fit='compact'], [data-fit='slide']) button:hover:not(:disabled) .nm { visibility: visible; }
.themes:is([data-fit='compact'], [data-fit='slide']) button:hover:not(:disabled):not([aria-checked='true']) .nm { background: var(--studio); box-shadow: 0 0 0 3px var(--studio); border-radius: 3px; }
/* and when one row of them would be too small to press, the row slides sideways rather than shrink further */
.themes[data-fit='slide'] {
  flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; width: calc(100% + 12px); max-width: none; margin: -6px -6px 0; padding: 6px 6px 0;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
}
.themes[data-fit='slide']::-webkit-scrollbar { display: none; }
.themes[data-fit='slide'] button { flex-basis: 40px; }
.themes[data-fit='slide'] button:first-child .nm { left: 0; transform: none; }
.themes .ico {
  display: block; width: min(44px, 100% - 8px); aspect-ratio: 1; border-radius: 11px; overflow: hidden;
  box-shadow: 0 0 0 1px #05050a, 0 0 0 3px #0b0b13, 0 0 0 4px var(--line);
  opacity: 0.74; filter: saturate(0.8);
  transition: opacity 0.2s, filter 0.2s, transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.2s;
}
.themes .ico svg { display: block; width: 100%; height: 100%; }
.themes .nm { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color 0.2s; }
.themes button:hover:not(:disabled) { color: var(--text); }
.themes button:hover:not(:disabled) .ico { opacity: 1; filter: none; transform: translateY(-2px); }
.themes button[aria-checked='true'] { color: var(--sun); }
.themes button[aria-checked='true'] .ico {
  opacity: 1; filter: none;
  box-shadow: 0 0 0 1px #05050a, 0 0 0 3px #0b0b13, 0 0 0 4.5px var(--sun), 0 8px 24px -6px rgba(255, 203, 61, 0.6);
}
.themes button:focus-visible { outline: none; }
.themes button:focus-visible .ico { outline: 2px solid var(--sun); outline-offset: 6px; }
.themes button:disabled { cursor: default; color: #6a687c; }
.themes button:disabled .ico { opacity: 0.3; filter: grayscale(1) brightness(0.8); }
.themes .tag {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, 30px); font: 600 8px/1 var(--mono); font-style: normal;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text); background: rgba(16, 16, 25, 0.92);
  border: 1px solid var(--line); border-radius: 4px; padding: 2.5px 4px 2px 5px;
}
/* this story has already been told in that theme: one press and it is there (a ring: partly, the rest is retold) */
.themes button[data-has='yes']:not([aria-checked='true'])::after, .themes button[data-has='behind']:not([aria-checked='true'])::after {
  content: ''; position: absolute; top: 0; left: calc(50% + min(22px, 50% - 4px) - 7px); width: 9px; height: 9px; border-radius: 50%;
  background: var(--sun); box-shadow: 0 0 0 2.5px var(--studio); pointer-events: none;
}
.themes button[data-has='behind']:not([aria-checked='true'])::after { background: var(--studio); box-shadow: inset 0 0 0 2px var(--sun), 0 0 0 2.5px var(--studio); }
/* on air the bank goes quiet: nothing competes with the picture (a theme can still be changed) */
.app[data-air='on'] .themes button:not([aria-checked='true']):not(:hover) .ico { opacity: 0.45; }
/* a story on its way into a theme: that theme's monitor breathes until it has arrived */
.picker[data-busy='yes'] .themes button[aria-checked='true'] .ico { animation: k-busy 1.3s ease-in-out infinite; }
@keyframes k-busy { 50% { box-shadow: 0 0 0 1px #05050a, 0 0 0 3px #0b0b13, 0 0 0 4.5px var(--sun), 0 0 0 9px rgba(255, 203, 61, 0.22), 0 8px 24px -6px rgba(255, 203, 61, 0.6); } }
/* while a story is being retold or redrawn the chosen theme's own options wait */
.picker[data-busy='yes'] .looks { opacity: 0.4; pointer-events: none; }

/* under the tiles: what the chosen theme is built on, the switch for words on the picture, and the theme's own options */
.under { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px 16px; width: 100%; min-width: 0; }
.credit { margin: 0; font: 500 11.5px/1.25 var(--ui); color: var(--dim); white-space: nowrap; }
.credit b { color: var(--text); font-weight: 600; }
.sw { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: none; border-radius: 999px; padding: 3px 6px 3px 9px; font-size: 12px; font-weight: 500; color: var(--dim); white-space: nowrap; }
.sw b { font: 700 11px/1 var(--ui); letter-spacing: -0.02em; color: inherit; }
.sw i { position: relative; width: 24px; height: 14px; border-radius: 7px; background: var(--line); transition: background 0.2s; }
.sw i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--dim); transition: transform 0.2s cubic-bezier(0.3, 1.4, 0.5, 1), background 0.2s; }
.sw:hover { color: var(--text); border-color: var(--dim); }
.sw[aria-checked='true'] { color: var(--text); }
.sw[aria-checked='true'] i { background: var(--sun); }
.sw[aria-checked='true'] i::after { transform: translateX(10px); background: var(--ink); }

/* the chosen theme's own options (a storybook's papers, the emoji sets): one picture, several ways of showing it */
.looks { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; max-width: 100%; min-width: 0; transition: opacity 0.2s; }
.looks .lbl { font: 600 10px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin-right: 4px; flex: none; }
.looks button { flex: none; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: none; border-radius: 999px; padding: 4px 11px 4px 5px; font-size: 12.5px; font-weight: 500; color: var(--dim); white-space: nowrap; }
.looks button i { width: 26px; height: 18px; border-radius: 9px; display: block; position: relative; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
.looks button i::before, .looks button i::after { content: ''; position: absolute; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--a); box-shadow: 0 0 0 1.5px var(--k); }
.looks button i::before { left: 4px; }
.looks button i::after { left: 14px; background: var(--b); }
.looks button:hover { color: var(--text); border-color: var(--dim); }
.looks button[aria-checked='true'] { color: var(--text); border-color: var(--sun); background: rgba(255, 203, 61, 0.08); }

/* the moving pictures on the tiles. Each rests in its finished pose when it is not moving:
   a theme that is not built yet, and every tile while a story is being told (nothing competes with the picture). */
.themes button:disabled .ico svg *, .app[data-air='on'] .themes .ico svg * { animation: none !important; }
.themes button:disabled .k-boil-b, .app[data-air='on'] .themes .k-boil-b { opacity: 0; }
.k-boil-a { animation: k-boil 0.9s steps(1, end) infinite; }
.k-boil-b { animation: k-boil 0.9s steps(1, end) -0.45s infinite; }
.k-mo-a { animation: k-mo-a 2.4s cubic-bezier(0.65, 0, 0.35, 1) infinite alternate; }
.k-mo-b { transform-box: fill-box; transform-origin: 50% 50%; animation: k-mo-b 2.4s cubic-bezier(0.65, 0, 0.35, 1) -0.5s infinite alternate; }
.k-mo-c { transform-box: fill-box; transform-origin: 0 50%; animation: k-mo-c 2.4s cubic-bezier(0.65, 0, 0.35, 1) -1s infinite alternate; }
.k-em-face { transform-box: fill-box; transform-origin: 50% 100%; animation: k-em 2.6s cubic-bezier(0.3, 0, 0.5, 1) infinite; }
.k-em-shadow { transform-box: fill-box; transform-origin: 50% 50%; animation: k-em-sh 2.6s cubic-bezier(0.3, 0, 0.5, 1) infinite; }
.k-di-block { animation: k-di 2.8s cubic-bezier(0.5, 0, 0.3, 1) infinite; }
.k-sw circle { animation: k-sw 3.4s cubic-bezier(0.6, 0, 0.3, 1) var(--d, 0s) infinite alternate; }
.k-ty-aa { transform-box: fill-box; transform-origin: 50% 60%; animation: k-ty 3s cubic-bezier(0.2, 0.9, 0.2, 1) infinite; }
.k-ty-bar { transform-box: fill-box; transform-origin: 0 50%; animation: k-ty-bar 3s cubic-bezier(0.2, 0.9, 0.2, 1) infinite; }
.k-mp-l1, .k-mp-l2, .k-mp-l3 { stroke-dasharray: 1; animation: k-mp-l 5.4s ease-in-out infinite; }
.k-mp-n1, .k-mp-n2, .k-mp-n3 { transform-box: fill-box; transform-origin: 50% 50%; animation: k-mp-n 5.4s cubic-bezier(0.3, 1.5, 0.5, 1) infinite; }
.k-mp-l2, .k-mp-n2 { animation-delay: 0.3s; }
.k-mp-l3, .k-mp-n3 { animation-delay: 0.6s; }
.k-sk path { stroke-dasharray: 9 8; animation: k-sk 2.6s linear infinite; }
.k-sk path:nth-child(2) { stroke-dasharray: 6 11; animation-duration: 3.5s; }
.k-sk path:nth-child(3) { stroke-dasharray: 11 6; animation-duration: 2.2s; }
.k-sk path:nth-child(4) { stroke-dasharray: 7 10; animation-duration: 3.1s; }
.k-sk path:nth-child(5) { stroke-dasharray: 5 12; animation-duration: 4s; }
.k-dg-l { stroke-dasharray: 1; animation: k-mp-l 5.4s ease-in-out infinite; }
.k-dg-b { transform-box: fill-box; transform-origin: 50% 50%; animation: k-mp-n 5.4s cubic-bezier(0.3, 1.5, 0.5, 1) infinite; }
.k-dg-2 { animation-delay: 0.22s; } .k-dg-3 { animation-delay: 0.44s; } .k-dg-4 { animation-delay: 0.66s; } .k-dg-5 { animation-delay: 0.88s; }
.k-any { transform-box: fill-box; transform-origin: 50% 50%; animation: m-pulse 1.6s ease-in-out infinite alternate; }
@keyframes k-sk { to { stroke-dashoffset: -34; } }
@keyframes k-boil { 0% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes k-mo-a { from { transform: translate(0, 0); } to { transform: translate(17px, 14px); } }
@keyframes k-mo-b { from { transform: rotate(0) scale(1); } to { transform: translate(-15px, 0) rotate(135deg) scale(0.72); } }
@keyframes k-mo-c { from { transform: scaleX(0.3); } to { transform: scaleX(1); } }
@keyframes k-em { 0%, 15%, 30%, 100% { transform: translateY(0) scale(1.07, 0.91); } 2%, 17% { transform: translateY(-2px) scale(0.96, 1.05); } 7.5%, 22.5% { transform: translateY(-10px) scale(1); } 13%, 28% { transform: translateY(-2px) scale(0.96, 1.05); } 36%, 94% { transform: translateY(0) scale(1); } }
@keyframes k-em-sh { 0%, 15%, 30%, 100% { transform: scale(1); opacity: 0.38; } 7.5%, 22.5% { transform: scale(0.6); opacity: 0.18; } 36%, 94% { transform: scale(1); opacity: 0.38; } }
@keyframes k-di { 0%, 100% { transform: translateY(-9px); } 12% { transform: translateY(-9px); } 30% { transform: translateY(4px); } 36% { transform: translateY(2.6px); } 42%, 78% { transform: translateY(4px); } }
@keyframes k-sw { 0%, 12% { transform: translate(var(--x), var(--y)) scale(0.75); opacity: 0.7; } 70%, 100% { transform: translate(0, 0) scale(1); opacity: 1; } }
@keyframes k-ty { 0%, 66% { transform: scale(1); opacity: 1; } 72% { transform: scale(0.88); opacity: 1; } 74% { transform: scale(2.5); opacity: 0; } 84% { transform: scale(0.92); opacity: 1; } 90% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes k-ty-bar { 0%, 70% { transform: scaleX(1); } 74%, 86% { transform: scaleX(0); } 100% { transform: scaleX(1); } }
@keyframes k-mp-l { 0%, 76% { stroke-dashoffset: 0; opacity: 0.85; } 82% { stroke-dashoffset: 0; opacity: 0; } 83% { stroke-dashoffset: 1; opacity: 0.85; } 96%, 100% { stroke-dashoffset: 0; } }
@keyframes k-mp-n { 0%, 76% { transform: scale(1); opacity: 1; } 82% { transform: scale(1); opacity: 0; } 83%, 92% { transform: scale(0); opacity: 1; } 100% { transform: scale(1); } }

/* the reel of scenes */
.reel { flex: none; display: flex; align-items: center; gap: 12px; min-height: 66px; }
.replay { flex: none; display: flex; gap: 8px; flex-wrap: wrap; }
.play.alt { background: none; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--sun); }
.play.alt:hover { background: rgba(255, 203, 61, 0.1); }
.play.quiet { box-shadow: inset 0 0 0 1.5px var(--line); color: var(--dim); }
.play.quiet:hover { background: none; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--dim); }
.play { flex: none; border: 0; background: var(--paper); color: var(--ink); font-weight: 700; font-size: 14px; padding: 10px 16px; border-radius: 999px; white-space: nowrap; }
.strip { flex: 1 1 auto; min-width: 0; display: flex; gap: 8px; margin: 0; padding: 4px 2px; list-style: none; overflow-x: auto; scrollbar-width: thin; }
.strip li { flex: none; }
.strip button { position: relative; display: block; width: 93px; height: 58px; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--paper); box-shadow: 0 0 0 1px var(--line); }
.strip button svg, .strip button img { width: 100%; height: 100%; display: block; object-fit: cover; }
/* a scene whose theme has no small picture of it yet: its number and its first words */
.strip .tile { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 5px 6px; background: var(--raised); color: var(--dim); font: 600 9.5px/1.2 var(--hand); text-align: left; overflow: hidden; }
.strip button b { position: absolute; left: 4px; top: 4px; font: 600 10px/1 var(--mono); background: rgba(16, 16, 25, 0.8); color: #fff; padding: 3px 5px; border-radius: 3px; }
.strip button[aria-current='true'] { box-shadow: 0 0 0 2px var(--sun); }
.links { flex: none; display: flex; gap: 16px; margin-left: auto; }
.linkish { flex: none; border: 0; background: none; color: var(--dim); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 6px 2px; white-space: nowrap; }
.linkish:hover { color: var(--text); }

/* the shelf: every story he has told here, newest first */
.shelf { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: flex-end; background: rgba(6, 6, 12, 0.6); animation: shelf-dim 0.2s ease-out; }
.shelf-in { width: min(430px, 100vw); height: 100%; overflow-y: auto; padding: max(14px, env(safe-area-inset-top, 0)) 18px 22px; background: var(--raised); border-left: 1px solid var(--line); box-shadow: -40px 0 90px -40px #000; animation: shelf-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1); }
.shelf header { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: -14px; padding-block: 6px; background: var(--raised); z-index: 1; }
.shelf h2 { margin: 0; font: 700 26px/1.1 var(--hand); letter-spacing: 0.01em; }
.shelf-note { margin: 2px 0 14px; font-size: 13px; color: var(--dim); text-wrap: pretty; }
.shelf ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.shelf li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px; border-radius: 12px; padding: 4px 4px 4px 0; }
.shelf li:hover, .shelf li:focus-within { background: rgba(255, 255, 255, 0.035); }
.shelf .open { display: flex; align-items: center; gap: 12px; min-width: 0; border: 0; background: none; padding: 6px; border-radius: 10px; text-align: left; color: var(--text); }
.shelf .cover { flex: none; width: 93px; height: 58px; border-radius: 6px; overflow: hidden; background: var(--paper); box-shadow: 0 0 0 1px var(--line); }
.shelf .cover svg, .shelf .cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shelf .cover.none { background: var(--studio) radial-gradient(circle at 50% 50%, var(--line) 0 5px, transparent 6px); }
.shelf li.here .cover { box-shadow: 0 0 0 2px var(--sun); }
.shelf .what { display: grid; gap: 4px; min-width: 0; }
.shelf .what b { font: 600 15px/1.25 var(--hand); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shelf .meta { font: 500 11px/1.3 var(--mono); color: var(--dim); letter-spacing: 0.02em; }
.shelf li.here .meta { color: var(--sun); }
.shelf .del { border: 0; background: none; color: var(--dim); font-size: 12px; padding: 8px 8px; border-radius: 8px; white-space: nowrap; opacity: 0.55; }
.shelf li:hover .del, .shelf .del:focus-visible, .shelf .del[data-sure='1'] { opacity: 1; }
.shelf .del:hover { color: #ff8e80; }
.shelf .del[data-sure='1'] { color: #ff8e80; font-weight: 600; box-shadow: inset 0 0 0 1px currentColor; }
/* the film chooser: the same panel, one row per treatment */
.films li { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 4px 12px; padding: 10px 8px; }
.films li + li { border-top: 1px solid var(--line); border-radius: 0; }
.films .sw8 { grid-row: span 2; width: 58px; height: 36px; margin-top: 2px; border-radius: 6px; position: relative; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.films .sw8::before, .films .sw8::after { content: ''; position: absolute; top: 11px; width: 14px; height: 14px; border-radius: 50%; background: var(--a); }
.films .sw8::before { left: 12px; }
.films .sw8::after { left: 32px; background: var(--b); }
.films .what b { font: 600 16px/1.2 var(--hand); display: block; }
.films .what .meta { display: block; margin-top: 3px; }
.films .what .made { display: block; margin-top: 3px; font: 500 11px/1.3 var(--mono); color: var(--sun); }
.films .acts { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.films .acts button { border: 0; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700; background: var(--paper); color: var(--ink); white-space: nowrap; }
.films .acts button.again { background: none; color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--line); }
.films .acts button.again:hover { box-shadow: inset 0 0 0 1.5px var(--dim); }
.films-foot { margin: 16px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
@keyframes shelf-in { from { transform: translateX(28px); opacity: 0; } }
@keyframes shelf-dim { from { background: rgba(6, 6, 12, 0); } }

/* things in the picture: placement glides, and each may carry one gentle loop */
.stage .obj { transition: transform 1.05s cubic-bezier(0.3, 1.22, 0.4, 1), opacity 0.45s ease; }
.stage .obj.linger { opacity: 0.3; }
.stage .mo { transform-box: fill-box; transform-origin: 50% 100%; }
.stage .m-drift { animation: m-drift 12s ease-in-out infinite alternate; }
.stage .m-bob { animation: m-bob 2.6s ease-in-out infinite alternate; }
.stage .m-sway { animation: m-sway 3.4s ease-in-out infinite alternate; }
.stage .m-pulse { transform-origin: 50% 50%; animation: m-pulse 1.9s ease-in-out infinite alternate; }
.stage .m-twinkle { animation: m-twinkle 1.5s steps(3, jump-none) infinite alternate; }
.stage .m-spin { transform-origin: 50% 50%; animation: m-spin 14s linear infinite; }
.stage .m-float { transform-origin: 50% 50%; animation: m-float 5.2s ease-in-out infinite alternate; }
.stage .m-flicker { animation: m-flicker 0.42s ease-in-out infinite alternate; }
.stage .m-fall { animation: m-fall 1.25s linear infinite; }
.stage .m-fall.slow { animation-duration: 4.6s; }
.stage .m-hop { animation: m-hop 1.15s cubic-bezier(0.3, 0, 0.4, 1) infinite; }
@keyframes m-drift { from { transform: translateX(-16px); } to { transform: translateX(16px); } }
@keyframes m-bob { from { transform: translateY(1px); } to { transform: translateY(-8px); } }
@keyframes m-sway { from { transform: rotate(-2.4deg); } to { transform: rotate(2.4deg); } }
@keyframes m-pulse { from { transform: scale(1); } to { transform: scale(1.07); } }
@keyframes m-twinkle { from { opacity: 1; } to { opacity: 0.3; } }
@keyframes m-spin { to { transform: rotate(360deg); } }
@keyframes m-float { from { transform: translateY(6px) rotate(-1.3deg); } to { transform: translateY(-7px) rotate(1.3deg); } }
@keyframes m-flicker { from { transform: scale(1, 1) skewX(-1.5deg); } to { transform: scale(0.95, 1.09) skewX(2deg); } }
@keyframes m-fall { 0% { transform: translateY(-34px); opacity: 0; } 18% { opacity: 1; } 82% { opacity: 1; } 100% { transform: translateY(44px); opacity: 0; } }
@keyframes m-hop { 0%, 58%, 100% { transform: translateY(0); } 28% { transform: translateY(-15px); } }

@media (prefers-reduced-motion: reduce) {
  .stage .mo, .bars.busy i, .app[data-air='on'] .mic, .app[data-air='on'] .lamp, .themes .ico, .themes .ico svg * { animation: none !important; }
  .stage .obj, .themes .ico { transition: none; }
  .shelf, .shelf-in { animation: none; }
  .k-boil-b { opacity: 0; }
}

/* Wide windows open like a picture book: the picture on the left page, the words and the desk on the right. */
@media (min-width: 1000px) and (min-aspect-ratio: 3/2) {
  .studio {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 27vw, 400px);
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    grid-template-areas: 'set caption' 'set desk' 'set picker' 'set notice' 'set reel';
    column-gap: 30px;
    row-gap: 14px;
  }
  .set { grid-area: set; }
  .caption {
    grid-area: caption; margin: 6px 0 0; max-width: none; height: auto; min-height: calc(1.45em * 4); max-height: calc(1.45em * 8);
    place-content: start; text-align: left; text-wrap: pretty; font-size: clamp(19px, 1.65vw, 25px); line-height: 1.45;
  }
  .desk { grid-area: desk; flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 10px; }
  .mic { justify-content: center; flex: 1 1 auto; min-width: 0; }
  .type { flex: none; }
  .stat { min-height: 1.2em; }
  .picker { grid-area: picker; justify-items: start; }
  .themes { justify-content: flex-start; max-width: none; }
  .under { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'credit sw' 'looks looks'; gap: 8px 10px; }
  .credit { grid-area: credit; overflow: hidden; text-overflow: ellipsis; }
  .sw { grid-area: sw; }
  .looks { grid-area: looks; justify-content: flex-start; }
  .notice { grid-area: notice; text-align: left; text-wrap: pretty; min-height: 0; }
  .reel { grid-area: reel; min-height: 0; flex-direction: column; align-items: stretch; gap: 10px; }
  /* three buttons (Listen back, Upgrade the visuals, Download) on one line of the narrow column */
  .replay { align-self: flex-start; gap: 6px; }
  .replay .play { padding-inline: 13px; }
  .strip { flex: 1 1 auto; min-height: 0; flex-wrap: wrap; align-content: flex-start; overflow: hidden auto; }
  .links { margin: 0; justify-content: flex-start; }
}

/* the book on a window that is not tall: the options keep to one line and slide */
@media (min-width: 1000px) and (min-aspect-ratio: 3/2) and (max-height: 940px) {
  .looks { flex-wrap: nowrap; justify-content: flex-start; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .looks[data-more='yes'] { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); padding-right: 26px; }
  .looks::-webkit-scrollbar { display: none; }
}
@media (min-width: 1000px) and (min-aspect-ratio: 3/2) and (max-height: 800px) {
  .caption { min-height: calc(1.45em * 3); }
}
/* shorter still: the tiles keep to one row so the reel of scenes has room */
@media (min-width: 1000px) and (min-aspect-ratio: 3/2) and (max-height: 759px) {
  .themes { --rows-max: 1; }
  /* ... and the four buttons keep to one line: a little smaller, and "Upgrade the visuals" says "Upgrade" (its full name is still what a screen reader hears) */
  .replay { gap: 5px; }
  .replay .play { padding: 9px 11px; font-size: 13px; }
  .replay .play[data-short] { font-size: 0; }
  .replay .play[data-short]::after { content: attr(data-short); font-size: 13px; }
}

/* A wide window that is not wide enough for the book: talking, typing and the themes share one line,
   so the picture keeps its height. */
@media (min-width: 1000px) and (max-aspect-ratio: 1499/1000) and (min-height: 481px) {
  .studio {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto auto auto auto;
    grid-template-areas: 'set set set set' 'caption caption caption caption' '. desk themes .' 'looks looks looks looks' 'notice notice notice notice' 'reel reel reel reel';
    column-gap: 14px;
  }
  .set { grid-area: set; }
  .caption { grid-area: caption; }
  .desk { grid-area: desk; flex-wrap: nowrap; justify-content: flex-end; }
  .cam { width: 44px; height: 44px; }
  .type { flex: none; width: 210px; }
  .stat { display: none; }
  .picker { display: contents; }
  /* the page edges (36) + the button, the camera and the box (444) + three column gaps (42): what is left of the line is the tiles' */
  .themes { --rows-max: 1; grid-area: themes; width: min(calc(var(--n, 7) * 58px), calc(100vw - 522px)); max-width: none; align-self: center; }
  .themes button { padding-top: 0; }
  .under { grid-area: looks; justify-self: center; width: auto; max-width: 100%; }
  .sw { order: 3; }
  /* (with a row of options beside it there is no room for the credit here until the window is wider: the tile still says it) */
  .picker[data-opts='yes'] .credit { display: none; }
  .notice { grid-area: notice; }
  .reel { grid-area: reel; }
}

@media (min-width: 1150px) and (max-aspect-ratio: 1499/1000) and (min-height: 481px) {
  .picker[data-opts='yes'] .credit { display: block; }
}
@media (min-width: 1260px) and (max-aspect-ratio: 1499/1000) and (min-height: 481px) {
  .type { width: 300px; }
  .stat { display: block; }
  .themes { width: min(calc(var(--n, 7) * 58px), calc(100vw - 720px)); }
}

/* small or short screens: the page scrolls and the picture takes the full width */
@media (max-width: 760px), (max-height: 480px) {
  .app { height: auto; min-height: 100dvh; }
  .set { flex: none; container-type: inline-size; }
  .tube { width: 100cqw; border-radius: 10px; }
  /* the name and the pens on one line, the story's buttons on the next */
  .bar { padding-block: 10px 6px; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .brand { font-size: 20px; margin-right: auto; }
  .tools { display: contents; }
  .pens button { white-space: nowrap; }
  .desk { gap: 10px; }
  .talk { flex: 1 1 100%; justify-content: center; }
  .type { flex: 1 1 100%; }
  .stat { display: none; }
  .reel { flex-wrap: wrap; }
  .replay { flex: 0 1 auto; min-width: 0; }
  .strip { order: 3; flex-basis: 100%; }
  .notice { text-wrap: balance; }
  /* the options sit on one line and slide sideways under a thumb */
  .looks { flex-wrap: nowrap; justify-content: flex-start; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .looks[data-more='yes'] { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); padding-right: 26px; }
  .looks::-webkit-scrollbar { display: none; }
  .shelf-in { width: 100vw; border-left: 0; }
}
/* a phone with no height to spare, on a theme that has options: no line of its own for the credit;
   the switch for words leads the row of options instead */
@media (max-width: 760px) and (max-height: 799px) {
  .picker[data-opts='yes'] .under { flex-wrap: nowrap; justify-content: flex-start; gap: 8px; }
  .picker[data-opts='yes'] .credit { display: none; }
  .picker[data-opts='yes'] .looks { flex: 1 1 0; width: auto; }
}
@media (max-width: 380px) {
  .brand { font-size: 18px; }
  .pens button { padding: 5px 7px !important; }
}
@media (max-width: 420px) {
  .pens button { padding: 5px 9px; font-size: 12px; }
  .ghost { padding: 6px 10px; font-size: 12px; }
  .mic { flex: 1 1 auto; justify-content: center; }
  /* three buttons on one line (Play back, Upgrade the visuals, Download), and three options with their label */
  .replay { gap: 6px; }
  .play { padding: 10px 12px; font-size: 13px; }
  .looks { gap: 5px; }
  .looks .lbl { letter-spacing: 0.08em; margin-right: 2px; }
  .looks button { padding: 4px 9px 4px 5px; font-size: 12px; gap: 5px; }
  .looks button i { width: 24px; }
}
@media (max-width: 359px) {
  .replay { flex-wrap: wrap; }
}
