:root {
  --white: #ffffff;
  --blush: #fff5f8;
  --petal: #ffe3ec;
  --line: #f7d2de;
  --rose: #f28cab;
  --berry: #c93a6b;
  --berry-dark: #a82c58;
  --plum: #3b1e2d;
  --plum-soft: #7a5565;

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;

  --shadow-pink: 0 24px 50px -26px rgba(201, 58, 107, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% 110%, var(--petal) 0%, rgba(255, 227, 236, 0) 60%),
    var(--white);
  color: var(--plum);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--rose); outline-offset: 3px; border-radius: 12px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1:focus, h2:focus { outline: none; }

#app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

/* ---------- Ekranlar ---------- */
.screen {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.screen--center { align-items: center; text-align: center; }
.screen.enter { animation: enter 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.screen.leave { animation: leave 0.22s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Tipografiya ---------- */
.display {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.1rem, 9.4vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 7vw, 2.15rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.subtitle {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.25rem;
  margin-bottom: 10px;
}
.lead {
  color: var(--plum-soft);
  font-size: 1.05rem;
  max-width: 34ch;
  text-wrap: pretty;
}
.lead--left { max-width: none; margin-top: -8px; }
.hint {
  color: var(--berry);
  font-weight: 600;
  animation: breathe 2.4s ease-in-out infinite;
}
.hint--static { animation: none; font-family: var(--serif); font-style: italic; font-size: 1.2rem; font-weight: 500; }
@keyframes breathe { 50% { opacity: 0.45; } }

/* ---------- Tugmalar ---------- */
.actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 6px; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 16px 30px;
  min-height: 54px;
  background: var(--berry);
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  box-shadow: 0 14px 26px -14px rgba(201, 58, 107, 0.9);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, opacity 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { background: #e9c6d2; box-shadow: none; cursor: not-allowed; transform: none; }
.btn.is-loading { pointer-events: none; opacity: 0.75; }
.link {
  appearance: none;
  background: none;
  border: 0;
  padding: 8px 10px;
  color: var(--plum-soft);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
  font-size: 0.95rem;
}

/* ---------- Bosqich nuqtalari ---------- */
.steps {
  position: fixed;
  z-index: 3;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
}
.steps i {
  width: 8px; height: 8px; border-radius: 99px;
  background: var(--line);
  transition: width 0.35s ease, background 0.35s ease;
}
.steps i.done { background: var(--rose); }
.steps i.now { width: 24px; background: var(--berry); }

/* ---------- Konvert ---------- */
.envelope {
  --w: min(78vw, 320px);
  position: relative;
  width: var(--w);
  aspect-ratio: 16 / 11;
  margin: 26px 0 18px;
  perspective: 900px;
  filter: drop-shadow(0 26px 24px rgba(201, 58, 107, 0.22));
}
.envelope > * { position: absolute; }
.env-back { inset: 0; background: #f3a9bf; border-radius: 10px; }
.env-letter {
  left: 7%; right: 7%; top: 7%; bottom: 7%;
  z-index: 2;
  background: #fff;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  padding-top: 11px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--berry);
  box-shadow: 0 0 0 1px var(--line) inset;
  transition: transform 0.9s cubic-bezier(0.3, 0.7, 0.2, 1) 0.7s;
}
.env-front {
  inset: 0;
  z-index: 3;
  background: linear-gradient(180deg, #f9c3d3 0%, #f6b3c8 100%);
  clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%);
  border-radius: 10px;
}
.env-flap {
  left: 0; top: 0; width: 100%; height: 52%;
  z-index: 4;
  background: #f4a0b9;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 10px 10px 0 0;
  transform-origin: top center;
  transition: transform 0.75s cubic-bezier(0.5, 0, 0.2, 1) 0.15s, z-index 0s 0.5s;
}
.seal {
  left: 50%; top: 52%;
  z-index: 5;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #ffd9e4;
  background: radial-gradient(circle at 32% 28%, #e0557f, var(--berry) 55%, #8f2149);
  box-shadow: 0 6px 12px -4px rgba(143, 33, 73, 0.7), inset 0 -3px 5px rgba(0, 0, 0, 0.18), inset 0 2px 3px rgba(255, 255, 255, 0.35);
  animation: seal-pulse 1.9s ease-in-out infinite;
  transition: transform 0.35s ease, opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
@keyframes seal-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 140, 171, 0.55), 0 6px 12px -4px rgba(143, 33, 73, 0.7), inset 0 -3px 5px rgba(0,0,0,.18), inset 0 2px 3px rgba(255,255,255,.35); }
  60% { box-shadow: 0 0 0 16px rgba(242, 140, 171, 0), 0 6px 12px -4px rgba(143, 33, 73, 0.7), inset 0 -3px 5px rgba(0,0,0,.18), inset 0 2px 3px rgba(255,255,255,.35); }
}
.envelope.open .seal { transform: scale(0); opacity: 0; animation: none; pointer-events: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.envelope.open .env-letter { transform: translateY(-58%); }

/* ---------- Xat ---------- */
.paper {
  position: relative;
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, #fde8ef 31px 32px),
    #fff;
  background-position: 0 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 24px 22px;
  box-shadow: var(--shadow-pink);
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 32px;
  cursor: default;
}
.paper p { margin: 0 0 32px; }
.paper p:first-child { font-size: 1.3rem; font-style: italic; color: var(--berry); font-weight: 500; text-wrap: balance; }
.paper p:last-of-type { margin-bottom: 0; }
.w { opacity: 0; transition: opacity 0.35s ease; }
.w.on { opacity: 1; }
.sign {
  margin-top: 32px;
  text-align: right;
  font-style: italic;
  color: var(--plum-soft);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.sign.on { opacity: 1; }

/* ---------- Asosiy savol ---------- */
.ask-actions {
  position: relative;
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.btn--yes {
  transform: scale(var(--grow, 1));
  transform-origin: center top;
  padding-inline: 34px;
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1), background 0.18s;
}
.btn--yes:active { transform: scale(calc(var(--grow, 1) * 0.97)); }

/* ---------- Kun tanlash ---------- */
.days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 8px;
}
.day {
  appearance: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  padding: 9px 4px 8px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  line-height: 1.15;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.day small { font-size: 0.72rem; color: var(--plum-soft); }
.day strong { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.day:active { transform: scale(0.95); }
.day[aria-pressed="true"] { background: var(--berry); border-color: var(--berry); color: #fff; }
.day[aria-pressed="true"] small { color: #ffdbe6; }

.time-block { animation: enter 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  appearance: none;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px;
  min-height: 44px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"] { background: var(--petal); border-color: var(--berry); color: var(--berry-dark); }
.chip[aria-pressed="true"]::after { content: "✓"; font-size: 0.85em; }
.picked { min-height: 1.5em; color: var(--berry-dark); font-weight: 600; text-align: center; }

/* ---------- Joy kartalari ---------- */
.places { display: grid; gap: 10px; }
.place {
  appearance: none;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.place:active { transform: scale(0.985); }
.place .em {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 1.5rem;
  background: var(--blush);
}
.place b { display: block; font-family: var(--serif); font-size: 1.12rem; font-weight: 600; }
.place span.note { display: block; color: var(--plum-soft); font-size: 0.9rem; line-height: 1.35; }
.place .heart { opacity: 0; transform: scale(0.4); transition: 0.25s cubic-bezier(0.3, 1.5, 0.5, 1); }
.place[aria-checked="true"] { border-color: var(--berry); background: var(--blush); }
.place[aria-checked="true"] .heart { opacity: 1; transform: none; }

/* ---------- Tafsilotlar ---------- */
.chips--wrap { gap: 9px; }
.field { display: flex; flex-direction: column; gap: 8px; font-weight: 600; }
.field textarea {
  width: 100%;
  resize: vertical;
  min-height: 112px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: #fff;
  font: 400 1rem/1.5 var(--sans);
  color: var(--plum);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea::placeholder { color: #b99aa7; }
.field textarea:focus { outline: none; border-color: var(--berry); box-shadow: 0 0 0 4px rgba(242, 140, 171, 0.25); }
.error {
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff0f0;
  border: 1px solid #f3c2c2;
  color: #9b2c2c;
  font-size: 0.95rem;
}

/* ---------- Taklifnoma ---------- */
.ticket {
  width: 100%;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  text-align: left;
  box-shadow: var(--shadow-pink);
}
.ticket-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: var(--petal);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--berry-dark);
  border-bottom: 1.5px dashed var(--rose);
}
.ticket-body { padding: 8px 20px 14px; }
.ticket-body div { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid #fdeaf0; }
.ticket-body div:last-child { border-bottom: 0; }
.ticket-body dt { color: var(--plum-soft); font-size: 0.92rem; }
.ticket-body dd { font-weight: 600; text-wrap: pretty; overflow-wrap: anywhere; }

/* ---------- Gulbarglar va konfetti ---------- */
.petals { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 1s ease; }
body[data-screen="envelope"] .petals,
body[data-screen="done"] .petals { opacity: 1; }
.petal {
  position: absolute;
  top: -40px;
  background: linear-gradient(135deg, #ffd3e0, #f7a3bd);
  border-radius: 80% 0 80% 0;
  opacity: 0.75;
  animation: fall linear infinite;
}
@keyframes fall {
  0% { transform: translate3d(0, -10vh, 0) rotate(0deg); }
  50% { transform: translate3d(var(--sway), 55vh, 0) rotate(200deg); }
  100% { transform: translate3d(calc(var(--sway) * -0.6), 112vh, 0) rotate(380deg); }
}
#confetti { position: fixed; inset: 0; z-index: 4; width: 100%; height: 100%; pointer-events: none; }

/* ---------- Kichik ekranlar / harakatni cheklash ---------- */
@media (max-width: 360px) {
  .paper { padding: 22px 18px 18px; font-size: 1.02rem; }
  .days { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .petals { display: none; }
}

/* ---------- Telefon uchun qo'shimchalar ---------- */
@media (hover: hover) {
  .btn:not(:disabled):hover { background: var(--berry-dark); transform: translateY(-1px); }
  .link:hover { color: var(--berry); text-decoration-color: var(--rose); }
  .seal:hover { transform: scale(1.08); }
  .btn--yes:hover { transform: scale(calc(var(--grow, 1) * 1.03)); }
  .day:hover { border-color: var(--rose); }
  .chip:hover { border-color: var(--rose); }
  .place:hover { border-color: var(--rose); }
}
button, .day, .chip, .place { touch-action: manipulation; }
body { overscroll-behavior-y: none; }
.link { min-height: 44px; align-self: center; display: inline-flex; align-items: center; }

/* Asosiy tugma har doim ekran pastida ko'rinib turadi */
.actions--sticky {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 0 -18px;
  padding: 18px 18px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(255, 255, 255, 0.97) 65%, rgba(255, 255, 255, 0));
}
.actions--sticky .btn { width: min(100%, 320px); }

/* Bosqich nuqtalari kontent ustidan o'tganda ham o'qilsin */
.steps { padding: 7px 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.88); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
body.has-steps #app { padding-top: max(60px, calc(env(safe-area-inset-top) + 48px)); }

/* Past (gorizontal) ekranlar */
@media (max-height: 560px) {
  .envelope { --w: min(78vw, 320px, calc(36dvh * 1.4545)); margin: 14px 0 8px; }
  .display { font-size: clamp(1.7rem, 6vw, 2.2rem); }
  .screen { gap: 14px; }
  .paper { padding: 20px 22px 16px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .screen { max-width: 520px; }
  .days { grid-template-columns: repeat(7, 1fr); }
}

/* Telefonda: sarlavha tepada, asosiy tugma pastda */
@media (max-width: 600px) {
  .screen--form { align-self: stretch; }
  .screen--form > .actions--sticky { margin-top: auto; }
  #app:has(.screen--form:not([hidden])) { padding-bottom: 0; }
}

/* ---------- Qochuvchi tugma ---------- */
.btn--decoy {
  position: relative;
  z-index: 6;
  background: #fff;
  color: var(--plum);
  border: 1.5px solid var(--line);
  box-shadow: 0 10px 22px -14px rgba(201, 58, 107, 0.55);
  white-space: nowrap;
  max-width: calc(100vw - 24px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.26s cubic-bezier(0.3, 1.35, 0.5, 1), background 0.18s;
}
