/*
  Source Serif 4: Copyright 2014-2023 Adobe, Reserved Font Name "Source".
  IBM Plex Mono: Copyright 2017 IBM Corp., Reserved Font Name "Plex".
  Both are distributed under the SIL Open Font License 1.1 from their official repositories.
  License texts: https://github.com/adobe-fonts/source-serif/blob/release/LICENSE.md
  and https://github.com/IBM/plex/blob/master/LICENSE.txt
*/
@font-face {
  font-family: "Source Serif 4";
  src: url("assets/fonts/SourceSerif4-Regular.ttf.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("assets/fonts/SourceSerif4-It.ttf.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("assets/fonts/SourceSerif4-Semibold.ttf.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper: #f4efe4;
  --paper-deep: #e9e1d4;
  --sheet: #fbf9f3;
  --ink: #1b1815;
  --muted: #6b655c;
  --rule: #ded6c6;
  --signal: #d6421f;
  --oxblood: #5a1f18;
  --display: "Source Serif 4", Georgia, serif;
  --text: "Source Serif 4", Georgia, serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", Helvetica, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
  --gutter: clamp(1rem, 3.5vw, 3.5rem);
  --max-width: 96rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html[data-welcome-state="first"] .studio-app > .app-view,
html[data-welcome-state="first"] .studio-app > .takeaway-scrim {
  visibility: hidden;
}

html[data-welcome-state="returning"] .welcome {
  display: none;
}

html {
  min-width: 0;
  color-scheme: light;
  background: var(--paper);
}

body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(27, 24, 21, 0.015) 1px, transparent 1px) 0 0 / 3px 3px,
    var(--paper);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

button {
  color: inherit;
}

::selection {
  color: var(--sheet);
  background: var(--signal);
}

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 200;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--sheet);
  background: var(--ink);
  font: 800 0.72rem/1 var(--sans);
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.transport-warning {
  display: none;
  margin: 0;
  padding: 0.8rem var(--gutter);
  color: var(--sheet);
  background: var(--oxblood);
  font: 0.78rem/1.5 var(--sans);
}

.transport-warning code {
  font-family: var(--mono);
}

.file-mode .transport-warning {
  display: block;
}

.studio-app,
.app-view {
  min-width: 0;
  min-height: 100svh;
}

.studio-bar,
.composer-bar {
  display: flex;
  width: min(calc(100% - 2 * var(--gutter)), var(--max-width));
  min-height: 5rem;
  margin-inline: auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  display: inline-flex;
  gap: 0.25em;
  align-items: baseline;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.55rem, 2vw, 2rem);
  letter-spacing: -0.045em;
  line-height: 1;
}

.wordmark__studio {
  color: var(--signal);
  font-family: var(--sans);
  font-size: 0.4em;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transform: translateY(-0.12em);
}

.edition-mark,
.eyebrow,
.control-label,
.article-kicker,
.article-folio,
.layout-metrics dt,
.welcome-count,
.landing-credit {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  line-height: 1.35;
  text-transform: uppercase;
}

.edition-mark {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  color: var(--signal);
}

.primary-action,
.quiet-action,
.back-action,
.context-link,
.take-action,
.welcome-skip,
.welcome-back,
.welcome-next,
.guide-skip {
  border-radius: 0;
}

.primary-action {
  min-height: 3rem;
  padding: 0.72rem 1.25rem;
  border: 1px solid var(--ink);
  color: var(--sheet);
  background: var(--ink);
  font-family: var(--text);
  font-size: 1.03rem;
  transition: color 160ms ease, background 160ms ease;
}

.primary-action:hover {
  border-color: var(--signal);
  background: var(--signal);
}

.quiet-action,
.context-link,
.back-action,
.guide-skip,
.welcome-skip,
.welcome-back {
  padding: 0.25rem 0.05rem;
  border: 0;
  border-bottom: 1px solid #b7ae9c;
  background: transparent;
}

.quiet-action:hover,
.context-link:hover,
.back-action:hover,
.guide-skip:hover,
.welcome-skip:hover,
.welcome-back:hover {
  color: var(--signal);
  border-bottom-color: var(--signal);
}

/* Landing */

.landing-view {
  display: flex;
  flex-direction: column;
}

.landing-shell {
  display: grid;
  grid-template-columns: minmax(19rem, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(2rem, 4vw, 4.75rem);
  width: min(calc(100% - 2 * var(--gutter)), var(--max-width));
  min-height: calc(100svh - 9rem);
  margin-inline: auto;
  padding-block: clamp(2rem, 4.5vw, 4.75rem) 2rem;
}

.landing-lead {
  min-width: 0;
}

.landing-lead h1 {
  max-width: 11ch;
  margin: 1rem 0 0;
  font-family: var(--display);
  font-size: clamp(3rem, 5.6vw, 5.8rem);
  font-weight: 400;
  letter-spacing: -0.06em;
  line-height: 0.92;
}

.landing-lede {
  max-width: 33rem;
  margin: 1.35rem 0 0;
  color: #3a352f;
  font-size: clamp(1rem, 1.35vw, 1.18rem);
  line-height: 1.58;
}

.landing-actions {
  display: flex;
  margin-top: 1.7rem;
  flex-wrap: wrap;
  gap: 0.85rem 1.2rem;
  align-items: center;
}

.outcome-index {
  margin-top: clamp(1.7rem, 3vw, 2.8rem);
  border-top: 1px solid var(--rule);
}

.outcome-choice {
  display: flex;
  width: 100%;
  min-height: 4.25rem;
  padding: 0.8rem 0.2rem 0.8rem 0;
  flex-direction: column;
  gap: 0.12rem;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
}

.outcome-choice__title {
  color: var(--muted);
  font-family: var(--display);
  font-size: clamp(1.2rem, 1.7vw, 1.55rem);
  line-height: 1.08;
  transition: color 160ms ease;
}

.outcome-choice__line {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.74rem;
  line-height: 1.45;
}

.outcome-choice:hover .outcome-choice__title {
  color: var(--ink);
}

.outcome-choice[aria-pressed="true"] .outcome-choice__title {
  color: var(--signal);
}

.landing-proof-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}

.landing-proof {
  width: 100%;
  animation: soft-in 350ms ease both;
}

.landing-proof-open {
  margin-top: 1rem;
  font-size: 0.98rem;
}

.proof-boundary {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font: 0.64rem/1.55 var(--mono);
}

.landing-credit {
  width: min(calc(100% - 2 * var(--gutter)), var(--max-width));
  margin-inline: auto;
  padding-block: 1rem 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: none;
}

/* Proof and study surfaces */

.proof-frame {
  position: relative;
  width: 100%;
  min-height: 30rem;
  overflow: hidden;
  border: 1px solid rgba(28, 24, 20, 0.13);
  background: var(--paper-deep);
}

[data-proof-size="mini"] .proof-frame {
  min-height: clamp(21rem, 48vh, 31rem);
}

.proof-visual-lines {
  position: absolute;
  inset: 0;
  z-index: 1;
  user-select: text;
}

.proof-line {
  position: absolute;
  display: block;
  margin: 0;
  white-space: pre;
  cursor: text;
  user-select: text;
}

.proof-object {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.premise-proof {
  padding: clamp(2rem, 5vw, 4rem);
  background:
    radial-gradient(circle at 76% 18%, rgba(214, 66, 31, 0.08), transparent 24%),
    var(--sheet);
  box-shadow: 0 2.2rem 5rem -3.6rem rgba(27, 24, 21, 0.45);
}

.premise-proof .proof-visual-lines {
  inset: clamp(2rem, 5vw, 4rem);
}

.premise-orb {
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 1.2rem 2.5rem rgba(91, 35, 21, 0.2);
}

[data-proof-kind="flow-hero"],
[data-proof-kind="elements"],
[data-proof-kind="artemis-ii"] {
  width: 100%;
  min-width: 0;
}

.reading-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.4rem;
  align-items: center;
  margin-top: 0.85rem;
}

.reading-rail > button:not(.context-link),
.motion-actions button {
  min-height: 2.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(28, 24, 20, 0.2);
  background: transparent;
  font: 750 0.72rem/1 var(--sans);
}

/* Welcome */

.welcome {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  min-width: 0;
  min-height: 100svh;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}

.welcome-top,
.welcome-nav {
  display: flex;
  min-height: 5rem;
  padding-inline: var(--gutter);
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.welcome-skip,
.guide-skip {
  color: var(--muted);
  font: 800 0.65rem/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.welcome-body {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
}

.welcome-screen {
  display: grid;
  width: 100%;
  min-height: 0;
  padding: 0 var(--gutter) 1.5rem;
  grid-template-columns: minmax(18rem, 0.78fr) minmax(0, 1.22fr);
  gap: clamp(2rem, 4vw, 4.5rem);
  align-items: center;
  animation: welcome-screen-in 240ms var(--ease) both;
}

.welcome-copy {
  max-width: 30rem;
}

.welcome-copy h2,
.guide-card h1,
.reading-head h1,
.takeaway-modal h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -0.05em;
  line-height: 0.98;
}

.welcome-copy h2 {
  margin-top: 0.9rem;
  font-size: clamp(2.65rem, 5vw, 5rem);
}

.welcome-copy > p:not(.eyebrow) {
  margin: 1.2rem 0 0;
  color: #3a352f;
  font-size: clamp(1rem, 1.35vw, 1.15rem);
  line-height: 1.6;
}

.welcome-copy .quiet-note {
  color: var(--muted);
  font: 0.7rem/1.6 var(--mono);
}

.welcome-copy .closing-line {
  font-style: italic;
}

.welcome-stage {
  min-width: 0;
}

.welcome-nav {
  border-top: 1px solid var(--rule);
}

.welcome-count {
  color: var(--muted);
}

.welcome-nav-actions {
  display: flex;
  max-width: 75%;
  align-items: center;
  gap: 1.25rem;
}

.welcome-closing {
  color: var(--muted);
  font-style: italic;
}

.welcome-back:disabled {
  visibility: hidden;
}

.welcome-next {
  min-height: 2.85rem;
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--ink);
  color: var(--sheet);
  background: var(--ink);
  font-size: 1rem;
}

.welcome-next:hover {
  border-color: var(--signal);
  background: var(--signal);
}

.welcome-next.is-final {
  min-height: 3.35rem;
  padding-inline: 1.55rem;
  border-color: var(--signal);
  background: var(--signal);
  font-size: 1.1rem;
  box-shadow: 0 1.1rem 2.7rem -1rem rgba(214, 66, 31, 0.48);
}

/* Guided creation and composer */

.composer-view {
  display: flex;
  flex-direction: column;
}

.composer-bar {
  flex: none;
  border-bottom: 0;
}

.back-action {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 1rem;
}

.take-action {
  display: inline-flex;
  min-height: 2.6rem;
  padding: 0.45rem 0.8rem;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--rule);
  background: var(--sheet);
  animation: fade-up 350ms ease both;
}

.take-action > span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--signal);
}

.composer-main {
  display: flex;
  min-width: 0;
  flex: 1;
  padding: 0 var(--gutter) 2.5rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.guide-card {
  width: min(100%, 52rem);
  padding: clamp(2rem, 5vw, 4rem);
  border: 1px solid var(--rule);
  background: var(--sheet);
  box-shadow: 0 2rem 5rem -3rem rgba(27, 24, 21, 0.45);
}

.guide-card h1 {
  margin-top: 0.75rem;
  font-size: clamp(2.8rem, 5vw, 4.6rem);
}

.guide-card > p:not(.eyebrow) {
  max-width: 34rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.guide-card textarea,
.text-editor-card textarea,
.reading-editor textarea,
.scene-import textarea {
  width: 100%;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  resize: vertical;
}

.guide-card textarea {
  min-height: 10rem;
  margin-top: 1.5rem;
  padding: 0;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  line-height: 1.55;
}

.guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.25rem;
  align-items: center;
  margin-top: 1.8rem;
}

.guide-skip {
  margin-left: auto;
}

.intent-list {
  margin-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.intent-list button {
  display: flex;
  width: 100%;
  padding: 1rem 0.2rem;
  flex-direction: column;
  gap: 0.2rem;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
}

.intent-list button:hover {
  color: var(--signal);
}

.intent-list span {
  font-size: 1.25rem;
}

.intent-list small {
  color: var(--muted);
  font-family: var(--sans);
  line-height: 1.45;
}

.studio-surface {
  width: min(100%, 74rem);
  margin-inline: auto;
}

.composer-tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 1.2rem;
  padding: 0.25rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: var(--sheet);
}

.composer-tabs button {
  min-height: 2.65rem;
  padding: 0.55rem 1rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.composer-tabs button.is-selected,
.composer-tabs button[aria-selected="true"] {
  color: var(--sheet);
  background: var(--ink);
}

.text-editor-card {
  width: min(100%, 52rem);
  margin-inline: auto;
  padding: clamp(2rem, 5vw, 4rem);
  border: 1px solid var(--rule);
  background: var(--sheet);
  box-shadow: 0 2rem 5rem -3rem rgba(27, 24, 21, 0.4);
}

.text-editor-card label,
.reading-editor label,
.scene-import > div > label {
  display: block;
  color: var(--signal);
  font: 800 0.65rem/1.3 var(--sans);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.text-editor-card textarea {
  min-height: 15rem;
  margin-top: 1rem;
  padding: 0;
  font-size: clamp(1.25rem, 2.2vw, 1.65rem);
  line-height: 1.55;
}

.text-editor-card p {
  color: var(--muted);
}

.text-next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.text-next-actions button {
  min-height: 2.6rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--ink);
  background: transparent;
}

.text-next-actions button:hover {
  color: var(--sheet);
  background: var(--ink);
}

.live-composer {
  min-width: 0;
}

.workspace-header {
  display: flex;
  min-height: 5rem;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 0.85rem;
}

.workspace-header h2 {
  margin: 0.35rem 0 0;
  font-family: var(--display);
  font-size: clamp(2rem, 3.5vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 1;
}

.layout-metrics {
  display: flex;
  gap: clamp(0.85rem, 2vw, 1.7rem);
  margin: 0;
}

.layout-metrics div {
  min-width: 3.5rem;
}

.layout-metrics dt {
  color: var(--muted);
}

.layout-metrics dd {
  margin: 0.2rem 0 0;
  font-family: var(--display);
  font-size: 1.08rem;
}

.stage {
  display: grid;
  min-height: 0;
  padding: clamp(0.65rem, 2.5vw, 2.2rem);
  overflow: hidden;
  place-items: start center;
  border: 1px solid var(--rule);
  background:
    linear-gradient(rgba(72, 51, 37, 0.035) 1px, transparent 1px) 0 0 / 100% 2.2rem,
    var(--paper-deep);
}

.composition-page {
  --page-pad: 42px;
  position: relative;
  width: 100%;
  padding: var(--page-pad);
  overflow: hidden;
  background: var(--sheet);
  box-shadow: 0 1.1rem 3.8rem rgba(38, 25, 17, 0.1);
}

.article-folio {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--ink);
}

.article-folio p {
  margin: 0;
}

.article-kicker {
  margin: clamp(2rem, 5vw, 4rem) 0 0.7rem;
  color: var(--signal);
}

.article-header h3 {
  max-width: 10ch;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.7rem, 5.5vw, 5.5rem);
  font-weight: 400;
  letter-spacing: -0.058em;
  line-height: 0.91;
}

.article-deck {
  max-width: 36rem;
  margin: 1.15rem 0 0;
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  line-height: 1.4;
}

.author-editorial {
  max-width: 42rem;
  margin-top: clamp(2.4rem, 5vw, 4.5rem);
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.author-editorial__kicker {
  margin: 0 0 0.55rem;
  color: var(--signal);
  font: 800 0.68rem/1.3 var(--sans);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.author-editorial h3 {
  max-width: 15ch;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 3.7rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.author-editorial__deck {
  max-width: 34rem;
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}

.flow-region {
  position: relative;
  min-height: 0;
  margin-top: clamp(2.4rem, 4vw, 4rem);
}

.flow-lines {
  position: absolute;
  z-index: 1;
  inset: 0;
  user-select: text;
}

.flow-line,
.flow-character {
  position: absolute;
  display: block;
  margin: 0;
  white-space: pre;
  cursor: text;
  user-select: text;
}

.flow-character {
  transform-origin: 50% 50%;
  will-change: transform;
}

.empty-state {
  position: absolute;
  z-index: 3;
  top: 1rem;
  left: 0;
  max-width: 30rem;
  margin: 0;
  padding-left: 1rem;
  border-left: 2px solid var(--signal);
  color: var(--muted);
  font-size: 1.15rem;
}

.embed-object {
  position: absolute;
  z-index: 4;
  display: grid;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0.8rem;
  align-content: center;
  touch-action: none;
  user-select: none;
  color: var(--sheet);
  background: var(--oxblood);
  box-shadow: 0 0.8rem 2.1rem rgba(57, 25, 17, 0.22);
  cursor: grab;
}

.embed-object:active {
  cursor: grabbing;
}

.embed-object--circle,
.embed-object--ellipse {
  place-content: center;
  border-radius: 50%;
  text-align: center;
}

.embed-object--circle {
  background: var(--signal);
}

.embed-object--ellipse {
  background: var(--ink);
}

.embed-object--image {
  place-content: stretch;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--oxblood);
  background:
    linear-gradient(135deg, rgba(214, 66, 31, 0.08) 25%, transparent 25%) 0 0 / 1rem 1rem,
    var(--paper-deep);
}

.embed-object__image,
.embed-object__hull {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.embed-object__image {
  object-fit: contain;
}

.embed-object__hull {
  z-index: 2;
  overflow: visible;
}

.embed-object__hull polygon {
  fill: rgba(214, 66, 31, 0.08);
  stroke: var(--signal);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.embed-object__placeholder {
  z-index: 1;
  align-self: center;
  padding: 0.7rem;
  color: var(--oxblood);
  font: 800 0.58rem/1.45 var(--sans);
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.embed-object--image .embed-object__index,
.embed-object--image .embed-object__label,
.embed-object--image .embed-object__rule {
  display: none;
}

.embed-object__index {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  font: 850 0.53rem/1 var(--sans);
  letter-spacing: 0.12em;
}

.embed-object__label {
  font-family: var(--display);
  font-size: clamp(1rem, 2vw, 1.55rem);
  font-weight: 400;
}

.embed-object__rule {
  display: block;
  width: 58%;
  height: 1px;
  margin-top: 0.65rem;
  background: currentColor;
}

.composer-context {
  min-height: 4.5rem;
  padding: 0.9rem 0.2rem;
  border-bottom: 1px solid var(--rule);
}

.composer-context section {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  align-items: center;
  justify-content: space-between;
}

.composer-context p,
.studio-status {
  margin: 0;
  color: var(--muted);
  font: 0.7rem/1.5 var(--sans);
}

.viewport-note {
  flex-basis: 100%;
  color: var(--oxblood) !important;
  font-weight: 700 !important;
}

.position-readout {
  font-family: var(--mono) !important;
  white-space: nowrap;
}

.behavior-interaction {
  width: 100%;
}

.motion-actions {
  display: flex;
  gap: 0.5rem;
}

.control-rail {
  margin-top: 0.8rem;
  border-top: 1px solid var(--ink);
}

.control-panel {
  padding-block: 0.4rem;
}

.control-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding-block: 0.65rem;
  border-bottom: 1px solid var(--rule);
}

.control-label {
  min-width: 7rem;
  color: var(--muted);
}

.control-line > button,
.behavior-options > button {
  min-height: 2.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--rule);
  background: transparent;
  font: 750 0.7rem/1.3 var(--sans);
}

.control-line > button.is-selected,
.control-line > button[aria-checked="true"],
.behavior-options > button.is-selected,
.behavior-options > button[aria-checked="true"] {
  color: var(--sheet);
  background: var(--ink);
}

.control-details,
.image-controls,
.behavior-values {
  margin: 0;
  padding: 0.8rem 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
}

.shape-dimensions,
.common-controls__body,
.editorial-context__body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem 1rem;
  margin-top: 0.8rem;
}

.shape-dimensions label,
.common-controls__body label,
.editorial-context__body label,
.file-field,
.text-field,
.check-field,
.range-field {
  min-width: 0;
  color: #4d453f;
  font: 700 0.7rem/1.4 var(--sans);
}

.shape-dimensions label > span,
.common-controls__body label > span:first-child,
.editorial-context__body label > span:first-child,
.file-field > span:first-child,
.text-field > span:first-child,
.range-field > span:first-child {
  display: block;
  margin-bottom: 0.35rem;
}

.shape-dimensions label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(5rem, auto) auto;
  gap: 0.45rem;
  align-items: center;
}

.shape-dimensions label > span {
  margin: 0;
}

.shape-dimensions input,
select,
input[type="text"],
input[type="file"],
.scene-import textarea {
  width: 100%;
  min-height: 2.4rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  color: var(--ink);
  background: rgba(251, 249, 243, 0.72);
}

.image-controls > * + * {
  margin-top: 0.8rem;
}

.image-controls p {
  margin-bottom: 0;
  color: var(--muted);
  font: 0.68rem/1.55 var(--sans);
}

.attachment-state {
  padding: 0.65rem 0.75rem;
  border-left: 2px solid var(--signal);
  color: var(--oxblood) !important;
  background: rgba(214, 66, 31, 0.06);
}

.check-field {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
}

.range-field > span:last-child {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--signal);
}

.range-field output {
  min-width: 3.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-align: right;
}

.layout-actions {
  align-items: end;
}

.layout-actions .range-field {
  flex: 1;
}

.behavior-values legend {
  padding: 0;
  color: var(--signal);
  font: 800 0.65rem/1.3 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.behavior-values > p {
  display: flex;
  justify-content: space-between;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font: 0.7rem/1.4 var(--sans);
}

.behavior-value {
  display: block;
  margin-top: 0.8rem;
}

.behavior-value__label {
  display: flex !important;
  justify-content: space-between;
}

.behavior-value__bounds {
  color: var(--muted);
  font-size: 0.62rem;
}

.story-actions {
  display: flex;
  margin: 0.85rem 0;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

.measure-control {
  display: grid;
  padding: 0.9rem 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.measure-control .quiet-action {
  white-space: nowrap;
}

.common-controls,
.editorial-context {
  border-bottom: 1px solid var(--rule);
}

.common-controls summary,
.editorial-context summary,
.output-inspect summary,
.scene-import summary {
  padding: 0.8rem 0;
  font: 800 0.65rem/1.3 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.common-controls__body {
  padding-bottom: 1rem;
}

.editorial-context__body {
  grid-template-columns: 1fr;
  padding-bottom: 1rem;
}

.editorial-context__body p {
  margin: 0;
  color: var(--muted);
  font: 0.68rem/1.5 var(--sans);
}

.studio-status {
  min-height: 1.2rem;
  margin-top: 0.65rem;
}

.studio-status[data-state="error"],
.image-status[data-state="error"],
#scene-import-status[data-state="error"] {
  color: var(--signal);
  font-weight: 700;
}

.studio-status[data-state="success"],
.image-status[data-state="success"],
#scene-import-status[data-state="success"] {
  color: var(--oxblood);
}

/* Reading */

.reading-main {
  width: min(calc(100% - 2 * var(--gutter)), 52rem);
  margin-inline: auto;
  padding-bottom: 3rem;
}

.reading-head {
  padding-block: clamp(2rem, 5vw, 4rem) 1.5rem;
}

.reading-head h1 {
  margin-top: 0.8rem;
  font-size: clamp(3rem, 5vw, 5rem);
}

.reading-head > p:last-child {
  max-width: 40rem;
  color: #3a352f;
  font-size: 1.1rem;
  line-height: 1.58;
}

.reading-surface {
  position: relative;
  width: 100%;
  min-height: 20rem;
  overflow: hidden;
  border: 1px solid rgba(28, 24, 20, 0.13);
  background:
    radial-gradient(circle at 78% 16%, rgba(184, 76, 42, 0.08), transparent 22%),
    linear-gradient(180deg, #f4efe6 0%, #ece4d8 100%);
}

.reading-lines {
  position: absolute;
  inset: 1.7rem;
  user-select: text;
}

.reading-marker {
  position: absolute;
  z-index: 4;
  display: grid;
  width: 8.6rem;
  height: 4.5rem;
  padding: 0.65rem 0.75rem;
  align-content: center;
  gap: 0.15rem;
  border: 1px solid rgba(116, 76, 34, 0.18);
  border-radius: 1rem;
  color: #432817;
  background: linear-gradient(135deg, #fff6dc 0%, #f3cb8e 100%);
  box-shadow: 0 0.9rem 1.9rem rgba(143, 93, 43, 0.14);
  pointer-events: none;
}

.reading-marker strong {
  font: 400 1.3rem/1 var(--mono);
}

.reading-marker span,
.reading-marker em {
  font: 700 0.54rem/1.2 var(--sans);
  font-style: normal;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.reading-rail {
  padding: 0.9rem 0.1rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.reading-rail .range-field {
  min-width: 10rem;
  flex: 1 1 10rem;
}

.reading-status {
  margin-left: auto;
  color: var(--muted);
  font: 0.65rem/1.3 var(--mono);
  white-space: nowrap;
}

.reading-editor {
  margin-top: 1rem;
  padding: 1.2rem;
  border: 1px solid var(--rule);
  background: var(--sheet);
}

.reading-editor textarea {
  min-height: 12rem;
  margin-block: 0.8rem;
  padding: 0.7rem;
  border: 1px solid var(--rule);
  font-size: 1.1rem;
  line-height: 1.55;
}

/* Takeaway */

.takeaway-scrim {
  position: fixed;
  z-index: 140;
  inset: 0;
  display: grid;
  padding: 1.5rem;
  overflow-y: auto;
  place-items: center;
  background: rgba(27, 24, 21, 0.43);
  backdrop-filter: blur(2px);
}

.takeaway-modal {
  width: min(100%, 40rem);
  max-height: calc(100svh - 3rem);
  padding: clamp(1.5rem, 4vw, 3rem);
  overflow-y: auto;
  border: 1px solid var(--rule);
  background: var(--sheet);
  box-shadow: 0 2.5rem 6rem -1.8rem rgba(27, 24, 21, 0.5);
}

.takeaway-modal > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.takeaway-modal h2 {
  font-size: clamp(2.4rem, 5vw, 3.8rem);
}

#takeaway-close {
  padding: 0.2rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
}

.takeaway-lede {
  color: #3a352f;
  font-size: 1.08rem;
  line-height: 1.55;
}

.delivery-routes {
  border-top: 1px solid var(--rule);
}

.delivery-routes > section {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.7rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--rule);
}

.delivery-routes > section > span {
  color: var(--signal);
  font: 0.7rem/1.5 var(--mono);
}

.delivery-routes h3,
.output-inspect h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 400;
}

.delivery-routes p,
.delivery-limit,
.scene-import p,
#scene-import-status {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font: 0.74rem/1.55 var(--sans);
}

.delivery-limit {
  padding-left: 0.75rem;
  border-left: 2px solid var(--signal);
}

.takeaway-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: center;
  margin-top: 1.25rem;
}

.takeaway-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.output-inspect,
.scene-import {
  margin-top: 1rem;
  border-top: 1px solid var(--rule);
}

.output-inspect > div {
  display: grid;
  gap: 0.8rem;
}

.output-inspect pre {
  max-width: 100%;
  max-height: 15rem;
  margin: 0.4rem 0 0;
  padding: 0.7rem;
  overflow: auto;
  border-left: 1px solid var(--rule);
  background: var(--paper);
  font: 0.64rem/1.5 var(--mono);
  white-space: pre;
}

.scene-import textarea {
  min-height: 8rem;
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.68rem;
}

.scene-import textarea[aria-invalid="true"] {
  border-color: var(--signal);
  box-shadow: inset 3px 0 0 var(--signal);
}

.scene-import-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.scene-import-actions button {
  min-height: 2.4rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--ink);
  background: transparent;
}

.scene-import-actions button:first-child,
.scene-import-actions button:hover {
  color: var(--sheet);
  background: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes soft-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes welcome-screen-in {
  from { opacity: 0; transform: translateY(0.35rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 940px) {
  .landing-shell {
    gap: 2rem;
  }

  .welcome-screen {
    grid-template-columns: 1fr;
    align-content: start;
    overflow-y: auto;
  }

  .welcome-copy {
    max-width: 42rem;
  }

  .welcome-stage .proof-frame {
    min-height: 24rem;
  }
}

@media (min-width: 761px) and (max-height: 800px) {
  .landing-shell {
    padding-top: 2rem;
  }

  .landing-lead h1 {
    margin-top: 0.75rem;
    font-size: clamp(3rem, 4.8vw, 4.6rem);
  }

  .landing-lede {
    margin-top: 0.9rem;
    font-size: 1rem;
    line-height: 1.48;
  }

  .landing-lead > .primary-action {
    margin-top: 1rem;
  }

  .outcome-index {
    margin-top: 1rem;
  }

  .outcome-choice {
    min-height: 3.45rem;
    padding-block: 0.5rem;
  }
}

@media (max-width: 760px) {
  .landing-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .landing-lead h1 {
    max-width: 12ch;
  }

  .workspace-header {
    display: block;
  }

  .layout-metrics {
    margin-top: 0.8rem;
  }

  .shape-dimensions,
  .common-controls__body,
  .editorial-context__body {
    grid-template-columns: 1fr;
  }

  .measure-control {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  :root {
    --gutter: 0.9rem;
  }

  .studio-bar,
  .composer-bar,
  .welcome-top {
    min-height: 4.25rem;
  }

  .edition-mark {
    display: none;
  }

  .landing-shell {
    padding-top: 1.7rem;
  }

  .landing-lead h1 {
    font-size: clamp(3rem, 16vw, 4.2rem);
  }

  .welcome-screen {
    padding-bottom: 0.8rem;
    gap: 1.2rem;
  }

  .welcome-copy h2 {
    font-size: clamp(2.5rem, 13vw, 3.5rem);
  }

  .welcome-copy > p:not(.eyebrow) {
    font-size: 0.98rem;
  }

  .welcome-stage .proof-frame {
    min-height: 19rem;
  }

  .welcome-nav {
    min-height: auto;
    padding-block: 0.8rem;
    flex-direction: column;
    align-items: stretch;
  }

  .welcome-nav-actions {
    max-width: none;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .welcome-closing {
    order: -1;
    flex-basis: 100%;
    font-size: 0.9rem;
  }

  .welcome-next {
    flex: 1;
  }

  .guide-card {
    padding: 1.5rem 1.2rem;
  }

  .guide-skip {
    width: 100%;
    margin-left: 0;
    text-align: left;
  }

  .composer-main {
    padding-inline: 0.65rem;
  }

  .composer-tabs {
    width: 100%;
  }

  .composer-tabs button {
    flex: 1;
    padding-inline: 0.55rem;
    white-space: normal;
  }

  .text-editor-card {
    padding: 1.5rem 1.1rem;
  }

  .layout-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layout-metrics div {
    min-width: 0;
  }

  .stage {
    padding: 0.4rem;
  }

  .composition-page {
    --page-pad: 20px;
  }

  .article-header h3 {
    font-size: clamp(2.7rem, 14vw, 3.8rem);
  }

  .author-editorial h3 {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .control-label {
    flex-basis: 100%;
  }

  .shape-dimensions label {
    grid-template-columns: minmax(0, 1fr) minmax(4.5rem, auto) auto;
  }

  .composer-context section,
  .behavior-interaction {
    display: block;
  }

  .motion-actions {
    margin-top: 0.7rem;
  }

  .reading-main {
    width: calc(100% - 1.4rem);
  }

  .reading-surface {
    min-height: 23rem;
  }

  .reading-lines {
    inset: 1rem;
  }

  .reading-status {
    margin-left: 0;
    flex-basis: 100%;
  }

  .takeaway-scrim {
    padding: 0.65rem;
  }

  .takeaway-modal {
    max-height: calc(100svh - 1.3rem);
    padding: 1.4rem 1.1rem;
  }

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

  .takeaway-actions button {
    width: 100%;
    text-align: left;
  }
}

@media (max-width: 360px) {
  :root {
    --gutter: 0.7rem;
  }

  .wordmark {
    font-size: 1.45rem;
  }

  .landing-lead h1 {
    font-size: 2.8rem;
  }

  .composer-tabs button {
    font-size: 0.85rem;
  }

  .layout-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
