.inStudio {
  --paper: #eeeade;
  --ink: #312c37;
  --plum: #73588c;
  --green: #c7db9c;
  --cover-ink: var(--green);
  --cover-font: 27cqw;
  --mono: Consolas, "Courier New", monospace;
  color-scheme: light;
}

.inStudio #preview { color-scheme: dark; }

.story-width {
  width: min(1192px, calc(100% - clamp(40px, 10vw, 164px)));
  margin-inline: auto;
}

.chapter-title {
  margin: 0;
  font: 400 clamp(70px, 7.8vw, 120px)/.82 Jersey, monospace;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.chapter-title em { font-style: normal; color: var(--plum); }

.inStudio .story-width p {
  margin: 24px 0 0;
  font-size: clamp(16px, 1.21vw, 19px);
  line-height: 1.55;
  max-width: 40ch;
  color: inherit;
}

.inStudio :is(input, summary, button, a):focus-visible {
  outline: 3px solid #8759ad;
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.desk { --progress: 0; }

.desk h1 {
  translate: 0 calc(var(--progress) * -84px);
}

.desk .terminal {
  pointer-events: none;
  transform: translate3d(calc(var(--progress) * 3vw), calc(var(--progress) * 85px), 0)
    rotate(calc(var(--progress) * -6deg)) scale(calc(1 + var(--progress) * .1));
}

.studio-console {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  image-rendering: pixelated;
  filter: drop-shadow(8px 15px 0 #53455c26);
}

.phosphor-bar {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: phosphor-level 1.4s steps(5, end) infinite alternate paused;
}

.machine-running .phosphor-bar { animation-play-state: running; }
.inStudio:has(#preview[open]) .phosphor-bar { animation-play-state: paused; }

@keyframes phosphor-level {
  0% { transform: scaleY(.66); }
  28% { transform: scaleY(1.16); }
  57% { transform: scaleY(.44); }
  100% { transform: scaleY(.92); }
}

.desk .memo { translate: 0 calc(var(--progress) * -42px); }
.desk .disk { translate: 0 calc(var(--progress) * -58px); }

.desk-scroll {
  position: absolute;
  bottom: 3.4%;
  right: 4%;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #4a4052;
  font: 12px var(--mono);
  pointer-events: none;
}

.desk-scroll i {
  display: inline-block;
  font: 22px Jersey;
  animation: nudge-down 2.1s steps(5, end) infinite paused;
}

.machine-running .desk-scroll i { animation-play-state: running; }

@keyframes nudge-down {
  0%, 100% { transform: translateY(0); }
  60% { transform: translateY(5px); }
}

.layer-chapter {
  --progress: .72;
  --pin-height: clamp(550px, 90svh, 880px);
  color: #f4eee5;
  min-height: calc(var(--pin-height) + clamp(200px, 47svh, 500px));
  background: #302b37;
  border-block: 6px solid #514758;
}

.layer-layout {
  position: sticky;
  top: 0;
  min-height: var(--pin-height);
  display: grid;
  grid-template-columns: minmax(0, .84fr) minmax(0, 1.16fr);
  align-items: center;
  gap: 4%;
  padding-block: 42px;
}

.layer-intro { position: relative; z-index: 1; }
.layer-chapter .chapter-title em { color: #cfb5eb; }
.inStudio .layer-intro p { color: #d9d0df; max-width: 36ch; }

.layer-key {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  list-style: none;
  padding: 17px 0 0;
  margin: 25px 0 0;
  border-top: 1px solid #75677a;
  width: fit-content;
  font: 12px var(--mono);
}

.layer-key li { display: flex; align-items: center; gap: 7px; }
.layer-key li::before { content: ""; width: 9px; height: 9px; background: var(--green); }
.layer-key li:nth-child(2)::before { background: #b394c9; }
.layer-key li:nth-child(3)::before { background: #efd9b6; }

.layer-bench {
  height: clamp(350px, 38vw, 545px);
  position: relative;
  isolation: isolate;
}

.bench-floor {
  position: absolute;
  width: 88%;
  height: 57%;
  left: 7%;
  top: 48%;
  background: repeating-linear-gradient(0deg, #a292b132 0 1px, transparent 1px 20px),
    repeating-linear-gradient(90deg, #a292b132 0 1px, transparent 1px 20px);
  transform: rotateX(60deg) rotateZ(-33deg);
  mask-image: radial-gradient(ellipse at center, black 28%, transparent 77%);
}

.sheet {
  --dy: 0px;
  --dx: 0px;
  position: absolute;
  top: 48%;
  left: 50%;
  width: 65%;
  aspect-ratio: 1.24;
  border: 2px solid;
  transform: translate(-50%, -50%)
    translate3d(calc(var(--progress) * var(--dx)), calc(var(--progress) * var(--dy)), 0)
    rotateX(calc(34deg + var(--progress) * 20deg)) rotateZ(calc(-14deg - var(--progress) * 18deg));
}

.base-sheet {
  --dy: clamp(68px, 7.2vw, 112px);
  --dx: 14px;
  color: #829861;
  background: #c7d99e;
  box-shadow: -3px 4px #96ab79, -7px 9px #758962, -10px 14px #201d26;
  overflow: hidden;
}

.base-sheet img {
  position: absolute;
  right: -9%;
  top: 5%;
  width: 76%;
  opacity: .67;
  image-rendering: pixelated;
}

.print-bars {
  position: absolute;
  width: 22%;
  height: 7%;
  bottom: 8%;
  right: 7%;
  background: repeating-linear-gradient(90deg, #322d32 0 2px, transparent 2px 4px,
    #322d32 4px 5px, transparent 5px 8px, #322d32 8px 12px, transparent 12px 14px);
}

.vinyl-sheet {
  background: rgb(173 147 200 / 28%);
  border-color: #bca2cb;
  box-shadow: -3px 4px #897598;
}

.vinyl-sheet img {
  position: absolute;
  height: 91%;
  right: 5%;
  top: 4%;
  image-rendering: pixelated;
  transform: rotate(calc(var(--progress) * 68deg));
}

.type-sheet {
  --dy: clamp(-113px, -7.5vw, -70px);
  --dx: -14px;
  color: #e9d4b6;
  background: rgb(223 212 189 / 9%);
  box-shadow: -3px 4px #9e8d91;
}

.type-sheet b {
  position: absolute;
  left: 7%;
  bottom: 10%;
  font: 400 clamp(48px, 6.6vw, 100px)/.84 Jersey, monospace;
  color: #fbebd7;
  background: #352f3a;
  padding: 0 3% 1.8%;
}

.register { position: absolute; width: 12px; height: 12px; color: inherit; }
.register::before, .register::after { content: ""; position: absolute; background: currentColor; }
.register::before { width: 100%; height: 2px; top: 5px; }
.register::after { height: 100%; width: 2px; left: 5px; }
.register.tl { left: 6%; top: 7%; }
.register.br { right: 6%; bottom: 7%; }

.edit-chapter {
  --progress: .6;
  overflow: clip;
  background-color: #e5d9eb;
  background-image: radial-gradient(#79608632 .8px, transparent .8px);
  background-size: 9px 9px;
  color: var(--ink);
  border-bottom: 1px solid #97899f;
}

.edit-layout {
  display: grid;
  grid-template-columns: minmax(0, .87fr) minmax(0, 1.13fr);
  align-items: center;
  gap: 9%;
  padding-block: clamp(68px, 9vw, 145px);
}

.edit-controls {
  margin-top: 29px;
  width: min(100%, 350px);
  display: grid;
  grid-template-columns: 1fr;
}

.edit-controls > label, .edit-controls legend {
  color: #4b4052;
  font: 13px var(--mono);
}

#cover-title {
  width: 100%;
  margin: 7px 0 16px;
  padding: 8px 12px 7px;
  border: 1.5px solid #64576b;
  border-radius: 0;
  background: #f8f4eb;
  color: #312c37;
  box-shadow: 3px 3px #9f8cab;
  font: 32px/1 Jersey, monospace;
}

.edit-controls fieldset {
  display: flex;
  border: 0;
  padding: 0;
  margin: 0;
}

.edit-controls legend { padding: 0; }
.ink-options { display: flex; gap: 6px; }
.ink-swatch { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; position: relative; }
.ink-swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.ink-swatch span[aria-hidden] {
  width: 31px; height: 24px;
  border: 1px solid #756781;
  background: var(--swatch);
  box-shadow: 2px 2px #8e8197;
  pointer-events: none;
}
.ink-swatch input:checked + span {
  outline: 2px solid #44394d;
  outline-offset: 3px;
}
.ink-swatch input:focus-visible + span { outline: 3px dashed #56346e; outline-offset: 3px; }

.press-bed {
  position: relative;
  height: clamp(320px, 36vw, 520px);
  isolation: isolate;
}

.proof-shadow {
  position: absolute;
  left: 7%; bottom: 9%; width: 85%; height: 16%;
  background: #75647b24;
  transform: skew(-43deg) rotate(-6deg);
  clip-path: polygon(15% 0, 100% 15%, 72% 100%, 0 82%);
}

.album-jacket, .press-vinyl {
  position: absolute;
  width: 63%;
  aspect-ratio: 1;
  left: 8%;
  top: 50%;
}

.album-jacket {
  background: var(--cover-ink, var(--green));
  container-type: inline-size;
  overflow: hidden;
  color: #302a34;
  border: 2px solid currentColor;
  box-shadow: -2px 3px #e7dfcb, -4px 5px #675d63, -8px 10px #56425947;
  transform: translateY(-46%) rotate(calc(-10deg + var(--progress) * 5deg));
}

.jacket-rule { position: absolute; inset: 5%; border: 1px solid #3d37407a; }
.album-jacket > img {
  position: absolute;
  top: 8%; left: -6%;
  width: 114%; height: 50%;
  image-rendering: pixelated;
}

.album-jacket b {
  position: absolute;
  left: 8%; bottom: 16%;
  width: 85%;
  font: 400 var(--cover-font, 27cqw)/.9 Jersey, monospace;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}

.album-jacket .print-bars { left: 8%; bottom: 7.5%; height: 5%; width: 28%; }
.press-vinyl {
  image-rendering: pixelated;
  transform: translate(calc(12% + 38% * var(--progress)), calc(-53% - 13% * var(--progress)))
    rotate(calc(20deg + var(--progress) * 105deg));
}

.sequence-chapter {
  --progress: 0;
  --play: 0;
  --pin-height: clamp(610px, 90svh, 870px);
  color: #f2ede0;
  background: #292a26;
  border-block: 6px solid #4d5146;
  min-height: calc(var(--pin-height) + clamp(260px, 53svh, 570px));
}

.sequence-pin {
  position: sticky;
  top: 0;
  min-height: var(--pin-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(36px, 5vh, 70px);
}

.sequence-heading { margin-bottom: clamp(24px, 3vw, 40px); }
.sequence-heading .chapter-title { font-size: clamp(68px, 7.4vw, 110px); }
.sequence-heading .chapter-title em { color: var(--green); }
.inStudio .sequence-heading p { max-width: 68ch; margin-top: 16px; color: #dddcd0; }

.cutting-table {
  display: grid;
  grid-template-columns: 1.04fr 1fr;
  align-items: stretch;
  background: #dad9ca;
  color: #35372f;
  padding: clamp(12px, 1.6vw, 24px);
  gap: clamp(18px, 2.5vw, 38px);
  border: 2px solid #e1e1d3;
  box-shadow: 5px 6px #898b7c, 8px 10px #1e211d;
}

.motion-window {
  --arrive: clamp(0, calc(var(--play) * 2.5), 1);
  --letters: clamp(0, calc((var(--play) - .15) * 3.3), 1);
  position: relative;
  overflow: hidden;
  align-self: center;
  aspect-ratio: 16 / 10;
  container-type: inline-size;
  border: 3px solid #423e46;
  background: var(--cover-ink, var(--green));
  color: #352d38;
}

.motion-waves {
  position: absolute;
  right: -12%; bottom: -12%;
  width: 86%;
  opacity: .48;
  transform: translateX(calc(var(--play) * -15%));
  image-rendering: pixelated;
}

.motion-disc {
  position: absolute;
  right: -3%;
  top: -16%;
  width: 70%;
  image-rendering: pixelated;
  transform: translateX(calc(82% - var(--arrive) * 82%)) translateY(calc(var(--play) * 12%))
    rotate(calc(-32deg + var(--play) * 465deg));
}

.motion-title {
  position: absolute;
  left: 8%;
  bottom: 13%;
  max-width: 85%;
  padding: .04em .11em .10em;
  background: #302b35;
  color: #fff5df;
  font: 400 min(19cqw, var(--cover-font, 27cqw))/.87 Jersey, monospace;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
  clip-path: inset(0 calc(100% - var(--letters) * 100%) 0 0);
  transform: translateY(calc(22% - var(--letters) * 22%));
}

.timeline-console { min-width: 0; align-self: center; font-family: var(--mono); }
.counter-line, .track-label, .time-ruler, .render-count {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.counter-line {
  border-bottom: 1px solid #939484;
  padding: 0 0 8px;
  font-size: 13px;
}
.counter-line > span { letter-spacing: 1.6px; }
.counter-line b { font: 400 clamp(42px, 4.1vw, 64px)/.9 Jersey; font-variant-numeric: tabular-nums; }
.track-label { padding: 14px 0 8px; font: 12px var(--mono); }
.time-ruler { font-size: 10px; color: #5b5d52; padding-bottom: 5px; }
.tracks {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 10px 0 4px;
  background: repeating-linear-gradient(90deg, #999c8e73 0 1px, transparent 1px 6.25%);
  border-top: 1px solid #65685c;
}

.track { height: 23px; }
.track span {
  display: flex;
  align-items: center;
  height: 100%;
  border: 1px solid #718158;
  background: #bed296;
  padding-left: 8px;
  font: 11px var(--mono);
}
.record-track span { background: #bba6cb; border-color: #8d789e; }
.type-track span { margin-left: 15%; background: #e2b99a; border-color: #9a7d65; }

.playhead {
  position: absolute;
  top: 0; bottom: 0;
  left: clamp(0px, calc(var(--play) * 100%), calc(100% - 2px));
  border-left: 2px solid #3c3144;
  pointer-events: none;
}
.playhead::before {
  content: "";
  position: absolute;
  top: -6px; left: -7px;
  width: 12px; height: 14px;
  background: #3c3144;
  clip-path: polygon(0 0, 100% 0, 100% 50%, 50% 100%, 0 50%);
}
#frame-scrub { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: ew-resize; touch-action: pan-y; }
.tracks:focus-within { outline: 3px solid #77558d; outline-offset: 5px; }

.render-chapter {
  --progress: 1;
  background-color: #dae1cf;
  background-image: linear-gradient(#84997422 1px, transparent 1px), linear-gradient(90deg, #84997422 1px, transparent 1px);
  background-size: 20px 20px;
}
.render-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.13fr) minmax(0, .87fr);
  align-items: center;
  column-gap: 8%;
  padding-block: clamp(65px, 7vw, 114px);
  color: #303629;
}
.render-notes { grid-column: 2; grid-row: 1; }
.render-notes .chapter-title em { color: #536946; }
.render-count {
  max-width: 370px; margin: 28px 0 6px;
  font: 11px var(--mono); letter-spacing: .3px;
}
.render-count b { font-weight: 400; font-variant-numeric: tabular-nums; }
.render-meter { max-width: 370px; height: 8px; border: 1px solid #64715c; padding: 1px; }
.render-meter i {
  display: block; height: 100%; background: #566747;
  transform-origin: left;
  transform: scaleX(var(--progress));
}
.press-printer {
  grid-column: 1; grid-row: 1;
  position: relative;
  width: 100%;
  aspect-ratio: 280 / 212;
}
.press-printer > img {
  position: absolute;
  width: 100%;
  left: 0; top: 0;
  image-rendering: pixelated;
}
.paper-slot {
  position: absolute;
  left: 16.3%; top: 37.7%;
  width: 46.5%; height: 59%;
  overflow: hidden;
}
.render-paper {
  position: relative;
  width: 100%; height: 94%;
  background: #f6f0de;
  border: 1px solid #baafa1;
  color: #423a42;
  padding: 12% 10% 0;
  display: flex; flex-direction: column;
  gap: 8px;
  box-shadow: 2px 3px #766d7044;
  transform: translateY(calc(-91% + var(--progress) * 91%));
  font: clamp(10px, 1vw, 15px) var(--mono);
  clip-path: polygon(0 0,100% 0,100% 100%,95% 98%,90% 100%,85% 98%,80% 100%,75% 98%,70% 100%,65% 98%,60% 100%,55% 98%,50% 100%,45% 98%,40% 100%,35% 98%,30% 100%,25% 98%,20% 100%,15% 98%,10% 100%,5% 98%,0 100%);
}
.render-paper::before, .render-paper::after {
  content: "";
  position: absolute;
  top: 2%; bottom: 2%; width: 5px;
  background: radial-gradient(circle at center, #a4a195 0 2px, transparent 2.4px) center top / 5px 12px repeat-y;
}
.render-paper::before { left: 2%; }
.render-paper::after { right: 2%; }
.paper-top { font: 10px var(--mono); letter-spacing: 1px; border-bottom: 1px dashed #a2999c; padding-bottom: 7px; }
.render-paper strong { overflow-wrap: anywhere; font: 400 clamp(21px, 2.8vw, 42px)/.92 Jersey; }
.render-paper .print-bars { left: 10%; bottom: 10%; width: 45%; height: 7%; }

.start-chapter { color: var(--ink); background: var(--paper); }
.start-layout {
  display: grid; grid-template-columns: .78fr 1.22fr; gap: 10%;
  padding-block: clamp(64px, 8vw, 127px);
}
.studio-questions { border-top: 1px solid #948a93; }
.studio-questions details { border-bottom: 1px solid #a0989e; }
.studio-questions summary {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 15px;
  padding: 16px 0;
  font: 400 clamp(24px, 2.4vw, 36px)/1.1 Jersey;
}
.studio-questions summary::-webkit-details-marker { display: none; }
.studio-questions summary::after { content: "+"; color: #70577f; font: 22px var(--mono); }
.studio-questions details[open] summary::after { content: "−"; }
.inStudio .studio-questions p { font-size: 16px; max-width: 54ch; margin: 0; padding: 0 26px 20px 0; }
.studio-imprint {
  display: flex; align-items: center; justify-content: space-between; gap: 15px;
  padding: 17px max(5%, calc((100% - 1192px) / 2));
  background: #312c37; color: #f4ede4;
  font: 12px var(--mono);
}
.studio-imprint span:first-child { font: 30px/1 Jersey; color: #dec9ea; }

@media (max-width: 850px) {
  .edit-layout { gap: 4%; }
  .layer-layout { gap: 0; }
  .layer-key { gap: 10px; font-size: 11px; }
  .render-layout { gap: 4%; }
  .cutting-table { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .story-width { width: min(90%, 540px); }
  .chapter-title, .sequence-heading .chapter-title { font-size: clamp(58px, 12.8vw, 82px); }
  .inStudio .story-width p { margin-top: 15px; }
  .desk-scroll { right: 4%; bottom: 4%; }
  .desk-scroll span { display: none; }
  .desk-scroll i { font-size: 29px; }
  .disklabel { display: flex; flex-direction: column; justify-content: center; padding: 3% 5%; }
  .disklabel strong { font-size: clamp(19px, 5.2vw, 27px); white-space: nowrap; }
  .layer-chapter { --pin-height: auto; min-height: 0; }
  .layer-layout {
    position: relative; grid-template-columns: 1fr; padding-block: 54px 18px;
  }
  .layer-intro .chapter-title br { display: none; }
  .layer-intro .chapter-title br::after { content: " "; }
  .layer-key { margin-top: 15px; padding-top: 12px; }
  .layer-bench { height: clamp(295px, 76vw, 440px); }
  .sheet { width: 59%; }
  .base-sheet { --dy: 54px; }
  .type-sheet { --dy: -60px; }
  .type-sheet b { font-size: clamp(44px, 10vw, 63px); }
  .edit-layout { grid-template-columns: 1fr; padding-block: 48px 18px; gap: 10px; }
  .edit-controls { margin-top: 20px; width: min(100%, 370px); }
  .press-bed { height: clamp(282px, 78vw, 410px); }
  .sequence-chapter { min-height: 0; }
  .sequence-pin { position: relative; min-height: 0; padding-block: 48px; }
  .sequence-heading { margin-bottom: 19px; }
  .cutting-table { grid-template-columns: 1fr; gap: 14px; }
  .counter-line b { font-size: 38px; }
  .track-label { padding-block: 8px 5px; }
  .track { height: 20px; }
  .render-layout { grid-template-columns: 1fr; padding-block: 52px 16px; gap: 10px; }
  .render-notes, .press-printer { grid-column: auto; grid-row: auto; }
  .press-printer { width: min(100%, 440px); justify-self: center; }
  .render-count { margin-top: 18px; }
  .paper-top { font-size: 8px; padding-bottom: 4px; }
  .render-paper { gap: 4px; padding-top: 9%; }
  .start-layout { grid-template-columns: 1fr; gap: 27px; padding-block: 48px; }
  .start-layout .chapter-title br { display: none; }
  .studio-imprint { font-size: 10px; }
}

@media (min-width: 681px) and (max-height: 620px) {
  .scene-pin { position: relative; min-height: 0; }
  .layer-chapter, .sequence-chapter { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .layer-chapter, .sequence-chapter { min-height: 0; }
  .scene-pin { position: relative; min-height: auto; padding-block: 50px; }
  .scroll-instruction, .desk-scroll { display: none; }
  .desk h1, .desk .memo, .desk .disk { translate: none; }
  .desk .terminal { transform: none; }
}
