@font-face {
  font-family: "Bricolage";
  src: url("../assets/bricolage-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Bricolage";
  src: url("../assets/bricolage-bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --yellow: #ffd84d;
  --yellow-soft: #ffe889;
  --plum: #291c35;
  --night: #160d20;
  --night-raised: #211529;
  --purple: #743690;
  --violet: #d68cff;
  --coral: #ff7066;
  --paper: #fff9e9;
  --ink: #291c35;
  --white: #fffdf8;
  --muted: #c9bdce;
  --line: rgba(255, 255, 255, 0.2);
  --shadow: #08040b;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 82% 18%, rgba(116, 54, 144, 0.28), transparent 29rem),
    var(--night);
  color: var(--white);
  font-family: "Bricolage", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

button,
a,
textarea,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

::selection {
  background: var(--yellow);
  color: var(--ink);
}

::-webkit-scrollbar {
  width: 11px;
}

::-webkit-scrollbar-track {
  background: var(--night);
}

::-webkit-scrollbar-thumb {
  border: 3px solid var(--night);
  border-radius: 999px;
  background: var(--purple);
}

.skip {
  position: fixed;
  z-index: 99;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border: 2px solid var(--night);
  border-radius: 7px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

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

.topbar {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.brand {
  padding: 10px 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand span {
  color: var(--yellow);
}

.topbar-note {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.topbar-note i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 5px rgba(255, 216, 77, 0.11);
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(48px, 6.5vw, 88px) 0 68px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(270px, 0.55fr);
  align-items: end;
  gap: clamp(26px, 5vw, 76px);
  margin-bottom: clamp(42px, 6vw, 72px);
}

.intro h1 {
  max-width: 880px;
  margin: 0;
  font-size: clamp(54px, 6.8vw, 96px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.86;
  text-transform: uppercase;
}

.intro h1 span {
  display: inline-block;
  color: var(--yellow);
  white-space: nowrap;
}

.intro-copy {
  max-width: 36ch;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: clamp(16px, 1.35vw, 19px);
  line-height: 1.55;
}

.machine {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: clamp(24px, 3.5vw, 50px);
  align-items: start;
}

.mobile-flow {
  display: none;
}

.machine::before {
  content: "";
  position: absolute;
  z-index: 3;
  top: 42%;
  left: calc(44% + 3px);
  width: 26px;
  height: 6px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--night);
  border-radius: 99px;
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(255, 216, 77, 0.16);
}

.input-desk {
  position: relative;
  z-index: 1;
  padding: clamp(22px, 3vw, 34px);
  transform: rotate(-0.35deg);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 12px 12px 0 var(--shadow);
  color: var(--ink);
}

.desk-header,
.reply-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 2px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.desk-header strong {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.input-desk > label,
.tone-picker legend {
  display: block;
  margin: 24px 0 9px;
  font-size: 13px;
  font-weight: 700;
}

textarea {
  display: block;
  width: 100%;
  min-height: 154px;
  resize: vertical;
  border: 2px solid var(--ink);
  border-radius: 8px;
  outline: 0;
  background: #fffdf6;
  color: var(--ink);
  caret-color: var(--purple);
  padding: 16px;
  font-size: 17px;
  line-height: 1.45;
  box-shadow: inset 0 -4px 0 rgba(41, 28, 53, 0.05);
  transition: box-shadow 160ms ease, transform 160ms ease;
}

textarea::placeholder {
  color: #7f7189;
}

textarea:focus-visible {
  box-shadow: 0 0 0 4px var(--yellow), 0 0 0 7px var(--ink);
  transform: translateY(-1px);
}

.input-helper,
.privacy-note,
.form-status {
  margin: 9px 0 0;
  color: #66566f;
  font-size: 12px;
  line-height: 1.45;
}

.tone-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.tone-picker legend {
  grid-column: 1 / -1;
}

.tone-picker label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.tone-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.tone-picker span {
  position: relative;
  display: flex;
  min-height: 70px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 11px 12px 11px 15px;
  border: 2px solid rgba(41, 28, 53, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.38);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.tone-picker span::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 6px;
  width: 4px;
  transform: scaleY(0.2);
  border-radius: 99px;
  background: var(--purple);
  opacity: 0;
  transition: transform 170ms ease, opacity 170ms ease;
}

.tone-picker strong {
  font-size: 15px;
}

.tone-picker small {
  overflow: hidden;
  color: #6a5a73;
  font-size: 11px;
  line-height: 1.25;
}

.tone-picker input:checked + span {
  border-color: var(--ink);
  background: var(--yellow);
  transform: translateY(-2px);
}

.tone-picker input:checked + span::before {
  transform: scaleY(1);
  opacity: 1;
}

.tone-picker input:focus-visible + span {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

.generate-button,
.reply-actions button {
  min-height: 54px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--yellow);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.generate-button {
  width: 100%;
  margin-top: 22px;
}

.generate-button:not(:disabled):hover,
.reply-actions button:hover {
  transform: translate(2px, 2px);
  box-shadow: 3px 3px 0 var(--ink);
}

.generate-button:not(:disabled):active,
.reply-actions button:active {
  transform: translate(5px, 5px);
  box-shadow: 0 0 0 var(--ink);
}

.generate-button:disabled {
  border-color: #9f93a4;
  background: #d7d0d5;
  color: #584c60;
  cursor: not-allowed;
  box-shadow: 4px 4px 0 #aea4b1;
}

.generate-button:focus-visible,
.reply-actions button:focus-visible,
.brand:focus-visible,
footer a:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 4px;
}

.input-desk .generate-button:focus-visible {
  outline-color: var(--purple);
}

.form-status {
  min-height: 18px;
  font-weight: 700;
}

.privacy-note {
  padding-top: 11px;
  border-top: 1px solid rgba(41, 28, 53, 0.18);
}

.reply-desk {
  min-width: 0;
  padding: clamp(15px, 2vw, 22px);
  border: 2px solid rgba(255, 255, 255, 0.52);
  border-radius: calc(var(--radius) + 4px);
  background: #0e0912;
  box-shadow: 15px 15px 0 var(--shadow);
}

.reply-heading {
  padding: 1px 2px 13px;
  border-color: rgba(255, 255, 255, 0.24);
  color: var(--muted);
}

.reply-heading strong {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 99px;
  color: var(--yellow);
  font-size: 11px;
}

.reply-stage {
  position: relative;
  display: grid;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  margin-top: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--night-raised);
  background-size: 30px 30px;
}

.reply-stage::before,
.reply-stage::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 34px;
  height: 34px;
  pointer-events: none;
}

.reply-stage::before {
  top: 12px;
  left: 12px;
  border-top: 2px solid var(--yellow);
  border-left: 2px solid var(--yellow);
}

.reply-stage::after {
  right: 12px;
  bottom: 12px;
  border-right: 2px solid var(--yellow);
  border-bottom: 2px solid var(--yellow);
}

.empty-reply {
  display: grid;
  max-width: 330px;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.empty-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin-bottom: 14px;
  transform: rotate(-4deg);
  border: 2px solid var(--night);
  border-radius: 11px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 32px;
  font-weight: 700;
  box-shadow: 5px 5px 0 var(--purple);
}

.empty-reply h2 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 30px);
  letter-spacing: -0.035em;
}

.empty-reply p {
  max-width: 32ch;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

#reply-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#reply-canvas[hidden] {
  display: none;
}

.reply-desk.is-revealing #reply-canvas {
  animation: poster-press 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.reply-desk.is-revealing .reply-stage::after {
  animation: scan-guide 560ms ease-out both;
}

#reply-text {
  margin: 18px 2px 0;
  padding: 13px 0 0;
  border-top: 2px solid var(--yellow);
  color: var(--white);
  font-size: clamp(16px, 1.55vw, 19px);
  line-height: 1.45;
}

.reply-actions {
  display: grid;
  grid-template-columns: 1fr 1.18fr 0.84fr;
  gap: 9px;
  margin-top: 17px;
}

.reply-actions[hidden] {
  display: none;
}

.reply-actions button {
  min-height: 49px;
  padding: 9px 10px;
  font-size: 11px;
  box-shadow: none;
}

.reply-actions button:nth-child(2) {
  border-color: rgba(255, 255, 255, 0.72);
  background: transparent;
  color: var(--white);
}

.reply-actions .quiet-button {
  border-color: rgba(255, 255, 255, 0.22);
  background: #25182d;
  color: var(--muted);
}

.reply-actions button:hover {
  box-shadow: none;
}

.action-status {
  min-height: 18px;
  margin: 10px 2px 0;
  color: var(--yellow-soft);
  font-size: 12px;
  font-weight: 700;
}

.guardrail {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-top: 50px;
  padding: 18px 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-top: 4px solid var(--coral);
  background: rgba(41, 28, 53, 0.72);
}

.guardrail strong {
  color: var(--yellow);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.guardrail p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 25px 0 38px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

footer a {
  font-weight: 700;
  text-underline-offset: 4px;
}

footer a:last-child {
  justify-self: end;
}

.noscript {
  margin: 0;
  padding: 12px 20px;
  background: var(--coral);
  color: var(--ink);
  text-align: center;
  font-weight: 700;
}

.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 poster-press {
  0% {
    opacity: 0;
    transform: translateY(24px) rotate(1.5deg) scale(0.98);
    filter: blur(8px);
    clip-path: inset(0 0 100% 0);
  }
  58% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0) scale(1);
    filter: blur(0);
    clip-path: inset(0 0 0 0);
  }
}

@keyframes scan-guide {
  0% {
    transform: translateY(-320px);
    border-color: var(--yellow);
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 940px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .intro-copy {
    max-width: 52ch;
  }

  .machine {
    grid-template-columns: 1fr;
    gap: 38px;
  }

  .machine::before {
    top: calc(50% - 4px);
    left: 50%;
    width: 72px;
    height: 7px;
    transform: translate(-50%, -50%) rotate(90deg);
  }

  .input-desk {
    transform: none;
  }

  .reply-desk {
    width: 100%;
  }
}

@media (max-width: 640px) {
  body {
    background-size: 42px 42px, 42px 42px, auto, auto;
  }

  .topbar,
  main,
  footer {
    width: min(100% - 28px, 1180px);
  }

  .topbar {
    min-height: 62px;
  }

  main {
    padding: 42px 0 54px;
  }

  .machine {
    gap: 18px;
  }

  .machine::before {
    display: none;
  }

  .intro {
    margin-bottom: 36px;
  }

  .intro h1 {
    font-size: clamp(45px, 14.3vw, 62px);
    line-height: 0.91;
  }

  .intro h1 span {
    white-space: normal;
  }

  .intro-copy {
    font-size: 16px;
  }

  .mobile-flow {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: #211529;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
  }

  .mobile-flow span {
    text-align: right;
    text-decoration: line-through;
    text-decoration-color: var(--coral);
  }

  .mobile-flow b {
    color: var(--yellow);
    font-size: 18px;
  }

  .mobile-flow strong {
    color: var(--yellow);
  }

  .input-desk {
    padding: 20px 16px 22px;
    box-shadow: 7px 7px 0 var(--shadow);
  }

  textarea {
    min-height: 140px;
    font-size: 16px;
  }

  .tone-picker span {
    min-height: 74px;
    padding: 10px 9px 10px 14px;
  }

  .tone-picker strong {
    font-size: 14px;
  }

  .tone-picker small {
    font-size: 11px;
  }

  .reply-desk {
    padding: 12px;
    box-shadow: 8px 8px 0 var(--shadow);
  }

  .reply-stage {
    margin-top: 12px;
  }

  .reply-actions {
    grid-template-columns: 1fr 1.12fr;
  }

  .reply-actions .quiet-button {
    grid-column: 1 / -1;
  }

  .guardrail {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 40px;
    padding: 16px;
  }

  footer {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
  }

  footer span {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 350px) {
  .topbar-note span {
    font-size: 11px;
  }

  .tone-picker {
    grid-template-columns: 1fr;
  }

  .tone-picker span {
    min-height: 60px;
  }

  .reply-actions {
    grid-template-columns: 1fr;
  }

  .reply-actions .quiet-button {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .input-desk {
    transform: none;
  }
}

@media (forced-colors: active) {
  .topbar-note i,
  .tone-picker span::before,
  .machine::before {
    forced-color-adjust: none;
    background: Highlight;
  }

  .input-desk,
  .reply-desk,
  textarea,
  .tone-picker span,
  button {
    border: 2px solid ButtonText;
  }
}
