:root {
  color-scheme: light;
  --ink: #1c1917;
  --muted: #57534e;
  --paper: #f6f1e8;
  --card: #fffdf8;
  --line: #e7dfd2;
  --accent: #9f1239;
  --accent-ink: #fff7f8;
  --shadow: 0 24px 60px rgba(68, 42, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(159, 18, 57, 0.08), transparent 32%),
    var(--paper);
}

.page {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  align-items: start;
}

.panel,
.preview {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 36px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 680;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.lead {
  margin: 16px 0 28px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

label,
legend {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 600;
}

input[type="text"] {
  width: 100%;
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
}

input[type="text"]:focus,
input[type="range"]:focus-visible {
  outline: 3px solid rgba(159, 18, 57, 0.25);
  border-color: var(--accent);
}

fieldset {
  margin: 0 0 22px;
  padding: 0;
  border: 0;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
}

.swatch input {
  margin: 0;
  accent-color: var(--swatch);
}

.swatch span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--swatch);
}

.swatch:has(input:checked) {
  border-color: var(--ink);
  background: #faf7f2;
}

input[type="range"] {
  width: 100%;
  margin: 4px 0 18px;
  accent-color: var(--accent);
}

.message {
  min-height: 1.3em;
  margin: 0 0 16px;
  color: var(--accent);
  font-size: 0.92rem;
}

.actions {
  display: flex;
  gap: 12px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  background: #d6d3d1;
  color: #78716c;
  cursor: not-allowed;
}

.preview {
  padding: 28px;
  position: sticky;
  top: 24px;
}

.frame {
  display: grid;
  place-items: center;
  min-height: 320px;
  border-radius: 22px;
  background:
    linear-gradient(45deg, #f3eee6 25%, transparent 25%),
    linear-gradient(-45deg, #f3eee6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f3eee6 75%),
    linear-gradient(-45deg, transparent 75%, #f3eee6 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-color: #fff;
}

canvas {
  width: min(100%, 280px);
  height: auto;
  background: #fff;
  border-radius: 12px;
}

.placeholder {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.encoded {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
  word-break: break-all;
}

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

  .panel,
  .preview {
    padding: 22px;
  }

  .preview {
    position: static;
    order: -1;
  }
}
