:root {
  color-scheme: light;
  --color-bg: #fdfbf7;
  --color-container: #f4eae1;
  --color-text: #4a2e2b;
  --color-muted: #806762;
  --color-accent: #d98880;
  --color-button: #e07a5f;
  --color-border: #e9d8cf;
  --color-input: #fffdfa;
  --color-shadow: 0 24px 70px rgb(74 46 43 / 9%);
  font-family: ui-rounded, "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="night"] {
  color-scheme: dark;
  --color-bg: #0d0b14;
  --color-container: #161224;
  --color-text: #eae6f3;
  --color-muted: #b0a7c0;
  --color-accent: #ff4081;
  --color-button: #7b2cbf;
  --color-border: #33283f;
  --color-input: #100d19;
  --color-shadow: 0 24px 70px rgb(0 0 0 / 28%);
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--color-text);
  background:
    radial-gradient(ellipse at 50% -15%, color-mix(in srgb, var(--color-accent) 18%, transparent), transparent 55%),
    var(--color-bg);
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.site-header {
  width: min(100% - 40px, 1080px);
  height: 78px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.recipient-page { display: flex; flex-direction: column; }
.recipient-page .page-shell {
  display: flex;
  flex: 1;
  align-items: center;
  width: min(100% - 32px, 900px);
  margin: 0 auto;
  padding: clamp(20px, 5vh, 48px) 0;
}
.recipient-page .recipient-view { width: 100%; }
.brand {
  color: var(--color-text);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.06em;
  text-decoration: none;
}
.brand span { color: var(--color-button); }
.theme-toggle, .close-button {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-container);
  cursor: pointer;
}
.theme-toggle { padding: 9px 14px; color: var(--color-text); font-size: .9rem; }
.theme-toggle span { margin-left: 4px; }
.page-shell { width: min(100% - 32px, 620px); margin: 25px auto 56px; }
.create-shell { width: min(100% - 40px, 1120px); }
.hero, .recipient-view, .not-found-view { animation: rise-in .5s ease both; }
#create-view { width: 100%; margin-inline: auto; }
.not-found-view { max-width: 620px; margin-inline: auto; }
#create-view > .intro { margin: 10px 0 24px; }
.create-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr); align-items: start; gap: clamp(22px, 4vw, 48px); }
.eyebrow {
  margin: 0 0 14px;
  color: var(--color-button);
  font-size: .73rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(2.15rem, 7vw, 3.55rem);
  line-height: 1.02;
  letter-spacing: -.065em;
}
h1 span { color: var(--color-button); }
@media (min-width: 851px) {
  .hero-title-break { display: none; }
}
.intro { color: var(--color-muted); line-height: 1.6; }
.hero > .intro { margin: 10px 0 18px; }
.card {
  padding: clamp(20px, 4vw, 28px);
  border: 1px solid var(--color-border);
  border-radius: 26px;
  background: color-mix(in srgb, var(--color-container) 72%, var(--color-bg));
  box-shadow: var(--color-shadow);
}
.create-form { display: flex; flex-direction: column; }
.step-progress { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 26px; padding-bottom: 18px; border-bottom: 1px solid var(--color-border); }
.step-indicator { display: inline-flex; align-items: center; gap: 8px; color: var(--color-muted); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.step-indicator > span { display: grid; width: 27px; height: 27px; place-items: center; border: 1px solid var(--color-border); border-radius: 50%; color: var(--color-muted); font-size: .75rem; }
.step-indicator[aria-current="step"] { color: var(--color-text); }
.step-indicator[aria-current="step"] > span { border-color: var(--color-button); color: white; background: var(--color-button); }
.form-step h2, .preview-heading h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 1.75rem); letter-spacing: -.04em; }
.step-description { margin: 7px 0 20px; color: var(--color-muted); font-size: .9rem; line-height: 1.5; }
.step-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; }
.step-actions .primary-button { flex: 1; width: auto; margin-top: 0; }
.step-actions .step-back { margin: 0; }
.preview-panel { position: sticky; top: 24px; padding: clamp(18px, 2.5vw, 28px); border: 1px solid var(--color-border); border-radius: 26px; background: color-mix(in srgb, var(--color-container) 72%, var(--color-bg)); box-shadow: var(--color-shadow); }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.preview-heading .eyebrow { margin-bottom: 6px; font-size: .65rem; }
.preview-heading h2 { font-size: 1.15rem; }
.preview-live { padding: 6px 9px; border: 1px solid var(--color-border); border-radius: 999px; color: var(--color-muted); font-size: .68rem; white-space: nowrap; }
.preview-note-wrap { display: grid; min-height: clamp(260px, 38vh, 410px); place-items: center; overflow: hidden; border: 1px solid rgb(74 46 43 / 10%); border-radius: 17px; background-color: var(--color-input); background-position: center; background-size: cover; }
.preview-note { width: 100%; margin: 0; padding: clamp(24px, 4vw, 42px); color: var(--note-text-color, #4a302e); font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; font-size: var(--note-font-size, 22px); line-height: 1.65; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; text-shadow: 0 1px 4px rgb(255 250 242 / 85%), 0 1px 12px rgb(20 12 25 / 35%); }
.preview-note:empty { color: var(--color-muted); }
.preview-note-wrap[data-template="paper"] { background-image: linear-gradient(rgb(255 253 248 / 12%), rgb(255 253 248 / 12%)), url("./assets/papel-bonito.jpg"); }
.preview-note-wrap[data-template="hearts"] { background-image: linear-gradient(rgb(255 250 250 / 16%), rgb(255 250 250 / 16%)), url("./assets/corazones.jpg"); }
.preview-note-wrap[data-template="stars"] { background-image: linear-gradient(rgb(12 9 25 / 30%), rgb(12 9 25 / 30%)), url("./assets/noche-estrellada.jpg"); }
.preview-note-wrap[data-template="sunset"] { background-image: linear-gradient(rgb(30 18 24 / 40%), rgb(30 18 24 / 40%)), url("./assets/atardecer-playa.jpg"); }
.preview-details { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 14px; color: var(--color-muted); font-size: .72rem; }
.preview-details span:first-child { color: var(--color-button); font-weight: 800; }
.preview-caption { margin: 12px 0 0; color: var(--color-muted); font-size: .72rem; line-height: 1.5; }
.field-label { display: block; margin: 14px 0 7px; font-size: .91rem; font-weight: 750; }
.field-label:first-child { margin-top: 0; }
textarea, input, select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 13px;
  outline: none;
  color: var(--color-text);
  background: var(--color-input);
  transition: border-color .18s ease, box-shadow .18s ease;
}
fieldset { min-width: 0; margin: 18px 0 0; padding: 0; border: 0; }
legend.field-label { padding: 0; }
textarea:focus, input:focus, select:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 20%, transparent); }
textarea { min-height: 150px; padding: 15px; resize: vertical; line-height: 1.55; }
input, select { min-height: 48px; padding: 0 13px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--color-muted) 50%), linear-gradient(135deg, var(--color-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-repeat: no-repeat; background-size: 5px 5px; }
.field-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--color-muted); font-size: .76rem; }
.check-row { display: flex; align-items: flex-start; gap: 11px; margin: 24px 0 3px; cursor: pointer; line-height: 1.45; }
.check-row input { width: 18px; min-height: 18px; margin: 2px 0 0; accent-color: var(--color-button); }
.conditional-fields { padding: 0 0 5px; }
.template-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.template-option { position: relative; display: grid; gap: 7px; cursor: pointer; }
.template-option input { position: absolute; width: 1px; height: 1px; min-height: 1px; opacity: 0; }
.template-swatch { position: relative; height: 63px; overflow: hidden; border: 2px solid var(--color-border); border-radius: 12px; transition: border-color .16s ease, transform .16s ease; }
.template-option input:checked + .template-swatch { border-color: var(--color-button); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-button) 18%, transparent); }
.template-option input:focus-visible + .template-swatch { outline: 3px solid color-mix(in srgb, var(--color-accent) 55%, transparent); outline-offset: 2px; }
.template-name { color: var(--color-muted); font-size: .77rem; text-align: center; }
.template-paper { background: url("./assets/papel-bonito.jpg") center / cover; }
.template-hearts { background: url("./assets/corazones.jpg") center / cover; }
.template-stars { background: url("./assets/noche-estrellada.jpg") center / cover; }
.template-sunset { background: url("./assets/atardecer-playa.jpg") center / cover; }
.note-typography { margin-top: 18px; }
.note-typography .field-label { display: flex; align-items: baseline; justify-content: space-between; }
.note-typography output { color: var(--color-muted); font-size: .78rem; font-weight: 600; }
.note-typography input[type="range"] { min-height: 28px; padding: 0; accent-color: var(--color-button); }
.color-picker-row { display: flex; align-items: center; gap: 12px; color: var(--color-muted); font-size: .78rem; }
.color-picker-row input[type="color"] { flex: 0 0 52px; width: 52px; min-height: 42px; padding: 4px; cursor: pointer; }
.slug-input { display: flex; align-items: center; border: 1px solid var(--color-border); border-radius: 13px; background: var(--color-input); }
.slug-input:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 20%, transparent); }
.slug-input span { flex: 0 0 auto; padding-left: 12px; color: var(--color-muted); font-size: .9rem; }
.slug-input input { min-width: 0; border: 0; background: transparent; box-shadow: none; }
.optional { color: var(--color-muted); font-weight: 400; }
.hint { margin: 7px 0 0; color: var(--color-muted); font-size: .8rem; line-height: 1.5; }
.primary-button, .secondary-button, .copy-button {
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease;
}
.primary-button { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; margin-top: 24px; color: #fff; background: var(--color-button); box-shadow: 0 9px 20px color-mix(in srgb, var(--color-button) 27%, transparent); }
.primary-button:hover, .copy-button:hover, .secondary-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .7; transform: none; }
.form-status { min-height: 1.25em; margin: 12px 0 0; color: var(--color-muted); font-size: .87rem; line-height: 1.45; }
.form-status[data-kind="error"] { color: #ba354c; }
.form-status[data-kind="success"] { color: #287b57; }
.privacy-note { max-width: 520px; margin: 12px auto 0; color: var(--color-muted); font-size: .78rem; line-height: 1.55; text-align: center; }
.not-found-view > h1 { margin-bottom: 25px; }
.recipient-card {
  position: relative;
  display: flex;
  min-height: min(62vh, 660px);
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 7vw, 76px);
}
.recipient-card > div { width: min(100%, 640px); margin-inline: auto; }
.recipient-prompt { max-width: 580px; margin-bottom: 18px; }
.recipient-card .intro { margin: 0 0 14px; }
.recipient-card .primary-button { margin-top: 20px; }
.recipient-card input[type="password"] { margin-top: 0; }
.trivia-question { margin: 0 0 12px; font-size: clamp(1.35rem, 5vw, 1.9rem); line-height: 1.25; }
.recipient-card #trivia-stage .eyebrow { margin-bottom: 8px; }
#message-stage[data-template="paper"] .message-wrap { background-image: linear-gradient(rgb(255 253 248 / 15%), rgb(255 253 248 / 15%)), url("./assets/papel-bonito.jpg"); }
#message-stage[data-template="hearts"] .message-wrap { background-image: linear-gradient(rgb(255 250 250 / 18%), rgb(255 250 250 / 18%)), url("./assets/corazones.jpg"); }
#message-stage[data-template="stars"] .message-wrap { background-image: linear-gradient(rgb(12 9 25 / 30%), rgb(12 9 25 / 30%)), url("./assets/noche-estrellada.jpg"); }
#message-stage[data-template="sunset"] .message-wrap { background-image: linear-gradient(rgb(30 18 24 / 40%), rgb(30 18 24 / 40%)), url("./assets/atardecer-playa.jpg"); }
#message-stage[data-template="paper"] .revealed-message,
#message-stage[data-template="hearts"] .revealed-message { font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; }
#message-stage[data-template="stars"] .revealed-message,
#message-stage[data-template="sunset"] .revealed-message { font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; }
.message-wrap { position: relative; min-height: clamp(320px, 56vh, 600px); overflow: hidden; border-radius: 20px; background-color: var(--color-input); }
.message-wrap { background-position: center; background-size: cover; }
.revealed-message { display: grid; min-height: inherit; place-items: center; margin: 0; padding: clamp(28px, 7vw, 76px); color: var(--note-text-color, var(--color-text)); font-size: var(--note-font-size, 22px); line-height: 1.7; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; user-select: none; text-shadow: 0 1px 4px rgb(255 250 242 / 85%), 0 1px 12px rgb(20 12 25 / 35%); }
.revealed-message.reveal-fade { animation: rise-in .8s ease both; }
#scratch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.scratch-hint { margin: 10px 0 0; color: var(--color-muted); font-size: .83rem; text-align: center; }
.timer-copy { margin: 17px 0 12px; color: var(--color-muted); font-size: .82rem; text-align: center; }
.timer-copy strong { color: var(--color-text); font-variant-numeric: tabular-nums; }
.secondary-button { display: block; min-height: 43px; margin: auto; padding: 0 18px; border: 1px solid var(--color-border); background: transparent; }
.message-wrap.disappearing { animation: dissolve .65s ease forwards; }
.text-link { display: inline-flex; margin-top: 18px; color: var(--color-button); font-weight: 800; }
.link-dialog { width: min(calc(100% - 28px), 480px); padding: 30px; border: 1px solid var(--color-border); border-radius: 24px; color: var(--color-text); background: var(--color-bg); box-shadow: var(--color-shadow); }
.link-dialog::backdrop { background: rgb(16 10 22 / 55%); backdrop-filter: blur(4px); }
.link-dialog h2 { margin: 0; font-size: 1.7rem; letter-spacing: -.04em; }
.dialog-close-form { position: absolute; top: 17px; right: 17px; }
.close-button { width: 34px; height: 34px; font-size: 1.4rem; line-height: 1; }
.share-link-row { display: flex; gap: 8px; margin-top: 18px; }
.share-link-row input { min-width: 0; font-size: .85rem; }
.copy-button { flex: 0 0 auto; min-height: 48px; padding: 0 15px; color: white; background: var(--color-button); }
.site-footer { display: grid; justify-items: center; gap: 12px; width: min(100% - 40px, 1080px); margin: 0 auto; padding: 22px 0 26px; border-top: 1px solid var(--color-border); color: var(--color-muted); text-align: center; }
.site-footer p { margin: 0; }
.footer-credit { color: var(--color-text); font-size: .86rem; font-weight: 800; letter-spacing: .015em; }
.footer-credit span:first-child { color: var(--color-button); }
.footer-credit span:last-child { color: var(--color-accent); }
.footer-copyright { font-size: .72rem; }

@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dissolve { to { opacity: 0; filter: blur(9px); transform: translateY(-6px) scale(.98); } }
@media (max-width: 520px) {
  .page-shell { margin-top: 26px; }
  .create-shell { width: min(100% - 24px, 620px); margin-top: 18px; }
  .create-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .preview-panel { position: static; grid-row: 1; padding: 15px; border-radius: 20px; }
  .preview-heading { margin-bottom: 11px; }
  .preview-note-wrap { min-height: 190px; border-radius: 13px; }
  .preview-note { padding: 20px; font-size: 1.05rem; }
  .preview-caption { display: none; }
  .step-progress { gap: 4px; margin-bottom: 20px; padding-bottom: 14px; }
  .step-indicator { gap: 5px; font-size: .7rem; }
  .step-indicator > span { width: 24px; height: 24px; }
  .form-step h2 { font-size: 1.4rem; }
  .step-actions { gap: 8px; }
  .step-actions .primary-button, .step-actions .secondary-button { min-height: 47px; font-size: .86rem; }
  .recipient-page .page-shell { width: min(100% - 20px, 900px); padding: 12px 0; }
  .site-header { height: 68px; }
  .card { border-radius: 21px; }
  .recipient-card { min-height: min(70svh, 700px); padding: 26px 20px; }
  .message-wrap { min-height: clamp(300px, 56svh, 520px); }
  .field-foot { font-size: .7rem; }
  .template-options { gap: 7px; }
  .template-swatch { height: 55px; }
  .template-name { font-size: .69rem; }
  .template-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-footer { padding: 17px 0 20px; }
  .footer-credit { font-size: .77rem; }
}
@media (min-width: 521px) and (max-width: 850px) {
  .create-layout { grid-template-columns: minmax(0, 1fr); }
  .preview-panel { position: static; }
  .preview-note-wrap { min-height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
