:root {
  color-scheme: light;
  --ink: #191725;
  --muted: #6d6880;
  --paper: #f8f7ff;
  --field: #d9d4ff;
  --blue: #2f32ff;
  --red: #ff553e;
  --acid: #d9ff43;
  --line: rgba(25, 23, 37, 0.2);
  --shadow: 0 24px 80px rgba(45, 35, 99, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--field);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
textarea {
  color: inherit;
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.app {
  display: grid;
  grid-template-columns: minmax(330px, 0.78fr) minmax(520px, 1.42fr);
  min-height: 100dvh;
}

.brief {
  background: var(--field);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(22px, 3vw, 48px);
  position: relative;
}

.masthead,
.workbench-header,
.dialog-heading,
.dialog-actions,
.final-actions,
.workbench-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.issue,
.eyebrow,
.workbench-kicker,
.final-label,
.privacy-note {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.quiet-button,
.undo-button,
.dialog-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  min-height: 44px;
  padding: 8px 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.quiet-button:hover,
.undo-button:hover {
  color: var(--blue);
}

.intro-copy {
  margin: clamp(48px, 8vh, 96px) 0 clamp(32px, 5vh, 60px);
  max-width: 520px;
}

.eyebrow {
  color: var(--blue);
  margin: 0 0 12px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.8rem, 4.2vw, 4.6rem);
  font-weight: 850;
  letter-spacing: -0.08em;
  line-height: 0.82;
  margin-bottom: 24px;
}

.lede {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.02rem, 1.5vw, 1.3rem);
  line-height: 1.48;
  margin-bottom: 0;
  max-width: 470px;
}

.drafts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.draft-card {
  background: rgba(248, 247, 255, 0.38);
  border: 1px solid transparent;
  min-height: 84px;
  opacity: 0.55;
  padding: 14px 16px;
  transition: opacity 180ms ease, background 180ms ease, transform 180ms ease;
}

.draft-card:nth-child(1) {
  width: 100%;
}

.draft-card:nth-child(2) {
  align-self: flex-end;
  width: 73%;
}

.draft-card:nth-child(3) {
  align-self: flex-end;
  width: 46%;
}

.draft-card.current {
  background: var(--acid);
  border-color: var(--ink);
  opacity: 1;
  transform: translateX(8px);
}

.draft-card.complete {
  background: rgba(248, 247, 255, 0.72);
  opacity: 1;
}

.draft-heading {
  align-items: center;
  display: flex;
  font-size: 0.76rem;
  gap: 10px;
  justify-content: space-between;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.draft-copy {
  display: -webkit-box;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.92rem;
  line-height: 1.3;
  margin: 12px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.privacy-note {
  color: var(--muted);
  margin-top: 24px;
}

.workbench {
  background: var(--paper);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: clamp(22px, 3.2vw, 58px);
  position: relative;
}

.workbench::before {
  background: var(--red);
  content: "";
  height: 9px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.workbench-header {
  align-items: flex-end;
  gap: 24px;
}

.workbench-kicker {
  color: var(--red);
  display: block;
  margin-bottom: 9px;
}

.workbench h2 {
  font-size: clamp(1.8rem, 3vw, 3.8rem);
  letter-spacing: -0.055em;
  line-height: 0.95;
  margin: 0;
}

.word-meter {
  flex: 0 0 auto;
  text-align: right;
}

.word-meter strong {
  display: block;
  font-size: clamp(2.5rem, 4.8vw, 5.8rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.08em;
  line-height: 0.75;
}

.word-meter span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.instruction {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 34px 0 14px;
}

.source-shell {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  flex: 1 1 auto;
  min-height: 340px;
  overflow: auto;
  position: relative;
}

.source-field {
  align-content: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 5px;
  min-height: 100%;
  padding: clamp(22px, 3vw, 48px);
  position: relative;
  z-index: 2;
}

.word {
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 1.7vw, 1.58rem);
  line-height: 1.35;
  min-height: 44px;
  padding: 0 3px 2px;
  position: relative;
  transition: color 140ms ease, background 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.word:hover:not(:disabled) {
  background: var(--acid);
}

.word.round-cut {
  color: #908ba0;
  text-decoration: line-through;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
}

.word.locked-cut {
  color: #d7d3dc;
  cursor: default;
  opacity: 0.52;
  text-decoration: line-through;
}

.word:disabled {
  cursor: not-allowed;
}

.workbench-actions {
  gap: 18px;
  margin-top: 24px;
}

.undo-button:disabled {
  cursor: default;
  opacity: 0.36;
}

.primary-button {
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  color: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  min-height: 50px;
  padding: 12px 22px;
  text-transform: uppercase;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.primary-button:hover:not(:disabled) {
  background: var(--blue);
  border-color: var(--blue);
  transform: translateY(-2px);
}

.primary-button:disabled {
  background: transparent;
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.52;
}

.status {
  color: var(--muted);
  font-size: 0.8rem;
  min-height: 1.3em;
  margin: 10px 0 0;
  text-align: right;
}

.final-card {
  display: none;
}

.spine-line {
  height: 100%;
  inset: 0;
  overflow: visible;
  pointer-events: none;
  position: absolute;
  width: 100%;
  z-index: 4;
}

.spine-line path {
  fill: none;
  stroke: var(--red);
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.app[data-view="spine"] .workbench::before {
  background: var(--acid);
}

.app[data-view="spine"] .instruction,
.app[data-view="spine"] .workbench-actions,
.app[data-view="spine"] .status {
  display: none;
}

.app[data-view="spine"] .source-shell {
  background: #151322;
  border-color: #151322;
  margin-top: 28px;
  overflow: hidden;
}

.app[data-view="spine"] .source-field {
  align-content: center;
}

.app[data-view="spine"] .word {
  color: rgba(248, 247, 255, 0.14);
  cursor: default;
  opacity: 1;
  padding-bottom: 0;
  text-decoration: none;
}

.app[data-view="spine"] .word.survivor {
  animation: survivor-pulse 440ms both;
  animation-delay: calc(var(--order) * 120ms);
  background: var(--acid);
  color: var(--ink);
  font-weight: 700;
  transform: translateY(-2px);
  z-index: 3;
}

.app[data-view="spine"] .spine-line path {
  animation: draw-spine 1.1s 720ms ease-out forwards;
}

.app[data-view="spine"] .drafts,
.app[data-view="spine"] .intro-copy,
.app[data-view="spine"] .privacy-note {
  display: none;
}

.app[data-view="spine"] .final-card {
  display: block;
  margin: auto 0;
}

.final-label {
  color: var(--blue);
  display: block;
  margin-bottom: 18px;
}

.final-card > p {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4.8rem);
  letter-spacing: -0.04em;
  line-height: 1.03;
  margin-bottom: 38px;
}

.final-actions {
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
}

.text-dialog {
  background: var(--acid);
  border: 1px solid var(--ink);
  box-shadow: 20px 20px 0 var(--blue);
  color: var(--ink);
  max-height: min(760px, calc(100dvh - 40px));
  max-width: 650px;
  padding: clamp(24px, 4vw, 48px);
  width: calc(100% - 40px);
}

.text-dialog::backdrop {
  backdrop-filter: blur(7px);
  background: rgba(25, 23, 37, 0.7);
}

.text-dialog h2 {
  font-size: clamp(2.3rem, 5vw, 4.8rem);
  letter-spacing: -0.07em;
  line-height: 0.9;
  margin: 34px 0 18px;
}

.text-dialog p {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.45;
  max-width: 530px;
}

.dialog-close {
  font-size: 2rem;
  line-height: 1;
  min-width: 44px;
  text-decoration: none;
}

.text-dialog label {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin: 30px 0 8px;
  text-transform: uppercase;
}

.text-dialog textarea {
  background: var(--paper);
  border: 1px solid var(--ink);
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.45;
  padding: 16px;
  resize: vertical;
  width: 100%;
}

.dialog-meta {
  display: flex;
  font-size: 0.75rem;
  font-weight: 700;
  justify-content: space-between;
  margin: 7px 0 20px;
  min-height: 1.2em;
}

#input-error {
  color: #a32116;
}

.dialog-actions {
  gap: 20px;
}

noscript {
  background: var(--red);
  bottom: 0;
  color: #fff;
  left: 0;
  padding: 16px;
  position: fixed;
  right: 0;
  text-align: center;
  z-index: 10;
}

@keyframes survivor-pulse {
  from {
    background: transparent;
    color: rgba(248, 247, 255, 0.14);
    transform: scale(1.6);
  }
  to {
    background: var(--acid);
    color: var(--ink);
    transform: translateY(-2px) scale(1);
  }
}

@keyframes draw-spine {
  to {
    stroke-dashoffset: 0;
  }
}

@media (max-width: 900px) {
  .app {
    display: flex;
    flex-direction: column;
  }

  .brief {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    min-height: auto;
    padding: 20px;
  }

  .intro-copy {
    margin: 42px 0 28px;
  }

  h1 {
    font-size: clamp(3rem, 15vw, 4.2rem);
  }

  .lede {
    font-size: 1rem;
  }

  .drafts {
    display: grid;
    gap: 7px;
    grid-template-columns: 1fr 0.75fr 0.5fr;
  }

  .draft-card:nth-child(n) {
    align-self: stretch;
    min-height: 74px;
    padding: 11px;
    width: 100%;
  }

  .draft-card.current {
    transform: translateY(5px);
  }

  .draft-copy {
    font-size: 0.78rem;
    margin-top: 8px;
  }

  .privacy-note {
    display: none;
  }

  .workbench {
    min-height: 70dvh;
    padding: 28px 16px 24px;
  }

  .workbench-header {
    align-items: flex-start;
  }

  .workbench h2 {
    font-size: 2.1rem;
  }

  .word-meter strong {
    font-size: 3rem;
  }

  .instruction {
    margin-top: 28px;
  }

  .source-shell {
    min-height: 410px;
  }

  .source-field {
    gap: 4px 2px;
    padding: 21px 17px;
  }

  .word {
    font-size: 1.08rem;
    min-height: 44px;
    padding: 2px 3px;
  }

  .workbench-actions {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 2px;
  }

  .next-button,
  .undo-button {
    width: 100%;
  }

  .status {
    text-align: left;
  }

  .app[data-view="spine"] .brief {
    min-height: 0;
    padding: 16px 20px 14px;
  }

  .app[data-view="spine"] .masthead {
    display: none;
  }

  .app[data-view="spine"] .final-card {
    margin: 0;
  }

  .app[data-view="spine"] .final-label {
    margin-bottom: 8px;
  }

  .app[data-view="spine"] .final-card > p {
    font-size: clamp(1.45rem, 6.5vw, 2rem);
    line-height: 1.02;
    margin-bottom: 12px;
  }

  .app[data-view="spine"] .final-actions {
    align-items: center;
    flex-direction: row;
    gap: 16px;
  }

  .app[data-view="spine"] .final-actions .primary-button {
    min-height: 44px;
    padding: 8px 14px;
  }

  .app[data-view="spine"] .final-actions .quiet-button {
    white-space: nowrap;
  }

  .app[data-view="spine"] .workbench {
    min-height: 0;
    padding: 20px 16px 18px;
  }

  .app[data-view="spine"] .workbench-header {
    align-items: center;
  }

  .app[data-view="spine"] .workbench-kicker {
    font-size: 0.62rem;
    margin-bottom: 5px;
  }

  .app[data-view="spine"] .workbench h2 {
    font-size: 1.75rem;
  }

  .app[data-view="spine"] .word-meter strong {
    font-size: 2.4rem;
  }

  .app[data-view="spine"] .word-meter span {
    font-size: 0.62rem;
  }

  .app[data-view="spine"] .source-shell {
    flex: 0 0 auto;
    margin-top: 12px;
    min-height: 0;
  }

  .app[data-view="spine"] .source-field {
    gap: 1px 2px;
    min-height: 0;
    padding: 14px 12px;
  }

  .app[data-view="spine"] .word {
    font-size: 0.82rem;
    line-height: 1.05;
    min-height: 22px;
    padding: 1px 2px;
  }

  .text-dialog {
    box-shadow: 9px 9px 0 var(--blue);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 22px;
    width: calc(100% - 24px);
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 4px;
  }
}

@media (max-width: 430px) {
  .masthead .issue {
    max-width: 130px;
  }

  .intro-copy {
    margin-top: 34px;
  }

  .draft-heading span {
    display: none;
  }

  .draft-heading {
    justify-content: flex-start;
  }
}

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

  .app[data-view="spine"] .spine-line path {
    animation: none !important;
    stroke-dashoffset: 0;
  }

  .app[data-view="spine"] .word.survivor {
    animation: none !important;
    background: var(--acid);
    color: var(--ink);
    transform: translateY(-2px) scale(1);
  }
}
