@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@500;700&family=Inter:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #2b1a22;
  --muted: #7a6670;
  --line: #ecdfe4;
  --accent: #c8102e;
  --panel: #ffffff;
  --page: #fbf7f8;
  --radius: 16px;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Rose scene (shared) ---------- */
.scene {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px 24px;
  transition: background 0.4s ease;
  overflow: hidden;
}
.scene .rose { width: 170px; height: auto; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.18)); }
.scene .note {
  max-width: 420px;
  width: 100%;
  padding: 18px 22px;
  border-radius: 14px;
  text-align: center;
  font-family: 'Dancing Script', cursive;
  font-size: 1.7rem;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: rgba(255, 255, 255, 0.6);
  color: #3a1f2b;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.scene.is-dark .note { background: rgba(0, 0, 0, 0.35); color: #fbeff3; }
.scene .note.placeholder { opacity: 0.55; }

/* Bloom animation */
.scene.animate .bloom { transform-origin: 100px 100px; animation: bloom 1.6s ease-in-out both; }
.scene.animate .stem { animation: rise 1s ease-out both; }
.scene.animate .note { animation: fadeUp 0.9s ease-out 1.1s both; }
@keyframes bloom { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Falling petals */
.petal {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 9px;
  border-radius: 60% 10% 60% 10%;
  opacity: 0.7;
  pointer-events: none;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg) translateX(40px); }
}

/* ---------- Creator page ---------- */
.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.app header h1 {
  margin: 0;
  font-family: 'Dancing Script', cursive;
  font-size: 2.6rem;
  color: var(--accent);
}
.app header p { margin: 4px 0 24px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } .preview-wrap { order: -1; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.field + .field { margin-top: 24px; }
.field > label, .field > .label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.swatch.bg { border-radius: 10px; width: 54px; height: 40px; }

.custom-color {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  cursor: pointer;
}
.custom-color.bg { border-radius: 10px; width: 54px; height: 40px; }
.custom-color[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.custom-color input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; }

textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12); }
.counter { text-align: right; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 13px 22px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; width: 100%; margin-top: 24px; }
.btn-ghost { background: #f4ecef; color: var(--ink); }

.error { color: #b91c1c; font-size: 0.9rem; margin-top: 12px; min-height: 1.2em; }

.preview-wrap { position: sticky; top: 20px; }
.preview-wrap .scene { border-radius: var(--radius); min-height: 520px; border: 1px solid var(--line); }
.preview-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; text-align: center; }

/* Share result */
.share { text-align: center; }
.share h2 { font-family: 'Dancing Script', cursive; font-size: 2rem; margin: 0 0 6px; color: var(--accent); }
.share p { color: var(--muted); margin: 0 0 18px; }
.link-row { display: flex; gap: 8px; }
.link-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fdfafb;
  color: var(--ink);
}
.timer { margin-top: 18px; font-size: 0.95rem; color: var(--muted); }
.timer strong { font-variant-numeric: tabular-nums; color: var(--ink); font-size: 1.1rem; }
.share-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.hidden { display: none !important; }

/* ---------- Viewer page ---------- */
.viewer { min-height: 100vh; min-height: 100dvh; }
.viewer .rose { width: 210px; }
.viewer .note { font-size: 2rem; }
.viewer-footer {
  position: fixed;
  bottom: 76px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 16px;
  align-items: center;
  font-size: 0.85rem;
  flex-wrap: wrap;
  padding: 0 16px;
}
.pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: #3a1f2b;
  text-decoration: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.is-dark .pill { background: rgba(0, 0, 0, 0.4); color: #fbeff3; }
.pill strong { font-variant-numeric: tabular-nums; }

.wilted { text-align: center; max-width: 380px; padding: 24px; }
.wilted .icon { font-size: 3.5rem; filter: grayscale(0.6); }
.wilted h1 { font-family: 'Dancing Script', cursive; font-size: 2.4rem; margin: 8px 0; color: var(--accent); }
.wilted p { color: var(--muted); margin: 0 0 22px; }
.loading { color: var(--muted); }

/* ---------- Site footer ---------- */
.site-footer {
  text-align: center;
  padding: 24px 16px 28px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
.site-footer a:hover { text-decoration: underline; }
.site-footer--overlay {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 16px max(4px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.site-footer--overlay p {
  display: table;
  margin: 0 auto;
  color: #3a1f2b;
}
.site-footer--overlay a { pointer-events: auto; }
body.is-dark .site-footer--overlay p { color: #fbeff3; }
body.is-dark .site-footer--overlay a { color: #ff8fa3; }
