:root {
  --bg: #FFF8F0;
  --bg-soft: #FBEAD9;
  --paper: #FFFCF7;
  --pink: #F8C8D4;
  --pink-deep: #E8A4B6;
  --peach: #FFD6BA;
  --sage: #C7D9B8;
  --gold: #D4A574;
  --gold-deep: #B88955;
  --text: #6B4F3F;
  --text-soft: #9B7F6E;
  --text-mute: #B89B85;
  --line: rgba(212, 165, 116, 0.22);
  --shadow-soft: 0 24px 60px rgba(107, 79, 63, 0.10);
  --shadow-card: 0 8px 24px rgba(184, 137, 85, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans KR', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1100px 600px at 12% -10%, #FFEDE0 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 10%, #FFE1E8 0%, transparent 55%),
    radial-gradient(800px 700px at 50% 110%, #E9F1E0 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { max-width: 100%; height: auto; }
img { display: block; }

[hidden] { display: none !important; }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(255, 248, 240, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(212, 165, 116, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-mark {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--peach));
  color: #fff;
}

.toolbar-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease, color .15s ease;
  color: var(--text);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(212, 165, 116, 0.35);
}
.btn-ghost:hover { background: #fff; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--pink-deep));
  color: #fff;
  box-shadow: 0 6px 16px rgba(212, 124, 132, 0.28);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
  margin: 18px 16px 0;
}
.hint strong { color: var(--gold-deep); font-weight: 700; }

/* ---------- Stage / Poster ---------- */
.stage {
  display: flex;
  justify-content: center;
  padding: 24px 16px 80px;
}

.poster {
  position: relative;
  width: 100%;
  max-width: 560px;
  background:
    radial-gradient(380px 280px at 50% -10%, rgba(248, 200, 212, 0.30), transparent 70%),
    radial-gradient(420px 280px at 50% 110%, rgba(199, 217, 184, 0.30), transparent 70%),
    var(--paper);
  border-radius: 32px;
  padding: 52px 30px 44px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  isolation: isolate;
}

.poster::before, .poster::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1.5px solid var(--line);
  border-radius: 26px;
  pointer-events: none;
  z-index: 0;
}
.poster::after {
  inset: 18px;
  border: 1px dashed rgba(212, 165, 116, 0.35);
  border-radius: 22px;
}

.poster-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- Decorations ---------- */
.decor {
  position: absolute;
  z-index: 1;
  opacity: 0;
  animation: decor-in 1.1s cubic-bezier(.2,.7,.2,1) forwards;
  animation-delay: var(--delay, 0s);
  pointer-events: none;
}

.decor-tl { top: 8px; left: 6px; transform-origin: top left; animation-name: decor-in, float-a; animation-duration: 1.1s, 6s; animation-delay: var(--delay, 0s), 1.2s; animation-iteration-count: 1, infinite; animation-timing-function: cubic-bezier(.2,.7,.2,1), ease-in-out; }
.decor-tr { top: 4px; right: 10px; }
.decor-r  { top: 38%; right: -10px; }
.decor-bl { bottom: 0; left: -12px; }
.decor-br { bottom: 8px; right: 4px; }
.decor-l  { top: 52%; left: -6px; }

@keyframes decor-in {
  from { opacity: 0; transform: translateY(10px) scale(.92); }
  to   { opacity: .85; transform: translateY(0) scale(1); }
}
@keyframes float-a {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-6px) rotate(-3deg); }
}

/* ---------- Title block ---------- */
.kicker {
  font-family: 'Noto Sans KR', sans-serif;
  letter-spacing: 0.55em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-deep);
  text-align: center;
  margin: 6px 0 14px;
  padding-left: 0.55em;
}

.title {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 700;
  text-align: center;
  font-size: clamp(26px, 6.4vw, 38px);
  line-height: 1.32;
  margin: 0 0 14px;
  color: var(--text);
}

.title-name {
  font-family: 'Gaegu', 'Nanum Myeongjo', cursive;
  font-weight: 700;
  font-size: 1.5em;
  color: var(--gold-deep);
  background: linear-gradient(180deg, transparent 62%, rgba(248, 200, 212, 0.55) 62%, rgba(248, 200, 212, 0.55) 92%, transparent 92%);
  padding: 0 8px 2px;
  border-radius: 4px;
  display: inline-block;
  min-width: 1.5em;
}

.title-suffix { font-weight: 500; color: var(--text); }

.subtitle {
  font-size: 14px;
  text-align: center;
  color: var(--text-soft);
  margin: 4px 14px 6px;
  line-height: 1.7;
  max-width: 360px;
  font-weight: 400;
}

/* ---------- Photo ---------- */
.photo-wrap {
  display: flex;
  justify-content: center;
  margin: 22px 0 22px;
}

.photo-ring {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  padding: 7px;
  background: conic-gradient(from 200deg, var(--pink) 0deg, var(--peach) 90deg, var(--sage) 180deg, var(--gold) 270deg, var(--pink) 360deg);
  box-shadow: 0 12px 30px rgba(232, 164, 182, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #FCE7E0 0%, #F5DCE6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter .15s ease;
}
.photo:hover { filter: brightness(1.03); }

.photo input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); border: 0;
}

.photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.photo[data-state="set"] img { display: block; }
.photo[data-state="set"] .photo-placeholder { display: none; }
.photo[data-state="set"] .photo-remove { display: flex; }

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-mute);
  text-align: center;
  padding: 0 12px;
}

.photo-remove {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(107, 79, 63, 0.6);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
}
.photo:hover .photo-remove,
.photo:focus-within .photo-remove { opacity: 1; }
.photo-remove:hover { background: rgba(107, 79, 63, 0.85); }

/* ---------- Birth stamp ---------- */
.birth-stamp {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  margin-bottom: 26px;
}

.stamp-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--gold-deep);
}

.stamp-value {
  font-family: 'Nanum Myeongjo', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Event card ---------- */
.event-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, #FFF7EE 0%, #FFEFE2 100%);
  border: 1px solid rgba(212, 165, 116, 0.28);
  border-radius: 22px;
  padding: 22px 22px 24px;
  box-shadow: var(--shadow-card);
  margin-top: 4px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}

.card-flourish {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 50%, transparent);
  max-width: 60px;
}

.card-title {
  font-family: 'Nanum Myeongjo', serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.005em;
  text-align: center;
}

.card-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 4px 0;
}

.card-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.card-body { flex: 1; min-width: 0; }

.card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--gold-deep);
  margin: 0 0 4px;
  text-transform: uppercase;
}

.card-main {
  font-family: 'Nanum Myeongjo', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
  line-height: 1.4;
}

.card-sub {
  font-size: 13.5px;
  color: var(--text-soft);
  margin: 0;
  line-height: 1.5;
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent);
  margin: 14px 4px;
}

/* ---------- Signoff ---------- */
.signoff {
  font-family: 'Nanum Myeongjo', serif;
  font-size: 13.5px;
  font-style: italic;
  color: var(--text-soft);
  text-align: center;
  margin: 26px 8px 8px;
  line-height: 1.6;
}

.family {
  font-family: 'Gaegu', cursive;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold-deep);
  text-align: center;
  margin: 6px 0 0;
}

/* ---------- Inline editing affordance ---------- */
[contenteditable="true"] {
  transition: background .15s ease, box-shadow .15s ease;
  border-radius: 6px;
  outline: none;
  cursor: text;
}

[contenteditable="true"]:hover {
  background: rgba(248, 200, 212, 0.18);
  box-shadow: 0 0 0 4px rgba(248, 200, 212, 0.18);
}

[contenteditable="true"]:focus {
  background: rgba(255, 252, 247, 0.95);
  box-shadow: 0 0 0 2px var(--pink), 0 0 0 6px rgba(248, 200, 212, 0.25);
}

[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-mute);
  font-style: italic;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(107, 79, 63, 0.94);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(107, 79, 63, 0.28);
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast.is-error { background: #B85450; }

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .toolbar { padding: 12px 14px; }
  .toolbar-actions .btn { padding: 8px 12px; font-size: 12.5px; }
  .hint { font-size: 12.5px; margin: 14px 12px 0; }
  .poster { padding: 44px 22px 36px; border-radius: 26px; }
  .photo-ring { width: 170px; height: 170px; }
  .event-card { padding: 18px 16px 20px; }
  .card-main { font-size: 15px; }
  .card-sub { font-size: 13px; }
  .decor-tl svg { width: 56px; height: 56px; }
  .decor-tr svg { width: 44px; height: 56px; }
  .decor-bl svg { width: 70px; height: 70px; }
  .decor-br svg { width: 52px; height: 52px; }
}

@media (max-width: 390px) {
  .stage { padding: 16px 10px 60px; }
  .poster { padding: 40px 18px 32px; }
  .title { font-size: 26px; }
  .photo-ring { width: 156px; height: 156px; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .toolbar, .hint, .toast, .photo-remove { display: none !important; }
  .stage { padding: 0; }
  .poster {
    box-shadow: none;
    max-width: 100%;
    border-radius: 0;
    page-break-inside: avoid;
  }
  [contenteditable="true"]:hover,
  [contenteditable="true"]:focus { background: transparent; box-shadow: none; }
}
