:root {
  color-scheme: light;
  --page-bg-top: #fffaf5;
  --page-bg-bottom: #ffe6de;
  --paper: #fff8f2;
  --paper-strong: #fff4ea;
  --ink: #382326;
  --muted: #7b5961;
  --rose: #c74963;
  --rose-deep: #a11d3c;
  --coral: #ef7f6e;
  --gold: #d9a441;
  --shadow: rgba(120, 53, 65, 0.18);
  --border: rgba(176, 87, 104, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.1)),
    linear-gradient(135deg, var(--page-bg-top), var(--page-bg-bottom));
}

body {
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(
      90deg,
      transparent 0,
      transparent calc(100% - 1px),
      rgba(199, 73, 99, 0.06) calc(100% - 1px)
    ),
    linear-gradient(
      0deg,
      transparent 0,
      transparent calc(100% - 1px),
      rgba(217, 164, 65, 0.05) calc(100% - 1px)
    );
  background-size: 36px 36px;
}

.page {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(320px, 1fr);
  gap: 28px;
  align-items: center;
  padding: 32px 0;
}

.builder[hidden] {
  display: none;
}

html.recipient-mode .builder {
  display: none;
}

.builder,
.message-frame {
  background: linear-gradient(180deg, rgba(255, 248, 242, 0.98), rgba(255, 244, 234, 0.94));
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 22px 60px var(--shadow);
}

.builder {
  padding: 32px;
  position: relative;
  z-index: 1;
}

.kicker {
  margin: 0 0 12px;
  color: var(--rose-deep);
  font-size: 0.95rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 2.7rem;
  line-height: 1.05;
  font-family: "Georgia", "Times New Roman", serif;
}

.builder-copy {
  margin: 18px 0 28px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.builder-form {
  display: grid;
  gap: 14px;
}

.field-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--rose-deep);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
button {
  min-height: 52px;
  border-radius: 8px;
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid rgba(161, 29, 60, 0.16);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  padding: 0 16px;
  outline: none;
}

input:focus {
  border-color: rgba(161, 29, 60, 0.42);
  box-shadow: 0 0 0 3px rgba(199, 73, 99, 0.12);
}

button {
  padding: 0 18px;
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.primary-button {
  background: linear-gradient(135deg, var(--rose), var(--coral));
  color: #fff8f2;
  box-shadow: 0 12px 24px rgba(199, 73, 99, 0.24);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.95);
  color: var(--rose-deep);
  border: 1px solid rgba(161, 29, 60, 0.16);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(123, 89, 97, 0.18);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.status-message[data-tone="success"] {
  color: var(--rose-deep);
}

.status-message[data-tone="error"] {
  color: #8f1b1b;
}

.preview {
  min-width: 0;
}

html.recipient-mode .page {
  width: min(960px, calc(100% - 32px));
  grid-template-columns: minmax(320px, 1fr);
  justify-items: center;
}

html.recipient-mode .preview {
  width: 100%;
}

.message-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  min-height: 620px;
}

html.recipient-mode .message-frame {
  min-height: min(82vh, 860px);
}

.message-frame::after {
  content: "";
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(217, 164, 65, 0.32);
  border-radius: 8px;
  pointer-events: none;
}

.frame-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-copy {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 96px;
  text-align: center;
  z-index: 1;
}

html.recipient-mode .message-copy {
  padding: 104px;
}

.message-intro,
.message-outro {
  margin: 0;
  color: var(--rose-deep);
}

.message-intro {
  font-size: 1.05rem;
  font-weight: 700;
}

.message-line {
  margin: 10px 0 0;
  font-size: 2rem;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--ink);
}

.message-name {
  margin: 0;
  font-size: 4.4rem;
  line-height: 1.05;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--rose-deep);
  overflow-wrap: anywhere;
}

html.recipient-mode .message-line {
  font-size: 2.35rem;
}

html.recipient-mode .message-name {
  font-size: clamp(3.4rem, 8vw, 6rem);
}

.message-outro {
  font-size: 1.1rem;
  line-height: 1.6;
}

.floating-hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.floating-hearts span {
  position: absolute;
  display: block;
  font-size: var(--size);
  line-height: 1;
  color: var(--color);
  opacity: 0.75;
  transform: translate3d(0, 0, 0);
  animation: drift var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
}

.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 drift {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  50% {
    transform: translateY(-16px) rotate(10deg) scale(1.08);
  }
}

@media (max-width: 960px) {
  .page {
    grid-template-columns: 1fr;
    padding: 20px 0 32px;
  }

  .message-frame {
    min-height: 540px;
  }

  .message-copy {
    padding: 72px;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 1200px);
    gap: 20px;
  }

  .builder {
    padding: 24px;
  }

  h1 {
    font-size: 2.15rem;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .message-frame {
    min-height: 460px;
  }

  .message-copy {
    padding: 52px 32px;
  }

  html.recipient-mode .message-copy {
    padding: 68px 34px;
  }

  .message-line {
    font-size: 1.65rem;
  }

  .message-name {
    font-size: 2.75rem;
  }

  html.recipient-mode .message-line {
    font-size: 1.9rem;
  }

  html.recipient-mode .message-name {
    font-size: clamp(2.8rem, 12vw, 4.2rem);
  }
}
