:root {
  --paper: #fffaf8;
  --mist: #f7f2f4;
  --sage: #dfe9e2;
  --sage-strong: #6f8d7a;
  --rose: #b86b7c;
  --ink: #3f353a;
  --muted: #756a6f;
  --line: rgba(63, 53, 58, 0.14);
  --shadow: 0 18px 50px rgba(86, 63, 72, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f9f3f5 0%, #edf5ef 48%, #fffaf8 100%);
  font-family: ui-serif, "Songti SC", "Noto Serif SC", Georgia, serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.boot-fallback {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.boot-fallback div {
  max-width: 360px;
}

.boot-fallback h1 {
  margin: 0 0 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.45rem;
}

.boot-fallback p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.gift-page {
  position: relative;
  width: min(100%, 540px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px 10px 30px;
}

.gift-hero {
  position: relative;
  min-height: 72vh;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: #ead7dc;
  box-shadow: var(--shadow);
}

.hero-media {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #ead7dc, #dce8df);
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) brightness(0.88);
}

.hero-media::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(180deg, rgba(42, 32, 37, 0.06) 0%, rgba(42, 32, 37, 0.24) 48%, rgba(42, 32, 37, 0.72) 100%),
    linear-gradient(90deg, rgba(35, 57, 47, 0.2), rgba(184, 107, 124, 0.14));
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 30px 18px 24px;
  color: #fffaf8;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--rose);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-content .eyebrow {
  color: rgba(255, 250, 248, 0.78);
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

.gift-hero h1 {
  max-width: 12em;
  margin: 0;
  font-size: clamp(2.2rem, 14vw, 4.7rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: 0;
}

.main-message {
  max-width: 29em;
  margin: 18px 0 0;
  color: rgba(255, 250, 248, 0.9);
  font-size: 1.02rem;
  line-height: 1.85;
}

.panel,
.message-window,
.link-section,
.countdown-section {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 248, 0.84);
  box-shadow: 0 12px 34px rgba(86, 63, 72, 0.08);
  backdrop-filter: blur(18px);
}

.panel p,
.link-section p,
.countdown-section p {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.8;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--rose);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  font-weight: 850;
  letter-spacing: 0;
}

.photo-section {
  min-height: 260px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--sage);
  box-shadow: var(--shadow);
}

.photo-section img {
  display: block;
  width: 100%;
  min-height: 260px;
  max-height: 560px;
  object-fit: cover;
}

.empty-photo {
  display: grid;
  min-height: 260px;
  place-items: center;
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.music-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-top: 14px;
  padding: 0 14px 0 16px;
  border: 1px solid rgba(184, 107, 124, 0.22);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  text-decoration: none;
}

.music-title {
  margin: 12px 0 0;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.98rem;
  font-weight: 850;
}

.music-player {
  display: block;
  width: 100%;
  margin-top: 12px;
  accent-color: var(--rose);
}

.countdown-grid,
.countdown-labels {
  display: grid;
  grid-template-columns: 1.35fr repeat(3, 1fr);
  gap: 8px;
  align-items: center;
  text-align: center;
}

.countdown-grid {
  margin-top: 16px;
}

.countdown-grid strong,
.countdown-grid span,
.days-lived {
  display: grid;
  min-height: 58px;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(63, 53, 58, 0.08);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.35rem;
  color: var(--ink);
}

.countdown-grid strong,
.days-lived {
  color: var(--rose);
  font-weight: 850;
}

.countdown-labels {
  margin-top: 7px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78rem;
}

.muted,
.tiny-note {
  color: var(--muted) !important;
}

.sync-status {
  margin: -4px 0 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.86rem;
  line-height: 1.6;
}

.message-window,
.message-form,
.message-list {
  display: grid;
  gap: 14px;
}

.sender-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(63, 53, 58, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.sender-toggle button {
  min-height: 38px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 850;
  cursor: pointer;
}

.sender-toggle button.active {
  background: #fff;
  color: var(--rose);
  box-shadow: 0 8px 20px rgba(86, 63, 72, 0.08);
}

.message-input,
.field {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  font-weight: 850;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(63, 53, 58, 0.15);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 104px;
  padding: 12px 13px;
  line-height: 1.65;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(184, 107, 124, 0.58);
  box-shadow: 0 0 0 3px rgba(184, 107, 124, 0.12);
}

.message-actions,
.admin-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.send-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  border-radius: 8px;
  background: var(--ink);
  color: #fffaf8;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 850;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 250, 248, 0.9);
  color: var(--ink);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.message-bubble {
  max-width: 100%;
  padding: 12px 13px;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(63, 53, 58, 0.08);
}

.message-bubble.you {
  justify-self: end;
  background: rgba(223, 233, 226, 0.82);
}

.message-bubble div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--rose);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
}

.message-bubble.you div {
  color: var(--sage-strong);
}

.message-bubble time {
  color: var(--muted);
  font-weight: 600;
}

.message-bubble p {
  margin: 8px 0 0;
  line-height: 1.72;
}

.egg-button {
  position: fixed;
  right: max(18px, calc((100vw - 540px) / 2 + 18px));
  bottom: 18px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(255, 250, 248, 0.78);
  color: var(--rose);
  box-shadow: 0 12px 28px rgba(63, 53, 58, 0.18);
  backdrop-filter: blur(14px);
  cursor: pointer;
}

.intro-overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 236, 230, 0.5), transparent 32%),
    linear-gradient(180deg, #1e1418 0%, #5d2930 48%, #f4dfd5 100%);
}

.intro-cover {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 51%;
  background:
    linear-gradient(180deg, rgba(36, 22, 27, 0.58), rgba(123, 57, 65, 0.4), rgba(255, 240, 231, 0.22)),
    linear-gradient(135deg, rgba(255, 250, 248, 0.16), rgba(184, 107, 124, 0.18));
  backdrop-filter: blur(18px);
  transition: transform 0.86s cubic-bezier(0.68, 0, 0.18, 1);
}

.intro-cover.left {
  left: 0;
  border-right: 1px solid rgba(184, 107, 124, 0.15);
}

.intro-cover.right {
  right: 0;
  border-left: 1px solid rgba(184, 107, 124, 0.15);
}

.intro-content {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  width: min(100%, 430px);
  text-align: center;
  color: #fffaf8;
}

.intro-content .eyebrow {
  color: rgba(255, 250, 248, 0.72);
}

.rose-stage {
  display: grid;
  width: min(84vw, 430px);
  height: min(68vh, 680px);
  min-height: 390px;
  place-items: center;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 250, 248, 0.2);
  border-radius: 28px;
  background:
    image-set(
      url("./images/rose-cover.webp") type("image/webp"),
      url("./images/rose-cover.jpg") type("image/jpeg")
    )
    center / cover no-repeat,
    rgba(255, 250, 248, 0.1);
  box-shadow:
    0 28px 80px rgba(17, 10, 14, 0.42),
    0 0 0 8px rgba(255, 250, 248, 0.05);
  transform-origin: 50% 82%;
  animation: roseFloat 5.6s ease-in-out infinite;
}

.rose-stage picture {
  display: block;
  width: 100%;
  height: 100%;
}

.rose-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.08) contrast(1.04);
  transform: scale(1.02);
}

.intro-content h2 {
  margin: 0;
  font-family: ui-serif, "Songti SC", "Noto Serif SC", Georgia, serif;
  font-size: clamp(2rem, 10vw, 3.6rem);
  font-weight: 500;
  line-height: 1.05;
  text-shadow: 0 12px 36px rgba(17, 10, 14, 0.32);
}

.intro-content p:not(.eyebrow) {
  max-width: 24em;
  margin: 14px 0 0;
  color: rgba(255, 250, 248, 0.82);
  line-height: 1.8;
}

.intro-button {
  min-height: 48px;
  margin-top: 24px;
  padding: 0 22px;
  border-radius: 999px;
  background: rgba(255, 250, 248, 0.92);
  color: #3f353a;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 850;
  box-shadow: 0 16px 42px rgba(17, 10, 14, 0.3);
  cursor: pointer;
}

.intro-overlay.is-shaking .rose-stage {
  animation: roseShake 0.54s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.intro-overlay.is-opening .intro-cover.left {
  transform: translateX(-102%);
}

.intro-overlay.is-opening .intro-cover.right {
  transform: translateX(102%);
}

.intro-overlay.is-opening .intro-content {
  animation: introFade 0.72s ease forwards;
}

@keyframes roseFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-1.2deg);
  }

  50% {
    transform: translateY(-7px) rotate(1.2deg);
  }
}

@keyframes roseShake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg) scale(1);
  }

  18% {
    transform: translateX(-7px) rotate(-2.2deg) scale(1.01);
  }

  36% {
    transform: translateX(7px) rotate(2.2deg) scale(1.01);
  }

  54% {
    transform: translateX(-5px) rotate(-1.4deg) scale(1.008);
  }

  72% {
    transform: translateX(4px) rotate(1deg) scale(1.004);
  }
}

@keyframes introFade {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rose-stage {
    animation: none;
  }

  .intro-cover,
  .intro-overlay.is-opening .intro-content {
    transition-duration: 0.01ms;
    animation-duration: 0.01ms;
  }
}

.modal-backdrop {
  position: fixed;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(42, 32, 37, 0.36);
}

.egg-modal {
  width: min(100%, 390px);
  padding: 24px;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.modal-close {
  float: right;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 8px;
  background: var(--sage);
  color: var(--ink);
  cursor: pointer;
}

.admin-page {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 16px 42px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-page {
  display: grid;
  place-items: center;
}

.login-panel,
.editor-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 248, 0.92);
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(100%, 420px);
  padding: 24px;
}

.login-panel form,
.editor-panel {
  display: grid;
  gap: 16px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-header h1,
.login-panel h1 {
  margin: 8px 0 0;
  font-size: 2rem;
  letter-spacing: 0;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.editor-panel,
.preview-panel {
  padding: 18px;
}

.preview-panel {
  position: sticky;
  top: 16px;
}

.notice {
  margin: 0;
  padding: 12px 13px;
  border-radius: 8px;
  line-height: 1.5;
}

.notice.ok {
  background: rgba(111, 141, 122, 0.16);
  color: #345b45;
}

.notice.error {
  background: rgba(184, 107, 124, 0.16);
  color: #8d364a;
}

.phone-preview {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.phone-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.phone-preview h2,
.phone-preview p,
.phone-preview small {
  display: block;
  margin: 12px 16px 0;
}

.phone-preview small {
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 780px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }
}
