:root {
  --bg: #f5edd6;
  --bg-tint: #efe4c2;
  --ink: #161311;
  --ink-soft: #4a3f33;
  --muted: #a89e88;
  --rule: #221a14;
  --pill-bg: #fffaf0;
  --shadow: 0 1px 0 rgba(60, 40, 20, 0.08);
  --mono: 'Courier Prime', 'Courier New', ui-monospace, monospace;
  --script: 'Pinyon Script', 'Bilbo Swash Caps', cursive;
}

* { box-sizing: border-box; }

/* ---------- CORNER DECORATIONS ---------- */
.corner-deco {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  user-select: none;
  opacity: 0.9;
  background-image: var(--corner-src, none);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: opacity 0.3s ease;
}
.corner-deco--tl {
  top: -110px;
  left: -110px;
  width: 280px;
  height: 280px;
  transform: rotate(var(--corner-rot, -22deg));
}
.corner-deco--br {
  bottom: -120px;
  right: -110px;
  width: 320px;
  height: 320px;
  transform: rotate(var(--corner-rot, 155deg));
}
@media (max-width: 800px) {
  .corner-deco--tl { width: 180px; height: 180px; top: -70px; left: -70px; }
  .corner-deco--br { width: 200px; height: 200px; bottom: -80px; right: -70px; }
}
.bw .corner-deco { filter: grayscale(1) contrast(1.02); }

/* Keep page content above corner decorations */
.page { position: relative; z-index: 1; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--ink); }

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- LOGO ---------- */
.logo {
  font-family: var(--script);
  font-size: 64px;
  line-height: 1;
  margin: 0;
  letter-spacing: -1px;
}
.logo--sm { font-size: 44px; }

.peony-icon {
  display: block;
  width: 110px;
  height: auto;
  margin: 8px auto 0;
}

.tagline {
  text-align: center;
  font-size: 13px;
  margin: 12px 0 28px;
  letter-spacing: 0.02em;
}

/* ---------- BUTTONS ---------- */
.btn {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 14px 32px;
  border: 1px solid var(--rule);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  min-width: 240px;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.85; }
.btn:disabled {
  background: #d8d6c8;
  color: #8a8678;
  border-color: #d8d6c8;
  cursor: not-allowed;
}

.btn--outline {
  background: transparent;
  color: var(--ink);
}

.btn--small {
  min-width: auto;
  padding: 10px 22px;
  font-size: 12px;
}

.linklike {
  background: none;
  border: 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--ink);
  padding: 8px;
}

.stack > * + * { margin-top: 14px; }

/* ---------- LANDING ---------- */
.landing {
  min-height: 100vh;
  justify-content: center;
  gap: 36px;
  padding: 48px 24px;
}
.landing .peony-icon { margin: 0; }
.landing .tagline { margin: 0; }
.landing .actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.landing .attribution {
  margin: 0;
  font-size: 12px;
  color: #888;
}

/* ---------- BUILD (pick flowers) ---------- */
.build .heading {
  text-align: center;
  margin: 18px 0 6px;
  font-size: 16px;
  letter-spacing: 0.06em;
}
.build .sub {
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 28px;
}

.flowers {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 24px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.flower {
  position: relative;
  background: none;
  border: 0;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
  transition: transform 0.15s ease;
}
.flower:hover { transform: translateY(-3px) scale(1.03); }

.flower img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.flower .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-family: var(--mono);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
}
.flower.has-count .badge { visibility: visible; }

/* Tooltip card */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: #fff;
  border: 1px solid var(--rule);
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.4;
  z-index: 30;
  min-width: 140px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.1s ease;
  text-align: center;
}
.tooltip.show { opacity: 1; }
.tooltip strong { display: block; letter-spacing: 0.06em; margin-bottom: 4px; }

/* Selected pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 36px auto 22px;
  max-width: 900px;
}
.pill {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  background: var(--pill-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
}
.pill:hover { background: #f0eedf; }

/* ---------- CUSTOMIZE ---------- */
.customize .heading {
  text-align: center;
  font-size: 16px;
  letter-spacing: 0.06em;
  margin: 14px 0 18px;
}
.customize .toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.customize-hint {
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  margin: -6px 0 14px;
}
.flower-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 16px auto 0;
  max-width: 720px;
}
.flower-controls[hidden] { display: none; }
.flower-controls__label {
  font-size: 13px;
  letter-spacing: 0.08em;
}
.flower-controls__row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.bouquet-stage {
  width: 100%;
  max-width: 720px;
  aspect-ratio: 1000 / 900;
  margin: 0 auto;
  touch-action: none;
}
.bouquet-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.bouquet-stage canvas.is-dragging {
  cursor: grabbing;
}

.bouquet-stage canvas.is-dragging {
  cursor: grabbing;
}
.save-garden {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 18px auto 0;
  max-width: 720px;
  width: 100%;
}
.save-garden__label {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.save-garden__row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.save-garden__row input {
  font-family: var(--mono);
  font-size: 14px;
  border: 1px solid var(--rule);
  background: var(--pill-bg);
  padding: 10px 14px;
  min-width: 200px;
  flex: 1 1 200px;
  max-width: 280px;
  color: var(--ink);
}
.save-garden__row input::placeholder {
  color: var(--muted);
}
.save-garden__msg {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0;
  text-align: center;
}
.save-garden__msg--error {
  color: #aa2222;
}

/* ---------- GARDEN ---------- */
.garden .heading {
  text-align: center;
  font-size: 16px;
  letter-spacing: 0.06em;
  margin: 14px 0 8px;
}
.garden .sub {
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 28px;
}
.garden-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 24px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}
.garden-section__title {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  margin: 8px 0 0;
  color: var(--ink-soft);
}
.garden-section__title:not(:first-child) {
  margin-top: 28px;
}
.garden-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
}
.garden-item--saved .garden-item__title {
  font-size: 30px;
}
.garden-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.garden-item__stage {
  width: 100%;
  aspect-ratio: 1000 / 900;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--rule);
}
.garden-item__stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.garden-item__stage--error {
  background: #f3f1e8;
}
.garden-item__title {
  font-family: var(--script);
  font-size: 34px;
  font-weight: normal;
  margin: 4px 0 0;
}
.garden-item__tagline {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.45;
}
.garden-item__blooms {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #777;
  margin: 0;
}
.garden-item__btn {
  margin-top: 4px;
}

/* ---------- CARD ---------- */
.card-frame {
  position: relative;
  max-width: 980px;
  margin: 28px auto 16px;
  padding: 0 12px 56px;
}
.card-frame__bush {
  position: absolute;
  bottom: 0;
  width: clamp(90px, 14vw, 140px);
  height: auto;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}
.card-frame__bush--left {
  left: 18%;
  transform: scaleX(-1);
}
.card-frame__bush--right {
  right: 18%;
}
.card-stage {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 44px;
  margin: 0 auto;
  max-width: 900px;
}
.card-stage .side {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex: 0 0 auto;
  padding-bottom: 8px;
}
.card-stage .side img {
  height: 130px;
  width: auto;
}
.card {
  background: #fff;
  border: 1px solid var(--rule);
  padding: 22px 26px;
  width: 360px;
  min-height: 280px;
  font-size: 14px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
}
.card .row { display: flex; align-items: baseline; gap: 6px; }
.card label.b { font-weight: 700; letter-spacing: 0.04em; }
.card input,
.card textarea {
  font-family: var(--mono);
  font-size: 14px;
  border: 0;
  background: transparent;
  outline: none;
  padding: 2px 0;
  color: var(--ink);
  width: 100%;
}
.card input::placeholder,
.card textarea::placeholder {
  color: var(--muted);
}
.card textarea {
  resize: vertical;
  min-height: 90px;
  margin-top: 6px;
}
.card .sign-row {
  margin-top: auto;
  text-align: right;
  align-self: flex-end;
  width: 100%;
}
.card .sign-row .row { justify-content: flex-end; }
.card .sign-row input { text-align: right; }
.sign-row__closing {
  margin-bottom: 8px;
}

/* Themed select — matches btn / pill styling */
.theme-select {
  position: relative;
  display: inline-block;
}
.theme-select__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.theme-select__trigger {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 9px 14px;
  min-width: 196px;
  border: 1px solid var(--rule);
  background: var(--pill-bg);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-select__trigger:hover {
  background: #f0eedf;
}
.theme-select.is-open .theme-select__trigger {
  background: var(--ink);
  color: #fff;
}
.theme-select__chev {
  font-size: 11px;
  line-height: 1;
  opacity: 0.75;
}
.theme-select__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  list-style: none;
  margin: 0;
  padding: 6px;
  min-width: 100%;
  background: var(--pill-bg);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  z-index: 30;
  max-height: 240px;
  overflow-y: auto;
}
.theme-select__menu[hidden] {
  display: none;
}
.theme-select__option {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.theme-select__option:hover {
  background: #f0eedf;
  border-color: var(--rule);
}
.theme-select__option.is-selected {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.theme-select__option.is-selected:hover {
  opacity: 0.9;
}

.email-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 14px auto 6px;
  font-size: 13px;
}
.email-row input {
  font-family: var(--mono);
  font-size: 14px;
  border: 1px solid var(--rule);
  background: #fff;
  padding: 10px 14px;
  width: 320px;
}

.nav-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 20px;
}

/* ---------- SENT ---------- */
.sent {
  min-height: 100vh;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding: 48px 24px;
}
.sent .peony-icon { margin: 0; }
.sent h2 {
  font-family: var(--script);
  font-weight: normal;
  font-size: 48px;
  margin: 0;
}
.sent p {
  font-size: 14px;
  margin: 0;
  color: var(--ink-soft);
}
.sent .actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}

/* ---------- LOADER ---------- */
.toast {
  position: fixed;
  inset: auto 0 28px 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.toast .inner {
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 4px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show .inner { opacity: 1; transform: translateY(0); }
.toast.error .inner { background: #aa2222; }

/* B&W mode */
.bw .flower img,
.bw .bouquet-stage canvas,
.bw .garden-item__stage canvas,
.bw .card-stage .side img,
.bw .card-frame__bush,
.bw .peony-icon {
  filter: grayscale(1) contrast(1.02);
}

/* Responsive */
@media (max-width: 800px) {
  .logo { font-size: 48px; }
  .flowers { grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
  .garden-grid { grid-template-columns: 1fr; }
  .card-stage { flex-direction: column; gap: 8px; align-items: center; }
  .card-stage .side { display: none; }
  .card-frame { padding-bottom: 40px; }
  .card-frame__bush { width: 72px; opacity: 0.75; }
  .card-frame__bush--left { left: 8%; }
  .card-frame__bush--right { right: 8%; }
  .card { width: 100%; }
  .btn { min-width: 200px; }
}

/* ---------- PAGE TRANSITION ---------- */
html.pt-pending body {
  overflow: hidden;
}

#page-transition {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  visibility: hidden;
  background: transparent;
  overflow: hidden;
}

#page-transition.pt--active {
  visibility: visible;
  pointer-events: auto;
}

.pt-field {
  position: absolute;
  inset: -8%;
}

.pt-bloom {
  position: absolute;
  z-index: var(--z, 1);
  opacity: 0;
  will-change: transform, opacity;
  transform: translate(var(--enter-x, 0), var(--enter-y, 0));
  transition:
    transform var(--pt-enter-duration, 900ms) cubic-bezier(0.22, 1, 0.36, 1),
    opacity calc(var(--pt-enter-duration, 900ms) * 0.55) ease;
  transition-delay: var(--delay, 0ms);
}

#page-transition.pt--covering .pt-bloom {
  opacity: 1;
  transform: translate(0, 0);
}

#page-transition.pt--exiting .pt-bloom {
  transition:
    transform var(--pt-exit-duration, 1400ms) cubic-bezier(0.25, 0.05, 0.2, 1),
    opacity calc(var(--pt-exit-duration, 1400ms) * 0.9) ease;
  transition-delay: var(--exit-delay, var(--delay, 0ms));
}

.pt-flower {
  display: block;
  width: clamp(100px, 20vmin, 230px);
  height: auto;
  margin: -12% 0 0 -15%;
  transform: rotate(var(--rot, 0deg)) scale(var(--scale, 0.85));
  filter: drop-shadow(0 4px 12px rgba(40, 28, 12, 0.14));
  will-change: transform;
}

#page-transition.pt--covering:not(.pt--exiting) .pt-flower {
  transform: rotate(var(--rot, 0deg)) scale(var(--scale, 1));
  animation: pt-sway var(--sway-dur, 3s) ease-in-out infinite;
  animation-delay: var(--sway-delay, 0ms);
}

@keyframes pt-sway {
  0%, 100% {
    transform:
      rotate(var(--rot, 0deg))
      scale(var(--scale, 1))
      translate(0, 0);
  }
  25% {
    transform:
      rotate(calc(var(--rot, 0deg) + var(--sway, 3deg)))
      scale(var(--scale, 1))
      translate(var(--sway-x, 2px), calc(var(--sway-y, 2px) * -1));
  }
  50% {
    transform:
      rotate(calc(var(--rot, 0deg) - var(--sway, 3deg)))
      scale(var(--scale, 1))
      translate(calc(var(--sway-x, 2px) * -1), var(--sway-y, 2px));
  }
  75% {
    transform:
      rotate(calc(var(--rot, 0deg) + calc(var(--sway, 3deg) * 0.45)))
      scale(var(--scale, 1))
      translate(calc(var(--sway-x, 2px) * 0.6), calc(var(--sway-y, 2px) * 0.5));
  }
}

#page-transition.pt--exiting .pt-flower {
  animation: none;
}

#page-transition.pt--bw .pt-flower {
  filter: grayscale(1) contrast(1.02) drop-shadow(0 4px 12px rgba(40, 28, 12, 0.14));
}

@media (max-width: 600px) {
  .pt-flower { width: clamp(82px, 24vmin, 155px); }
}

@media (prefers-reduced-motion: reduce) {
  #page-transition { display: none !important; }
}
