:root {
  --ink: #1b160f;
  --ink-soft: #4a4034;
  --paper: #efe4cf;
  --paper-2: #e6d8bc;
  --rule: rgba(27, 22, 15, 0.1);
  --room: #221c16;
  --room-deep: #14110d;
  --rust: #b5361c;
  --rust-deep: #8c2714;
  --dust: #8d7f6a;
  --cream: #f6eedc;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 50% -10%, #3a2e22, transparent 55%),
    var(--room-deep);
  font-family: "IBM Plex Sans", sans-serif;
  line-height: 1.5;
}

.grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.045;
  pointer-events: none;
  mix-blend-mode: overlay;
  z-index: 8;
}

.masthead,
.colophon {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--cream);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.masthead {
  padding: 28px 0 18px;
}

.colophon {
  padding: 22px 0 40px;
  justify-content: center;
  color: #b7a790;
}

.brand {
  margin: 0;
  font-family: "Instrument Serif", serif;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  text-transform: none;
}

.clock,
.colophon p {
  margin: 0;
}

main {
  padding-bottom: 8px;
}

body.is-cut .masthead,
body.is-cut .sheet {
  width: min(1100px, calc(100% - 32px));
}

.sheet {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 28px 1fr;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 90px),
    repeating-linear-gradient(
      to bottom,
      transparent 0 31px,
      var(--rule) 31px 32px
    ),
    var(--paper);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 24px 60px rgba(0, 0, 0, 0.35);
  min-height: 640px;
}

.sprockets {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  border-right: 1px solid rgba(27, 22, 15, 0.08);
  background: color-mix(in srgb, var(--paper-2) 70%, transparent);
}

.sprockets span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--room-deep);
  opacity: 0.22;
  box-shadow: 0 0 0 2px rgba(27, 22, 15, 0.04);
}

.sheet-body {
  padding: 36px 36px 40px 28px;
}

.kicker {
  margin: 0 0 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rust);
}

h1,
h2 {
  margin: 0;
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.3rem, 6vw, 3.5rem);
}

h1 em {
  font-style: italic;
}

h2 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.lede {
  max-width: 34rem;
  margin: 16px 0 32px;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dust);
}

#topic {
  width: 100%;
  resize: none;
  border: 0;
  border-bottom: 2px solid var(--ink);
  padding: 4px 0 10px;
  background: transparent;
  color: var(--ink);
  font-family: "Instrument Serif", serif;
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  line-height: 1.25;
  outline: none;
}

#topic::placeholder {
  color: rgba(27, 22, 15, 0.28);
}

#topic:focus {
  border-bottom-color: var(--rust);
}

.formats {
  margin: 28px 0 0;
  padding: 0;
  border: 0;
}

.formats-world {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

.formats legend {
  padding: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dust);
}

.format-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
}

.format-row button {
  appearance: none;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  background: none;
  color: var(--ink-soft);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.98rem;
  cursor: pointer;
}

.format-row button[aria-pressed="true"] {
  color: var(--rust);
  border-bottom-color: var(--rust);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 22px;
  margin-top: 36px;
}

.btn-primary,
.btn-ghost {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.btn-primary {
  padding: 14px 28px;
  background: var(--rust);
  color: #fff8ef;
}

.btn-primary:hover:not(:disabled) {
  background: var(--rust-deep);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: wait;
}

.btn-ghost {
  padding: 14px 0;
  background: none;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
}

.hint {
  margin: 0;
  max-width: 18rem;
  color: var(--dust);
  font-size: 0.82rem;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 16px;
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.examples p {
  margin: 0 8px 0 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dust);
}

.examples button {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-style: italic;
  font-family: "Instrument Serif", serif;
  font-size: 1.1rem;
  cursor: pointer;
}

.examples button:hover {
  color: var(--rust);
}

.cut-head {
  margin-bottom: 22px;
}

.hook {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.slate {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}

.slate li {
  display: grid;
  grid-template-columns: 1.4rem 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--dust);
  font-size: 0.92rem;
}

.slate li[data-state="active"] {
  color: var(--ink);
}

.slate li[data-state="done"] {
  color: var(--ink-soft);
}

.slate li[data-state="done"] .mark::before {
  content: "×";
}

.slate li[data-state="active"] .mark::before {
  content: "›";
  color: var(--rust);
}

.slate .mark::before {
  content: "·";
  font-family: "IBM Plex Mono", monospace;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px 22px;
  margin: 8px 0 12px;
  align-items: start;
}

.stage:has(.notes:not([hidden])) {
  grid-template-columns: minmax(0, 1fr) minmax(200px, 260px);
}

@media (min-width: 861px) {
  .stage:has(.notes:not([hidden])) .notes {
    padding-left: 16px;
    border-left: 1px solid var(--rule);
  }
}

.notes {
  padding: 2px 0 0;
  min-height: 8rem;
}

.notes-kicker {
  margin: 0 0 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rust);
}

.notes h3 {
  margin: 0 0 8px;
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.15;
  color: var(--ink);
}

.notes #note-body {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.45;
}

.note-figure {
  margin: 12px 0 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  contain: layout paint;
}

.note-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 168px;
  object-fit: contain;
  background: transparent;
  transform-origin: top center;
  transform: translateZ(0) scaleY(0.03);
  opacity: 0;
}

.note-figure img.is-drawing {
  animation: ink-draw 0.32s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.note-figure img.is-drawn {
  transform: none;
  opacity: 1;
}

@keyframes ink-draw {
  from {
    transform: translateZ(0) scaleY(0.03);
    opacity: 0.75;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.notes.is-fresh h3,
.notes.is-fresh #note-body {
  animation: note-in 280ms ease-out;
}

@keyframes note-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.stage-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0c0a08;
  overflow: hidden;
}

.stage-screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
  pointer-events: none;
  z-index: 0;
}

.stage-screen video.is-front {
  z-index: 1;
}

.reel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 2px 0;
}

.reel button {
  appearance: none;
  height: 4px;
  padding: 0;
  border: 0;
  background: rgba(27, 22, 15, 0.16);
  cursor: pointer;
}

.reel button[data-ready="true"] {
  background: rgba(27, 22, 15, 0.35);
}

.reel button[data-active="true"] {
  background: var(--rust);
}

.reel button:disabled {
  cursor: default;
}

.stage-meta {
  display: flex;
  justify-content: flex-end;
  padding: 8px 2px 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dust);
}

.hold,
.punch,
.error {
  margin: 16px 0 0;
}

.hold {
  color: var(--dust);
  font-style: italic;
}

.punch {
  font-family: "Instrument Serif", serif;
  font-size: 1.35rem;
  font-style: italic;
}

.error {
  color: var(--rust);
}

.cut-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: center;
  margin-top: 28px;
}

@media (max-width: 860px) {
  .stage:has(.notes:not([hidden])) {
    grid-template-columns: 1fr;
  }

  .notes {
    padding-top: 12px;
    border-top: 1px solid var(--rule);
  }
}

@media (max-width: 640px) {
  .sheet {
    grid-template-columns: 18px 1fr;
    min-height: 0;
  }

  .sheet-body {
    padding: 28px 20px 32px 14px;
  }

  .actions {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }

  .note-figure img {
    transform: none;
    opacity: 1;
  }
}

html.is-embed,
html.is-embed body {
  height: 100%;
  min-height: 100%;
}

html.is-embed .masthead,
html.is-embed .colophon,
html.is-embed .grain {
  display: none;
}

html.is-embed main {
  min-height: 100%;
  padding: 16px 0 24px;
}

html.is-embed .sheet {
  min-height: calc(100dvh - 40px);
}
